Class: DrgDSL::Parser
- Inherits:
-
Parslet::Parser
- Object
- Parslet::Parser
- DrgDSL::Parser
- Defined in:
- lib/drgdsl/parser.rb
Overview
Used to parse logic expressions in flowchart decision tree. Based on the Grouper’s DRG parser, only difference being that this parser doesn’t know about statements, since they do not occur in the decision nodes.
To learn more about Parslet see the parser and transform docs.
The full syntax of the logic is described in documents/Spec-Handbuch_v2.2.3.pdf in chapter 5.5.
Class Method Summary collapse
Instance Method Summary collapse
-
#stri(str) ⇒ Object
Case-insensitive string matching.
Class Method Details
.parse(expression) ⇒ Ast::Node
33 34 35 36 37 |
# File 'lib/drgdsl/parser.rb', line 33 def self.parse(expression) AstBuilder.build new.parse(expression.to_s.strip) rescue Parslet::ParseFailed => e raise ParserError.new(parslet_error: e, input: expression) end |
Instance Method Details
#stri(str) ⇒ Object
Case-insensitive string matching
42 43 44 45 46 47 |
# File 'lib/drgdsl/parser.rb', line 42 def stri(str) key_chars = str.split(//) key_chars .map { |c| match["#{c.upcase}#{c.downcase}".squeeze] } .inject(:>>) end |