class DrgDSL::Parser
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.
Public Class Methods
parse(expression)
click to toggle source
@param expression [String] @return [Ast::Node]
# 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
Public Instance Methods
stri(str)
click to toggle source
Case-insensitive string matching
kschiess.github.io/parslet/tricks.html
# 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