public ReferenceModule ParseModule(string text) { lexer = new CSharpLexer(new StringBuffer(text)); Start(); XmlToken token = null; try { token = ParseModuleName(); } catch (UnexpectedToken ex) { token = ex.ParsingResult as XmlToken; if(token != null) { ReferenceModule @ref = CreateReferenceModule(token); UnexpectedToken th = new UnexpectedToken("Unexpected token"); th.ParsingResult = @ref; throw th; } throw; } return CreateReferenceModule(token); }
public ReferenceName ParseMemberIdentifier(string text, IQualifier qualifier) { lexer = new CSharpLexer(new StringBuffer(text)); Start(); TreeElement firstIdentifier = ParseIdentifier(); ReferenceName referenceName = CreateMemeberIdentifier(firstIdentifier, qualifier); if(lexer.TokenType != null) { UnexpectedToken ex = new UnexpectedToken("Unexpected token"); ex.ParsingResult = referenceName; throw ex; } return referenceName; }
private void Parse(string expressionString, ISearchExpressionContext searchExpressionContext) { if (string.IsNullOrWhiteSpace(expressionString)) { return; } while (!string.IsNullOrEmpty(expressionString)) { var prevExpressionString = expressionString; if (TryParseAsKeyword(ref expressionString, this)) { continue; } if (TryParseAsArgument(ref expressionString, this, searchExpressionContext)) { continue; } if (prevExpressionString == expressionString) { var unexpectedString = expressionString.Substring(0, 1); expressionString = expressionString.Remove(0, 1); var unexpectedToken = LastToken as UnexpectedToken; if (unexpectedToken != null) { var newValue = unexpectedToken.Value + unexpectedString; unexpectedToken.SetValue(new PresetItem(newValue, newValue)); } else { unexpectedToken = new UnexpectedToken(); unexpectedToken.SetValue(new PresetItem(unexpectedString, unexpectedString)); AddToken(unexpectedToken); } _isValid = false; } _isValid = false; } _asString = AsString(); }
private XmlToken CreateModuleNameToken(int start, int end, bool unexpectedToken) { if(start == 0 && end == 0) throw new UnexpectedToken("Unexpected token"); XmlToken ret = new XmlToken(L4NTokenNodeType.IDENTIFIER, lexer.Buffer, start, end); if(unexpectedToken) { UnexpectedToken ex = new UnexpectedToken("Unexpected token"); ex.ParsingResult = ret; throw ex; } return ret; }
public ReferenceType ParseTypeReference(string text) { // it's stub try { ReferenceName referenceName = ParseReferenceName(text); ReferenceType referenceType = new ReferenceType(); referenceType.AddChild(referenceName); return referenceType; } catch (UnexpectedToken ex) { ReferenceName referenceName = ex.ParsingResult as ReferenceName; if(referenceName != null) { ReferenceType referenceType = new ReferenceType(); referenceType.AddChild(referenceName); UnexpectedToken newEx = new UnexpectedToken("Unexpected token"); newEx.ParsingResult = referenceType; throw newEx; } throw; } }