public static Terminal_NumericValue Parse( ParserContext context, string spelling, string regex, int length) { context.Push("NumericValue", spelling + "," + regex); bool parsed = true; Terminal_NumericValue numericValue = null; try { string value = context.text.Substring(context.index, length); if ((parsed = Regex.IsMatch(value, regex))) { context.index += length; numericValue = new Terminal_NumericValue(value, null); } } catch (ArgumentOutOfRangeException) {parsed = false;} context.Pop("NumericValue", parsed); return numericValue; }
public static Terminal_NumericValue Parse( ParserContext context, string spelling, string regex, int length) { context.Push("NumericValue", spelling + "," + regex); bool parsed = true; Terminal_NumericValue numericValue = null; try { string value = context.text.Substring(context.index, length); if ((parsed = Regex.IsMatch(value, regex))) { context.index += length; numericValue = new Terminal_NumericValue(value, null); } } catch (ArgumentOutOfRangeException) { parsed = false; } context.Pop("NumericValue", parsed); return(numericValue); }
public static Rule_DIGIT Parse(ParserContext context) { context.Push("DIGIT"); Rule rule; bool parsed = true; ParserAlternative b; int s0 = context.index; ParserAlternative a0 = new ParserAlternative(s0); List <ParserAlternative> as1 = new List <ParserAlternative>(); parsed = false; { int s1 = context.index; ParserAlternative a1 = new ParserAlternative(s1); parsed = true; if (parsed) { bool f1 = true; int c1 = 0; for (int i1 = 0; i1 < 1 && f1; i1++) { rule = Terminal_NumericValue.Parse(context, "%x30-39", "[\\x30-\\x39]", 1); if ((f1 = rule != null)) { a1.Add(rule, context.index); c1++; } } parsed = c1 == 1; } if (parsed) { as1.Add(a1); } context.index = s1; } b = ParserAlternative.GetBest(as1); parsed = b != null; if (parsed) { a0.Add(b.rules, b.end); context.index = b.end; } rule = null; if (parsed) { rule = new Rule_DIGIT(context.text.Substring(a0.start, a0.end - a0.start), a0.rules); } else { context.index = s0; } context.Pop("DIGIT", parsed); return((Rule_DIGIT)rule); }
public object Visit(Terminal_NumericValue value) { /* WON'T BE VISITED */ return true; }