Class: Semantic::AttributeGrammar

Inherits:
Abnf::File show all
Defined in:
../lib/attribute_grammar.rb

Overview

The semantically extended Abnf::File.

This class adds the semantic attributes and semantic functions to the syntactic description of the grammar. The semantic functions for context free grammars are described in: cms.dc.uba.ar/materias/tl/2009/c2/practicas/Knuth-1968-SemanticsCFL.pdf

Semantic functions are added to the tree (triggered) by the expansion of a nonterminal node. Attributes and functions are defined in the YAML file (see AttributeGrammar#semantic= ).

Instance Attribute Summary (collapse)

Attributes inherited from Abnf::FileLoader

#filename

Attributes inherited from Mapper::Grammar

#start_symbol

Instance Method Summary (collapse)

Methods inherited from Abnf::FileLoader

#initialize

Methods inherited from Mapper::Grammar

#deep_copy, #initialize, #symbols

Constructor Details

This class inherits a constructor from Abnf::FileLoader

Instance Attribute Details

- (Object) semantic_functions (readonly)

The instance of the Function class (all parsed semantic functions).



26
27
28
# File '../lib/attribute_grammar.rb', line 26

def semantic_functions
  @semantic_functions
end

Instance Method Details

- (Object) semantic=(filename)

Load the semantic file. For the description see Functions#initialize



21
22
23
# File '../lib/attribute_grammar.rb', line 21

def semantic= filename
  @semantic_functions = Functions.new( IO.read( filename ) )
end