Beispiel #1
0
        internal Parser(Scanner scanner, ServiceProvider services)
        {
            this.scanner  = scanner;
            this.services = services;

            this.compilerError = services.GetRequiredService <ICompilerError>();
        }
Beispiel #2
0
        internal Scanner(string data, IServiceProvider serviceProvider, bool isFile = true)
        {
            this.compilerError = serviceProvider.GetRequiredService <ICompilerError>();
            if (isFile)
            {
                if (string.IsNullOrEmpty(data))
                {
                    throw new ArgumentNullException("The path is null");
                }

                if (!File.Exists(data))
                {
                    throw new FileLoadException("Unable to find file " + data);
                }

                fileData = File.ReadAllBytes(data);
                return;
            }

            fileData = Encoding.ASCII.GetBytes(data);
        }
Beispiel #3
0
    protected int currentType;              // current type expected in the parse.

   //--- add error object if the parser is not recovering.
   protected void semanticError (ICompilerError err) {
      if (parser.IsRecovering) return;      // don't record semantic errors if already recovering from syntax error.
      parser.Errors.Add (err);
      if (!(parser is RecoveringRdParser))
         throw new CompilerErrorException();     // terminate compilation on 1st error.
   } // end semanticError method.