class Pegasus::Pda::Grammar

Overview

A Grammar associated with the language, contianing a list of terminals, nonterminals, and the context-free production rules given by the Item class.

Defined in:

pegasus/grammar.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new(terminals : Array(Pegasus::Elements::TerminalId), nonterminals : Array(Pegasus::Elements::NonterminalId)) #

Initializes this grammar with the given terminals and nonterminals.


[View source]

Instance Method Detail

def add_item(i) #

Add an item to the Grammar.


[View source]
def create_lalr_pda(lr_pda) #

Converts an LR(1) PDA to an LALR(1) PDA by merging states with the corresponding bodies, and combining the lookahead sets of every matching item.


[View source]
def create_lr_pda #

Create an LR(1) PDA given a start symbol.


[View source]
def items : Array(Item) #

The items that belong to this grammar.


[View source]
def nonterminals : Array(Elements::NonterminalId) #

The nonterminals that belong to this grammar.


[View source]
def terminals : Array(Elements::TerminalId) #

The terminals that belong to this grammar.


[View source]