public MixedToken(LexicToken lexicToken) { if (lexicToken == null) throw new ArgumentNullException("lexicToken"); this.lexicToken = lexicToken; }
public MixedToken(LexicToken lexicToken) { if (lexicToken == null) { throw new ArgumentNullException("lexicToken"); } this.lexicToken = lexicToken; }
public StringReader(string s, LexicToken token) { if (string.IsNullOrEmpty(s)) { throw new ArgumentException(); } this.S = s; this.Token = token; }
public override InputStream TryRead(InputStream stream, out LexicToken token) { token = null; if (stream.Content.StartsWith(this.S)) { token = this.Token; return(stream.Move(this.S.Length)); } return(stream); }
public override InputStream TryRead(InputStream stream, out LexicToken token) { token = null; if (stream.Content[0] == C) { token = this.Token; return(stream.Move(1)); } return(stream); }
public override InputStream TryRead(InputStream stream, out LexicToken token) { token = null; Match match = regex.Match(stream.Content); if (match.Success) { token = GetToken(match.Value); return stream.Move(match.Value.Length); } return stream; }
public override InputStream TryRead(InputStream stream, out LexicToken token) { token = null; if (stream.Content[0] == c) { token = this.token; return stream.Move(1); } return stream; }
public override InputStream TryRead(InputStream stream, out LexicToken token) { token = null; char c = stream.Content[0]; if (c == ' ' || c == '\t' || c == '\n' || c == '\r') { token = new WhitespaceLexicToken(); return(stream.Move(1)); } return(stream); }
public override InputStream TryRead(InputStream stream, out LexicToken token) { token = null; Match match = regex.Match(stream.Content); if (match.Success) { token = GetToken(match.Value); return(stream.Move(match.Value.Length)); } return(stream); }
public override InputStream TryRead(InputStream stream, out LexicToken token) { token = null; if (stream.Content.StartsWith(str)) { token = this.token; return stream.Move(str.Length); } return stream; }
public IEnumerable <LexicToken> Parse(InputStream input) { textInfo.Clear(); parameterExpressions.Clear(); // sorting to prevent situation when parameter 'x1' is parsed as parameter 'x' when 'x' is available, too. parameterReader.ParameterNames = parameters.OrderByDescending(s => s.Length); namedConstantReader.Constants = NamedConstants; functionReader.Functions = registeredFunctions; List <LexicToken> tokens = new List <LexicToken>(); int start = 0; do { var copy = input; foreach (var reader in lexicReaders) { LexicToken token = null; if (input.IsEmpty) { break; } start = input.Position; input = reader.TryRead(input, out token); if (token != null) { TokenInTextInfo info = new TokenInTextInfo { StartIndex = start, Length = input.Position - start, Token = token }; textInfo.Add(info); tokens.Add(token); } } if (input == copy) { throw new ParserException(String.Format("Unexpected character '{0}' in position {1}.", input.Content[0], input.Position)); } } while (!input.IsEmpty); return(tokens); }
public override InputStream TryRead(InputStream stream, out LexicToken token) { token = null; foreach (var function in Functions) { if (stream.Content.StartsWith(function.Name)) { FunctionCallToken functionToken = new FunctionCallToken { Method = function.Method }; token = functionToken; return stream.Move(function.Name.Length); } } return stream; }
public override InputStream TryRead(InputStream stream, out LexicToken token) { token = null; char firstChar = stream.Content[0]; if (firstChar == ' ' || firstChar == '\t' || firstChar == '\n' || firstChar == '\r') { token = new WhitespaceToken(); return stream.Move(1); } return stream; }
public override InputStream TryRead(InputStream stream, out LexicToken token) { token = null; foreach (var parameterName in parameterNames) { if (stream.Content.StartsWith(parameterName)) { ParameterToken paramToken = new ParameterToken(parameterName); token = paramToken; return stream.Move(parameterName.Length); } } return stream; }
public override InputStream TryRead(InputStream stream, out LexicToken token) { token = null; foreach (var constant in Constants) { if (stream.Content.StartsWith(constant.Name)) { NamedConstantToken constantToken = new NamedConstantToken(constant.Name, constant.Value); token = constantToken; return(stream.Move(constant.Name.Length)); } } return(stream); }
public override InputStream TryRead(InputStream stream, out LexicToken token) { token = null; foreach (var parameterName in parameterNames) { if (stream.Content.StartsWith(parameterName)) { ParameterToken paramToken = new ParameterToken(parameterName); token = paramToken; return(stream.Move(parameterName.Length)); } } return(stream); }
public override InputStream TryRead(InputStream stream, out LexicToken token) { token = null; foreach (var constant in Constants) { if (stream.Content.StartsWith(constant.Name)) { NamedConstantToken constantToken = new NamedConstantToken(constant.Name, constant.Value); token = constantToken; return stream.Move(constant.Name.Length); } } return stream; }
public override InputStream TryRead(InputStream stream, out LexicToken token) { token = null; foreach (var function in Functions) { if (stream.Content.StartsWith(function.Name)) { FunctionCallToken functionToken = new FunctionCallToken { Method = function.Method }; token = functionToken; return(stream.Move(function.Name.Length)); } } return(stream); }
public CharReader(char c, LexicToken token) { this.c = c; this.token = token; }
public abstract InputStream TryRead(InputStream stream, out LexicToken token);
public StringReader(string str, LexicToken token) { this.str = str; this.token = token; }
public CharReader(char c, LexicToken token) { this.C = c; this.Token = token; }