Class: Pione::Lang::DataExpr
- Defined in:
- lib/pione/lang/data-expr.rb
Overview
DataExpr is a class for data name expressions of rule input and output.
Direct Known Subclasses
Instance Method Summary collapse
-
#===(other) ⇒ Object
Pattern match.
-
#=~(other) ⇒ Object
Same as Regexp#=~ but return 0 if it matched.
-
#accept_nonexistence? ⇒ Boolean
Return if the expression accepts nonexistence of corresponding data.
-
#eval(env) ⇒ Object
Evaluate exceptions and expand embeded expressions of data pattern.
-
#match(name) ⇒ Object
Return matched data if the name is matched with the expression.
Methods inherited from Piece
Methods included from Util::Positionable
#line_and_column, #pos, #set_source_position
Instance Method Details
#===(other) ⇒ Object
Pattern match.
68 69 70 |
# File 'lib/pione/lang/data-expr.rb', line 68 def ===(other) match(other) ? true : false end |
#=~(other) ⇒ Object
Same as Regexp#=~ but return 0 if it matched.
63 64 65 |
# File 'lib/pione/lang/data-expr.rb', line 63 def =~(other) match(other) ? 0 : nil end |
#accept_nonexistence? ⇒ Boolean
Return if the expression accepts nonexistence of corresponding data.
58 59 60 |
# File 'lib/pione/lang/data-expr.rb', line 58 def accept_nonexistence? false end |
#eval(env) ⇒ Object
Evaluate exceptions and expand embeded expressions of data pattern.
39 40 41 42 43 |
# File 'lib/pione/lang/data-expr.rb', line 39 def eval(env) new_pattern = Util::EmbededExprExpander.(env, pattern) new_exceptions = exceptions.eval(env) set(pattern: new_pattern, exceptions: new_exceptions) end |
#match(name) ⇒ Object
Return matched data if the name is matched with the expression.
46 47 48 49 50 51 52 |
# File 'lib/pione/lang/data-expr.rb', line 46 def match(name) # check exceptions return nil if exceptions.match?(name) # match test return DataExprCompiler.compile(pattern).match(name) end |