Beispiel #1
0
 public ObjSymbolInfo(IdToken idToken, SimpleToken filenameToken, Expr countExpr, bool needsVarSpace)
     : base(idToken)
 {
     this.filenameToken = filenameToken;
     this.countExpr = countExpr;
     this.needsVarSpace = needsVarSpace;
 }
Beispiel #2
0
 public void AssertUndefined(IdToken idToken)
 {
     if (Lookup(idToken) != null)
         throw new ParseException(idToken.Text + " is already defined", idToken);
 }
Beispiel #3
0
 public DatLabelEntry(int alignment, IdToken labelToken, bool standalone)
 {
     this.alignment = alignment;
     this.labelToken = labelToken;
     this.standalone = standalone;
 }
Beispiel #4
0
 public void AddObjSymbol(IdToken idToken, SimpleToken filenameToken, Expr countExpr, bool needsVarSpace)
 {
     AssertUndefined(idToken);
     ObjSymbolInfo objSymbolInfo = new ObjSymbolInfo(idToken, filenameToken, countExpr, needsVarSpace);
     AddSymbolInfo(objSymbolInfo);
     objList.Add(objSymbolInfo);
 }
Beispiel #5
0
        public void AddVarSymbol(IdToken idToken, SizeToken sizeToken, ArrayList countExprList)
        {
            AssertUndefined(idToken);
            VarSymbolInfo varSymbolInfo = new VarSymbolInfo(idToken, sizeToken, countExprList);

            AddSymbolInfo(varSymbolInfo);

            switch (sizeToken.Text.ToUpper())
            {
                case "BYTE":
                    byteVarList.Add(varSymbolInfo);
                    break;
                case "WORD":
                    wordVarList.Add(varSymbolInfo);
                    break;
                case "LONG":
                    longVarList.Add(varSymbolInfo);
                    break;
            }
        }
Beispiel #6
0
 public ConSymbolInfo(IdToken idToken, Expr e)
     : base(idToken)
 {
     this.e = e;
 }
Beispiel #7
0
        public override bool Std(out Stmt s)
        {
            s = null;

            ArrayList localNameList = new ArrayList();
            ArrayList localCountList = new ArrayList();
            // I *should* make a name/countExpr structure, but I'm too lazy,
            // so for now I'll keep name and count expressions in parallel arraylists.

            localNameList.Add(null);	// placeholder for result variable
            localCountList.Add(null);	// and its count expression.

            if (this.Column != 0)
                throw new ParseException("PUB/PRI must be in 1st column", this);
            Tokenizer.Advance();	// past "PUB" or "PRI"
            SimpleToken token = Tokenizer.GetToken();
            IdToken methodName = token as IdToken;
            if (methodName == null)
                throw new ParseException("Expected method name", token);

            int nParams = 0;

            if (Tokenizer.Current.Text == "(")	// Parse parameter list.
            {
                Tokenizer.Advance("(");
                while (true)
                {
                    IdToken paramToken = Tokenizer.Current as IdToken;
                    if (paramToken == null)
                        throw new ParseException("Expected parameter name", Tokenizer.Current);
                    Tokenizer.Advance();
                    localNameList.Add(paramToken);
                    localCountList.Add(null);
                    ++nParams;
                    if (Tokenizer.Current.Text != ",")
                        break;
                    Tokenizer.Advance(",");
                }
                Tokenizer.Advance(")");
            }
            if (Tokenizer.Current.Text == ":") // Parse result variable.
            {
                Tokenizer.Advance(":");
                Token t = Tokenizer.GetToken();
                IdToken resultToken = t as IdToken;
                if (resultToken == null)
                {
                    if (t.Text.ToUpper() == "RESULT")
                        resultToken = new IdToken(t);
                    else
                        throw new ParseException("Expected result variable", t);
                }
                localNameList[0] = resultToken;
            }
            if (Tokenizer.Current.Text == "|") // Parse local variables.
            {
                Tokenizer.Advance("|");
                while (true)
                {
                    IdToken localToken = Tokenizer.GetToken() as IdToken;
                    if (localToken == null)
                        throw new ParseException("Expected local variable name", Tokenizer.Current);
                    localNameList.Add(localToken);
                    if (Tokenizer.Current.Text == "[")
                    {
                        Tokenizer.Advance("[");
                        localCountList.Add(ParseExpression(Tokenizer, 13));
                        Tokenizer.Advance("]");
                    }
                    else
                    {
                        localCountList.Add(null);
                    }
                    if (Tokenizer.Current.Text != ",")
                        break;
                    Tokenizer.Advance(",");
                }
            }
            int endLineNumber = Tokenizer.Current.LineNumber;

            Tokenizer.Advance("(eol)");

            ArrayList statementList = ParseStatements(Tokenizer, -1);

            SymbolTable.AddMethod(methodName, isPub, nParams, localNameList, localCountList, statementList, endLineNumber);
            return true;
        }
