class

Arborist::Grammar::GrammarParserBuilder

Inherits Arborist::DSL / Reference / Object

Instance methods

add_to_mutex_alt_set(strings_or_dot : Set(String) | Dot, new_strings : Set(String)) : Set(String) | Dot

def add_to_mutex_alt_set(strings_or_dot : Set(String) | Dot, new_string : String) : Set(String) | Dot

if !strings.empty?

existing_string = strings.first

raise MutexAltBuildFailure.new("Alternatives not all same string length.") unless existing_string.size == new_string.size

end

if strings_or_dot.is_a?(Set(String)) strings_or_dot << new_string end strings_or_dot end

Source
build_grammar_parser(grammar_parse_tree : ApplyTree) : Matcher

takes a parse tree for an Arborist grammar definition and returns a Matcher that can build parse trees for that grammar definition

Source
build_mutex_alt_for_rule_parse_tree(rule_name : String, parse_tree : ParseTree, rule_name_to_parse_tree_map : Hash(String, ParseTree)) : MutexAlt | Dot | Nil

returns a MutexAlt if the rule can be represented as a MutexAlt, or a Dot if the rule represents any character; nil otherwise rule_name is the name of the rule that, as a result of being evaluated, yielded the parse_tree node. In other words, rule_name was the name of the rule that was actively being matched and produced a parse tree that included the parse tree node represented by parse_tree. parse_tree is the first (and only) child of an ApplyTree node. Returns a MutexAlt if the parse tree can be represented as a MutexAlt; nil otherwise

Source
build_mutex_alt_string_set_for_rule_parse_tree(rule_name : String, parse_tree : ParseTree, rule_name_to_parse_tree_map : Hash(String, ParseTree), visited_nodes : Set(ParseTree), string_set_union : Set(String) | Dot) : Set(String) | Dot

parse_tree is the first (and only) child of an ApplyTree node - it is the root tree node of a rule definition

Source
build_mutex_alt_string_set_for_rule_parse_tree(apply_tree : ApplyTree, rule_name_to_parse_tree_map : Hash(String, ParseTree), visited_nodes : Set(ParseTree), string_set_union : Set(String) | Dot) : Set(String) | Dot
Source
build_parser_for_grammar(parse_tree) : Matcher

returns a Matcher that knows how to parse the grammar represented by parse_tree parse_tree is a ParseTree produced by Arborist::Grammar::Rules::GrammarParser

Source
build_rule_name_to_parse_tree_map(parse_tree) : Hash(String, ParseTree)

takes a grammar parse tree and returns a Hash(String, ParseTree) representing the rules as a map of rule-name -> rule-body-parse-tree pairs

Source
build_string_set_from_range_rule_application_parse_tree(range_rule_body : ParseTree) : Set(String)
Source
build_string_set_from_terminal(terminal_rule_body : ParseTree) : Set(String)
Source
escape_char_to_string(parse_tree : ParseTree) : String
Source
is_mutex_alt_string_set_valid?(strings : Set(String)) : Bool
Source
terminal_char_to_string(terminal_char : ParseTree) : String
Source
top_level_alternative_label(parse_tree : ParseTree) : String
Source

Nested types