// This code was generated by the Gardens Point Parser Generator // Copyright (c) Wayne Kelly, QUT 2005-2010 // (see accompanying GPPGcopyright.rtf) // GPPG version 1.3.6 // Machine: IVAN-PC // DateTime: 09.05.2017 19:33:14 // UserName: Ivan // Input file // options: no-lines gplex using System; using System.Collections.Generic; using System.Globalization; using System.Text; using QUT.Gppg; using PascalABCCompiler.SyntaxTree; namespace GPPGPreprocessor3 { public enum Tokens { error=1,EOF=2,DIRECTIVE=3,NODIRECTIVE=4}; // Abstract base class for GPLEX scanners public abstract class ScanBase : AbstractScanner { private LexLocation __yylloc = new LexLocation(); public override LexLocation yylloc { get { return __yylloc; } set { __yylloc = value; } } protected virtual bool yywrap() { return true; } } public partial class PreprocessorParser: ShiftReduceParser { // Verbatim content from Preprocessor3Yacc.y public List compilerDirectives; public PreprocessorParser(PreprocessorScanner scanner) : base(scanner) { } // End verbatim content from Preprocessor3Yacc.y #pragma warning disable 649 private static Dictionary aliasses; #pragma warning restore 649 private static Rule[] rules = new Rule[5]; private static State[] states = new State[5]; private static string[] nonTerms = new string[] { "directives", "$accept", }; static PreprocessorParser() { states[0] = new State(-2,new int[]{-1,1}); states[1] = new State(new int[]{2,2,3,3,4,4}); states[2] = new State(-1); states[3] = new State(-3); states[4] = new State(-4); rules[1] = new Rule(-2, new int[]{-1,2}); rules[2] = new Rule(-1, new int[]{}); rules[3] = new Rule(-1, new int[]{-1,3}); rules[4] = new Rule(-1, new int[]{-1,4}); } protected override void Initialize() { this.InitSpecialTokens((int)Tokens.error, (int)Tokens.EOF); this.InitStates(states); this.InitRules(rules); this.InitNonTerminals(nonTerms); } protected override void DoAction(int action) { switch (action) { case 2: // directives -> /* empty */ { Directive.dirs.Clear(); } break; case 3: // directives -> directives, DIRECTIVE { compilerDirectives.Add(PreprocessorTools.MakeDirective(ValueStack[ValueStack.Depth-1].text, ValueStack[ValueStack.Depth-1].loc)); } break; case 4: // directives -> directives, NODIRECTIVE { } break; } } protected override string TerminalToString(int terminal) { if (aliasses != null && aliasses.ContainsKey(terminal)) return aliasses[terminal]; else if (((Tokens)terminal).ToString() != terminal.ToString(CultureInfo.InvariantCulture)) return ((Tokens)terminal).ToString(); else return CharToString((char)terminal); } } }