我无法根据最基本的规则集进行 Treetop 解析。任何帮助,将不胜感激
# my_grammar.treetop
grammar MyGrammar
rule hello
'hello'
end
rule world
'world'
end
rule greeting
hello ' ' world
end
end
# test.rb
require 'treetop'
Treetop.load 'my_grammar'
parser = MyGrammarParser.new
puts parser.parse("hello").inspect # => SyntaxNode offset=0, "hello"
puts parser.parse("world").inspect # => nil
puts parser.parse("hello world").inspect # => nil