|
Mercury.Formats library
1.0
The library provides format parsers for the Mercury library components.
|
Parses a grammar from a StreamReader. Grammar is expected in the format More...
Public Member Functions | |
| GrammarParser (StreamReader reader) | |
| Creates a parser that will parse grammar from provided StreamReader instance. More... | |
| GrammarParser (string filename) | |
| Initializes a new instance of the GrammarParser class. More... | |
| GrammarBuilder | GetBuilder () |
| Parses the file provided by the constructor's argument and returns the builder. More... | |
| void | Dispose () |
Parses a grammar from a StreamReader. Grammar is expected in the format
# comment
[root Root]
[epsilon e ] LHS -> RHS0 [| RHS1]*
[|? RHS2 ]
where LHS -> RHS is complaint to the conditions of class Mercury.Syntax.Rule and symbols of RHS are delimited by space.
Escape characters:
", \', |, \, [space]
Aggregated rules are rules of the form LHS -> RHS1 | RHS2; the notation is equivalent to LHS -> RHS1 and LHS -> RHS2. They can take more than one line. The next line can (but is not required to) start with RHS sparator '|'.
Grammar header (lines before first rule) can specify Root symbol and epsilon symbol in format
root Root
epsilon e
then the Root will be used as Root Nonterminal and e will be used as epsilon symbol. If those lines are missing, symbols from Mercury.Defaults will be used.
Example Grammar:
# Expression language
# i.e. (1 + (5 / 3)) # Header
root Expr # Rules
Expr -> (Expr @Op Expr) | @Number
@Op -> + | - | * | /
Definition at line 59 of file GrammarParser.cs.
| Mercury.Formats.Basic.GrammarParser.GrammarParser | ( | StreamReader | reader | ) |
Creates a parser that will parse grammar from provided StreamReader instance.
| reader | The source reader |
| System.ArgumentNullException | When provided stream is null |
Definition at line 79 of file GrammarParser.cs.
| Mercury.Formats.Basic.GrammarParser.GrammarParser | ( | string | filename | ) |
Initializes a new instance of the GrammarParser class.
| filename | The file name. |
Definition at line 90 of file GrammarParser.cs.
| void Mercury.Formats.Basic.GrammarParser.Dispose | ( | ) |
Definition at line 210 of file GrammarParser.cs.
| GrammarBuilder Mercury.Formats.Basic.GrammarParser.GetBuilder | ( | ) |
Parses the file provided by the constructor's argument and returns the builder.
| System.FormatException |
Definition at line 188 of file GrammarParser.cs.
1.8.7