-
-
Save practicingruby/9535940 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Parser | |
rule | |
string | |
| a_or_cs abb | |
| abb | |
; | |
a_or_cs | |
: a_or_cs a_or_c | |
| a_or_c | |
; | |
a_or_c : 'a' | 'c' ; | |
abb : 'a' 'b' 'b' { puts "I found abb!" }; | |
end | |
---- header | |
# $Id$ | |
---- inner | |
def next_token | |
@q.shift | |
end | |
def parse(text) | |
@q = [] | |
text.chars.each do |c| | |
@q.push([c, c]) | |
end | |
do_parse | |
rescue Racc::ParseError => e | |
puts e.message.strip | |
end | |
---- footer | |
parser = Parser.new | |
parser.parse(ARGV[0]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment