Module: DrgDSL::Ast::Node
- Included in:
- AndExpression, BasicExpression, Comparison, Constant, DateExpression, DrgLink, Empty, Expression, FunctionCall, NotExpression, ParenExpression, SrglrbTableCondition, TableCondition, UnaryCondition, Variable
- Defined in:
- lib/drgdsl/ast.rb
Class Method Summary collapse
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
- #accept(visitor) ⇒ Object
-
#hash ⇒ Integer
Object hash for this AST node.
-
#mdc_equality? ⇒ Boolean
Whether this node represents a MDC equality check, e.g.
- #pretty_print(**pretty_printer_options) ⇒ Object (also: #to_s)
-
#sep_equality? ⇒ Boolean
Whether this node represents a SEP equality check, e.g.
-
#to_hash ⇒ Hash
Hash representation of the node.
-
#type ⇒ Object
Class name of the concrete node without the module name.
Class Method Details
.included(node_class) ⇒ Object
19 20 21 |
# File 'lib/drgdsl/ast.rb', line 19 def included(node_class) node_classes << node_class end |
.node_classes ⇒ Object
15 16 17 |
# File 'lib/drgdsl/ast.rb', line 15 def node_classes @node_classes ||= [] end |
.type(node_class) ⇒ Object
23 24 25 |
# File 'lib/drgdsl/ast.rb', line 23 def type(node_class) node_class.to_s[/\w+$/] end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
62 63 64 |
# File 'lib/drgdsl/ast.rb', line 62 def ==(other) type == other.type && hash == other.hash end |
#accept(visitor) ⇒ Object
28 29 30 |
# File 'lib/drgdsl/ast.rb', line 28 def accept(visitor) visitor.visit(self) end |
#hash ⇒ Integer
Returns object hash for this AST node. Node instances for the same expression should always return the same hash code. This is useful for optimizations.
58 59 60 |
# File 'lib/drgdsl/ast.rb', line 58 def hash raise NotImplementedError end |
#mdc_equality? ⇒ Boolean
Returns whether this node represents a MDC equality check, e.g. “MDC = ‘01’”.
40 41 42 |
# File 'lib/drgdsl/ast.rb', line 40 def mdc_equality? false end |
#pretty_print(**pretty_printer_options) ⇒ Object Also known as: to_s
68 69 70 |
# File 'lib/drgdsl/ast.rb', line 68 def pretty_print(**) accept PrettyPrinter.new(**) end |
#sep_equality? ⇒ Boolean
Returns whether this node represents a SEP equality check, e.g. “SEP = ‘07’”.
46 47 48 |
# File 'lib/drgdsl/ast.rb', line 46 def sep_equality? false end |
#to_hash ⇒ Hash
Returns Hash representation of the node.
51 52 53 |
# File 'lib/drgdsl/ast.rb', line 51 def to_hash raise NotImplementedError end |