Merge: lib/github: introduces Github hook events
[nit.git] / contrib / nitcc / src / nitcc.nit
index 6f6d065..0cc9d2a 100644 (file)
@@ -91,18 +91,18 @@ end
 
 var nbalts = 0
 for prod in gram.prods do nbalts += prod.alts.length
-print "Concrete grammar: {gram.prods.length} productions, {nbalts} alternatives (see {name}.concrete_grammar.txt)"
+print "Concrete grammar: {gram.prods.length} productions, {nbalts} alternatives (see {name}.concrete_grammar.out)"
 
 var pretty = gram.pretty
-var f = new OFStream.open("{name}.concrete_grammar.txt")
+var f = new OFStream.open("{name}.concrete_grammar.out")
 f.write "// Concrete grammar of {name}\n"
 f.write pretty
 f.close
 
-print "LR automaton: {lr.states.length} states (see {name}.lr.dot and {name}.lr.txt)"
+print "LR automaton: {lr.states.length} states (see {name}.lr.dot and {name}.lr.out)"
 lr.to_dot("{name}.lr.dot")
 pretty = lr.pretty
-f = new OFStream.open("{name}.lr.txt")
+f = new OFStream.open("{name}.lr.out")
 f.write "// LR automaton of {name}\n"
 f.write pretty
 f.close
@@ -114,6 +114,9 @@ print "NFA automaton: {nfa.states.length} states (see {name}.nfa.dot)"
 nfa.to_dot("{name}.nfa.dot")
 
 var dfa = nfa.to_dfa.to_minimal_dfa
+
+dfa.solve_token_inclusion
+
 print "DFA automaton: {dfa.states.length} states (see {name}.dfa.dot)"
 dfa.to_dot("{name}.dfa.dot")
 
@@ -121,7 +124,6 @@ if dfa.tags.has_key(dfa.start) then
        print "Error: Empty tokens {dfa.tags[dfa.start].join(" ")}"
        exit(1)
 end
-dfa.solve_token_inclusion
 for s, tks in dfa.tags do
        if tks.length <= 1 then continue
        print "Error: Conflicting tokens: {tks.join(" ")}"
@@ -142,9 +144,14 @@ lr.gen_to_nit("{name}_parser.nit", name)
 
 f = new OFStream.open("{name}_test_parser.nit")
 f.write """# Generated by nitcc for the language {{{name}}}
+
+# Standalone parser tester for the language {{{name}}}
+module {{{name}}}_test_parser
 import nitcc_runtime
 import {{{name}}}_lexer
 import {{{name}}}_parser
+
+# Class to test the parser for the language {{{name}}}
 class TestParser_{{{name}}}
        super TestParser
        redef fun name do return \"{{{name}}}\"