Mercury.Formats library 1.0 The library provides format parsers for the Mercury library components.

- Main Page
- Packages
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

All Classes Namespaces Files Functions Properties
Public Member Functions | List of all members
Mercury.Formats.Basic.RewriteRulesParser< T > Class Template Reference

Parses the file containing rewrite rules. It is of the following format:
More...

Inheritance diagram for Mercury.Formats.Basic.RewriteRulesParser< T >:

## 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 ()

## Detailed Description

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 -&gt (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))

Template Parameters

  T |

Type Constraints

  T | : | class |

Definition at line 53 of file RewriteRulesFileParser.cs.

## Constructor & Destructor Documentation

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.

Parameters

  reader | The stream reader (the source).
  epsilon | The epsilon symbol.
  actions | The list of actions.
  aliases | Dictionary of aliases.

Exceptions

  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.

## Member Function Documentation

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.

Returns
  Collection of rewrite rules.

Exceptions

  System.FormatException | When something is wrong.

Definition at line 154 of file RewriteRulesFileParser.cs.

The documentation for this class was generated from the following file:

- Mercury/Mercury.Formats/Basic/RewriteRulesFileParser.cs