43 lines
1.1 KiB
C#
43 lines
1.1 KiB
C#
|
|
using System.Collections;
|
||
|
|
using System.Collections.Generic;
|
||
|
|
using System.Text.RegularExpressions;
|
||
|
|
|
||
|
|
namespace Rokojori
|
||
|
|
{
|
||
|
|
|
||
|
|
public class UIExpressionLexer:Lexer
|
||
|
|
{
|
||
|
|
public static List<LexerEvent> Lex( string source )
|
||
|
|
{
|
||
|
|
var lexer = new UIExpressionLexer();
|
||
|
|
var events = lexer.LexToList( source );
|
||
|
|
|
||
|
|
if ( lexer.hasError )
|
||
|
|
{
|
||
|
|
return null;
|
||
|
|
}
|
||
|
|
|
||
|
|
events.ForEach( ev => { ev.GrabMatch( source ); } );
|
||
|
|
return events;
|
||
|
|
}
|
||
|
|
|
||
|
|
public UIExpressionLexer()
|
||
|
|
{
|
||
|
|
AddAllMatchers(
|
||
|
|
LexerMatcherLibrary.SingleLineCommentMatcher,
|
||
|
|
LexerMatcherLibrary.MultiLineCommentMatcher,
|
||
|
|
LexerMatcherLibrary.NumberMatcher,
|
||
|
|
LexerMatcherLibrary.NullMatcher,
|
||
|
|
LexerMatcherLibrary.BoolMatcher,
|
||
|
|
LexerMatcherLibrary.BreakMatcher,
|
||
|
|
LexerMatcherLibrary.WhiteSpaceMatcher,
|
||
|
|
LexerMatcherLibrary.LogicMatcher,
|
||
|
|
LexerMatcherLibrary.BracketMatcher,
|
||
|
|
LexerMatcherLibrary.OperatorMatcher,
|
||
|
|
LexerMatcherLibrary.CFunctionMatcher,
|
||
|
|
LexerMatcherLibrary.CwordMatcher,
|
||
|
|
LexerMatcherLibrary.AnySymbolMatcher
|
||
|
|
);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|