Class: RParsec::Keywords

Class | RParsec::Keywords
In: | rparsec/keywords.rb
Parent: | Object

This class helps building lexers and parsers for keywords.

### Methods

[] case_insensitive case_sensitive case_sensitive? new parser

### Attributes

keyword_symbol | [R] | The symbol used to identify a keyword token
lexer | [R] | The lexer that parses all the keywords represented

### Public Class methods

case_insensitive(words, default_lexer=word.token(:word), keyword_symbol=:keyword, &block)

To create an instance that lexes the given keywords case insensitively. default_lexer is used to lex a token first, the token text is then compared with the given keywords. If it matches any of the keyword, a keyword token is generated instead using keyword_symbol. The block parameter, if present, is used to convert the token text to another object when the token is recognized during parsing phase.

case_sensitive(words, default_lexer=word.token(:word), keyword_symbol=:keyword, &block)

To create an instance that lexes the given keywords case sensitively. default_lexer is used to lex a token first, the token text is then compared with the given keywords. If it matches any of the keyword, a keyword token is generated instead using keyword_symbol. The block parameter, if present, is used to convert the token text to another object when the token is recognized during grammar parsing phase.

new(words, case_sensitive, default_lexer, keyword_symbol, &block)

scanner has to return a string

### Public Instance methods

[](key)

Alias for parser

case_sensitive?()

Do we lex case sensitively?

parser(key)

Get the parser that recognizes the token of the given keyword during the parsing phase.

[Validate]