Giter Club home page Giter Club logo

clgen's People

Contributors

sanhozay avatar

Watchers

 avatar

Forkers

ujust4fun

clgen's Issues

Null pointer exception when a binding refers to an undefined alias

Parsing should report an error but not produce a stack trace.

Test case:

item("Parking Brake") {
    state("ON", brake > 0) brake = 1;
}
checklist("Before Starting Engines") {
    check("Parking Brake", "ON");
}

Stack trace:

$ clgen test.clg
CLGen 1.1.1
error at line 2: Alias 'brake' is not defined in item 'Parking Brake'
    state("ON", brake > 0) brake = 1;
                ^
error at line 2: Alias 'brake' is not defined in item 'Parking Brake'
    state("ON", brake > 0) brake = 1;
                           ^
java.lang.NullPointerException
        at org.flightgear.clgen.listener.ItemListener.enterAssignInt(ItemListener.java:258)
        at org.flightgear.clgen.CLGenParser$AssignIntContext.enterRule(CLGenParser.java:1445)
        at org.antlr.v4.runtime.tree.ParseTreeWalker.enterRule(ParseTreeWalker.java:42)
        at org.antlr.v4.runtime.tree.ParseTreeWalker.walk(ParseTreeWalker.java:25)
        at org.antlr.v4.runtime.tree.ParseTreeWalker.walk(ParseTreeWalker.java:28)
        at org.antlr.v4.runtime.tree.ParseTreeWalker.walk(ParseTreeWalker.java:28)
        at org.antlr.v4.runtime.tree.ParseTreeWalker.walk(ParseTreeWalker.java:28)
        at org.antlr.v4.runtime.tree.ParseTreeWalker.walk(ParseTreeWalker.java:28)
        at org.antlr.v4.runtime.tree.ParseTreeWalker.walk(ParseTreeWalker.java:28)
        at org.antlr.v4.runtime.tree.ParseTreeWalker.walk(ParseTreeWalker.java:28)
        at org.antlr.v4.runtime.tree.ParseTreeWalker.walk(ParseTreeWalker.java:28)
        at org.antlr.v4.runtime.tree.ParseTreeWalker.walk(ParseTreeWalker.java:28)
        at org.flightgear.clgen.CLGen.buildItems(CLGen.java:170)
        at org.flightgear.clgen.CLGen.run(CLGen.java:126)
        at org.flightgear.clgen.CLGen.main(CLGen.java:80)
Generation failed.

Allow options to be passed into the generation process

The only thing that really needs an option for the time being is a preference to generate a single XML file or multiple XML files included under a single header. All the code is there, it just needs the option passing through from the invocation scripts to the JVM.

Support conditional compound bindings

Conditional bindings can only include one binding action, e.g.

if (VARIANT == "pup100") trim = 4.0;
if (VARIANT == "pup150") trim = 5.0;

For multiple-engined aircraft, it could be useful to allow conditional bindings with compound actions, e.g.

if (VARIANT == "777-200") {
    e0 = 0.5;
    e1 = 0.5;
}
if (VARIANT == "777-300") {
    e0 = 0.4;
    e1 = 0.4;
}

Type checking

CLGen does not perform any type checking, e.g.

v = "some/property";
state("OFF", p == 0) p = false;
state("ON", p == 1.0) p = "true";

This is no worse than writing XML by hand, but CLGen could check the types and warn of any potential problems during checklist generation.

Allow checks without an item definition

Instead of requiring an item definition for plain checks, create an implicit item for easy definition of basic checklists, e.g.

checklist("Before Starting Engines") {
    check("Parking Brake", "ON");
    check("Navigation Lights", "ON");
}

Redefinition of aliases

It is possible to redefine an alias to a different property without warning, e.g.

item("Some Item") {
    p = "controls/gear/brake-parking";
    p = "controls/engines/engine/throttle";
    ...
}

This is a nonsense example, but redefining an alias should be a semantic error.

Provide language support for subtitles and spacers

Dummy checklist items are commonly used to create subtitles within checklists and for blank lines in the checklist dialog.

These can be created by defining dummy items in CLGen, but it is slightly cumbersome:

item("") {
    state("");
}

item("Subtitle:") {
    state("");
}

Some syntactic sugar could be added to the language to support these, e.g.

checklist("Climb") {
    check("Flaps", "UP");
    subtitle("Above 10,000ft:");
    check("Landing Lights", "OFF");
    check("Seat Belt Signs", "OFF");
}

These elements would create dummy elements in the items table without having to create them as dummy items in the .clg file.

Dummy checklist items are not handled well by the PDF and DOT outputs

Flightgear developers commonly use dummy checks as spacers or subtitles in checklists, e.g.

<item>
  <name></name>
</item>

<item>
  <name>Subtitle for a section of checks</name>
</item>

The PDF output shows a series of '.' characters for these. The DOT output shows empty boxes.

Allow global aliases

Items sometimes use the same aliases, e.g.

aero = "sim/aero";

These could be defined outside the scope of an item as global aliases.

Reverse engineering XML does not escape double-quotes

For example:

<checklist>
  <title>Start Engines</title>
  <item>
    <name>Mixture</name>
    <value>FULL RICH</value>
  </item>
  <item>
    <name>Throttle</name>
    <value>OPEN 1/4"</value>
  </item>
</checklist>

This produces:

checklist("Start Engines") {
    check("Mixture", "FULL RICH");
    check("Throttle", "OPEN 1/4"");
}

The state name should be "OPEN 1/4"", i.e. the double-quote should be escaped.

Items not visitable

The AST walk visits the check (which is an item and state) and the check accepts the visitor for the item marker directly. For consistency, the check should have the item and state accept the visitor.

XML generated by conditions is not optimized for Simgear

Given a condition such as:

a && b && c

The generated output follows the structure of the parse tree, which ends up like:

<and>
  <and>
    <property>a</property>
    <property>b</property>
  </and>
  <property>c</property>
</and>

It should probably output the more readable:

<and>
  <property>a</property>
  <property>b</property>
  <property>c</property>
</and>

The nested form is valid and works perfectly well, but the optimized version is what an aircraft developer would write.

No additional values without items

When creating a prototype checklist with no items, adding additional values to checklists does not produce output in the XML, PDF or DOT files.

Support reverse engineering of .xml files into .clg files

The structure of the AST mirrors the structure of the .xml output so it should be possible to build the AST by parsing existing XML files.

The resulting CLG can be used for further maintenance of the checklists, or the AST can simply be used for visualisation using the PDF and DOT outputs.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.