Order of arguments

Issue #176 resolved
Jesper Mattsson created an issue

When a class is declared in one .jrag or .jadd file (call it a.jrag), and then an element is added to it in another file (b.jrag), then the order they are passed to JastAdd determines the outcome. If a.jrag is passed before b.jrag. then it works. If b.jrag is passed before a.jrag, then you get an error.

This can be troublesome in build scripts. Especially so in Ant, since the JastAdd Ant task only takes FileSets (that by nature are unordered). There are workarounds, but the result is a rather fragile system that can be broken by changing the name of a source file (resulting in a different alphabetical order).

Comments (5)

  1. Jesper Öqvist

    We should add a mechanism to specify source file order in jastadd-test to properly test this. There are some other bugs related to source file ordering which this could also be useful for testing.

  2. Jesper Öqvist

    This problem exists because apparently some things such as inter-type methods, fields and constructors are inserted into the grammar during Jrag parsing rather than attribute weaving, so the classes have not yet been weaved into the grammar (which also happens during parsing) if the class declaration occurs later in the parsed files than the corresponding ITD.

    This problem should also happen even in a single file if the declarations are ordered in a particular way.

  3. Jesper Öqvist

    Possible solutions:

    1. Parse all Jrag files twice - once to weave new types, then a second time to weave attributes and inter-type declarations.
    2. Delay weaving of inter-type declarations until the attribute weaving phase.

    The second alternative seems more attractive since it should not be as slow as re-parsing all Jrag files a second time.

  4. Log in to comment