public void SymbolTest() { var sym = from s in Tok.Symbol("***") select s; var res = sym.Parse("*** "); Assert.True(!res.IsFaulted); }
public GenTokenParser(LanguageDef def) { Identifier = Tok.Id.Identifier(def); reserved = def.ReservedNames.ToDictionary(name => name, name => Tok.Id.Reserved(name, def) as Parser <ReservedToken>); Operator = Tok.Ops.Operator(def); reservedOp = def.ReservedOpNames.ToDictionary(name => name, name => Tok.Ops.ReservedOp(name, def) as Parser <ReservedOpToken>); CharLiteral = Tok.Chars.CharLiteral(); StringLiteral = Tok.Strings.StringLiteral(); Natural = Tok.Numbers.Natural(); Integer = Tok.Numbers.Integer(); // floating = Tok.Numbers.Floating(); TODO // naturalOrFloat = Tok.Numbers.NaturalOrFloating(); TODO WhiteSpace = Tok.WhiteSpace(def); Decimal = Tok.Numbers.Decimal(); Hexadecimal = Tok.Numbers.Hexadecimal(); Octal = Tok.Numbers.Octal(); Symbol = (string name) => Tok.Symbol(name); Lexeme = (Parser <A> p) => Tok.Lexeme(p); Parens = (Parser <A> p) => Tok.Bracketing.Parens(p); Braces = (Parser <A> p) => Tok.Bracketing.Braces(p); Angles = (Parser <A> p) => Tok.Bracketing.Angles(p); Brackets = (Parser <A> p) => Tok.Bracketing.Brackets(p); Semi = Tok.Symbol(";"); Comma = Tok.Symbol(","); Colon = Tok.Symbol(":"); Dot = Tok.Symbol("."); CommaSep = (Parser <A> p) => Prim.SepBy(p, Comma); SemiSep = (Parser <A> p) => Prim.SepBy(p, Semi); CommaSep1 = (Parser <A> p) => Prim.SepBy1(p, Comma); SemiSep1 = (Parser <A> p) => Prim.SepBy1(p, Semi); Reserved = name => reserved[name]; ReservedOp = name => reservedOp[name]; }
public Brackets(Parser <A> betweenParser) : base(inp => Prim.Between(Tok.Symbol("["), Tok.Symbol("]"), betweenParser) .Parse(inp)) { }
public Angles(Parser <A> betweenParser) : base(inp => Prim.Between(Tok.Symbol("<"), Tok.Symbol(">"), betweenParser) .Parse(inp)) { }
public Braces(Parser <A> betweenParser) : base(inp => Prim.Between(Tok.Symbol("{"), Tok.Symbol("}"), betweenParser) .Parse(inp)) { }
public Parens(Parser <A> betweenParser) : base(inp => Prim.Between(Tok.Symbol("("), Tok.Symbol(")"), betweenParser) .Parse(inp)) { }