Order of arguments
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)
-
-
Added test
weaving/classdecl01
in jastadd-test to test this bug. -
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.
-
Possible solutions:
- Parse all Jrag files twice - once to weave new types, then a second time to weave attributes and inter-type declarations.
- 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.
-
- changed status to resolved
Delay weaving of inter-type declarations
- inter-type declarations are now weaved after Jrag parsing is finished
fixes issue
#176(bitbucket)→ <<cset 9581b19c41c9>>
- Log in to comment
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.