at.jku.ssw.Coco.Scanner.Init C# (CSharp) Method

Init() public method

public Init ( ) : void
return void
        void Init()
        {
            pos = -1; line = 1; col = 0; charPos = -1;
            oldEols = 0;
            NextCh();
            if (ch == 0xEF) { // check optional byte order mark for UTF-8
            NextCh(); int ch1 = ch;
            NextCh(); int ch2 = ch;
            if (ch1 != 0xBB || ch2 != 0xBF) {
                throw new FatalError(String.Format("illegal byte order mark: EF {0,2:X} {1,2:X}", ch1, ch2));
            }
            buffer = new UTF8Buffer(buffer); col = 0; charPos = -1;
            NextCh();
            }
            pt = tokens = new Token();  // first token is a dummy
        }

Usage Example

Example #1
0
        public static void Main(string[] arg)
        {
            Console.WriteLine("Coco/R (Aug 4, 2003)");
            string ATGName = null;

            for (int i = 0; i < arg.Length; i++)
            {
                if (arg[i] == "-nonamespace")
                {
                    Tab.nsName = null;
                }
                else if (arg[i] == "-namespace")
                {
                    Tab.nsName = arg[++i];
                }
                else if (arg[i] == "-trace")
                {
                    Tab.SetDDT(arg[++i]);
                }
                else
                {
                    ATGName = arg[i];
                }
            }
            if (arg.Length > 0 && ATGName != null)
            {
                int pos = ATGName.LastIndexOf('/');
                if (pos < 0)
                {
                    pos = ATGName.LastIndexOf('\\');
                }
                string file = ATGName;
                string dir  = ATGName.Substring(0, pos + 1);

                Scanner.Init(file);
                Trace.Init(dir);
                Tab.Init();
                DFA.Init(dir);
                ParserGen.Init(file, dir);

                Parser.Parse();

                Trace.Close();
                Console.WriteLine();
                Console.WriteLine("{0} errors detected", Errors.count);
            }
            else
            {
                Console.WriteLine("Usage: Coco {{Option}} Grammar.ATG {{Option}}{0}" +
                                  "Options:{0}" +
                                  "  -nonamespace{0}" +
                                  "  -namespace <packageName>{0}" +
                                  "  -trace   <traceString>{0}" +
                                  "Valid characters in the trace string:{0}" +
                                  "  A  trace automaton{0}" +
                                  "  F  list first/follow sets{0}" +
                                  "  G  print syntax graph{0}" +
                                  "  I  trace computation of first sets{0}" +
                                  "  P  print statistics{0}" +
                                  "  S  list symbol table{0}" +
                                  "  X  list cross reference table{0}" +
                                  "Scanner.frame and Parser.frame files needed in ATG directory{0}" +
                                  "or in a directory referenced by the environment variable CRFRAMES.",
                                  Environment.NewLine);
            }
        }