-
-
Save practicingruby/9535963 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 | |
---- inner | |
def next_token | |
@q.shift | |
end | |
def parse(text) | |
@q = text.chars.map { |c| [c, c] } | |
do_parse | |
end | |
---- footer | |
parser = Parser.new | |
# raises Racc::ParseError on failed match | |
parser.parse(ARGV[0]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment