46 lines
876 B
C#
46 lines
876 B
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.Text.RegularExpressions;
|
|
using System.Text;
|
|
|
|
using System.Globalization;
|
|
using Godot;
|
|
|
|
namespace Rokojori;
|
|
|
|
|
|
|
|
public class TokenPredicateData
|
|
{
|
|
public string type;
|
|
public string match;
|
|
|
|
public bool Matches( ASTNode node )
|
|
{
|
|
return node.IsToken( type, match );
|
|
}
|
|
|
|
public System.Predicate<Token> predicate
|
|
{
|
|
get
|
|
{
|
|
System.Predicate<Token> pred = ( tk ) => tk.Is( type, match );
|
|
return pred;
|
|
}
|
|
}
|
|
|
|
public static TokenPredicateData Create( string type, string match = null )
|
|
{
|
|
var pd = new TokenPredicateData();
|
|
pd.type = type;
|
|
pd.match = match;
|
|
return pd;
|
|
}
|
|
|
|
public static TokenPredicateData Lexed( Lexer lexer, string value )
|
|
{
|
|
var lexedSequence = Token.CreateLexedSequenceData( lexer, value );
|
|
return lexedSequence[ 0 ];
|
|
}
|
|
}
|