rj-action-library/Runtime/Text/Lexing/LexerMatcherLibrary.cs

100 lines
3.8 KiB
C#

using System.Collections;
using System.Collections.Generic;
using System.Text.RegularExpressions;
namespace Rokojori
{
public class LexerMatcherLibrary
{
public static readonly LexerMatcher CWORD_MATCHER =
new LexerMatcher( "CWORD", @"[a-zA-Z_]\w*" );
public static readonly LexerMatcher CFUNCTION_MATCHER =
new LexerMatcher( "CFUNCTION", @"[a-zA-Z_]\w*(?=\s*\()" );
// public static readonly LexerMatcher LexerMatcherCLASSNAME_MATCHER =
// new LexerMatcher( "CLASSNAME", @"(?<=(?:(?:class|interface|struct)\s+))[a-zA-Z_]\w*" );
public static readonly LexerMatcher JSWORD_MATCHER =
new LexerMatcher( "JSWORD", @"[a-zA-Z_\$]\w*" );
public static readonly LexerMatcher PHPWORD_MATCHER =
new LexerMatcher( "PHPWORD", @"\$?[a-zA-Z_]\w*" );
public static readonly LexerMatcher CSS_CLASS_SELECTOR_MATCHER =
new LexerMatcher( "CSS_CLASS_SELECTOR", @"\.[a-zA-Z_](\w|\-)*" );
public static readonly LexerMatcher CSS_ID_SELECTOR_MATCHER =
new LexerMatcher( "CSS_ID_SELECTOR", @"\#[a-zA-Z_](\w|\-)*" );
public static readonly LexerMatcher CSS_WORD_MATCHER =
new LexerMatcher( "CSS_WORD", @"[a-zA-Z_](\w|\-)*" );
public static readonly LexerMatcher HTML_CUSTOM_ELEMENT_MATCHER =
new LexerMatcher( "HTML_CUSTOM_ELEMENT", @"[a-zA-Z]\w*\-(\w|\-)+" );
public static readonly LexerMatcher DOUBLE_QUOTED_STRING_MATCHER =
new LexerMatcher( "DOUBLE_QUOTED_STRING", "\"(?:[^\"\\\\]|\\\\.)*\"" );
public static readonly LexerMatcher SINGLE_QUOTED_STRING_MATCHER =
new LexerMatcher( "SINGLE_QUOTED_STRING", @"'(?:[^'\\]|\\.)*'" );
public static readonly LexerMatcher NUMBER_MATCHER =
new LexerMatcher( "NUMBER", @"(?=\.\d|\d)(?:\d+)?(?:\.?\d*)(?:[eE][+-]?\d+)?" );
public static readonly LexerMatcher WHITESPACE_MATCHER =
new LexerMatcher( "WHITESPACE", @"\s+" );
public static readonly LexerMatcher BREAK_MATCHER =
new LexerMatcher( "BREAK", @"(\r\n|\r|\n)" );
public static readonly LexerMatcher NULL_MATCHER =
new LexerMatcher( "NULL", "null" );
public static readonly LexerMatcher BOOL_MATCHER =
new LexerMatcher( "BOOL", "true|false" );
public static readonly LexerMatcher LOGIC_MATCHER =
new LexerMatcher( "LOGIC", "if|else|switch|do|while|for|break|continue|return" );
public static readonly LexerMatcher OPERATOR_MATCHER =
new LexerMatcher( "OPERATOR", "(?:\\=\\=)|(?:\\+\\+)|(?:\\-\\-)|\\+|\\-|\\*|\\/|\\^|\\||\\~|\\&|\\%|\\<|\\>|\\=|\\!|\\.|\\:|\\,|\\;" );
public static readonly LexerMatcher BRACKET_MATCHER =
new LexerMatcher( "BRACKET", @"\(|\)|\[|\]|\{|\}" );
public static readonly LexerMatcher BLOCKSTART_MATCHER =
new LexerMatcher( "BLOCKSTART", @"\{" );
public static readonly LexerMatcher BLOCKEND_MATCHER =
new LexerMatcher( "BLOCKEND", @"\}" );
public static readonly LexerMatcher CLASS_MATCHER =
new LexerMatcher( "CLASS", @"\bclass\b" );
public static readonly LexerMatcher ACCESS_MODIFIER_MATCHER =
new LexerMatcher( "ACCESS_MODIFIER", @"\b(?:public|protected|private)\b" );
public static readonly LexerMatcher SINGLE_LINE_COMMENT_MATCHER =
new LexerMatcher( "SINGLE_LINE_COMMENT", @"//.*" );
public static readonly LexerMatcher C_INSTRUCTION_MATCHER =
new LexerMatcher( "C_INSTRUCTION", @"\#.*" );
public static readonly LexerMatcher MULTI_LINE_COMMENT_MATCHER =
new LexerMatcher( "MULTI_LINE_COMMENT", @"\/\*(.|(\r\n|\r|\n))*?\*\/" );
public static readonly LexerMatcher ANY_SYMBOL_MATCHER =
new LexerMatcher( "ANY_SYMBOL", @"." );
public static readonly LexerMatcher HASH_TAG =
new LexerMatcher( "HASH_TAG", @"\#(\w|-|\d)+" );
public static readonly LexerMatcher URL =
new LexerMatcher( "URL", @"https?\:\/\/(\w|\.|\-|\?|\=|\+|\/)+" );
}
}