Beispiel #8
0
 public void AddDatSymbol(IdToken idToken, int alignment, int dp, int cogAddress4)
 {
     AssertUndefined(idToken);
     DatSymbolInfo dsi = new DatSymbolInfo(idToken, alignment, dp, cogAddress4);
     AddSymbolInfo(dsi);
     datList.Add(dsi);
 }
Beispiel #9
0
 public void AddLocalDatSymbol(IdToken idToken, int alignment, int dp, int cogAddress4)
 {
     idToken.Text = latestLabel + idToken.Text;
     AddDatSymbol(idToken, alignment, dp, cogAddress4);
 }
Beispiel #10
0
 public void AddConSymbol(IdToken idToken, Expr e)
 {
     AssertUndefined(idToken);
     ConSymbolInfo conSymbolInfo = new ConSymbolInfo(idToken, e);
     AddSymbolInfo(conSymbolInfo);
     conList.Add(conSymbolInfo);
 }
Beispiel #11
0
 public void AddDatLabelEntry(int alignment, IdToken labelToken, bool standalone)
 {
     datEntryList.Add(new DatLabelEntry(alignment, labelToken, standalone));
 }
Beispiel #12
0
 public void AddBuiltInConSymbol(IdToken idToken, Expr e)
 {
     AssertUndefined(idToken);
     ConSymbolInfo conSymbolInfo = new ConSymbolInfo(idToken, e);
     AddSymbolInfo(conSymbolInfo);
 }
Beispiel #13
0
 public ObjectFileSymbolInfo(IdToken idToken)
     : base(idToken)
 {
 }
Beispiel #14
0
 public DatSymbolInfo(IdToken idToken, int alignment, int dp, int cogAddressX4)
     : base(idToken)
 {
     this.alignment = alignment;
     this.dp = dp;
     this.cogAddressX4 = cogAddressX4;
 }
Beispiel #15
0
        public VarSymbolInfo(IdToken idToken, SizeToken sizeToken, ArrayList dimExprList)
            : base(idToken)
        {
            dimExprs = new Expr[dimExprList.Count];
            for (int i = 0; i < dimExprList.Count; ++i)
                dimExprs[i] = (Expr)dimExprList[i];

            this.size = Token.SizeSpecifier(sizeToken.Text);
        }
Beispiel #16
0
 public void AddLocalVariable(IdToken idToken, int offset)
 {
     AssertUndefined(idToken);
     LocalSymbolInfo localSymbolInfo = new LocalSymbolInfo(idToken, offset);
     localSymbolTable.AddSymbolInfo(localSymbolInfo);
 }
Beispiel #17
0
        int offset; // byte offset into local variable space.

        #endregion Fields

        #region Constructors

        public LocalSymbolInfo(IdToken idToken, int offset)
            : base(idToken)
        {
            this.offset = offset;
        }
Beispiel #18
0
 public void AddMethod(IdToken idToken, bool isPub, int paramCount, ArrayList localNameList, ArrayList localCountList, ArrayList statementList, int endLineNumber)
 {
     AssertUndefined(idToken);
     MethodSymbolInfo methodSymbolInfo = new MethodSymbolInfo(idToken, isPub, paramCount, localNameList, localCountList, statementList, endLineNumber);
     AddSymbolInfo(methodSymbolInfo);
     if (isPub)
         pubList.Add(methodSymbolInfo);
     else
         priList.Add(methodSymbolInfo);
 }
Beispiel #19
0
 public MethodSymbolInfo(IdToken idToken, bool isPub, int paramCount, ArrayList localNameList, ArrayList localCountList, ArrayList statementList, int endLineNumber)
     : base(idToken)
 {
     this.isPub = isPub;
     this.paramCount = paramCount;
     this.localNameList = localNameList;
     this.localCountList = localCountList;
     this.statementList = statementList;
     this.endLineNumber = endLineNumber;
 }
Beispiel #20
0
 public AtAtAtExpr(IdToken token)
     : base(token)
 {
     this.token = token;
 }