|
Enhanced C#
Loyc library documentation
|
Parses Enhanced C# code into a sequence of Loyc trees (LNode), one per top-level statement. More...
Parses Enhanced C# code into a sequence of Loyc trees (LNode), one per top-level statement.
You can use EcsLanguageService.Value with extension method ParsingService.Parse(IParsingService, UString, IMessageSink, ParsingMode, bool) to easily parse a text string (holding zero or more EC# statements) into a Loyc tree. One does not normally use this class directly.
Nested classes | |
| struct | TentativeResult |
| struct | TentativeState |
Public Types | |
| enum | TypeParseMode { Normal = 0, AfterAs = 1, Pattern = 2 } |
Public static fields | |
| static readonly Precedence | StartExpr = new Precedence(-100) |
| Below lowest precedence. | |
Public static fields inherited from Loyc.Syntax.BaseParser< Token, MatchType > | |
| static readonly IMessageSink | LogExceptionErrorSink |
| Throws LogException when it receives an error. Non-errors are sent to MessageSink.Default. More... | |
| static readonly IMessageSink | FormatExceptionErrorSink |
Properties | |
| IListSource< Token > | TokensRoot [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 LogExceptionErrorSink, which throws an exception 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, IParsingOptions parsingOptions) | |
| virtual void | Reset (IListSource< Token > tokens, ISourceFile file, IParsingOptions parsingOptions) |
| IListSource< LNode > | ParseExprs (bool allowTrailingComma=false, bool allowUnassignedVarDecl=false) |
| IListSource< LNode > | ParseStmtsGreedy () |
| IEnumerator< LNode > | ParseStmtsLazy () |
| IMessageSink | CurrentSink (bool incErrorCount) |
| LNode | DataType (bool afterAs=false) |
| LNode | ExprStart (bool allowUnassignedVarDecl) |
| LNode | ExprStartNNP (bool allowUnassignedVarDecl) |
| LNode | LinqQueryExpression () |
| 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... | |
| override string | ToString (int type_) |
| TT | LA (int i) |
| 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) |
| void | Write (Severity severity, int lookaheadIndex, string message, params object[] args) |
| 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) |
| int | GetTextPosition (int tokenPosition) |
| bool | Down (int li) |
| bool | Down (IListSource< Token > children) |
| T | Up< T > (T value) |
| void | Up () |
| LNode | SingleExprInside (Token group, string stmtType, bool allowUnassignedVarDecl=false) |
| LNode | SingleExprInside (Token group, string stmtType, bool allowUnassignedVarDecl, ref LNodeList list) |
| LNodeList | AppendExprsInside (Token group, LNodeList list, bool allowTrailingComma=false, bool allowUnassignedVarDecl=false) |
| void | AppendInitializersInside (Token group, ref LNodeList list) |
| LNodeList | ExprListInside (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) | |
| Initializes the base class. More... | |
| 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 | LaIndexToMsgContext (int lookaheadIndex) |
| Converts a lookahead token index to a SourceRange (or to a string if SourceFile was initialized to null.) More... | |
| virtual void | Error (int lookaheadIndex, string format, params object?[] args) |
| 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 | MatchError (bool inverted, params MatchType[] expected) |
| virtual void | MatchError (bool inverted, IEnumerable< MatchType > expected) |
| Handles an error that occurs during Match() or MatchExcept() More... | |
| 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 |
| TentativeState | _tentativeErrors |
Protected fields inherited from Loyc.Syntax.BaseParser< Token, MatchType > | |
| ISourceFile | _sourceFile |
| Token | _lt0 = default! |
| 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) |
|
inlineprotectedvirtual |
Returns the value used for EOF (normally 0)
Implements Loyc.Syntax.BaseParser< Token, MatchType >.
|
inlineprotectedvirtual |
Records an error or throws an exception.
| lookaheadIndex | Location 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 >.
|
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 >.
1.8.7