本文整理汇总了C#中IdentifierTerminal.AddSuffix方法的典型用法代码示例。如果您正苦于以下问题:C# IdentifierTerminal.AddSuffix方法的具体用法?C# IdentifierTerminal.AddSuffix怎么用?C# IdentifierTerminal.AddSuffix使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IdentifierTerminal
的用法示例。
在下文中一共展示了IdentifierTerminal.AddSuffix方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GWBasicGrammar
// BASIC is not case sensitive...
public GWBasicGrammar()
: base(false)
{
this.GrammarComments = "This grammar uses one new Irony feature - Scanner-Parser link. Parser helps Scanner to disambiguate " +
"similar but different token types when more than one terminal matches the current input char.\r\n" +
"See comments in GwBasicGrammar.cs file.";
/*
Scanner-Parser link.
The grammar defines 3 terminals for numbers: number, lineNumber and fileNumber. All three return decimal
digits in GetFirsts() method. So when current input is a digit, the scanner has 3 potential candidate terminals
to match the input. However, because each of the 3 terminals can appear in specific "places" in grammar,
the parser is able to assist scanner to pick the correct terminal, depending on the current parser state.
The disambiguation happens in Scanner.SelectTerminals method. When the terminal list for current input char
has more than 1 terminal, the scanner code gets the current parser state from core parser (through compilerContext),
and then checks the terminals agains the ExpectedTerms set in the parser state.
As you might see in Grammar Explorer, the conflict is resolved successfully.
*/
//Terminals
var lineNumber = new NumberLiteral("LINE_NUMBER", NumberOptions.IntOnly);
var fileNumber = new NumberLiteral("FILE_NUMBER", NumberOptions.IntOnly);
var number = new NumberLiteral("NUMBER", NumberOptions.AllowStartEndDot);
//ints that are too long for int32 are converted to int64
number.DefaultIntTypes = new TypeCode[] {TypeCode.Int32, TypeCode.Int64};
number.AddExponentSymbols("eE", TypeCode.Single);
number.AddExponentSymbols("dD", TypeCode.Double);
number.AddSuffix("!", TypeCode.Single);
number.AddSuffix("#", TypeCode.Double);
var variable = new IdentifierTerminal("Identifier");
variable.AddSuffix("$", TypeCode.String);
variable.AddSuffix("%", TypeCode.Int32);
variable.AddSuffix("!", TypeCode.Single);
variable.AddSuffix("#", TypeCode.Double);
var stringLiteral = new StringLiteral("STRING", "\"", StringOptions.None);
//Important: do not add comment term to base.NonGrammarTerminals list - we do use this terminal in grammar rules
var userFunctionName = variable;
var comment = new CommentTerminal("Comment", "REM", "\n");
var short_comment = new CommentTerminal("ShortComment", "'", "\n");
var line_cont = new LineContinuationTerminal("LineContinuation", "_");
var comma = ToTerm(",", "comma");
var colon = ToTerm(":", "colon");
var comma_opt = new NonTerminal("comma_opt");
comma_opt.Rule = Empty | ",";
var semi_opt = new NonTerminal("semi_opt");
semi_opt.Rule = Empty | ";";
var pound_opt = new NonTerminal("pound_opt");
pound_opt.Rule = Empty | "#";
// Non-terminals
var PROGRAM = new NonTerminal("PROGRAM");
var LINE = new NonTerminal("LINE");
var LINE_CONTENT_OPT = new NonTerminal("LINE_CONTENT_OPT");
var COMMENT_OPT = new NonTerminal("COMMENT_OPT");
var STATEMENT_LIST = new NonTerminal("STATEMENT_LIST");
var STATEMENT = new NonTerminal("STATEMENT");
var PRINT_STMT = new NonTerminal("PRINT_STMT");
var PRINT_LIST = new NonTerminal("PRINT_LIST");
var PRINT_ARG = new NonTerminal("PRINT_ARG");
var OPEN_STMT = new NonTerminal("OPEN_STMT");
var OPEN_STMT_MODE = new NonTerminal("OPEN_STMT_MODE");
var OPEN_STMT_ACCESS = new NonTerminal("OPEN_STMT_ACCESS");
var CLOSE_STMT = new NonTerminal("CLOSE_STMT");
var INPUT_STMT = new NonTerminal("INPUT_STMT");
var VARIABLES = new NonTerminal("VARIABLES");
var IF_STMT = new NonTerminal("IF_STMT");
var THEN_CLAUSE = new NonTerminal("THEN_CLAUSE");
var ELSE_CLAUSE_OPT = new NonTerminal("ELSE_CLAUSE_OPT"); //, typeof(AstNode));
var EXPR = new NonTerminal("EXPRESSION");
var EXPR_LIST = new NonTerminal("EXPRESSION_LIST");
var BINARY_OP = new NonTerminal("BINARY_OP", "operator");
var BINARY_EXPR = new NonTerminal("BINARY_EXPR");
var UNARY_EXPR = new NonTerminal("UNARY_EXPR");
var SIGN = new NonTerminal("SIGN");
var ASSIGN_STMT = new NonTerminal("ASSIGN_STMT");
var FOR_STMT = new NonTerminal("FOR_STMT");
var STEP_OPT = new NonTerminal("STEP_OPT");
var NEXT_STMT = new NonTerminal("NEXT_STMT");
var LOCATE_STMT = new NonTerminal("LOCATE_STMT");
var WHILE_STMT = new NonTerminal("WHILE_STMT");
var WEND_STMT = new NonTerminal("WEND_STMT");
var SWAP_STMT = new NonTerminal("SWAP_STMT");
var FUN_CALL = new NonTerminal("FUN_CALL");
var VARIABLE_OR_FUNCTION_EXPR = new NonTerminal("VARIABLE_OR_FUNCTION_EXPR");
var ARG_LIST = new NonTerminal("ARG_LIST");
var LINE_INPUT_STMT = new NonTerminal("LINE_INPUT_STMT");
var LINE_INPUT_POUND_STMT = new NonTerminal("LINE_INPUT_POUND_STMT");
var END_STMT = new NonTerminal("END_STMT");
var CLS_STMT = new NonTerminal("CLS_STMT");
var CLEAR_STMT = new NonTerminal("CLEAR_STMT");
var DIM_STMT = new NonTerminal("DIM_STMT");
var DEF_FN_STMT = new NonTerminal("DEF_FN_STMT");
var GOTO_STMT = new NonTerminal("GOTO_STMT");
var GOSUB_STMT = new NonTerminal("GOSUB_STMT");
var RETURN_STMT = new NonTerminal("RETURN_STMT");
var ON_STMT = new NonTerminal("ON_STMT");
//.........这里部分代码省略.........