Skip to content

Commit

Permalink
Explore how to debug Xtext grammar with Antlrworks @0.7
Browse files Browse the repository at this point in the history
  • Loading branch information
adamschmideg committed Dec 3, 2011
1 parent 211742e commit 00a1ae5
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
9 changes: 9 additions & 0 deletions devjournal.md
Expand Up @@ -95,10 +95,19 @@
The referrred `[Class]` will not create a new class name, but expects an existing name
* Syntactic predicate denoted as `=>`.

* Debugging Xtext grammar with Antlrworks
* The grammar generated doesn't compile, it's looking for a class
`DebugAbstractInternalAntlrParser` which cannot be found anywhere
* Xtext [claims to have new stuff for debugging][8].
New stuff includes a railroad diagram (`Views->Xtext->Xtext Syntax Graph`).
It also refers to a new generator fragment, `org.eclipse.xtext.generator.parser.antlr.DebugAntlrGeneratorFragment`
which I don't know yet how to use.

[1]: http://jevopisdeveloperblog.blogspot.com/2011/03/implement-tostring-with-xtexts.html
[2]: http://www.eclipse.org/Xtext/documentation/2_1_0/100-serialization.php#serializationcontract
[3]: http://stackoverflow.com/questions/8154790/visualize-lalr-grammar
[4]: http://goldparser.org/
[5]: http://stackoverflow.com/questions/8263772/left-factoring-grammar-of-coffeescript-expressions
[6]: http://stackoverflow.com/questions/8279790/convert-simple-antlr-grammar-to-xtext
[7]: http://stackoverflow.com/questions/8302333/xtext-grammar-in-two-files
[8]: http://eclipse.org/Xtext/documentation/indigo/new_and_noteworthy.php
12 changes: 9 additions & 3 deletions make.py
Expand Up @@ -92,11 +92,17 @@ def call_antlrworks(antlrworks_jar, class_path, prj, grammar):
Set up classpath and call antlrworks to debug grammar
"""
prj_bin = '{prj}/bin'.format(prj=prj)
real_class_path = os.pathsep.join(class_path + [prj_bin])
real_class_path = os.pathsep.join(class_path + [prj_bin, antlrworks_jar])
main_class = 'org.antlr.works.IDE'
grammar_file = '{prj}/src-gen/{prj}/parser/antlr/internal/Internal{grammar}.g'.format(prj=prj, grammar=grammar)
print grammar_file
raw_cmd = '''
java -cp {classpath} -jar {antlrworks_jar}
java -cp {classpath} {main_class} -open {grammar_file}
'''
cmd = raw_cmd.format(classpath=real_class_path, antlrworks_jar=antlrworks_jar).split()
cmd = raw_cmd.format(\
classpath=real_class_path,
main_class=main_class,
grammar_file=grammar_file).split()
call(cmd)

def main():
Expand Down

0 comments on commit 00a1ae5

Please sign in to comment.