library-ts/browser/text/lexer/DateExpressionLexer.ts

58 lines
2.2 KiB
TypeScript
Raw Normal View History

2025-11-15 18:58:30 +00:00
import { Lexer } from "./Lexer";
import { LexerMatcher } from "./LexerMatcher";
import { LexerMatcherLibrary } from "./LexerMatcherLibrary";
export class DateExpressionLexer extends Lexer
{
static readonly Now = new LexerMatcher( "Now", /now|jetzt/i );
static readonly Time = new LexerMatcher( "Time", /\d?\d\:\d\d(\:\d\d)?\s*(am|h|uhr)?/i );
static readonly LongDateMinus = new LexerMatcher( "LongDateMinus", /\d?\d\-\d?\d\-\d\d\d\d/ );
static readonly LongDateDot = new LexerMatcher( "LongDateDot", /\d?\d\.\d?\d\.\d\d\d\d/ );
static readonly LongDateSlash = new LexerMatcher( "LongDateSlash", /\d?\d\/\d?\d\/\d\d\d\d/ );
static readonly ReverseLongDateMinus = new LexerMatcher( "ReverseLongDateMinus", /\d\d\d\d\-\d?\d\-\d?\d/ );
static readonly ReverseLongDateDot = new LexerMatcher( "ReverseLongDateDot", /\d\d\d\d\.\d?\d\.\d?\d/ );
static readonly ReverseLongDateSlash = new LexerMatcher( "ReverseLongDateSlash", /\d\d\d\d\/\d?\d\/\d?\d/ );
static readonly DateMinus = new LexerMatcher( "DateMinus", /\d?\d\-\d?\d\-\d\d/ );
static readonly DateDot = new LexerMatcher( "DateDot", /\d?\d\.\d?\d\.\d\d/ );
static readonly DateSlash = new LexerMatcher( "DateSlash", /\d?\d\/\d?\d\/\d\d/ );
static readonly ShortDateMinus = new LexerMatcher( "ShortDateMinus", /\d?\d\-\d?\d(\-)?/ );
static readonly ShortDateDot = new LexerMatcher( "ShortDateDot", /\d?\d\.\d?\d(\.)?/ );
static readonly ShortDateSlash = new LexerMatcher( "ShortDateSlash", /\d?\d\/\d?\d(\/)?/ );
constructor()
{
super();
this.addAllMatchers(
DateExpressionLexer.Now,
DateExpressionLexer.Time,
DateExpressionLexer.LongDateMinus,
DateExpressionLexer.LongDateDot,
DateExpressionLexer.LongDateSlash,
DateExpressionLexer.ReverseLongDateMinus,
DateExpressionLexer.ReverseLongDateDot,
DateExpressionLexer.ReverseLongDateSlash,
DateExpressionLexer.DateMinus,
DateExpressionLexer.DateDot,
DateExpressionLexer.DateSlash,
DateExpressionLexer.ShortDateMinus,
DateExpressionLexer.ShortDateDot,
DateExpressionLexer.ShortDateSlash,
LexerMatcherLibrary.WHITESPACE_MATCHER,
LexerMatcherLibrary.BREAK_MATCHER,
LexerMatcherLibrary.ANY_SYMBOL_MATCHER
);
}
}