struct CrystalRobots::Compiler::Parser::GrammarRule
- CrystalRobots::Compiler::Parser::GrammarRule
- Struct
- Value
- Object
Overview
- Start by matching the first Regex. If initially assigned Nil in creation, it should get assigned by the next argument (TokenDef).
- Next, use the TokenDef Hash to select a type. If the rule Regex is Nil, assign it using the TokenDef Regex. If the it TokenDef Hash doesn't have a value match, don't assign a type yet.
- Next, use the provided type to set a type. If it is Nil, keep the already assigned type. If that is Nil, error out.
- Finally, run the mapping function using the mapping type to set the final node parameters. If it is Nil, drop the token.
Defined in:
compiler/parser.crConstructors
- .new(regex : Regex, tokendef : TokenDef, type : Type | Nil, map : MappingType)
- .new(rs : Tuple(Regex | Nil, Array(Tuple(String, Type)) | Nil, Type | Nil, MappingType | Nil))
Instance Method Summary
- #map : CrystalRobots::Compiler::Parser::MappingType
- #map=(map : CrystalRobots::Compiler::Parser::MappingType)
- #regex : Regex
- #regex=(regex : Regex)
- #tokendef : CrystalRobots::Compiler::Parser::TokenDef
- #tokendef=(tokendef : CrystalRobots::Compiler::Parser::TokenDef)
- #type : CrystalRobots::Compiler::Type?
- #type=(type : CrystalRobots::Compiler::Type | Nil)
Constructor Detail
def self.new(rs : Tuple(Regex | Nil, Array(Tuple(String, Type)) | Nil, Type | Nil, MappingType | Nil))
#