Class Dhaka::Parser
In: ../trunk/lib/dhaka/parser/parser.rb
Parent: Object

The parser generator. To generate a parser from a grammar specification ArithmeticPrecedenceGrammar, one would write:

  parser =

To compile this parser to Ruby source as ArithmeticPrecedenceParser:


which returns a string of Ruby code.


Included Modules



grammar  [R] 
start_state  [R] 

Public Class methods

Creates a new parser from the given grammar. Messages are logged by default to STDOUT and the log level is WARN. Shift-reduce conflicts are reported at WARN and reduce-reduce conflicts at ERROR. You may pass in your own logger. Logging at DEBUG shows a lot of progress output.

Public Instance methods

Returns the Ruby source of the generated parser compiled as parser_class_name. This can be written out to a file.

Returns the dot representation of the parser. If :hide_lookaheads is set to true in the options hash, lookaheads are not written out to the parser states, which is helpful when there are dozens of lookahead symbols for every item in every state.