Mercury.Formats library  1.0
The library provides format parsers for the Mercury library components.
 All Classes Namespaces Files Functions Properties
Classes | Public Member Functions | List of all members
Mercury.Formats.Basic.InterpreterEntityParser< T > Class Template Reference

Class for parsing interpreter entities used in Mercury. Since there is a lot of tokens to scan, methods of the class work like "scanners", that is, their first parameter is always the full sequence of tokens and they only scan a subsequence specified by other parameters. More...

Classes

class  AlternativeData
 

Public Member Functions

 InterpreterEntityParser (Symbol epsilon, IReadOnlyDictionary< string, InterpreterAction< T >> actions, IReadOnlyDictionary< string, string > aliases)
 
IElement ParseElement (IList< Token > tokens, int start, out int end)
 Parses the element. More...
 
Constant ParseConstant (IList< Token > tokens, int start, out int end)
 Parses the constant. It is of the form symbols:mask where symbols is a list of symbols separated by | and mask contains the symbols
More...
 
Variable ParseVariable (IList< Token > tokens, int start, out int end)
 Parses the variable. It is of the form #name:alternative where name is a variable name and alternative has the same format as defined in ParseConstant. More...
 
Wildcard ParseWildcard (IList< Token > tokens, int start, out int end)
 Parses the wildcard. It is of the form *name:alternative. The same conditions hold as in ParseVariable. More...
 
Structure ParseStructure (IList< Token > tokens, int start, out int end)
 Parses the structure. It is of the form [Root Elements...] where Root is an Mercury.Interpreting.Alternative and Elements is a list of elements. More...
 
IFormalParameter ParseParameter (IList< Token > tokens, int start, out int end)
 Parses the parameter. It might be a constant or an action call. More...
 
ActionCall< T > ParseActionCall (IList< Token > tokens, int start, out int end)
 Parses the action call. It is of the form (f x y z...) where f is a name of an action and x, y and z are its arguments parsed recursively. More...
 
IFormalParameter[] ParseParameters (IList< Token > tokens, int start, out int end)
 Parses the parameters of an action call. More...
 
RewriteRule< T > ParseRewriteRule (IList< Token > tokens)
 Parses the rewrite rule. It is of the form LHS ==> RHS where LHS is a Mercury.Interpreting.Structure and RHS is an Mercury.Interpreting.ActionCall{T}. More...
 

Detailed Description

Class for parsing interpreter entities used in Mercury. Since there is a lot of tokens to scan, methods of the class work like "scanners", that is, their first parameter is always the full sequence of tokens and they only scan a subsequence specified by other parameters.

Template Parameters
TInterpreter return type
Type Constraints
T :class 

Definition at line 149 of file EntityParser.cs.

Constructor & Destructor Documentation

Mercury.Formats.Basic.InterpreterEntityParser< T >.InterpreterEntityParser ( Symbol  epsilon,
IReadOnlyDictionary< string, InterpreterAction< T >>  actions,
IReadOnlyDictionary< string, string >  aliases 
)

Definition at line 171 of file EntityParser.cs.

Member Function Documentation

ActionCall<T> Mercury.Formats.Basic.InterpreterEntityParser< T >.ParseActionCall ( IList< Token >  tokens,
int  start,
out int  end 
)

Parses the action call. It is of the form (f x y z...) where f is a name of an action and x, y and z are its arguments parsed recursively.

Parameters
tokensThe list of tokens.
startIndex of the first token of the element.
endIndex of token AFTER the element.
Returns
The action call.
Exceptions
System.FormatException
System.ArgumentExceptionExpected ')' at the end of action call

Definition at line 404 of file EntityParser.cs.

Constant Mercury.Formats.Basic.InterpreterEntityParser< T >.ParseConstant ( IList< Token >  tokens,
int  start,
out int  end 
)

Parses the constant. It is of the form symbols:mask where symbols is a list of symbols separated by | and mask contains the symbols

  • N for nonterminals,
  • T for terminals,
  • e for epsilon.

If the mask is empty, the colon must be omitted.

Parameters
tokensThe list of tokens.
startIndex of the first token of the element.
endIndex of token AFTER the element.
Returns
A constant.

Definition at line 219 of file EntityParser.cs.

IElement Mercury.Formats.Basic.InterpreterEntityParser< T >.ParseElement ( IList< Token >  tokens,
int  start,
out int  end 
)

Parses the element.

Parameters
tokensThe list of tokens.
startIndex of the first token of the element.
endIndex of token AFTER the element.
Returns
The element

Definition at line 187 of file EntityParser.cs.

IFormalParameter Mercury.Formats.Basic.InterpreterEntityParser< T >.ParseParameter ( IList< Token >  tokens,
int  start,
out int  end 
)

Parses the parameter. It might be a constant or an action call.

Parameters
tokensThe list of tokens.
startIndex of the first token of the element.
endIndex of token AFTER the element.
Returns
The parameter.

Definition at line 369 of file EntityParser.cs.

IFormalParameter [] Mercury.Formats.Basic.InterpreterEntityParser< T >.ParseParameters ( IList< Token >  tokens,
int  start,
out int  end 
)

Parses the parameters of an action call.

Parameters
tokensThe list of tokens.
startIndex of the first token of the element.
endIndex of token AFTER the element.
Returns

Definition at line 436 of file EntityParser.cs.

RewriteRule<T> Mercury.Formats.Basic.InterpreterEntityParser< T >.ParseRewriteRule ( IList< Token >  tokens)

Parses the rewrite rule. It is of the form LHS ==> RHS where LHS is a Mercury.Interpreting.Structure and RHS is an Mercury.Interpreting.ActionCall{T}.

Parameters
tokensThe tokens.
Returns
The rewrite rule.
Exceptions
System.ArgumentException

Definition at line 461 of file EntityParser.cs.

Structure Mercury.Formats.Basic.InterpreterEntityParser< T >.ParseStructure ( IList< Token >  tokens,
int  start,
out int  end 
)

Parses the structure. It is of the form [Root Elements...] where Root is an Mercury.Interpreting.Alternative and Elements is a list of elements.

Parameters
tokensThe list of tokens.
startIndex of the first token of the element.
endIndex of token AFTER the element.
Returns
The structure.

Definition at line 343 of file EntityParser.cs.

Variable Mercury.Formats.Basic.InterpreterEntityParser< T >.ParseVariable ( IList< Token >  tokens,
int  start,
out int  end 
)

Parses the variable. It is of the form #name:alternative where name is a variable name and alternative has the same format as defined in ParseConstant.

In addition, #name is equivalent of #name::NTe.

Parameters
tokensThe tokens.
startThe start.
endThe end.
Returns
A variable.

Definition at line 276 of file EntityParser.cs.

Wildcard Mercury.Formats.Basic.InterpreterEntityParser< T >.ParseWildcard ( IList< Token >  tokens,
int  start,
out int  end 
)

Parses the wildcard. It is of the form *name:alternative. The same conditions hold as in ParseVariable.

The *name is a shorthand for *name\:\:NTe and * is a shorthand for *(random_name):NTe.

Parameters
tokensThe list of tokens.
startIndex of the first token of the element.
endIndex of token AFTER the element.
Returns
The variable.

Definition at line 309 of file EntityParser.cs.


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