Class: DrgDSL::Parser

Inherits:
Parslet::Parser
  • Object
show all
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.

0

github.com/swissdrg/grouper/blob/master/src/main/common/org/swissdrg/grouper/parser/DrgParser.jj

1

kschiess.github.io/parslet/parser.html

2

kschiess.github.io/parslet/transform.html

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.parse(expression) ⇒ Ast::Node

Parameters:

  • expression (String)

Returns:



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

kschiess.github.io/parslet/tricks.html



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