Class: Semantic::AttributeGrammar
- Inherits:
-
Abnf::File
- Object
- Hash
- Mapper::Grammar
- Abnf::FileLoader
- Abnf::File
- Semantic::AttributeGrammar
- 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)
-
- (Object) semantic_functions
readonly
The instance of the Function class (all parsed semantic functions).
Attributes inherited from Abnf::FileLoader
Attributes inherited from Mapper::Grammar
Instance Method Summary (collapse)
-
- (Object) semantic=(filename)
Load the semantic file.
Methods inherited from Abnf::FileLoader
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 |