Class: Vangrail::Colang::ValueParser
- Inherits:
-
Object
- Object
- Vangrail::Colang::ValueParser
- Defined in:
- lib/vangrail/colang/value_parser.rb
Overview
One grammar for assign RHS, if conditions, and action arguments.
Strings are tokenized before == / != is considered, so
"a == b" == $x is a compare of a literal against a variable.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(text, line, error) ⇒ ValueParser
constructor
A new instance of ValueParser.
- #parse ⇒ Object
Constructor Details
#initialize(text, line, error) ⇒ ValueParser
Returns a new instance of ValueParser.
16 17 18 19 20 |
# File 'lib/vangrail/colang/value_parser.rb', line 16 def initialize(text, line, error) @text = text @line = line @error = error end |
Class Method Details
.parse(text, line, error) ⇒ Object
12 13 14 |
# File 'lib/vangrail/colang/value_parser.rb', line 12 def self.parse(text, line, error) new(text, line, error).parse end |
Instance Method Details
#parse ⇒ Object
22 23 24 25 26 27 28 |
# File 'lib/vangrail/colang/value_parser.rb', line 22 def parse tokens = tokenize node, index = parse_value(tokens, 0) raise fail_value(@text) unless tokens[index][0] == :eof node end |