Enhanced C#
Language of your choice: library documentation

Documentation moved to ecsharp.net

GitHub doesn't support HTTP redirects, so you'll be redirected in 3 seconds.

 All Classes Namespaces Functions Variables Enumerations Enumerator Properties Events Pages
Public static fields | Properties | Public Member Functions | Protected Member Functions | Protected fields | List of all members
Loyc.Ecs.Parser.EcsParser Class Reference

Parses Enhanced C# code into a sequence of Loyc trees (LNode), one per top-level statement. More...


Source files:
Inheritance diagram for Loyc.Ecs.Parser.EcsParser:
Loyc.Syntax.BaseParser< Token > Loyc.Syntax.BaseParser< Token, MatchType >

Remarks

Parses Enhanced C# code into a sequence of Loyc trees (LNode), one per top-level statement.

You can use EcsLanguageService.Value with ParsingService.Parse to easily parse a text string (holding zero or more EC# statements) into a Loyc tree. One does not normally use this class directly.

Public static fields

static readonly Precedence ContinueExpr = new Precedence(-100)
 
- Public static fields inherited from Loyc.Syntax.BaseParser< Token, MatchType >
static readonly IMessageSink FormatExceptionErrorSink
 Throws FormatException when it receives an error. Non-errors are sent to MessageSink.Current. More...
 

Properties

IListSource< TokenTokensRoot [get]
 
sealed override int LA0Int [get]
 
TT LA0 [get]
 
- Properties inherited from Loyc.Syntax.BaseParser< Token, MatchType >
IMessageSink ErrorSink [get, set]
 Gets or sets the object to which error messages are sent. The default object is FormatExceptionErrorSink, which throws FormatException if an error occurs. More...
 
ISourceFile SourceFile [get]
 The ISourceFile object that was provided to the constructor, if any. More...
 
Token LT0 [get]
 Next token to parse (cached; is set to LT(0) whenever InputPosition is changed). More...
 
int InputPosition [get, set]
 Current position of the next token to be parsed. More...
 
abstract MatchType LA0Int [get]
 Returns the token type of _lt0 (normally _lt0.TypeInt) More...
 

Public Member Functions

 EcsParser (IListSource< Token > tokens, ISourceFile file, IMessageSink messageSink)
 
virtual void Reset (IListSource< Token > tokens, ISourceFile file)
 
IListSource< LNodeParseExprs ()
 
IListSource< LNodeParseStmtsGreedy ()
 
IEnumerator< LNodeParseStmtsLazy ()
 
LNode ExprStart (bool allowUnassignedVarDecl)
 
LNode ExprStart2 (bool allowUnassignedVarDecl)
 
LNode Stmt ()
 

Protected Member Functions

sealed override int EofInt ()
 Returns the value used for EOF (normally 0) More...
 
sealed override Token LT (int i)
 Returns the token at lookahead i (e.g. Source[InputPosition + i] if the tokens come from a list called Source) More...
 
LNode Error (string message, params object[] args)
 
void Error (LNode node, string message, params object[] args)
 
void Error (Token token, string message, params object[] args)
 
override void Error (int lookaheadIndex, string message)
 Records an error or throws an exception. More...
 
override void Error (int lookaheadIndex, string message, params object[] args)
 
int GetTextPosition (int tokenPosition)
 
override string ToString (int type_)
 
TT LA (int i)
 
bool Down (int li)
 
bool Down (IListSource< Token > children)
 
Up< T > (T value)
 
void Up ()
 
LNode SingleExprInside (Token group, string stmtType, WList< LNode > list=null, bool allowUnassignedVarDecl=false)
 
WList< LNodeAppendExprsInside (Token group, WList< LNode > list, bool allowTrailingComma=false, bool allowUnassignedVarDecl=false)
 
WList< LNodeAppendInitializersInside (Token group, WList< LNode > list)
 
WList< LNodeAppendStmtsInside (Token group, WList< LNode > list)
 
WList< LNodeExprListInside (Token t, bool allowTrailingComma=false, bool allowUnassignedVarDecl=false)
 
- Protected Member Functions inherited from Loyc.Syntax.BaseParser< Token >
 BaseParser (ISourceFile file=null, int startIndex=0)
 
- Protected Member Functions inherited from Loyc.Syntax.BaseParser< Token, MatchType >
 BaseParser (ISourceFile file=null, int startIndex=0)
 
abstract string ToString (MatchType tokenType)
 Returns a string representation of the specified token type. These strings are used in error messages. More...
 
virtual int LaIndexToCharIndex (int lookaheadIndex)
 Converts a lookahead token index to a character index (used for error reporting). More...
 
virtual object LaIndexToSourcePos (int lookaheadIndex)
 Converts a lookahead token index to a SourcePos object using LaIndexToCharIndex and SourceFile. More...
 
void Skip ()
 
Token MatchAny ()
 
Token Match (HashSet< MatchType > set, bool inverted=false)
 
Token Match (MatchType a)
 
Token Match (MatchType a, MatchType b)
 
Token Match (MatchType a, MatchType b, MatchType c)
 
Token Match (MatchType a, MatchType b, MatchType c, MatchType d)
 
Token MatchExcept ()
 
Token MatchExcept (MatchType a)
 
Token MatchExcept (MatchType a, MatchType b)
 
Token MatchExcept (MatchType a, MatchType b, MatchType c)
 
Token MatchExcept (MatchType a, MatchType b, MatchType c, MatchType d)
 
Token MatchExcept (HashSet< MatchType > set)
 
bool TryMatch (HashSet< MatchType > set, bool inverted=false)
 
bool TryMatch (MatchType a)
 
bool TryMatch (MatchType a, MatchType b)
 
bool TryMatch (MatchType a, MatchType b, MatchType c)
 
bool TryMatch (MatchType a, MatchType b, MatchType c, MatchType d)
 
bool TryMatchExcept ()
 
bool TryMatchExcept (MatchType a)
 
bool TryMatchExcept (MatchType a, MatchType b)
 
bool TryMatchExcept (MatchType a, MatchType b, MatchType c)
 
bool TryMatchExcept (MatchType a, MatchType b, MatchType c, MatchType d)
 
bool TryMatchExcept (HashSet< MatchType > set)
 
void Error (bool inverted, params MatchType[] expected)
 
virtual void Error (bool inverted, IEnumerable< MatchType > expected)
 
virtual string ToString (bool inverted, IEnumerable< MatchType > expected)
 
virtual void Check (bool expectation, string expectedDescr="")
 

Protected fields

LNodeFactory F
 
IListSource< Token_tokensRoot
 
IListSource< Token_tokens
 
int _startTextIndex = 0
 
LNode _triviaWordAttribute
 
LNode _triviaUseOperatorKeyword
 
LNode _triviaForwardedProperty
 
LNode _filePrivate
 
- Protected fields inherited from Loyc.Syntax.BaseParser< Token, MatchType >
ISourceFile _sourceFile
 
Token _lt0
 
int _inputPosition
 
MatchType EOF
 

Additional Inherited Members

- Static Protected Member Functions inherited from Loyc.Syntax.BaseParser< Token, MatchType >
static HashSet< MatchType > NewSet (params MatchType[] items)
 

Member Function Documentation

sealed override int Loyc.Ecs.Parser.EcsParser.EofInt ( )
inlineprotectedvirtual

Returns the value used for EOF (normally 0)

Implements Loyc.Syntax.BaseParser< Token, MatchType >.

override void Loyc.Ecs.Parser.EcsParser.Error ( int  lookaheadIndex,
string  message 
)
inlineprotectedvirtual

Records an error or throws an exception.

Parameters
lookaheadIndexLocation of the error relative to the current InputPosition. When called by BaseParser, lookaheadIndex is always equal to 0.

The default implementation throws a FormatException. When overriding this method, you can convert the lookaheadIndex to a SourcePos using the expression SourceFile.IndexToLine(LT(lookaheadIndex).StartIndex). This only works if an ISourceFile object was provided to the constructor of this class, and Token implements ISimpleToken.

Reimplemented from Loyc.Syntax.BaseParser< Token, MatchType >.

sealed override Token Loyc.Ecs.Parser.EcsParser.LT ( int  i)
inlineprotectedvirtual

Returns the token at lookahead i (e.g. Source[InputPosition + i] if the tokens come from a list called Source)

Implements Loyc.Syntax.BaseParser< Token, MatchType >.