Module: LLIP::Parser::ClassMethods
- Extended by:
- Forwardable
- Defined in:
- lib/llip/parser.rb
Instance Attribute Summary collapse
-
#parser ⇒ Object
readonly
A class descending from AbstractParser which will contain all the productions.
-
#regexp_parser ⇒ Object
readonly
It’s a RegexpParser.
-
#regexp_scanner ⇒ Object
readonly
It’s a RegexpScanner.
-
#scanner ⇒ Object
readonly
A class desceding from RegexpAbstractScanner which will contain all the token definitions.
Instance Method Summary collapse
-
#lookahead(lookahead = nil) ⇒ Object
:call-seq: lookahead lookahead(true).
-
#token(name, string) ⇒ Object
It use regexp_parser and regexp_scanner to compile a correct regular expression string in a RegexpSpecification.
Instance Attribute Details
#parser ⇒ Object (readonly)
A class descending from AbstractParser which will contain all the productions. The messages :production and :scope are redirected to it. See AbstractParser::ClassMethods#production, AbstractParser::ClassMethods#scope and ProductionSpecification.
44 45 46 |
# File 'lib/llip/parser.rb', line 44 def parser @parser end |
#regexp_parser ⇒ Object (readonly)
It’s a RegexpParser
51 52 53 |
# File 'lib/llip/parser.rb', line 51 def regexp_parser @regexp_parser end |
#regexp_scanner ⇒ Object (readonly)
It’s a RegexpScanner
54 55 56 |
# File 'lib/llip/parser.rb', line 54 def regexp_scanner @regexp_scanner end |
#scanner ⇒ Object (readonly)
A class desceding from RegexpAbstractScanner which will contain all the token definitions. To add it in a simple way use token.
48 49 50 |
# File 'lib/llip/parser.rb', line 48 def scanner @scanner end |
Instance Method Details
#lookahead(lookahead = nil) ⇒ Object
:call-seq: lookahead lookahead(true)
It allows to set the lookahead behaviour. If the lookahead is set to true, a Buffer will be used during parsing.
76 77 78 79 |
# File 'lib/llip/parser.rb', line 76 def lookahead(lookahead = nil) @lookahead = lookahead unless lookahead.nil? @lookahead end |
#token(name, string) ⇒ Object
It use regexp_parser and regexp_scanner to compile a correct regular expression string in a RegexpSpecification. A correct regular expression string must follow the grammar specified in RegexpParser.
The first argument is the name with which all the Token derived by this regular expression will be marked. It must be a symbol.
64 65 66 67 68 69 |
# File 'lib/llip/parser.rb', line 64 def token(name,string) regexp = @regexp_parser.parse(@regexp_scanner.scan(string)) regexp.name = name @scanner.add_regexp(regexp) self end |