18 lines
815 B
C#
18 lines
815 B
C#
using CanonSharp.Combinator.Abstractions;
|
|
using CanonSharp.Pascal.Scanner;
|
|
using static CanonSharp.Combinator.ParserBuilder;
|
|
|
|
namespace CanonSharp.Pascal.Parser;
|
|
|
|
public abstract class GrammarParserBuilder
|
|
{
|
|
protected static IParser<LexicalToken, LexicalToken> Keyword(string value)
|
|
=> Satisfy<LexicalToken>(token => token.TokenType == LexicalTokenType.Keyword && token.LiteralValue == value);
|
|
|
|
protected static IParser<LexicalToken, LexicalToken> Operator(string value)
|
|
=> Satisfy<LexicalToken>(token => token.TokenType == LexicalTokenType.Operator && token.LiteralValue == value);
|
|
|
|
protected static IParser<LexicalToken, LexicalToken> Delimiter(string value)
|
|
=> Satisfy<LexicalToken>(token => token.TokenType == LexicalTokenType.Delimiter && token.LiteralValue == value);
|
|
}
|