class Arborist::Grammar::GrammarParserBuilder
- Arborist::Grammar::GrammarParserBuilder
- Reference
- Object
Included Modules
Defined in:
grammar_semantics.crInstance Method Summary
-
#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
-
#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
-
#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 theparse_tree
node. -
#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 - #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
-
#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
-
#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
- #build_string_set_from_range_rule_application_parse_tree(range_rule_body : ParseTree) : Set(String)
- #build_string_set_from_terminal(terminal_rule_body : ParseTree) : Set(String)
- #escape_char_to_string(parse_tree : ParseTree) : String
- #is_mutex_alt_string_set_valid?(strings : Set(String)) : Bool
- #terminal_char_to_string(terminal_char : ParseTree) : String
- #top_level_alternative_label(parse_tree : ParseTree) : String
Instance methods inherited from module Arborist::DSL
alt(strings : Array(String)) : Expralt(alts : Array(String | Expr)) : Expr
alt(strings : Set(String)) : Expr
alt(*alternatives : String | Expr) : Expr alt, apply(rule_name : String) : Expr apply, choice(alternatives : Array(Expr)) : Expr
choice(*alternatives) : Expr choice, dot : Expr dot, label(label : String, expr : Expr) : Expr label, neg(expr : Expr) : Expr neg, opt(expr : Expr) : Expr opt, plus(expr : Expr) : Expr plus, pos(expr : Expr) : Expr pos, range(chars : Range(Char, Char)) : Expr range, seq(exprs : Array(Expr)) : Expr
seq(*exprs) : Expr seq, star(expr : Expr) : Expr star, term(string : String) : Expr term
Instance Method Detail
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
takes a parse tree for an Arborist grammar definition and returns a Matcher that can build parse trees for that grammar definition
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
parse_tree
is the first (and only) child of an ApplyTree node - it is the root tree node of a rule definition
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
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