Beispiel #1
0
 private void ReportError(SourceLocation location, string message, params object[] args)
 {
     if (args != null && args.Length > 0)
     {
         message = string.Format(message, args);
     }
     _context.AddError(location, message, null);
 }
Beispiel #2
0
 internal void ProcessParameter(Parameter node)
 {
     if (_currentModuleMember is Document)
     {
         _context.AddError(CompilerErrorFactory.ParametersCantBeDeclaredInDocuments(node, _currentModule.FileName));
     }
     else
     {
         var aliasDef = (AliasDefinition)_currentModuleMember;
         if (aliasDef.SyncTime < _syncTime)
         {
             aliasDef.SyncTime = _syncTime;
             aliasDef.Parameters.Clear();
         }
         aliasDef.Parameters.Add(node);
         node.AliasDefinition = (AliasDefinition)_currentModuleMember;
         if (node.Name == "_")
         {
             if (!node.IsValueNode)
             {
                 ((AliasDefinition)_currentModuleMember).HasDefaultBlockParameter = true;
             }
             else
             {
                 ((AliasDefinition)_currentModuleMember).HasDefaultValueParameter = true;
             }
         }
     }
 }
Beispiel #3
0
 public void Run()
 {
     try
     {
         foreach (var input in _context.Parameters.Input)
         {
             try
             {
                 using (var reader = input.Open())
                     DoParse(input.Name, reader);
             }
             catch (Exception ex)
             {
                 _context.AddError(CompilerErrorFactory.InputError(input.Name, ex));
             }
         }
     }
     catch (Exception ex)
     {
         _context.Errors.Add(CompilerErrorFactory.FatalError(ex));
     }
 }
Beispiel #4
0
 public void Run()
 {
     try
     {
         foreach (var input in _context.Parameters.Input)
         {
             try
             {
                 using (var reader = input.Open())
                     DoProcessAliasesAndNamespaces(input.Name, reader);
             }
             catch (Exception ex)
             {
                 _context.AddError(CompilerErrorFactory.InputError(input.Name, ex));
             }
         }
         _context.NamespaceResolver.ResolveAliasesAndDoChecks();
     }
     catch (Exception ex)
     {
         _context.Errors.Add(CompilerErrorFactory.FatalError(ex));
     }
 }
        private static void DoProcessAliasesAndNamespaces(string fileName, TextReader reader, CompilerContext context)
        {
            try
            {
                var lexer = new MalinaLexer(new AntlrInputStream(reader));

                lexer.RemoveErrorListeners();
                lexer.AddErrorListener(new LexerParserErrorListener <int>(context, fileName));

                var parser = MalinaParser.Create(new CommonTokenStream(lexer));
                parser.Interpreter.PredictionMode = PredictionMode.Sll;

                var resolvingListener = new AliasesAndNamespacesResolvingListener(context, fileName);

                parser.RemoveErrorListeners();
                parser.AddErrorListener(new LexerParserErrorListener <IToken>(context, fileName));
                parser.AddParseListener(resolvingListener);
                parser.module();
            }
            catch (Exception ex)
            {
                context.AddError(CompilerErrorFactory.FatalError(ex));
            }
        }
Beispiel #6
0
 /// <inheritdoc />
 public void OnError(int code, Interval interval, params object[] args)
 {
     _context.AddError(CompilerErrorFactory.ParserError(Syntactik.ParsingErrors.Format(code, args), _fileName, interval.Begin.Line,
                                                        interval.Begin.Column));
 }