Class: Cyclotone::MiniNotation::Parser
- Inherits:
-
Object
- Object
- Cyclotone::MiniNotation::Parser
- Defined in:
- lib/cyclotone/mini_notation/parser.rb
Defined Under Namespace
Classes: Token
Constant Summary collapse
- SINGLE_CHAR_TOKENS =
{ "[" => :lbracket, "]" => :rbracket, "{" => :lbrace, "}" => :rbrace, "(" => :lparen, ")" => :rparen, "," => :comma, "." => :dot, "~" => :tilde, "*" => :star, "/" => :slash, "!" => :bang, "_" => :underscore, "@" => :at, "?" => :question, "|" => :pipe, ":" => :colon, "%" => :percent }.freeze
Instance Method Summary collapse
Instance Method Details
#parse(input) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/cyclotone/mini_notation/parser.rb', line 29 def parse(input) @source = input.to_s @tokens = tokenize(@source) @index = 0 skip_spaces raise ParseError.new("input is empty", line: 1, column: 1, source: @source) if current.type == :eof ast = parse_stack(terminators: [:eof]) skip_spaces expect(:eof) ast end |