Example #1
0
        private static TotemParser CreateParserWorker(CompilerContext context, TotemLanguageOptions options)
        {
            ContractUtils.RequiresNotNull(context, "context");
            ContractUtils.RequiresNotNull(options, "options");

            TotemCompilerOptions compilerOptions = context.Options as TotemCompilerOptions;
            if (options == null)
                throw new NullReferenceException("Invalid compiler options");

            SourceCodeReader reader;

            try
            {
                reader = context.SourceUnit.GetReader();
            }
            catch (IOException e)
            {
                context.Errors.Add(context.SourceUnit, e.Message, SourceSpan.Invalid, 0, Severity.Error);
                throw;
            }

            TotemTokenizer tokenizer = new TotemTokenizer(context.Errors, compilerOptions);

            tokenizer.Initialize(null, reader, context.SourceUnit, SourceLocation.MinValue);

            TotemParser result = new TotemParser(context, tokenizer, context.Errors, context.ParserSink);
            result._sourceReader = reader;

            return result;
        }
Example #2
0
 public TokenizerErrorSink(TotemParser parser)
 {
     Assert.NotNull(parser);
     _parser = parser;
 }