hakk_builder 0.2.2

  • README.md
  • CHANGELOG.md
  • Installing
  • Versions
  • 18

Hakk Builder

Hakk builder is an API that allows you to construct hakkML source code using Dart.

The generated source code can then be uploaded to http://hakk.it and used in competition.

What is a Hakk?

A hakk is a "program" that is specially written for the game hakk.it. Hakks compete in combat arenas against other hakks, or to complete challenges.

Basic API

The basic API provides a higher-level abstraction over the VM machine language (hakkML). It provides support for expressions, logical branching and looping. The API also provides convience functions for common hakk tasks, such as turning toward the enemy.

Using the basic API provides and easier entry point to writing hakks, but the trade-off is that the hakk will likely operate slower than hakks written in pure hakkML.

Some of the higher level constructs supported by the basic API

  • IF/ENDIF - For conditional evaluation of expressions.
  • GOSUB/RETURN - Provides a way to call subroutines, including the ability to pass parameters and get a return result.
  • WHILE/ENDWHILE - Provides a basic looping mechanism.
  • FOR/NEXT - A familiar looping construct.

Hello World

Using the basic builder API, hello world looks like this:

 hakk('hello_world');
 Block.system(0, 1);

 output("Hello World!");

 print(build());

The builder generates the following hakkML for you:

 name: "hello_world"
 blocks:
   - core:
   - mem: {name: "__sys__", loc: [0, 1]}
 code:
   core:
     - out: "Hello World!"

The basic API provides some convience capabilities for utilizing traditional higher level programming techniques. These are not robust, but sufficient enough for the scope of what hakks are intended for.

Advanced API

The advanced API exposes direct access to each instruction supported by the VM, but allows Dart's available tooling (like the Dart Editor) to help with the development process.

Hello World

Using the builder, you would construct the Hakk like this.

final myHakk = 
  hakk('hello_world', (){
    blocks((){
      B.entry('main', 0, 1);
    });
    code((){
      codeBlock('main', (){
        I.out('Hello World');
      });
    });
  })
print(myHakk);

The builder generates the hakkML and outputs:

name: hello_world
blocks:
  - core:
  - entry: {name: "main", loc : [0, 1]}
code:
  main:
    - out: "Hello World"

Saving The Result

Using the example above, this library provides a helper function to save the generated source code:

saveToFile('my_hakk', myHakk);

You could of course use dart:io to save, or do whatever else you want with the source code.

0.2.2

  • Improved memory management during compilation. Memory reference clobbering should be very rare, if at all.
  • Added unit tests for basic API

0.2.1

Basic API changes

  • Added an MMU which conserves memory allocs during compilation.
  • Added some unit tests for the basic API

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  hakk_builder: "^0.2.2"

2. Install it

You can install packages from the command line:

with pub:


$ pub get

Alternatively, your editor might support pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:hakk_builder/advanced.dart';

import 'package:hakk_builder/basic.dart';

import 'package:hakk_builder/lang.dart';
        
Version Uploaded Documentation Archive
0.2.2 Oct 31, 2014 Go to the documentation of hakk_builder 0.2.2 Download hakk_builder 0.2.2 archive
0.2.1 Oct 29, 2014 Go to the documentation of hakk_builder 0.2.1 Download hakk_builder 0.2.1 archive
0.2.0 Oct 27, 2014 Go to the documentation of hakk_builder 0.2.0 Download hakk_builder 0.2.0 archive
0.1.0 Oct 21, 2014 Go to the documentation of hakk_builder 0.1.0 Download hakk_builder 0.1.0 archive
0.0.1+5 Oct 21, 2014 Go to the documentation of hakk_builder 0.0.1+5 Download hakk_builder 0.0.1+5 archive
0.0.1+4 Oct 21, 2014 Go to the documentation of hakk_builder 0.0.1+4 Download hakk_builder 0.0.1+4 archive
0.0.1+3 Oct 21, 2014 Go to the documentation of hakk_builder 0.0.1+3 Download hakk_builder 0.0.1+3 archive
0.0.1+2 Oct 21, 2014 Go to the documentation of hakk_builder 0.0.1+2 Download hakk_builder 0.0.1+2 archive
0.0.1+1 Oct 11, 2014 Go to the documentation of hakk_builder 0.0.1+1 Download hakk_builder 0.0.1+1 archive
0.0.1 Oct 11, 2014 Go to the documentation of hakk_builder 0.0.1 Download hakk_builder 0.0.1 archive

Analysis

This feature is new.
We welcome feedback.

We analyzed this package, and provided a score, details, and suggestions below.

  • tool failures on Dec 6, 2017
  • Dart: 2.0.0-dev.8.0
  • pana: 0.7.3+1

Scores

Popularity:
Describes how popular the package is relative to other packages. [more]
0
Health:
Code health derived from static analysis. [more]
61
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
0
Overall score:
Weighted score of the above. [more]
18

Platforms

Detected platforms:

Error(s) prevent platform classification.

Suggestions

  • Fix lib/src/lang/grammar.dart.

    Strong-mode analysis of lib/src/lang/grammar.dart failed with the following error:

    line: 8 col: 32
    Classes can only extend other classes.

  • Fix lib/src/basic/_operator_class.dart.

    Strong-mode analysis of lib/src/basic/_operator_class.dart failed with the following error:

    line: 64 col: 12
    The return type '_ExpressionNode' isn't a 'bool', as defined by the method '=='.

Dependencies

Package Constraint Resolved Available
Direct dependencies
logging >=0.9.2 <0.10.0 0.9.3 0.11.3+1
petitparser >=1.2.2 <2.0.0 1.6.1
Transitive dependencies
matcher 0.12.1+4
path 1.5.1
stack_trace 1.9.1
Dev dependencies
args >=0.12.0+2
unittest >=0.11.0+4