Ejemplo n.º 1
0
        public static Lexer Create(StreamReader reader, ErrorList errors)
        {
            Lexer lex = new Lexer(reader, errors);
            lex.MoveNext();

            return lex;
        }
 protected CompilerContext(string filePath, StreamReader inputReader, Importer importer, IEmitter emitter, CompilationFlags flags)
 {
     FilePath = filePath;
     Flags = flags;
     Emitter = emitter;
     CompileErrors = new ErrorList();
     Importer = importer;
     SymbolTable = new SymbolTable();
     Lexer = Lexer.Create(inputReader, CompileErrors);
 }
Ejemplo n.º 3
0
        public Translator(CompilerContext context)
        {
            MethodGenerator = new MethodGenerator(context);

            _context = context;
            _lexer = context.Lexer;
            _symbolTable = context.SymbolTable;
            _lastParsedPosition = _lexer.TokenStartPosition;
            _lexeme = string.Empty;
        }
        private Symbol ParseLValue(Lexer lvalLexer)
        {
            if (lvalLexer.CurrentToken != Token.Identifier)
            {
                AddLValueError();
                return null;
            }

            Symbol symbol = _context.SymbolTable.Lookup(lvalLexer.GetLexeme());
            if (symbol == null)
            {
                AddLValueError();
                return null;
            }

            IrisType lhs = symbol.Type;
            lvalLexer.MoveNext();
            if (lhs.IsArray)
            {
                // We should have an open bracket (We don't support changing the array value itself)
                if (lvalLexer.CurrentToken != Token.ChrOpenBracket)
                {
                    AddLValueError();
                    return null;
                }

                EmitLoadSymbol(symbol, SymbolLoadMode.Raw);

                lvalLexer.MoveNext();
                if (lvalLexer.CurrentToken != Token.Number)
                {
                    AddLValueError();
                    return null;
                }

                int index = lvalLexer.ParseInteger();
                MethodGenerator.PushIntConst(index);
                lvalLexer.MoveNext();
                if (lvalLexer.CurrentToken != Token.ChrCloseBracket)
                {
                    AddLValueError();
                    return null;
                }
            }
            else if (lhs.IsByRef)
            {
                EmitLoadSymbol(symbol, SymbolLoadMode.Raw);
            }

            return symbol;
        }
 public ExpressionTranslator(DebugCompilerContext context)
     : base(context)
 {
     _context = context;
     _lexer = context.Lexer;
 }