I am just starting to use TreeTop to do parsing works. The following is the snippets that puzzles me:
grammar Fortran
rule integer
[1-9] [0-9]*
end
rule id
[a-zA-Z] [a-zA-Z0-9]*
end
end
parser = FortranParser.new
ast = parser.parse('1')
The result ast
is:
[SyntaxNode offset=0, "1", SyntaxNode offset=1, ""]
But when I place rule id
above rule integer
, the result is nil
. So what is the problem? Thanks in advance!