Class: TL1::AST::Literal
Overview
A literal string. Not included in parsing output, but must match.
Instance Attribute Summary
Attributes inherited from Node
Class Method Summary collapse
Instance Method Summary collapse
- #format ⇒ Object
-
#initialize(fields) ⇒ Literal
constructor
A new instance of Literal.
- #parse(source) ⇒ Object
Methods inherited from Node
Constructor Details
#initialize(fields) ⇒ Literal
Returns a new instance of Literal.
221 222 223 |
# File 'lib/tl1/ast.rb', line 221 def initialize(fields) @fields = fields.to_str end |
Class Method Details
.parse(source) ⇒ Object
217 218 219 |
# File 'lib/tl1/ast.rb', line 217 def self.parse(source) new(source) end |
Instance Method Details
#format ⇒ Object
225 226 227 |
# File 'lib/tl1/ast.rb', line 225 def format(*) fields end |
#parse(source) ⇒ Object
229 230 231 232 |
# File 'lib/tl1/ast.rb', line 229 def parse(source, **) return if source == format raise "Message literal does not match format literal #{format.inspect}" end |