-
-
Save anonymous/f2186d671b8cbe71c91e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ARGLIST ::= '(' [IDENTIFIER ':'] ASSIGN {',' [IDENTIFIER ':'] ASSIGN} ')' | |
ASSIGN ::= CONDITION [ ASSIGNOP ASSIGN ] | |
ASSIGNOP ::= '=' | '+=' | '-=' | '*=' | '/=' | '|=' | '&=' | '^=' | '%=' | '**=' | '<<=' | '>>=' | '>>>=' | |
BITOP ::= '&' | '|' | '^' | '<<' | '>>' | '>>>' | |
BITS ::= single token: binary 0b or 0B, octal 0o or 0O, decimal 0d or 0D, hexadecimal 0x or 0X | |
BREAK ::= 'break' ';' | |
CASE ::= (('case' EXPR) | 'default') ':' {STATEMENT} | |
CAST ::= 'cast' '<' TYPE '>' '(' ASSIGN ')' | |
CLASS ::= {'shared' | 'abstract' | 'final'} 'class' IDENTIFIER [':' IDENTIFIER {',' IDENTIFIER}] '{' {VIRTPROP | FUNC | VAR} '}' | |
COMPOP ::= '==' | '!=' | '<' | '<=' | '>' | '>=' | 'is' | '!is' | |
CONDITION ::= EXPR ['?' ASSIGN ':' ASSIGN] | |
CONSTRUCTCALL ::= TYPE ARGLIST | |
CONTINUE ::= 'continue' ';' | |
DATATYPE ::= IDENTIFIER | PRIMTYPE | '?' | 'auto' | |
DOWHILE ::= 'do' STATEMENT 'while' '(' ASSIGN ')' ';' | |
ENUM ::= ['shared'] 'enum' IDENTIFIER '{' IDENTIFIER ['=' EXPR] {',' IDENTIFIER ['=' EXPR]} '}' | |
EXPR ::= (TYPE '=' INILIST) | (EXPRTERM {EXPROP EXPRTERM}) | |
EXPR_OP ::= MATHOP | COMPOP | LOGICOP | BITOP | |
EXPR_PREOP ::= '-' | '+' | '!' | '++' | '--' | '~' | '@' | |
EXPR_POSTOP ::= ('.' (FUNCCALL | IDENTIFIER)) | ('[' [IDENTIFIER ':'] ASSIGN {',' [IDENTIFIER ':' ASSIGN} ']') | ARGLIST | '++' | '--' | |
EXPR_STAT ::= [ASSIGN] ';' | |
EXPR_TERM ::= {EXPRPREOP} EXPRVALUE {EXPRPOSTOP} | |
EXPR_VALUE ::= 'void' | CONSTRUCTCALL | FUNCCALL | VARACCESS | CAST | LITERAL | '(' ASSIGN ')' | |
FOR ::= 'for' '(' (VAR | EXPR_STAT) EXPR_STAT [ASSIGN {',' ASSIGN}] ')' STATEMENT | |
FUNC ::= ['private' | 'protected' | 'shared'] [((TYPE ['&']) | '~')] IDENTIFIER PARAMLIST ['const'] {'override' | 'final'} STATBLOCK | |
FUNCCALL ::= SCOPE IDENTIFIER ARGLIST | |
FUNCDEF ::= 'funcdef' TYPE ['&'] IDENTIFIER PARAMLIST ';' | |
IDENTIFIER ::= single token: starts with letter or _, can include any letter and digit, same as in C++ | |
IF ::= 'if' '(' ASSIGN ')' STATEMENT ['else' STATEMENT] | |
IMPORT ::= 'import' TYPE ['&'] IDENTIFIER PARAMLIST 'from' STRING ';' | |
INITLIST ::= '{' [ASSIGN | INITLIST] {',' [ASSIGN | INITLIST]} '}' | |
INTERFACE ::= ['shared'] 'interface' IDENTIFIER [':' IDENTIFIER {',' IDENTIFIER}] '{' {VIRTPROP | INTFMTHD} '}' | |
INTFMTHD ::= TYPE ['&'] IDENTIFIER PARAMLIST ['const'] ';' | |
LITERAL ::= NUMBER | STRING | BITS | 'true' | 'false' | 'null' | |
LOGICOP ::= '&&' | '||' | '^^' | 'and' | 'or' | 'xor' | |
MATHOP ::= '+' | '-' | '*' | '/' | '%' | '**' | |
MIXIN ::= 'mixin' CLASS | |
NAMESPACE ::= 'namespace' IDENTIFIER '{' SCRIPT '}' | |
PARAMLIST ::= '(' ('void' | (TYPE TYPEMOD [IDENTIFIER] ['=' EXPR] {',' TYPE TYPEMOD [IDENTIFIER] ['=' EXPR]}) ')' | |
PRIMTYPE ::= 'void' | 'int' | 'int8' | 'int16' | 'int32' | 'int64' | 'uint' | 'uint8' | 'uint16' | 'uint32' | 'uint64' | 'float' | 'double' | 'bool' | |
NUMBER ::= single token: includes integers and real numbers, same as C++ | |
RETURN ::= 'return' [ASSIGN] ';' | |
SCOPE ::= [[IDENTIFIER] '::' {IDENTIFIER '::'}] | |
SCRIPT ::= {IMPORT | ENUM | TYPEDEF | CLASS | MIXIN | INTERFACE | FUNCDEF | VIRTPROP | VAR | FUNC | NAMESPACE | ';'} | |
STATBLOCK ::= '{' {VAR | STATEMENT} '}' | |
STATEMENT ::= (IF | FOR | WHILE | RETURN | STATBLOCK | BREAK | CONTINUE | DOWHILE | SWITCH | EXPR_STAT) | |
STRING ::= single token: single quoted ', double quoted ", or heredoc multi-line string """ | |
SWITCH ::= 'switch' '(' ASSIGN ')' '{' {CASE} '}' | |
TYPE ::= ['const'] SCOPE DATATYPE ['<' TYPE {',' TYPE} '>'] { ('[' ']') | '@' } | |
TYPEDEF ::= 'typedef' PRIMTYPE IDENTIFIER ';' | |
TYPEMOD ::= ['&' ['in' | 'out' | 'inout']] | |
VAR ::= ['private'|'protected'] TYPE IDENTIFIER [( '=' (INITLIST | EXPR)) | ARGLIST] {',' IDENTIFIER [( '=' (INITLIST | EXPR)) | ARGLIST]} ';' | |
VARACCESS ::= SCOPE IDENTIFIER | |
VIRTPROP ::= ['private' | 'protected'] TYPE ['&'] IDENTIFIER '{' {('get' | 'set') ['const'] [('override' | 'final')] (STATBLOCK | ';')} '}' | |
WHILE ::= 'while' '(' ASSIGN ')' STATEMENT |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Irony.Parsing; | |
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using System.Threading.Tasks; | |
using System.Diagnostics; // added for Debug.Print | |
namespace AngelScript | |
{ | |
[Language("Angel Script", "1.0", "Angel Script Programming Language")] | |
public class AngelScriptGrammar : Irony.Parsing.Grammar | |
{ | |
public AngelScriptGrammar() | |
{ | |
// Comments | |
var singleLineComment = new CommentTerminal("SingleLineComment", "//", "\r", "\n", "\u2085", "\u2028", "\u2029"); | |
var delimitedComment = new CommentTerminal("DelimitedComment", "/*", "*/"); | |
NonGrammarTerminals.Add(singleLineComment); | |
NonGrammarTerminals.Add(delimitedComment); | |
// Symbols / Operators | |
#region Operators | |
var op_ASSIGN = Operator("=", "op_assign"); | |
var op_PLUS_ASSIGN = Operator("+=", "plus_assign"); | |
var op_MINUS_ASSIGN = Operator("-=", "minus_assign"); | |
var op_STAR_ASSIGN = Operator("*=", "star_assign"); | |
var op_STAR_STAR_ASSIGN = Operator("**=", "star_star_assign"); | |
var op_SLASH_ASSIGN = Operator("/=", "slash_assign"); | |
var op_AMP_ASSIGN = Operator("&=", "amp_assign"); | |
var op_BAR_ASSIGN = Operator("|=", "bar_assign"); | |
var op_CARET_ASSIGN = Operator("^=", "caret_assign"); | |
var op_PERCENT_ASSIGN = Operator("%=", "percent_assign"); | |
var op_SHL_ASSIGN = Operator("<<=", "shl_assign"); | |
var op_SHR_ASSIGN = Operator(">>=", "shr_assign"); | |
var op_USHR_ASSIGN = Operator(">>>=", "ushr_assign"); | |
var op_AMP = Operator("&", "amp"); | |
var op_AT = Operator("@", "at"); | |
var op_BAR = Operator("|", "bar"); | |
var op_CARET = Operator("^", "caret"); | |
var op_COMMA = Operator(",", "comma"); | |
var op_DOT = Operator(".", "dot"); | |
var op_EMARK = Operator("!", "emark"); | |
var op_MINUS = Operator("-", "minus"); | |
var op_PERCENT = Operator("%", "percent"); | |
var op_PLUS = Operator("+", "plus"); | |
var op_QMARK = Operator("?", "qmark"); | |
var op_STAR = Operator("*", "star"); | |
var op_SLASH = Operator("/", "slash"); | |
var op_TILDE = Operator("~", "tilde"); | |
var op_AMP_AMP = Operator("&&", "amp_amp"); | |
var op_BAR_BAR = Operator("||", "bar_bar"); | |
var op_CARET_CARET = Operator("^^", "caret_caret"); | |
var op_MINUS_MINUS = Operator("--", "minus"); | |
var op_PLUS_PLUS = Operator("++", "plus_plus"); | |
var op_SHL = Operator("<<", "shl"); | |
var op_SHR = Operator(">>", "shr"); | |
var op_STAR_STAR = Operator("**", "star_star"); | |
var op_USHR = Operator(">>>", "ushr"); | |
var op_L_BKT = Operator("[", "l_bkt"); | |
var op_R_BKT = Operator("]", "r_bkt"); | |
var op_L_BRC = Operator("{", "l_brc"); | |
var op_R_BRC = Operator("}", "r_brc"); | |
var op_L_PAR = Operator("(", "l_par"); | |
var op_R_PAR = Operator(")", "r_par"); | |
var op_COLON = Operator(":", "colon"); | |
var op_COLON_COLON = Operator("::", "colon_colon"); | |
var op_SEMI = Operator(";", "semi"); | |
var op_EQ = Operator("==", "eq"); | |
var op_NEQ = Operator("!=", "neq"); | |
var op_GT = Operator(">", "gt"); | |
var op_GTEQ = Operator(">=", "gteq"); | |
var op_LT = Operator("<", "lt"); | |
var op_LTEQ = Operator("<=", "lteq"); | |
var op_AND = Operator("and", "and"); | |
var op_IS = Operator("is", "is"); | |
var op_IS_NOT = Operator("!is", "is_not"); | |
var op_NOT = Operator("not", "not"); | |
var op_OR = Operator("or", "or"); | |
var op_XOR = Operator("xor", "xor"); | |
#endregion | |
// Keywords | |
#region Keywords | |
KeyTerm k_AND = Keyword("and"); | |
KeyTerm k_ABSTRACT = Keyword("abstract"); | |
KeyTerm k_AUTO = Keyword("auto"); | |
KeyTerm k_BOOL = Keyword("bool"); | |
KeyTerm k_BREAK = Keyword("break"); | |
KeyTerm k_CASE = Keyword("case"); | |
KeyTerm k_CAST = Keyword("cast"); | |
KeyTerm k_CLASS = Keyword("class"); | |
KeyTerm k_CONST = Keyword("const"); | |
KeyTerm k_CONTINUE = Keyword("continue"); | |
KeyTerm k_DEFAULT = Keyword("default"); | |
KeyTerm k_DO = Keyword("do"); | |
KeyTerm k_DOUBLE = Keyword("double"); | |
KeyTerm k_ELSE = Keyword("else"); | |
KeyTerm k_ENUM = Keyword("enum"); | |
KeyTerm k_FALSE = Keyword("false"); | |
KeyTerm k_FINAL = Keyword("final"); | |
KeyTerm k_FLOAT = Keyword("float"); | |
KeyTerm k_FOR = Keyword("for"); | |
KeyTerm k_FROM = Keyword("from"); | |
KeyTerm k_FUNCDEF = Keyword("funcdef"); | |
KeyTerm k_GET = Keyword("get"); | |
KeyTerm k_IF = Keyword("if"); | |
KeyTerm k_IMPORT = Keyword("import"); | |
KeyTerm k_IN = Keyword("in"); | |
KeyTerm k_INOUT = Keyword("inout"); | |
KeyTerm k_INT = Keyword("int"); | |
KeyTerm k_INTERFACE = Keyword("interface"); | |
KeyTerm k_INT8 = Keyword("int8"); | |
KeyTerm k_INT16 = Keyword("int16"); | |
KeyTerm k_INT32 = Keyword("int32"); | |
KeyTerm k_INT64 = Keyword("int64"); | |
KeyTerm k_IS = Keyword("is"); | |
KeyTerm k_MIXIN = Keyword("mixin"); | |
KeyTerm k_NAMESPACE = Keyword("namespace"); | |
KeyTerm k_NOT = Keyword("not"); | |
KeyTerm k_NULL = Keyword("null"); | |
KeyTerm k_OR = Keyword("or"); | |
KeyTerm k_OUT = Keyword("out"); | |
KeyTerm k_OVERRIDE = Keyword("override"); | |
KeyTerm k_PRIVATE = Keyword("private"); | |
KeyTerm k_PROTECTED = Keyword("protected"); | |
KeyTerm k_RETURN = Keyword("return"); | |
KeyTerm k_SET = Keyword("set"); | |
KeyTerm k_SHARED = Keyword("shared"); | |
KeyTerm k_SUPER = Keyword("super"); | |
KeyTerm k_SWITCH = Keyword("switch"); | |
KeyTerm k_THIS = Keyword("this"); | |
KeyTerm k_TRUE = Keyword("true"); | |
KeyTerm k_TYPEDEF = Keyword("typedef"); | |
KeyTerm k_UINT = Keyword("uint"); | |
KeyTerm k_UINT8 = Keyword("uint8"); | |
KeyTerm k_UINT16 = Keyword("uint16"); | |
KeyTerm k_UINT32 = Keyword("uint32"); | |
KeyTerm k_UINT64 = Keyword("uint64"); | |
KeyTerm k_VOID = Keyword("void"); | |
KeyTerm k_WHILE = Keyword("while"); | |
KeyTerm k_XOR = Keyword("xor"); | |
#endregion | |
var IDENTIFIER = new IdentifierTerminal("identifier") | |
{ | |
AllFirstChars = ValidIdentifierStartCharacters, | |
AllChars = ValidIdentifierCharacters | |
}; | |
/* | |
bool enableAutomaticConflictResolution = true; | |
var IDENTIFIER_RAW = new IdentifierTerminal("_identifier_") | |
{ | |
AllFirstChars = ValidIdentifierStartCharacters, | |
AllChars = ValidIdentifierCharacters | |
}; | |
var IDENTIFIER = new NonTerminal("identifier") | |
{ | |
Rule = enableAutomaticConflictResolution | |
? PreferShiftHere() + IDENTIFIER_RAW | |
: IDENTIFIER_RAW | |
}; | |
*/ | |
// NonTerminals | |
NonTerminal SCOPE = new NonTerminal("scope"); | |
NonTerminal TYPEMOD = new NonTerminal("typemod"); | |
NonTerminal TYPE = new NonTerminal("type"); | |
NonTerminal TYPE_NO_LPAR = new NonTerminal("type_no_lpar"); | |
NonTerminal DATATYPE = new NonTerminal("datatype"); | |
NonTerminal PRIMTYPE = new NonTerminal("primtype"); | |
// var IDENTIFIER = new IdentifierTerminal("identifier"); | |
NonTerminal PARAMLIST = new NonTerminal("paramlist"); | |
NonTerminal CAST = new NonTerminal("cast"); | |
NonTerminal EXPR_VALUE = new NonTerminal("expr_value"); | |
NonTerminal LITERAL = new NonTerminal("literal"); | |
var NUMBER = CreateAngelScriptNumber("number"); | |
var STRING = new StringLiteral("string", "\""); | |
var BITS = CreateAngelScriptNumber("bits"); | |
NonTerminal FUNCCALL = new NonTerminal("funccall"); | |
NonTerminal VARACCESS = new NonTerminal("varaccess"); | |
NonTerminal CONSTRUCTCALL = new NonTerminal("constructcall"); | |
NonTerminal ARGLIST = new NonTerminal("arglist"); | |
NonTerminal ASSIGN = new NonTerminal("assign"); | |
NonTerminal CONDITION = new NonTerminal("condition"); | |
NonTerminal EXPR = new NonTerminal("expr"); | |
NonTerminal EXPR_TERM = new NonTerminal("expr_term"); | |
NonTerminal EXPR_PREOP = new NonTerminal("expr_preop"); | |
NonTerminal EXPR_POSTOP = new NonTerminal("expr_postop"); | |
NonTerminal EXPR_OP = new NonTerminal("expr_op"); | |
NonTerminal MATHOP = new NonTerminal("mathop"); | |
NonTerminal COMPOP = new NonTerminal("compop"); | |
NonTerminal LOGICOP = new NonTerminal("logicop"); | |
NonTerminal BITOP = new NonTerminal("bitop"); | |
NonTerminal ASSIGNOP = new NonTerminal("assignop"); | |
NonTerminal IMPORT = new NonTerminal("import"); | |
NonTerminal SCRIPT = new NonTerminal("script"); | |
NonTerminal NAMESPACE = new NonTerminal("namespace"); | |
NonTerminal ENUM = new NonTerminal("enum"); | |
NonTerminal FUNCDEF = new NonTerminal("funcdef"); | |
NonTerminal FUNC = new NonTerminal("func"); | |
NonTerminal INTFMTHD = new NonTerminal("intfmthd"); | |
NonTerminal VIRTPROP = new NonTerminal("virtprop"); | |
NonTerminal INTERFACE = new NonTerminal("interface"); | |
NonTerminal MIXIN = new NonTerminal("mixin"); | |
NonTerminal CLASS = new NonTerminal("class"); | |
NonTerminal STATBLOCK = new NonTerminal("statblock"); | |
NonTerminal INITLIST = new NonTerminal("initlist"); | |
NonTerminal VAR = new NonTerminal("var"); | |
NonTerminal STATEMENT = new NonTerminal("statement"); | |
NonTerminal EXPR_STAT = new NonTerminal("expr_stat"); | |
NonTerminal SWITCH = new NonTerminal("switch"); | |
NonTerminal CASE = new NonTerminal("case"); | |
NonTerminal IF = new NonTerminal("if"); | |
NonTerminal FOR = new NonTerminal("for"); | |
NonTerminal WHILE = new NonTerminal("while"); | |
NonTerminal DOWHILE = new NonTerminal("dowhile"); | |
NonTerminal RETURN = new NonTerminal("return"); | |
NonTerminal BREAK = new NonTerminal("break"); | |
NonTerminal CONTINUE = new NonTerminal("continue"); | |
NonTerminal TYPEDEF = new NonTerminal("typedef"); | |
// Rules | |
this.Root = SCRIPT; | |
Debug.Print("$$$$$$$$$$$$$$$$$$$$$$$$"); | |
// IDENTIFIER_COLON ::= IDENTIFIER ':' | |
NonTerminal IDENTIFIER_COLON = new NonTerminal("identifier_colon"); | |
IDENTIFIER_COLON.Rule = CustomActionHere(CheckIfIdentifierWithColon) + IDENTIFIER + op_COLON; | |
// IDENTIFIER_COLON_OPT ::= [IDENTIFIER ':'] | |
NonTerminal IDENTIFIER_COLON_OPT = new NonTerminal("identifier_colon_opt"); | |
IDENTIFIER_COLON_OPT.Rule = Empty | IDENTIFIER_COLON; | |
// IDENTIFIER_COLON_OPT_ASSIGN ::= [IDENTIFIER ':'] ASSIGN | |
NonTerminal IDENTIFIER_COLON_OPT_ASSIGN = new NonTerminal("identifier_colon_opt_assign"); | |
IDENTIFIER_COLON_OPT_ASSIGN.Rule = IDENTIFIER_COLON_OPT + ASSIGN; | |
// IDENTIFIER_COLON_COLON ::= IDENTIFIER '::' | |
NonTerminal IDENTIFIER_COLON_COLON = new NonTerminal("identifier_coloncolon"); | |
IDENTIFIER_COLON_COLON.Rule = CustomActionHere(CheckIfIdentifierWithColonColon) + IDENTIFIER + op_COLON_COLON; | |
// IDENTIFIER_COLON_COLON_LIST ::= {IDENTIFIER_COLON_COLON} | |
NonTerminal IDENTIFIER_COLON_COLON_LIST = new NonTerminal("identifier_coloncolon_list"); | |
IDENTIFIER_COLON_COLON_LIST.Rule = MakeStarRule(IDENTIFIER_COLON_COLON_LIST, IDENTIFIER_COLON_COLON); | |
// IDENTIFIER_NO_LPAR cannot be: IDENTIFIER '(' | |
NonTerminal IDENTIFIER_NO_LPAR = new NonTerminal("identifier_no_lpar"); | |
IDENTIFIER_NO_LPAR.Rule = CustomActionHere(CheckIfNotIdentifierWithLPar) + IDENTIFIER; | |
// ARGLIST ::= '(' [IDENTIFIER ':'] ASSIGN {',' [IDENTIFIER ':'] ASSIGN} ')' | |
// ARGLIST.Rule = op_L_PAR + IDENTIFIER_COLON_OPT_ASSIGN + MakeStarRule(op_COMMA + IDENTIFIER_COLON_OPT_ASSIGN) + op_R_PAR; | |
ARGLIST.Rule = op_L_PAR + MakeStarRule(op_COMMA, IDENTIFIER_COLON_OPT_ASSIGN, "arglist_list") + op_R_PAR; | |
// ASSIGN ::= CONDITION [ ASSIGNOP ASSIGN ] | |
ASSIGN.Rule = CONDITION + Optional(ASSIGNOP + ASSIGN, "assign_opt"); | |
// ASSIGNOP ::= '=' | '+=' | '-=' | '*=' | '/=' | '|=' | '&=' | '^=' | '%=' | '**=' | '<<=' | '>>=' | '>>>=' | |
ASSIGNOP.Rule = op_ASSIGN | op_PLUS_ASSIGN | op_MINUS_ASSIGN | op_STAR_ASSIGN | op_SLASH_ASSIGN | op_BAR_ASSIGN | op_AMP_ASSIGN | op_CARET_ASSIGN | op_PERCENT_ASSIGN | op_STAR_STAR_ASSIGN | op_SHL_ASSIGN | op_SHR_ASSIGN | op_USHR_ASSIGN; | |
// BITOP ::= '&' | '|' | '^' | '<<' | '>>' | '>>>' | |
BITOP.Rule = op_AMP | op_BAR | op_CARET | op_SHL | op_SHR | op_USHR; | |
// BITS ::= single token: binary 0b or 0B, "octal 0o or 0O, "decimal 0d or 0D, "hexadecimal 0x or 0X | |
// No need to set a Rule because it is type: CreateAngelScriptNumber | |
// BREAK ::= 'break' ';' | |
BREAK.Rule = k_BREAK + op_SEMI; | |
// CASE ::= (('case' EXPR) | 'default') ':' {STATEMENT} | |
CASE.Rule = ((k_CASE + EXPR) | k_DEFAULT) + op_COLON + MakeStarRule(STATEMENT); | |
// CAST ::= 'cast' '<' TYPE '>' '(' ASSIGN ')' | |
CAST.Rule = k_CAST + op_LT + TYPE + op_GT + op_L_PAR + ASSIGN + op_R_PAR; | |
// CLASS ::= {'shared' | 'abstract' | 'final'} 'class' IDENTIFIER [':' IDENTIFIER {',' IDENTIFIER}] '{' {VIRTPROP | FUNC | VAR} '}' | |
NonTerminal CLASS_MODIFIER = new NonTerminal("class modifier"); | |
CLASS_MODIFIER.Rule = k_SHARED | k_ABSTRACT | k_FINAL; | |
NonTerminal CLASS_MODIFIER_LIST = new NonTerminal("class modifier list"); | |
CLASS_MODIFIER_LIST.Rule = MakeStarRule(CLASS_MODIFIER_LIST, CLASS_MODIFIER); | |
CLASS.Rule = CLASS_MODIFIER_LIST + k_CLASS + IDENTIFIER + Optional(op_COLON + MakeStarRule(op_COMMA, IDENTIFIER, "class_id_list")) + op_L_BRC + MakeStarRule(VIRTPROP | FUNC | VAR) + op_R_BRC; | |
// this hint differentiates CLASS_MODIFIER, ENUM_MODIFIER, FUNC_MODIFIER, INTERFACE_MODIFIER | |
var class_mod_hint = new TokenPreviewHint(PreferredActionType.Reduce, k_CLASS, k_ENUM, op_L_PAR, k_INTERFACE); | |
CLASS_MODIFIER.AddHintToAll(class_mod_hint); | |
CLASS_MODIFIER_LIST.AddHintToAll(class_mod_hint); | |
// COMPOP ::= '==' | '!=' | '<' | '<=' | '>' | '>=' | 'is' | '!is' | |
COMPOP.Rule = op_EQ | op_NEQ | op_LT | op_LTEQ | op_GT | op_GTEQ | op_IS | op_IS_NOT; | |
// CONDITION ::= EXPR ['?' ASSIGN ':' ASSIGN] | |
CONDITION.Rule = EXPR + Optional(op_QMARK + ASSIGN + op_COLON + ASSIGN); | |
// CONSTRUCTCALL::= TYPE ARGLIST | |
CONSTRUCTCALL.Rule = TYPE + ARGLIST; | |
// CONTINUE ::= 'continue' ';' | |
CONTINUE.Rule = k_CONTINUE + op_SEMI; | |
// DATATYPE ::= (IDENTIFIER | PRIMTYPE | '?' | 'auto') | |
DATATYPE.Rule = IDENTIFIER | PRIMTYPE | op_QMARK | k_AUTO; | |
// DOWHILE ::= 'do' STATEMENT 'while' '(' ASSIGN ')' ';' | |
DOWHILE.Rule = k_DO + STATEMENT + k_WHILE + op_L_PAR + ASSIGN + op_R_PAR + op_SEMI; | |
// ENUM ::= ['shared'] 'enum' IDENTIFIER '{' IDENTIFIER ['=' EXPR] {',' IDENTIFIER ['=' EXPR]} '}' | |
NonTerminal ENUM_MODIFIER = new NonTerminal("enum_modifier"); | |
ENUM_MODIFIER.Rule = Empty | k_SHARED; | |
NonTerminal ENUM_ITEM = new NonTerminal("enum_item"); | |
ENUM_ITEM.Rule = IDENTIFIER + Optional(op_ASSIGN + EXPR, "assign_expr"); | |
ENUM.Rule = ENUM_MODIFIER + k_ENUM + IDENTIFIER + op_L_BRC + MakeStarRule(op_COMMA, ENUM_ITEM, "enum_list") + op_R_BRC; | |
// this hint differentiates CLASS_MODIFIER, ENUM_MODIFIER, FUNC_MODIFIER, INTERFACE_MODIFIER | |
// var enum_mod_hint = new TokenPreviewHint(PreferredActionType.Reduce, k_ENUM, k_CLASS, op_L_PAR, k_INTERFACE); | |
var enum_mod_hint = new TokenPreviewHint(PreferredActionType.Reduce, k_ENUM, k_CLASS, op_L_PAR, k_INTERFACE); | |
ENUM_MODIFIER.AddHintToAll(enum_mod_hint); | |
ENUM.AddHintToAll(enum_mod_hint); | |
// Original Rule: EXPR ::= (TYPE '=' INITLIST) | (EXPR_TERM {EXPR_OP EXPR_TERM}) | |
// Original Rule: EXPR.Rule = (TYPE + op_ASSIGN + INITLIST) | (EXPR_TERM + MakeStarRule(EXPR_OP + EXPR_TERM)); | |
NonTerminal EXPR1 = new NonTerminal("expr1"); | |
NonTerminal EXPR2 = new NonTerminal("expr2"); | |
// EXPR1 gets rolled into VOID_CONSTRUCTCALL_FUNCCALL_VARACCESS. | |
// And VOID_CONSTRUCTCALL_FUNCCALL_VARACCESS can be reached via EXPR2. | |
// So it doesn't have to be included here. | |
//EXPR1.Rule = TYPE + op_ASSIGN + INITLIST; | |
EXPR2.Rule = EXPR_TERM + MakeStarRule(EXPR_OP + EXPR_TERM, "expr2_star"); | |
EXPR.Rule = /*EXPR1 |*/ EXPR2; | |
// EXPR_OP ::= MATHOP | COMPOP | LOGICOP | BITOP | |
EXPR_OP.Rule = MATHOP | COMPOP | LOGICOP | BITOP; | |
// EXPR_POSTOP ::= ('.' (FUNCCALL | IDENTIFIER)) | ('[' [IDENTIFIER ':'] ASSIGN {',' [IDENTIFIER ':'] ASSIGN} ']') | ARGLIST | '++' | '--' | |
// EXPR_POSTOP.Rule = (op_DOT + (FUNCCALL | IDENTIFIER)) | (op_L_BKT + IDENTIFIER_COLON_OPT_ASSIGN + MakeStarRule(op_COMMA + IDENTIFIER_COLON_OPT_ASSIGN) + op_R_BKT) | ARGLIST | op_PLUS_PLUS | op_MINUS_MINUS; | |
EXPR_POSTOP.Rule = (op_DOT + (FUNCCALL | IDENTIFIER)) | (op_L_BKT + MakeStarRule(op_COMMA, IDENTIFIER_COLON_OPT_ASSIGN, "expr_postop_list") + op_R_BKT) | ARGLIST | op_PLUS_PLUS | op_MINUS_MINUS; | |
// EXPR_PREOP ::= '-' | '+' | '!' | '++' | '--' | '~' | '@' | |
EXPR_PREOP.Rule = op_MINUS | op_PLUS | op_EMARK | op_PLUS_PLUS | op_MINUS_MINUS | op_TILDE | op_AT; | |
// EXPR_STAT ::= [ASSIGN] ';' | |
EXPR_STAT.Rule = Optional(ASSIGN) + op_COLON; | |
// EXPR_TERM ::= {EXPR_PREOP} EXPR_VALUE {EXPR_POSTOP} | |
EXPR_TERM.Rule = MakeStarRule(EXPR_PREOP) + EXPR_VALUE + MakeStarRule(EXPR_POSTOP); | |
// Original Rule: EXPR_VALUE ::= 'void' | CONSTRUCTCALL | FUNCCALL | VARACCESS | CAST | LITERAL | '(' ASSIGN ')' | |
// VOID_CONSTRUCTCALL_FUNCCALL_VARACCESS ::= TYPE [ARGLIST] | |
NonTerminal VOID_CONSTRUCTCALL_FUNCCALL_VARACCESS = new NonTerminal("void_constructcall_funccall_varaccess"); | |
NonTerminal EXPR1_INITLIST = new NonTerminal("expr1_initlist"); | |
EXPR1_INITLIST.Rule = "=" + INITLIST; | |
// We remove the ARGLIST from the rule below because is can be reached by EXPR_POSTOP | |
VOID_CONSTRUCTCALL_FUNCCALL_VARACCESS.Rule = TYPE + (Empty | EXPR1_INITLIST /*| ARGLIST*/); | |
// We combine CONSTRUCTCALL and FUNCCALL and VARACCESS into one state since they are so similar. | |
// We also combine k_VOID into it since it can be made from TYPE. | |
// We also combine EXPR1 into it by adding an optional ("+" + INITLIST) at the end | |
EXPR_VALUE.Rule = VOID_CONSTRUCTCALL_FUNCCALL_VARACCESS | CAST | LITERAL | op_L_PAR + ASSIGN + op_R_PAR; | |
// FOR ::= 'for' '(' (VAR | EXPR_STAT) EXPR_STAT [ASSIGN {',' ASSIGN}] ')' STATEMENT | |
// FOR.Rule = k_FOR + op_L_PAR + (VAR | EXPR_STAT) + EXPR_STAT + Optional(ASSIGN + MakeStarRule(op_COMMA + ASSIGN)) + op_R_PAR + STATEMENT; | |
FOR.Rule = k_FOR + op_L_PAR + (VAR | EXPR_STAT) + EXPR_STAT + MakeStarRule(op_COMMA, ASSIGN, "for_assign_list") + op_R_PAR + STATEMENT; | |
// FUNC ::= ['private' | 'protected' | 'shared'] [((TYPE ['&']) | '~')] IDENTIFIER PARAMLIST ['const'] {'override' | 'final'} STATBLOCK | |
NonTerminal FUNC_MODIFIER = new NonTerminal("func_modifier"); | |
FUNC_MODIFIER.Rule = Empty | k_PRIVATE | k_PROTECTED | k_SHARED; | |
NonTerminal FUNC_MOD2 = new NonTerminal("func_mod2"); | |
FUNC_MOD2.Rule = Empty | CustomActionHere(CheckIfNotIdentifierWithLPar)+TYPE_NO_LPAR + Optional(op_AMP) | op_TILDE; | |
FUNC.Rule = FUNC_MODIFIER + FUNC_MOD2 + /*CustomActionHere(CheckIfIdentifierWithLPar) +*/ IDENTIFIER + PARAMLIST + Optional(k_CONST) + MakeStarRule(k_OVERRIDE | k_FINAL, "func_override_final") + STATBLOCK; | |
// this hint differentiates CLASS_MODIFIER, ENUM_MODIFIER, FUNC_MODIFIER, INTERFACE_MODIFIER | |
// this hint differentiates FUNC_MODIFIER, VAR_MODIFIER, VIRTPROP_MODIFIER | |
var func_mod_hint = new TokenPreviewHint(PreferredActionType.Reduce, op_L_PAR, k_CLASS, k_ENUM, k_INTERFACE, op_SEMI, op_L_BRC); | |
FUNC_MODIFIER.AddHintToAll(func_mod_hint); | |
// FUNCCALL ::= SCOPE IDENTIFIER ARGLIST | |
FUNCCALL.Rule = SCOPE + IDENTIFIER + ARGLIST; | |
// FUNCDEF ::= 'funcdef' TYPE ['&'] IDENTIFIER PARAMLIST ';' | |
FUNCDEF.Rule = k_FUNCDEF + TYPE + Optional(op_AMP) + IDENTIFIER + PARAMLIST + op_SEMI; | |
// IDENTIFIER ::= single token: starts with letter or _, can include any letter and digit, same as in C++ | |
// No need to set a Rule because it is type: IdentifierTerminal | |
// IF ::= 'if' '(' ASSIGN ')' STATEMENT ['else' STATEMENT] | |
IF.Rule = k_IF + op_L_PAR + ASSIGN + op_R_PAR + STATEMENT + Optional(PreferShiftHere() + k_ELSE + STATEMENT, "if_else_statement"); | |
// IMPORT ::= 'import' TYPE ['&'] IDENTIFIER PARAMLIST 'from' STRING ';' | |
IMPORT.Rule = k_IMPORT + TYPE + Optional(op_AMP) + IDENTIFIER + PARAMLIST + k_FROM + STRING + op_SEMI; | |
// INITLIST ::= '{' [ASSIGN | INITLIST] {',' [ASSIGN | INITLIST]} '}' | |
// INITLIST.Rule = op_L_BRC + Optional(ASSIGN | INITLIST) + MakeStarRule(op_COMMA + Optional(ASSIGN | INITLIST)) + op_R_BRC; | |
// ASSIGN_OR_INITLIST ::= ASSIGN | INITLIST | |
NonTerminal ASSIGN_OR_INITLIST = new NonTerminal("assign_or_initlist"); | |
ASSIGN_OR_INITLIST.Rule = ASSIGN | INITLIST; | |
// INITLIST ::= '{' [ASSIGN_OR_INITLIST] {',' [ASSIGN_OR_INITLIST]} '}' | |
INITLIST.Rule = op_L_BRC + Optional(ASSIGN_OR_INITLIST) + MakeStarRule(op_COMMA + Optional(ASSIGN_OR_INITLIST)) + op_R_BRC; | |
// INITLIST.Rule = op_L_BRC + MakeStarRule(op_COMMA, Optional(ASSIGN_OR_INITLIST), "initlist_list") + op_R_BRC; | |
// INTERFACE ::= ['shared'] 'interface' IDENTIFIER [':' IDENTIFIER {',' IDENTIFIER}] '{' {VIRTPROP | INTFMTHD} '}' | |
NonTerminal INTERFACE_MODIFIER = new NonTerminal("interface_modifier"); | |
INTERFACE_MODIFIER.Rule = Empty | k_SHARED; | |
NonTerminal INTERFACE_INTFMTHD = new NonTerminal("interface_intfmthd"); | |
INTERFACE_INTFMTHD.Rule = ReduceIf("{", "(") + INTFMTHD; | |
NonTerminal INTERFACE_VIRTPROP = new NonTerminal("interface_virtprop"); | |
INTERFACE_VIRTPROP.Rule = ReduceIf("(", "{") + VIRTPROP; | |
NonTerminal INTERFACE_IV = new NonTerminal("interface_iv"); | |
// INTERFACE_IV.Rule = INTERFACE_INTFMTHD | INTERFACE_VIRTPROP; | |
INTERFACE_IV.Rule = ReduceIf("{", "(") + INTFMTHD | ReduceIf("(", "{") + VIRTPROP; | |
INTERFACE.Rule = INTERFACE_MODIFIER + k_INTERFACE + IDENTIFIER | |
// + Optional(op_COLON + IDENTIFIER + MakeStarRule(op_COMMA + IDENTIFIER), "interface_id_star") | |
+ Optional(op_COLON + MakeStarRule(op_COMMA, IDENTIFIER, "interface_id_list"), "interface_id_list_opt") | |
+ op_L_BRC | |
+ MakeStarRule(INTERFACE_IV, "interface_iv_star") | |
+ op_R_BRC; | |
// this hint differentiates CLASS_MODIFIER, ENUM_MODIFIER, FUNC_MODIFIER, INTERFACE_MODIFIER | |
var interface_mod_hint = new TokenPreviewHint(PreferredActionType.Reduce, k_INTERFACE, k_CLASS, k_ENUM, op_L_PAR); | |
INTERFACE_MODIFIER.AddHintToAll(interface_mod_hint); | |
// INTFMTHD ::= TYPE ['&'] IDENTIFIER PARAMLIST ['const'] ';' | |
NonTerminal INTFMTHD_TYPE = new NonTerminal("intfmthd_type"); | |
INTFMTHD_TYPE.Rule = TYPE; | |
// INTFMTHD.Rule = ReduceIf("(", "{") + TYPE + Optional(op_AMP) + IDENTIFIER + PARAMLIST + Optional(k_CONST) + ";"; | |
INTFMTHD.Rule = INTFMTHD_TYPE + Optional(op_AMP) + IDENTIFIER + PARAMLIST + Optional(k_CONST) + ";"; | |
// this hint differentiates INTERFACE->INTFMTHD->TYPE and INTERFACE->VIRTPROP->TYPE | |
// var intfmthd_hint = new TokenPreviewHint(PreferredActionType.Reduce, op_L_PAR, op_L_BRC); | |
// INTFMTHD.AddHintToAll(intfmthd_hint); | |
// INTFMTHD_TYPE.AddHintToAll(intfmthd_hint); | |
// LITERAL ::= NUMBER | STRING | BITS | 'true' | 'false' | 'null' | |
LITERAL.Rule = NUMBER | STRING | BITS | k_TRUE | k_FALSE | k_NULL; | |
// LOGICOP ::= '&&' | '||' | '^^' | 'and' | 'or' | 'xor' | |
LOGICOP.Rule = op_AMP_AMP | op_BAR_BAR | op_CARET_CARET | op_AND | op_OR | op_XOR; | |
// MATHOP ::= '+' | '-' | '*' | '/' | '%' | '**' | |
MATHOP.Rule = op_PLUS | op_MINUS | op_STAR | op_SLASH | op_PERCENT | op_STAR_STAR; | |
// MIXIN ::= 'mixin' CLASS | |
MIXIN.Rule = "mixin" + CLASS; | |
// NAMESPACE ::= 'namespace' IDENTIFIER '{' SCRIPT '}' | |
NAMESPACE.Rule = k_NAMESPACE + IDENTIFIER + op_L_BRC + SCRIPT + op_R_BRC; | |
// NUMBER ::= single token: includes integers and real numbers, same as C++ | |
// No need to set a Rule because it is type: CreateAngelScriptNumber | |
// PARAMLIST ::= '(' ('void' | (TYPE TYPEMOD [IDENTIFIER] ['=' EXPR] {',' TYPE TYPEMOD [IDENTIFIER] ['=' EXPR]})) ')' | |
// PARAMLIST_TYPE ::= TYPE TYPEMOD [IDENTIFIER] ['=' EXPR] | |
NonTerminal PARAMLIST_TYPE = new NonTerminal("paramlist_type"); | |
PARAMLIST_TYPE.Rule = TYPE + TYPEMOD + Optional(IDENTIFIER) + Optional(op_ASSIGN + EXPR); | |
// PARAMLIST ::= '(' ('void' | (PARAMLIST_TYPE {',' PARAMLIST_TYPE})) ')' | |
// Note: Void is commented out because it can be reached via: PARAMLIST_TYPE -> TYPE | |
PARAMLIST.Rule = op_L_PAR + /*(k_VOID | (*/PARAMLIST_TYPE + MakeStarRule(op_COMMA + PARAMLIST_TYPE)/*))*/ + op_R_PAR; | |
// PRIMTYPE ::= 'void' | 'int' | 'int8' | 'int16' | 'int32' | 'int64' | 'uint' | 'uint8' | 'uint16' | 'uint32' | 'uint64' | 'float' | 'double' | 'bool' | |
PRIMTYPE.Rule = k_VOID | k_INT8 | k_INT16 | k_INT32 | k_INT64 | k_INT | k_UINT8 | k_UINT16 | k_UINT32 | k_UINT64 | k_UINT | k_FLOAT | k_DOUBLE | k_BOOL; | |
// RETURN ::= 'return' [ASSIGN] ';' | |
RETURN.Rule = k_RETURN + Optional(ASSIGN) + op_SEMI; | |
// Original Rule: SCOPE ::= [[IDENTIFIER] '::' {IDENTIFIER '::'}] | |
// Original Rule: SCOPE.Rule = Optional(Optional(IDENTIFIER, "scope_first_identifier_opt") + op_COLON_COLON + MakeStarRule((IDENTIFIER + op_COLON_COLON), "scope_next_identifier_star"), "scope_full_opt"); | |
// SCOPE ::= [(IDENTIFIER_COLON_COLON | '::') + IDENTIFIER_COLON_COLON_LIST] | |
SCOPE.Rule = Optional((IDENTIFIER_COLON_COLON | op_COLON_COLON) + IDENTIFIER_COLON_COLON_LIST, "scope_full_opt"); | |
// NonTerminal VAR_VIRTPROP_MODIFIER = new NonTerminal("var_virtprop_modifier"); | |
// VAR_VIRTPROP_MODIFIER.Rule = Empty | k_PRIVATE | k_PROTECTED; | |
// NonTerminal VAR_VIRTPROP = new NonTerminal("var_virtprop"); | |
// NonTerminal VAR_VIRTPROP_VAREND = new NonTerminal("VAR_VIRTPROP_VAREND"); | |
// VAR_VIRTPROP_VAREND.Rule = Optional((op_EQ + (INITLIST | EXPR)) | ARGLIST, "var_eq_iea1") + MakeStarRule(op_COMMA + IDENTIFIER + Optional((op_EQ + (INITLIST | EXPR)) | ARGLIST, "var_eq_iea2"), "var_star") + op_SEMI; | |
// NonTerminal VAR_VIRTPROP_VIRTPROPEND = new NonTerminal("VAR_VIRTPROP_VIRTPROPEND"); | |
// VAR_VIRTPROP_VIRTPROPEND.Rule = op_L_BRC + MakeStarRule((k_GET | k_SET) + Optional(k_CONST) + Optional(k_OVERRIDE | k_FINAL) + (STATBLOCK | op_SEMI), "virtprop_star") + op_R_BRC; | |
// // main rule | |
// VAR_VIRTPROP.Rule = VAR_VIRTPROP_MODIFIER + VAR_VIRTPROP_FUNC_START + IDENTIFIER + (VAR_VIRTPROP_VAREND | VAR_VIRTPROP_VIRTPROPEND); | |
// SCRIPT.Rule = MakeStarRule(SCRIPT, IMPORT | ENUM | TYPEDEF | CLASS | MIXIN | INTERFACE | FUNCDEF | VAR_VIRTPROP | FUNC | NAMESPACE | op_SEMI, "script_star"); | |
NonTerminal SCRIPT_ITEM = new NonTerminal("script_item"); | |
SCRIPT_ITEM.Rule = IMPORT | ENUM | TYPEDEF | CLASS | MIXIN | INTERFACE | FUNCDEF | VAR | VIRTPROP | FUNC | NAMESPACE | op_SEMI; | |
SCRIPT.Rule = MakeStarRule(SCRIPT, SCRIPT_ITEM); | |
// STATBLOCK ::= '{' {VAR | STATEMENT} '}' | |
STATBLOCK.Rule = op_L_BRC + MakeStarRule(VAR | STATEMENT) + op_R_BRC; | |
// STATEMENT ::= (IF | FOR | WHILE | RETURN | STATBLOCK | BREAK | CONTINUE | DOWHILE | SWITCH | EXPR_STAT) | |
STATEMENT.Rule = (IF | FOR | WHILE | RETURN | STATBLOCK | BREAK | CONTINUE | DOWHILE | SWITCH | EXPR_STAT); | |
// STRING ::= single token: single quoted ', "double quoted ", "or heredoc multi-line string """ | |
// No need to set a Rule because it is type: StringLiteral | |
// SWITCH ::= 'switch' '(' ASSIGN ')' '{' {CASE} '}' | |
SWITCH.Rule = k_SWITCH + op_L_PAR + ASSIGN + op_R_PAR + op_L_BRC + MakeStarRule(CASE) + op_R_BRC; | |
// TYPE ::= ['const'] SCOPE DATATYPE ['<' TYPE {',' TYPE} '>'] { ('[' ']') | '@' } | |
// We create two TYPEs, one that can have a following "(" and one that cannot. | |
// This is required to differentiate between states that includes TYPEs in them. | |
NonTerminal TYPE_ARRAY = new NonTerminal("type_array"); | |
TYPE_ARRAY.Rule = CustomActionHere(CheckIfLeftThenRightBracket) + op_L_BKT + op_R_BKT; | |
TYPE.Rule = Optional(k_CONST, "type_const") + /*(CustomActionHere(CheckIfNotIdentifierWithLPar) + SCOPE)*/ SCOPE + DATATYPE + Optional(op_LT + TYPE + MakeStarRule(op_COMMA + TYPE, "type_typelist_star") + op_GT, "type_typelist_opt") + MakeStarRule(TYPE_ARRAY | op_AT, "type_array_star"); | |
TYPE_NO_LPAR.Rule = Optional(k_CONST, "type_const") + (CustomActionHere(CheckIfNotIdentifierWithLPar) + SCOPE) + (CustomActionHere(CheckIfNotIdentifierWithLPar) + DATATYPE) + Optional(op_LT + TYPE + MakeStarRule(op_COMMA + TYPE, "type_typelist_star") + op_GT, "type_typelist_opt") + MakeStarRule(TYPE_ARRAY | op_AT, "type_array_star"); | |
// TYPEDEF ::= 'typedef' PRIMTYPE IDENTIFIER ';' | |
TYPEDEF.Rule = k_TYPEDEF + PRIMTYPE + IDENTIFIER + op_SEMI; | |
// TYPEMOD ::= ['&' ['in' | 'out' | 'inout']] | |
TYPEMOD.Rule = Optional(op_AMP + Optional(k_IN | k_OUT | k_INOUT)); | |
// VAR ::= ['private'|'protected'] TYPE IDENTIFIER [( '=' (INITLIST | EXPR)) | ARGLIST] {',' IDENTIFIER [( '=' (INITLIST | EXPR)) | ARGLIST]} ';' | |
NonTerminal VAR_MODIFIER = new NonTerminal("var_modifier"); | |
VAR_MODIFIER.Rule = Empty | k_PRIVATE | k_PROTECTED; | |
VAR.Rule = VAR_MODIFIER + TYPE + IDENTIFIER + Optional((op_EQ + (INITLIST | EXPR)) | ARGLIST, "var_eq_iea1") + MakeStarRule(op_COMMA + IDENTIFIER + Optional((op_EQ + (INITLIST | EXPR)) | ARGLIST, "var_eq_iea2"), "var_star") + op_SEMI; | |
// this hint differentiates FUNC_MODIFIER, VAR_MODIFIER, VIRTPROP_MODIFIER | |
var var_mod_hint = new TokenPreviewHint(PreferredActionType.Reduce, op_SEMI, op_L_PAR, op_L_BRC); | |
VAR_MODIFIER.AddHintToAll(var_mod_hint); | |
// VARACCESS ::= SCOPE IDENTIFIER | |
VARACCESS.Rule = SCOPE + IDENTIFIER; | |
// VIRTPROP ::= ['private' | 'protected'] TYPE ['&'] IDENTIFIER '{' {('get' | 'set') ['const'] [('override' | 'final')] (STATBLOCK | ';')} '}' | |
NonTerminal VIRTPROP_MODIFIER = new NonTerminal("virtprop_modifier"); | |
VIRTPROP_MODIFIER.Rule = Empty | k_PRIVATE | k_PROTECTED; | |
VIRTPROP.Rule = VIRTPROP_MODIFIER + TYPE + Optional(op_AMP) + IDENTIFIER | |
+ op_L_BRC | |
+ MakeStarRule( | |
(k_GET | k_SET) | |
+ Optional(k_CONST) | |
+ Optional(k_OVERRIDE | k_FINAL, "virtprop_o_f") | |
+ (STATBLOCK | op_SEMI) | |
, "virtprop_star") | |
+ op_R_BRC; | |
// this hint differentiates FUNC_MODIFIER, VAR_MODIFIER, VIRTPROP_MODIFIER | |
var virtprop_mod_hint = new TokenPreviewHint(PreferredActionType.Reduce, op_L_BRC, op_L_PAR, op_SEMI); | |
VIRTPROP.AddHintToAll(virtprop_mod_hint); | |
// this hint differentiates INTERFACE->INTFMTHD->TYPE and INTERFACE->VIRTPROP->TYPE | |
// var virtprop_hint = new TokenPreviewHint(PreferredActionType.Reduce, op_L_BRC, op_L_PAR); | |
// VIRTPROP.AddHintToAll(virtprop_hint); | |
// WHILE ::= 'while' '(' ASSIGN ')' STATEMENT | |
WHILE.Rule = k_WHILE + op_L_PAR + ASSIGN + op_R_PAR + STATEMENT; | |
this.RegisterBracePair("[", "]"); | |
this.RegisterBracePair("<", ">"); | |
this.RegisterBracePair("(", ")"); | |
this.RegisterBracePair("{", "}"); | |
this.MarkPunctuation(",", ";", "(", ")", "{", "}", "[", "]"); | |
// This was taken from: http://www.angelcode.com/angelscript/sdk/docs/manual/doc_operator_precedence.html | |
// However it doesn't include some operators (TODO: list them here...) | |
RegisterOperators( 1, Associativity.Right, op_ASSIGN, op_PLUS_ASSIGN, op_MINUS_ASSIGN, op_STAR_ASSIGN, op_SLASH_ASSIGN, op_PERCENT_ASSIGN, op_STAR_STAR_ASSIGN, op_AMP_ASSIGN, op_BAR_ASSIGN, op_CARET_ASSIGN, op_SHL_ASSIGN, op_SHR_ASSIGN, op_USHR_ASSIGN); | |
RegisterOperators( 2, Associativity.Right, op_QMARK, op_COLON); | |
RegisterOperators( 3, Associativity.Left, op_OR, op_BAR_BAR); | |
RegisterOperators( 4, Associativity.Left, op_AND, op_AMP_AMP); | |
RegisterOperators( 5, Associativity.Left, op_EQ, op_NEQ, op_IS, op_IS_NOT, op_XOR, op_CARET_CARET); | |
RegisterOperators( 6, Associativity.Left, op_LTEQ, op_LT, op_GTEQ, op_GT); | |
RegisterOperators( 7, Associativity.Left, op_BAR); | |
RegisterOperators( 8, Associativity.Left, op_CARET); | |
RegisterOperators( 9, Associativity.Left, op_AMP); | |
RegisterOperators(10, Associativity.Left, op_SHL, op_SHR, op_USHR); | |
RegisterOperators(11, Associativity.Left, op_PLUS, op_MINUS); | |
RegisterOperators(12, Associativity.Left, op_STAR, op_SLASH, op_PERCENT); | |
RegisterOperators(13, Associativity.Left, op_STAR_STAR); | |
RegisterOperators(14, Associativity.Left, op_AT); | |
RegisterOperators(15, Associativity.Right, op_TILDE); | |
RegisterOperators(16, Associativity.Right, op_NOT, op_EMARK); | |
RegisterOperators(17, Associativity.Left, op_DOT); | |
RegisterOperators(18, Associativity.Right, op_PLUS_PLUS, op_MINUS_MINUS); | |
RegisterOperators(19, Associativity.Neutral, op_R_BKT); | |
RegisterOperators(20, Associativity.Right, op_COLON_COLON); | |
} | |
// Only accept "[" if it is followed by "]" | |
// ie ("[" + "]") | |
private void CheckIfLeftThenRightBracket(ParsingContext context, CustomParserAction customAction) | |
{ | |
bool pair_found = false; | |
if (context.CurrentParserInput.Term.Name == "l_bkt") | |
{ | |
var scanner = context.Parser.Scanner; | |
scanner.BeginPreview(); | |
Token preview = scanner.GetToken(); | |
if (preview.Terminal.Name == "r_bkt") | |
pair_found = true; | |
scanner.EndPreview(true); | |
} | |
if (pair_found) | |
{ | |
// Is an ("[" + "]") pair | |
ParserAction action = customAction.ShiftActions.First(a => a.Term.Name == "l_bkt"); | |
action.Execute(context); | |
} | |
else | |
{ | |
// Not an ("[" + "]") pair | |
ParserAction action = customAction.ReduceActions.First(); | |
action.Execute(context); | |
} | |
} | |
// Only accept the current state if it IS NOT an IDENTIFIER followed by '(' | |
// ie don't allow (IDENTIFIER + '(') | |
private void CheckIfNotIdentifierWithLPar(ParsingContext context, CustomParserAction customAction) | |
{ | |
Debug.Print("!!!!!!!!!!!! CheckIfNotIdentifierWithLPar START"); | |
bool pair_found = false; | |
if (context.CurrentParserInput.Term.Name == "identifier") | |
{ | |
var scanner = context.Parser.Scanner; | |
scanner.BeginPreview(); | |
Token preview = scanner.GetToken(); | |
Debug.Print(" CheckIfNotIdentifierWithLPar preview is: " + preview.Terminal.Name); | |
if (preview.Terminal.Name == "l_par") | |
pair_found = true; | |
scanner.EndPreview(true); | |
} | |
if (pair_found) | |
{ | |
Debug.Print(" CheckIfNotIdentifierWithLPar REDUCE"); | |
// Is an (IDENTIFIER + "(") pair | |
ParserAction action = customAction.ReduceActions.First(); | |
action.Execute(context); | |
} | |
else | |
{ | |
Debug.Print(" CheckIfNotIdentifierWithLPar SHIFT"); | |
// Not an (IDENTIFIER + "(") pair | |
ParserAction action = customAction.ShiftActions.First(a => a.Term.Name == "identifier"); | |
action.Execute(context); | |
} | |
} | |
// Only accept an IDENTIFIER if it is followed by '(' | |
// ie (IDENTIFIER + '(') | |
private void CheckIfIdentifierWithLPar(ParsingContext context, CustomParserAction customAction) | |
{ | |
Debug.Print("!!!!!!!!!!!!!!! CheckIfIdentifierWithLPar START"); | |
bool pair_found = false; | |
if (context.CurrentParserInput.Term.Name == "identifier") | |
{ | |
var scanner = context.Parser.Scanner; | |
scanner.BeginPreview(); | |
Token preview = scanner.GetToken(); | |
Debug.Print(" CheckIfIdentifierWithLPar preview is: " + preview.Terminal.Name); | |
if (preview.Terminal.Name == "l_par") | |
pair_found = true; | |
scanner.EndPreview(true); | |
} | |
if (pair_found) | |
{ | |
Debug.Print(" CheckIfIdentifierWithLPar SHIFT"); | |
// Is an (IDENTIFIER + "(") pair | |
ParserAction action = customAction.ShiftActions.First(a => a.Term.Name == "identifier"); | |
action.Execute(context); | |
} | |
else | |
{ | |
Debug.Print(" CheckIfIdentifierWithLPar REDUCE"); | |
// Not an (IDENTIFIER + "(") pair | |
ParserAction action = customAction.ReduceActions.First(); | |
action.Execute(context); | |
} | |
} | |
// Only accept an IDENTIFIER if it is followed by ':' | |
// ie (IDENTIFIER + ':') | |
private void CheckIfIdentifierWithColon(ParsingContext context, CustomParserAction customAction) | |
{ | |
bool pair_found = false; | |
if (context.CurrentParserInput.Term.Name == "identifier") | |
{ | |
var scanner = context.Parser.Scanner; | |
scanner.BeginPreview(); | |
Token preview = scanner.GetToken(); | |
if (preview.Terminal.Name == "colon") | |
pair_found = true; | |
// if this is false it seems to skip the parsing of ':' | |
scanner.EndPreview(true); | |
} | |
if (pair_found) | |
{ | |
// Is an (IDENTIFIER + ":") pair | |
ParserAction action = customAction.ShiftActions.First(a => a.Term.Name == "identifier"); | |
action.Execute(context); | |
} | |
else | |
{ | |
// Not an (IDENTIFIER + ":") pair | |
ParserAction action = customAction.ReduceActions.First(); | |
action.Execute(context); | |
} | |
} | |
// Only accept an IDENTIFIER if it is followed by '::' | |
// ie (IDENTIFIER + '::') | |
private void CheckIfIdentifierWithColonColon(ParsingContext context, CustomParserAction customAction) | |
{ | |
bool pair_found = false; | |
if (context.CurrentParserInput.Term.Name == "identifier") | |
{ | |
var scanner = context.Parser.Scanner; | |
scanner.BeginPreview(); | |
Token preview = scanner.GetToken(); | |
if (preview.Terminal.Name == "colon_colon") | |
pair_found = true; | |
// if this is false it seems to skip the parsing of '::' | |
scanner.EndPreview(true); | |
} | |
if (pair_found) | |
{ | |
// Is an (IDENTIFIER + "::") pair | |
ParserAction action = customAction.ShiftActions.First(a => a.Term.Name == "identifier"); | |
action.Execute(context); | |
} | |
else | |
{ | |
// Not an (IDENTIFIER + "::") pair | |
ParserAction action = customAction.ReduceActions.First(); | |
action.Execute(context); | |
} | |
} | |
BnfExpression MakeStarRule(BnfTerm member) | |
{ | |
var list = new NonTerminal(member.Name + "*"); | |
var expr = MakeStarRule(list, member); | |
expr.Name = member.Name + "**"; | |
return expr; | |
//return MakeStarRule(new NonTerminal(member.Name + "*"), member); | |
} | |
BnfExpression MakeStarRule(BnfTerm member, string name) | |
{ | |
var list = new NonTerminal(name + "*list*"); | |
if (member.Name == "" || member.Name == null) | |
{ | |
member.Name = name + "*mmbr*"; | |
} | |
if (list.Name == "" || list.Name == null) | |
{ | |
list.Name = name + "*list*"; | |
} | |
var expr = MakeStarRule(list, member); | |
expr.Name = name + "*expr*"; | |
return expr; | |
//return MakeStarRule(new NonTerminal(name), member); | |
} | |
BnfExpression MakeStarRule(NonTerminal list, BnfTerm member, string name) | |
{ | |
if (member.Name == "" || member.Name == null) | |
{ | |
member.Name = name + "*mmbr*"; | |
} | |
if (list.Name == "" || list.Name == null) | |
{ | |
list.Name = name + "*list*"; | |
} | |
var expr = MakeStarRule(list, member); | |
expr.Name = name + "*expr*"; | |
return expr; | |
//return MakeStarRule(new NonTerminal(name), member); | |
} | |
BnfExpression MakeStarRule(BnfTerm delimiter, BnfTerm member, string name) | |
{ | |
var list = new NonTerminal(name + "*list*"); | |
if (member.Name == "" || member.Name == null) | |
{ | |
member.Name = name + "*mmbr*"; | |
} | |
if (list.Name == "" || list.Name == null) | |
{ | |
list.Name = name + "*list*"; | |
} | |
var expr = MakeStarRule(list, delimiter, member); | |
expr.Name = name + "*expr*"; | |
return expr; | |
//return MakeStarRule(new NonTerminal(name), member); | |
} | |
NonTerminal Optional(BnfTerm term) | |
{ | |
NonTerminal nt = new NonTerminal(term.Name + "?"); | |
nt.Rule = Empty | term; | |
//MarkTransient(nt); | |
//nt.Flags |= TermFlags.IsTransient | TermFlags.NoAstNode; | |
return nt; | |
} | |
NonTerminal Optional(BnfTerm term, string name) | |
{ | |
NonTerminal nt = new NonTerminal(name); | |
nt.Rule = Empty | term; | |
//MarkTransient(nt); | |
//nt.Flags |= TermFlags.IsTransient | TermFlags.NoAstNode; | |
return nt; | |
} | |
public KeyTerm Keyword(string keyword) | |
{ | |
var term = ToTerm(keyword, keyword); | |
// term.SetOption(TermOptions.IsKeyword, true); | |
// term.SetOption(TermOptions.IsReservedWord, true); | |
this.MarkReservedWords(keyword); | |
term.EditorInfo = new TokenEditorInfo(TokenType.Keyword, TokenColor.Keyword, TokenTriggers.None); | |
return term; | |
} | |
public KeyTerm Operator(string text, string name) | |
{ | |
//string opCased = this.CaseSensitive ? op : op.ToLower(); | |
//var term = new KeyTerm(opCased, op); | |
//term.SetOption(TermOptions.IsOperator, true); | |
//term.EditorInfo = new TokenEditorInfo(TokenType.Operator, TokenColor.Keyword, TokenTriggers.None); | |
var term = ToTerm(text, name); | |
return term; | |
} | |
public static NumberLiteral CreateAngelScriptNumber(string name) | |
{ | |
NumberLiteral term = new NumberLiteral(name, NumberOptions.AllowStartEndDot); | |
//default int types are Integer (32bit) -> LongInteger (BigInt); Try Int64 before BigInt: Better performance? | |
term.DefaultIntTypes = new TypeCode[] { TypeCode.Int32, TypeCode.Int64 }; | |
term.DefaultFloatType = TypeCode.Double; // it is default | |
term.AddPrefix("0b", NumberOptions.Binary); | |
term.AddPrefix("0o", NumberOptions.Octal); | |
term.AddPrefix("0d", NumberOptions.IntOnly); | |
term.AddPrefix("0x", NumberOptions.Hex); | |
term.AddSuffix("f", TypeCode.Double); | |
return term; | |
} | |
// The following are all used to specify the identifer character set | |
#region Identifier Character Set Stuff | |
private static void InitializeCharacterSet(ref string characterSet, IEnumerable<int[]> ranges) | |
{ | |
var sbCharSet = new StringBuilder(); | |
foreach (var range in ranges) | |
{ | |
for (int i = range[0]; i <= range[1]; ++i) | |
{ | |
sbCharSet.Append((Char)i); | |
} | |
} | |
characterSet = sbCharSet.ToString(); | |
} | |
private static string _validIdentifierStartCharacters; | |
public static string ValidIdentifierStartCharacters | |
{ | |
get | |
{ | |
if (_validIdentifierStartCharacters == null) | |
{ | |
InitializeCharacterSet(ref _validIdentifierStartCharacters, ValidIdentifierStartCharactersRanges); | |
} | |
return _validIdentifierStartCharacters; | |
} | |
} | |
private static string _validIdentifierCharacters; | |
public static string ValidIdentifierCharacters | |
{ | |
get | |
{ | |
if (_validIdentifierCharacters == null) | |
{ | |
InitializeCharacterSet(ref _validIdentifierCharacters, ValidIdentifierCharactersRanges); | |
} | |
return _validIdentifierCharacters; | |
} | |
} | |
private static readonly int[][] ValidIdentifierStartCharactersRanges = new[] | |
{ | |
#region Identifier Start Character Ranges | |
new[] {36, 36}, | |
new[] {65, 90}, | |
new[] {95, 95}, | |
new[] {97, 122}, | |
new[] {162, 165}, | |
new[] {170, 170}, | |
new[] {181, 181}, | |
new[] {186, 186}, | |
new[] {192, 214}, | |
new[] {216, 246}, | |
new[] {248, 566}, | |
new[] {592, 705}, | |
new[] {710, 721}, | |
new[] {736, 740}, | |
new[] {750, 750}, | |
new[] {890, 890}, | |
new[] {902, 902}, | |
new[] {904, 906}, | |
new[] {908, 908}, | |
new[] {910, 929}, | |
new[] {931, 974}, | |
new[] {976, 1013}, | |
new[] {1015, 1019}, | |
new[] {1024, 1153}, | |
new[] {1162, 1230}, | |
new[] {1232, 1269}, | |
new[] {1272, 1273}, | |
new[] {1280, 1295}, | |
new[] {1329, 1366}, | |
new[] {1369, 1369}, | |
new[] {1377, 1415}, | |
new[] {1488, 1514}, | |
new[] {1520, 1522}, | |
new[] {1569, 1594}, | |
new[] {1600, 1610}, | |
new[] {1646, 1647}, | |
new[] {1649, 1747}, | |
new[] {1749, 1749}, | |
new[] {1765, 1766}, | |
new[] {1774, 1775}, | |
new[] {1786, 1788}, | |
new[] {1791, 1791}, | |
new[] {1808, 1808}, | |
new[] {1810, 1839}, | |
new[] {1869, 1871}, | |
new[] {1920, 1957}, | |
new[] {1969, 1969}, | |
new[] {2308, 2361}, | |
new[] {2365, 2365}, | |
new[] {2384, 2384}, | |
new[] {2392, 2401}, | |
new[] {2437, 2444}, | |
new[] {2447, 2448}, | |
new[] {2451, 2472}, | |
new[] {2474, 2480}, | |
new[] {2482, 2482}, | |
new[] {2486, 2489}, | |
new[] {2493, 2493}, | |
new[] {2524, 2525}, | |
new[] {2527, 2529}, | |
new[] {2544, 2547}, | |
new[] {2565, 2570}, | |
new[] {2575, 2576}, | |
new[] {2579, 2600}, | |
new[] {2602, 2608}, | |
new[] {2610, 2611}, | |
new[] {2613, 2614}, | |
new[] {2616, 2617}, | |
new[] {2649, 2652}, | |
new[] {2654, 2654}, | |
new[] {2674, 2676}, | |
new[] {2693, 2701}, | |
new[] {2703, 2705}, | |
new[] {2707, 2728}, | |
new[] {2730, 2736}, | |
new[] {2738, 2739}, | |
new[] {2741, 2745}, | |
new[] {2749, 2749}, | |
new[] {2768, 2768}, | |
new[] {2784, 2785}, | |
new[] {2801, 2801}, | |
new[] {2821, 2828}, | |
new[] {2831, 2832}, | |
new[] {2835, 2856}, | |
new[] {2858, 2864}, | |
new[] {2866, 2867}, | |
new[] {2869, 2873}, | |
new[] {2877, 2877}, | |
new[] {2908, 2909}, | |
new[] {2911, 2913}, | |
new[] {2929, 2929}, | |
new[] {2947, 2947}, | |
new[] {2949, 2954}, | |
new[] {2958, 2960}, | |
new[] {2962, 2965}, | |
new[] {2969, 2970}, | |
new[] {2972, 2972}, | |
new[] {2974, 2975}, | |
new[] {2979, 2980}, | |
new[] {2984, 2986}, | |
new[] {2990, 2997}, | |
new[] {2999, 3001}, | |
new[] {3065, 3065}, | |
new[] {3077, 3084}, | |
new[] {3086, 3088}, | |
new[] {3090, 3112}, | |
new[] {3114, 3123}, | |
new[] {3125, 3129}, | |
new[] {3168, 3169}, | |
new[] {3205, 3212}, | |
new[] {3214, 3216}, | |
new[] {3218, 3240}, | |
new[] {3242, 3251}, | |
new[] {3253, 3257}, | |
new[] {3261, 3261}, | |
new[] {3294, 3294}, | |
new[] {3296, 3297}, | |
new[] {3333, 3340}, | |
new[] {3342, 3344}, | |
new[] {3346, 3368}, | |
new[] {3370, 3385}, | |
new[] {3424, 3425}, | |
new[] {3461, 3478}, | |
new[] {3482, 3505}, | |
new[] {3507, 3515}, | |
new[] {3517, 3517}, | |
new[] {3520, 3526}, | |
new[] {3585, 3632}, | |
new[] {3634, 3635}, | |
new[] {3647, 3654}, | |
new[] {3713, 3714}, | |
new[] {3716, 3716}, | |
new[] {3719, 3720}, | |
new[] {3722, 3722}, | |
new[] {3725, 3725}, | |
new[] {3732, 3735}, | |
new[] {3737, 3743}, | |
new[] {3745, 3747}, | |
new[] {3749, 3749}, | |
new[] {3751, 3751}, | |
new[] {3754, 3755}, | |
new[] {3757, 3760}, | |
new[] {3762, 3763}, | |
new[] {3773, 3773}, | |
new[] {3776, 3780}, | |
new[] {3782, 3782}, | |
new[] {3804, 3805}, | |
new[] {3840, 3840}, | |
new[] {3904, 3911}, | |
new[] {3913, 3946}, | |
new[] {3976, 3979}, | |
new[] {4096, 4129}, | |
new[] {4131, 4135}, | |
new[] {4137, 4138}, | |
new[] {4176, 4181}, | |
new[] {4256, 4293}, | |
new[] {4304, 4344}, | |
new[] {4352, 4441}, | |
new[] {4447, 4514}, | |
new[] {4520, 4601}, | |
new[] {4608, 4614}, | |
new[] {4616, 4678}, | |
new[] {4680, 4680}, | |
new[] {4682, 4685}, | |
new[] {4688, 4694}, | |
new[] {4696, 4696}, | |
new[] {4698, 4701}, | |
new[] {4704, 4742}, | |
new[] {4744, 4744}, | |
new[] {4746, 4749}, | |
new[] {4752, 4782}, | |
new[] {4784, 4784}, | |
new[] {4786, 4789}, | |
new[] {4792, 4798}, | |
new[] {4800, 4800}, | |
new[] {4802, 4805}, | |
new[] {4808, 4814}, | |
new[] {4816, 4822}, | |
new[] {4824, 4846}, | |
new[] {4848, 4878}, | |
new[] {4880, 4880}, | |
new[] {4882, 4885}, | |
new[] {4888, 4894}, | |
new[] {4896, 4934}, | |
new[] {4936, 4954}, | |
new[] {5024, 5108}, | |
new[] {5121, 5740}, | |
new[] {5743, 5750}, | |
new[] {5761, 5786}, | |
new[] {5792, 5866}, | |
new[] {5870, 5872}, | |
new[] {5888, 5900}, | |
new[] {5902, 5905}, | |
new[] {5920, 5937}, | |
new[] {5952, 5969}, | |
new[] {5984, 5996}, | |
new[] {5998, 6000}, | |
new[] {6016, 6067}, | |
new[] {6103, 6103}, | |
new[] {6107, 6108}, | |
new[] {6176, 6263}, | |
new[] {6272, 6312}, | |
new[] {6400, 6428}, | |
new[] {6480, 6509}, | |
new[] {6512, 6516}, | |
new[] {7424, 7531}, | |
new[] {7680, 7835}, | |
new[] {7840, 7929}, | |
new[] {7936, 7957}, | |
new[] {7960, 7965}, | |
new[] {7968, 8005}, | |
new[] {8008, 8013}, | |
new[] {8016, 8023}, | |
new[] {8025, 8025}, | |
new[] {8027, 8027}, | |
new[] {8029, 8029}, | |
new[] {8031, 8061}, | |
new[] {8064, 8116}, | |
new[] {8118, 8124}, | |
new[] {8126, 8126}, | |
new[] {8130, 8132}, | |
new[] {8134, 8140}, | |
new[] {8144, 8147}, | |
new[] {8150, 8155}, | |
new[] {8160, 8172}, | |
new[] {8178, 8180}, | |
new[] {8182, 8188}, | |
new[] {8255, 8256}, | |
new[] {8276, 8276}, | |
new[] {8305, 8305}, | |
new[] {8319, 8319}, | |
new[] {8352, 8369}, | |
new[] {8450, 8450}, | |
new[] {8455, 8455}, | |
new[] {8458, 8467}, | |
new[] {8469, 8469}, | |
new[] {8473, 8477}, | |
new[] {8484, 8484}, | |
new[] {8486, 8486}, | |
new[] {8488, 8488}, | |
new[] {8490, 8493}, | |
new[] {8495, 8497}, | |
new[] {8499, 8505}, | |
new[] {8509, 8511}, | |
new[] {8517, 8521}, | |
new[] {8544, 8579}, | |
new[] {12293, 12295}, | |
new[] {12321, 12329}, | |
new[] {12337, 12341}, | |
new[] {12344, 12348}, | |
new[] {12353, 12438}, | |
new[] {12445, 12447}, | |
new[] {12449, 12543}, | |
new[] {12549, 12588}, | |
new[] {12593, 12686}, | |
new[] {12704, 12727}, | |
new[] {12784, 12799}, | |
new[] {13312, 19893}, | |
new[] {19968, 40869}, | |
new[] {40960, 42124}, | |
new[] {44032, 55203}, | |
new[] {63744, 64045}, | |
new[] {64048, 64106}, | |
new[] {64256, 64262}, | |
new[] {64275, 64279}, | |
new[] {64285, 64285}, | |
new[] {64287, 64296}, | |
new[] {64298, 64310}, | |
new[] {64312, 64316}, | |
new[] {64318, 64318}, | |
new[] {64320, 64321}, | |
new[] {64323, 64324}, | |
new[] {64326, 64433}, | |
new[] {64467, 64829}, | |
new[] {64848, 64911}, | |
new[] {64914, 64967}, | |
new[] {65008, 65020}, | |
new[] {65075, 65076}, | |
new[] {65101, 65103}, | |
new[] {65129, 65129}, | |
new[] {65136, 65140}, | |
new[] {65142, 65276}, | |
new[] {65284, 65284}, | |
new[] {65313, 65338}, | |
new[] {65343, 65343}, | |
new[] {65345, 65370}, | |
new[] {65381, 65470}, | |
new[] {65474, 65479}, | |
new[] {65482, 65487}, | |
new[] {65490, 65495}, | |
new[] {65498, 65500}, | |
new[] {65504, 65505}, | |
new[] {65509, 65510}, | |
#endregion | |
}; | |
private static readonly int[][] ValidIdentifierCharactersRanges = new[] | |
{ | |
#region Identifier Character Ranges | |
new[] {0, 8}, | |
new[] {14, 27}, | |
new[] {36, 36}, | |
new[] {48, 57}, | |
new[] {65, 90}, | |
new[] {95, 95}, | |
new[] {97, 122}, | |
new[] {127, 159}, | |
new[] {162, 165}, | |
new[] {170, 170}, | |
new[] {173, 173}, | |
new[] {181, 181}, | |
new[] {186, 186}, | |
new[] {192, 214}, | |
new[] {216, 246}, | |
new[] {248, 566}, | |
new[] {592, 705}, | |
new[] {710, 721}, | |
new[] {736, 740}, | |
new[] {750, 750}, | |
new[] {768, 855}, | |
new[] {861, 879}, | |
new[] {890, 890}, | |
new[] {902, 902}, | |
new[] {904, 906}, | |
new[] {908, 908}, | |
new[] {910, 929}, | |
new[] {931, 974}, | |
new[] {976, 1013}, | |
new[] {1015, 1019}, | |
new[] {1024, 1153}, | |
new[] {1155, 1158}, | |
new[] {1162, 1230}, | |
new[] {1232, 1269}, | |
new[] {1272, 1273}, | |
new[] {1280, 1295}, | |
new[] {1329, 1366}, | |
new[] {1369, 1369}, | |
new[] {1377, 1415}, | |
new[] {1425, 1441}, | |
new[] {1443, 1465}, | |
new[] {1467, 1469}, | |
new[] {1471, 1471}, | |
new[] {1473, 1474}, | |
new[] {1476, 1476}, | |
new[] {1488, 1514}, | |
new[] {1520, 1522}, | |
new[] {1536, 1539}, | |
new[] {1552, 1557}, | |
new[] {1569, 1594}, | |
new[] {1600, 1624}, | |
new[] {1632, 1641}, | |
new[] {1646, 1747}, | |
new[] {1749, 1757}, | |
new[] {1759, 1768}, | |
new[] {1770, 1788}, | |
new[] {1791, 1791}, | |
new[] {1807, 1866}, | |
new[] {1869, 1871}, | |
new[] {1920, 1969}, | |
new[] {2305, 2361}, | |
new[] {2364, 2381}, | |
new[] {2384, 2388}, | |
new[] {2392, 2403}, | |
new[] {2406, 2415}, | |
new[] {2433, 2435}, | |
new[] {2437, 2444}, | |
new[] {2447, 2448}, | |
new[] {2451, 2472}, | |
new[] {2474, 2480}, | |
new[] {2482, 2482}, | |
new[] {2486, 2489}, | |
new[] {2492, 2500}, | |
new[] {2503, 2504}, | |
new[] {2507, 2509}, | |
new[] {2519, 2519}, | |
new[] {2524, 2525}, | |
new[] {2527, 2531}, | |
new[] {2534, 2547}, | |
new[] {2561, 2563}, | |
new[] {2565, 2570}, | |
new[] {2575, 2576}, | |
new[] {2579, 2600}, | |
new[] {2602, 2608}, | |
new[] {2610, 2611}, | |
new[] {2613, 2614}, | |
new[] {2616, 2617}, | |
new[] {2620, 2620}, | |
new[] {2622, 2626}, | |
new[] {2631, 2632}, | |
new[] {2635, 2637}, | |
new[] {2649, 2652}, | |
new[] {2654, 2654}, | |
new[] {2662, 2676}, | |
new[] {2689, 2691}, | |
new[] {2693, 2701}, | |
new[] {2703, 2705}, | |
new[] {2707, 2728}, | |
new[] {2730, 2736}, | |
new[] {2738, 2739}, | |
new[] {2741, 2745}, | |
new[] {2748, 2757}, | |
new[] {2759, 2761}, | |
new[] {2763, 2765}, | |
new[] {2768, 2768}, | |
new[] {2784, 2787}, | |
new[] {2790, 2799}, | |
new[] {2801, 2801}, | |
new[] {2817, 2819}, | |
new[] {2821, 2828}, | |
new[] {2831, 2832}, | |
new[] {2835, 2856}, | |
new[] {2858, 2864}, | |
new[] {2866, 2867}, | |
new[] {2869, 2873}, | |
new[] {2876, 2883}, | |
new[] {2887, 2888}, | |
new[] {2891, 2893}, | |
new[] {2902, 2903}, | |
new[] {2908, 2909}, | |
new[] {2911, 2913}, | |
new[] {2918, 2927}, | |
new[] {2929, 2929}, | |
new[] {2946, 2947}, | |
new[] {2949, 2954}, | |
new[] {2958, 2960}, | |
new[] {2962, 2965}, | |
new[] {2969, 2970}, | |
new[] {2972, 2972}, | |
new[] {2974, 2975}, | |
new[] {2979, 2980}, | |
new[] {2984, 2986}, | |
new[] {2990, 2997}, | |
new[] {2999, 3001}, | |
new[] {3006, 3010}, | |
new[] {3014, 3016}, | |
new[] {3018, 3021}, | |
new[] {3031, 3031}, | |
new[] {3047, 3055}, | |
new[] {3065, 3065}, | |
new[] {3073, 3075}, | |
new[] {3077, 3084}, | |
new[] {3086, 3088}, | |
new[] {3090, 3112}, | |
new[] {3114, 3123}, | |
new[] {3125, 3129}, | |
new[] {3134, 3140}, | |
new[] {3142, 3144}, | |
new[] {3146, 3149}, | |
new[] {3157, 3158}, | |
new[] {3168, 3169}, | |
new[] {3174, 3183}, | |
new[] {3202, 3203}, | |
new[] {3205, 3212}, | |
new[] {3214, 3216}, | |
new[] {3218, 3240}, | |
new[] {3242, 3251}, | |
new[] {3253, 3257}, | |
new[] {3260, 3268}, | |
new[] {3270, 3272}, | |
new[] {3274, 3277}, | |
new[] {3285, 3286}, | |
new[] {3294, 3294}, | |
new[] {3296, 3297}, | |
new[] {3302, 3311}, | |
new[] {3330, 3331}, | |
new[] {3333, 3340}, | |
new[] {3342, 3344}, | |
new[] {3346, 3368}, | |
new[] {3370, 3385}, | |
new[] {3390, 3395}, | |
new[] {3398, 3400}, | |
new[] {3402, 3405}, | |
new[] {3415, 3415}, | |
new[] {3424, 3425}, | |
new[] {3430, 3439}, | |
new[] {3458, 3459}, | |
new[] {3461, 3478}, | |
new[] {3482, 3505}, | |
new[] {3507, 3515}, | |
new[] {3517, 3517}, | |
new[] {3520, 3526}, | |
new[] {3530, 3530}, | |
new[] {3535, 3540}, | |
new[] {3542, 3542}, | |
new[] {3544, 3551}, | |
new[] {3570, 3571}, | |
new[] {3585, 3642}, | |
new[] {3647, 3662}, | |
new[] {3664, 3673}, | |
new[] {3713, 3714}, | |
new[] {3716, 3716}, | |
new[] {3719, 3720}, | |
new[] {3722, 3722}, | |
new[] {3725, 3725}, | |
new[] {3732, 3735}, | |
new[] {3737, 3743}, | |
new[] {3745, 3747}, | |
new[] {3749, 3749}, | |
new[] {3751, 3751}, | |
new[] {3754, 3755}, | |
new[] {3757, 3769}, | |
new[] {3771, 3773}, | |
new[] {3776, 3780}, | |
new[] {3782, 3782}, | |
new[] {3784, 3789}, | |
new[] {3792, 3801}, | |
new[] {3804, 3805}, | |
new[] {3840, 3840}, | |
new[] {3864, 3865}, | |
new[] {3872, 3881}, | |
new[] {3893, 3893}, | |
new[] {3895, 3895}, | |
new[] {3897, 3897}, | |
new[] {3902, 3911}, | |
new[] {3913, 3946}, | |
new[] {3953, 3972}, | |
new[] {3974, 3979}, | |
new[] {3984, 3991}, | |
new[] {3993, 4028}, | |
new[] {4038, 4038}, | |
new[] {4096, 4129}, | |
new[] {4131, 4135}, | |
new[] {4137, 4138}, | |
new[] {4140, 4146}, | |
new[] {4150, 4153}, | |
new[] {4160, 4169}, | |
new[] {4176, 4185}, | |
new[] {4256, 4293}, | |
new[] {4304, 4344}, | |
new[] {4352, 4441}, | |
new[] {4447, 4514}, | |
new[] {4520, 4601}, | |
new[] {4608, 4614}, | |
new[] {4616, 4678}, | |
new[] {4680, 4680}, | |
new[] {4682, 4685}, | |
new[] {4688, 4694}, | |
new[] {4696, 4696}, | |
new[] {4698, 4701}, | |
new[] {4704, 4742}, | |
new[] {4744, 4744}, | |
new[] {4746, 4749}, | |
new[] {4752, 4782}, | |
new[] {4784, 4784}, | |
new[] {4786, 4789}, | |
new[] {4792, 4798}, | |
new[] {4800, 4800}, | |
new[] {4802, 4805}, | |
new[] {4808, 4814}, | |
new[] {4816, 4822}, | |
new[] {4824, 4846}, | |
new[] {4848, 4878}, | |
new[] {4880, 4880}, | |
new[] {4882, 4885}, | |
new[] {4888, 4894}, | |
new[] {4896, 4934}, | |
new[] {4936, 4954}, | |
new[] {4969, 4977}, | |
new[] {5024, 5108}, | |
new[] {5121, 5740}, | |
new[] {5743, 5750}, | |
new[] {5761, 5786}, | |
new[] {5792, 5866}, | |
new[] {5870, 5872}, | |
new[] {5888, 5900}, | |
new[] {5902, 5908}, | |
new[] {5920, 5940}, | |
new[] {5952, 5971}, | |
new[] {5984, 5996}, | |
new[] {5998, 6000}, | |
new[] {6002, 6003}, | |
new[] {6016, 6099}, | |
new[] {6103, 6103}, | |
new[] {6107, 6109}, | |
new[] {6112, 6121}, | |
new[] {6155, 6157}, | |
new[] {6160, 6169}, | |
new[] {6176, 6263}, | |
new[] {6272, 6313}, | |
new[] {6400, 6428}, | |
new[] {6432, 6443}, | |
new[] {6448, 6459}, | |
new[] {6470, 6509}, | |
new[] {6512, 6516}, | |
new[] {7424, 7531}, | |
new[] {7680, 7835}, | |
new[] {7840, 7929}, | |
new[] {7936, 7957}, | |
new[] {7960, 7965}, | |
new[] {7968, 8005}, | |
new[] {8008, 8013}, | |
new[] {8016, 8023}, | |
new[] {8025, 8025}, | |
new[] {8027, 8027}, | |
new[] {8029, 8029}, | |
new[] {8031, 8061}, | |
new[] {8064, 8116}, | |
new[] {8118, 8124}, | |
new[] {8126, 8126}, | |
new[] {8130, 8132}, | |
new[] {8134, 8140}, | |
new[] {8144, 8147}, | |
new[] {8150, 8155}, | |
new[] {8160, 8172}, | |
new[] {8178, 8180}, | |
new[] {8182, 8188}, | |
new[] {8204, 8207}, | |
new[] {8234, 8238}, | |
new[] {8255, 8256}, | |
new[] {8276, 8276}, | |
new[] {8288, 8291}, | |
new[] {8298, 8303}, | |
new[] {8305, 8305}, | |
new[] {8319, 8319}, | |
new[] {8352, 8369}, | |
new[] {8400, 8412}, | |
new[] {8417, 8417}, | |
new[] {8421, 8426}, | |
new[] {8450, 8450}, | |
new[] {8455, 8455}, | |
new[] {8458, 8467}, | |
new[] {8469, 8469}, | |
new[] {8473, 8477}, | |
new[] {8484, 8484}, | |
new[] {8486, 8486}, | |
new[] {8488, 8488}, | |
new[] {8490, 8493}, | |
new[] {8495, 8497}, | |
new[] {8499, 8505}, | |
new[] {8509, 8511}, | |
new[] {8517, 8521}, | |
new[] {8544, 8579}, | |
new[] {12293, 12295}, | |
new[] {12321, 12335}, | |
new[] {12337, 12341}, | |
new[] {12344, 12348}, | |
new[] {12353, 12438}, | |
new[] {12441, 12442}, | |
new[] {12445, 12447}, | |
new[] {12449, 12543}, | |
new[] {12549, 12588}, | |
new[] {12593, 12686}, | |
new[] {12704, 12727}, | |
new[] {12784, 12799}, | |
new[] {13312, 19893}, | |
new[] {19968, 40869}, | |
new[] {40960, 42124}, | |
new[] {44032, 55203}, | |
new[] {63744, 64045}, | |
new[] {64048, 64106}, | |
new[] {64256, 64262}, | |
new[] {64275, 64279}, | |
new[] {64285, 64296}, | |
new[] {64298, 64310}, | |
new[] {64312, 64316}, | |
new[] {64318, 64318}, | |
new[] {64320, 64321}, | |
new[] {64323, 64324}, | |
new[] {64326, 64433}, | |
new[] {64467, 64829}, | |
new[] {64848, 64911}, | |
new[] {64914, 64967}, | |
new[] {65008, 65020}, | |
new[] {65024, 65039}, | |
new[] {65056, 65059}, | |
new[] {65075, 65076}, | |
new[] {65101, 65103}, | |
new[] {65129, 65129}, | |
new[] {65136, 65140}, | |
new[] {65142, 65276}, | |
new[] {65279, 65279}, | |
new[] {65284, 65284}, | |
new[] {65296, 65305}, | |
new[] {65313, 65338}, | |
new[] {65343, 65343}, | |
new[] {65345, 65370}, | |
new[] {65381, 65470}, | |
new[] {65474, 65479}, | |
new[] {65482, 65487}, | |
new[] {65490, 65495}, | |
new[] {65498, 65500}, | |
new[] {65504, 65505}, | |
new[] {65509, 65510}, | |
new[] {65529, 65531}, | |
#endregion | |
}; | |
#endregion | |
} // class | |
} // namespace |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment