Version 0.5.0

The version is the first and most preliminary version to be attempted to announce to public, which corresponds to the AAAI 2018 submission (rejected) [Manuscript (with some modifications like adding author names)]. Some featured examples (the Monster and Quiz example). Blue indicates new keywords introduced by GIGL and red indicates how other regular C++ source files interfaces with GIGL code. (Note that "initializer" related syntax such as that in Quiz example has been changed in later versions, which is already updated in the attached source file).

Dungeon Monster Generator

The Quiz Example; complete source code and execution I/O example.

[Download Complete GIGL Code]

[Download Full Source containing GIGL translated (generated) Code]

Language design

  • General

GIGL is designed on top of C/C++ to have extra support on expressing semantics around content generation over a stochastic grammar. It adopts all C syntax and many C++ syntax for non-domain-specific parts, such as expressions, statements, functions etc. in C. For newly introduced features in GIGL can be generally categorized into two parts, the item type definition part and item generator configuration & execution .

  • Item Type Definition

The item type definition (gigltype ... ;) defines the data structure for the "item". The syntax is designed in a close flavor to C++ class. The core part of it is specifying data structure for a syntax tree produced an attributed grammar. Attributes appears on each node of the syntax tree can be variables or functions. This data structure is wrapped in a wrapper structure as an entry point for the generator as well as the generated item. The probabilities to take each rule in the grammar and the stochastic selection are implicit in the item type definition.

  • Item Generator Configuration & Execution

The item generation statement (generate ... with ... ;) executes the item generator with some configuration. The configuration contains the binding of configure parameters, which contains rule probabilities as well as some custom parameters to pass into the item generator (such as min_int and max_int in the Quiz example). Those parameters are designed and implemented as lambda expressions. The configuration may be constructed inline in the item generation statement (as in Monster example), or constructed in advance separately (as in Quiz example).

Current Progress

    • Basic features for item type definition and item generator configuration & execution as shown in the examples.

    • Some features for facilitate having array as child type for rules, such as implicit allocation/deallocation for dynamically sized array, fill array statement etc. Incomplete.

Difficulties / Challenges

    • AbleC is only for C, and C is not a subset of C++ and having some syntax that intrinsically conflicts with C++ syntax, therefore only certain features of C++ can be added without modifying AbleC itself.

    • Because of the above, the allow "#include" arbitrary C++ file is problematic. Current ad hoc solution is to introduce an "import" statement which translate to "#include" macro, while not actually parsing through the input file. This is not shown in examples here, but appears in the Dungeon Map example in version 0.6.5.

    • Because of the above two, implementing type checking is very difficult.

Future Work

    • Add features to support deterministic controls on part of the generator.

    • Maybe: try to get around the type checking issue if possible.

    • Add features to support machine learning over the data structure.

    • Maybe: formulate closer to attribute grammar concepts, such as synthesized attribute, inherit attribute etc.

Resources

[gigl] (main gigl)

[simplecpp] (used to add part of C++ features that are not in AbleC)

Note: build the above with an appropriate (not necessary latest) version of Silver and AbleC to get the GIGL translator.

The Monster Example; complete source code and execution I/O example.

[Download Complete GIGL Code]

[Download Full Source containing GIGL translated (generated) Code]

Math Quiz Generator