|
Mercury.Formats library
1.0
The library provides format parsers for the Mercury library components.
|
Parses the file containing rewrite rules. It is of the following format:
More...
Public Member Functions | |
| RewriteRulesParser (StreamReader reader, Symbol epsilon, IEnumerable< InterpreterAction< T >> actions, IReadOnlyDictionary< string, string > aliases=null) | |
| Initializes a new instance of the RewriteRulesParser{T} class. More... | |
| RewriteRulesParser (string filename, Symbol epsilon, IEnumerable< InterpreterAction< T >> actions, IReadOnlyDictionary< string, string > aliases=null) | |
| RewriteRuleCollection< T > | GetRules () |
| Parses the stream and returns the collection of rules. More... | |
| void | Dispose () |
Parses the file containing rewrite rules. It is of the following format:
# comment
Structure0 ==> ActionCall0
Structure1 ==> ActionCall1
where Structure_ and ActionCall_ are parsed by InterpreterEntityParser{T}.
To use any special symbol like :, # etc. in other contexts, it is possible to quote ":" or use the prefixed version \:.
Tokens are always parsed regardless white spaces. Therefore A|B|C:NT is the same as A | B | C : NT. The only exception is variable and wildcard name; #name does not equal # name nor *name equals * name.
Example:
# Interpreter rules for grammar specified # in the grammar parser example.
# Expr -> (Expr @Op Expr)
[Expr ? #l #o #r ?]
==> (let x (Eval #l)
y (Eval #r)
(Case (Preterminal #o) (Fail)
'+' (Add (var x) (var y))
'-' (Sub (var x) (var y))
'*' (Mul (var x) (var y))
'/' (Div (var x) (var y))
)
)# Expr -> @Number [Expr [@Number #x]] ==> (ParseInteger (Name #x))
| T |
| T | : | class |
Definition at line 53 of file RewriteRulesFileParser.cs.
| Mercury.Formats.Basic.RewriteRulesParser< T >.RewriteRulesParser | ( | StreamReader | reader, |
| Symbol | epsilon, | ||
| IEnumerable< InterpreterAction< T >> | actions, | ||
| IReadOnlyDictionary< string, string > | aliases = null |
||
| ) |
Initializes a new instance of the RewriteRulesParser{T} class.
| reader | The stream reader (the source). |
| epsilon | The epsilon symbol. |
| actions | The list of actions. |
| aliases | Dictionary of aliases. |
| System.ArgumentNullException | reader or actions |
Definition at line 81 of file RewriteRulesFileParser.cs.
| Mercury.Formats.Basic.RewriteRulesParser< T >.RewriteRulesParser | ( | string | filename, |
| Symbol | epsilon, | ||
| IEnumerable< InterpreterAction< T >> | actions, | ||
| IReadOnlyDictionary< string, string > | aliases = null |
||
| ) |
Definition at line 98 of file RewriteRulesFileParser.cs.
| void Mercury.Formats.Basic.RewriteRulesParser< T >.Dispose | ( | ) |
Definition at line 174 of file RewriteRulesFileParser.cs.
| RewriteRuleCollection<T> Mercury.Formats.Basic.RewriteRulesParser< T >.GetRules | ( | ) |
Parses the stream and returns the collection of rules.
| System.FormatException | When something is wrong. |
Definition at line 154 of file RewriteRulesFileParser.cs.
1.8.7