Exemplo n.º 1
0
 public override void Visit(BooleanConstantExpressionNode node)
 {
     if (node.value == true)
         Gen("mov", "eax", "1");
     else
         Gen("mov", "eax", "0");
 }
Exemplo n.º 2
0
        // ============== The main tokenizer code =================

        int Scan()
        {
                for (; ; )
                {
                    int next;              // next state to enter                   
#if BACKUP
                    Result rslt = Result.noMatch;
#endif // BACKUP
#if LEFTANCHORS
                    for (;;)
                    {
                        // Discard characters that do not start any pattern.
                        // Must check the left anchor condition after *every* GetCode!
                        state = ((cCol == 0) ? anchorState[currentScOrd] : currentStart);
                        if ((next = NextState()) != goStart) 
                            break; // LOOP EXIT HERE...
                        GetCode();
                    }
                    
#else // !LEFTANCHORS
                    state = currentStart;
                    while ((next = NextState()) == goStart)
                        // At this point, the current character has no
                        // transition from the current state.  We discard 
                        // the "no-match" char.   In traditional LEX such 
                        // characters are echoed to the console.
                        GetCode();
#endif // LEFTANCHORS                    
                    // At last, a valid transition ...    
                    MarkToken();
                    state = next;
                    GetCode();
                    
                    while ((next = NextState()) > eofNum) // Exit for goStart AND for eofNum
#if BACKUP
                        if (state <= maxAccept && next > maxAccept) // need to prepare backup data
                        {
                            // ctx is an object. The fields may be 
                            // mutated by the call to Recurse2.
                            // On return the data in ctx is the
                            // *latest* accept state that was found.
                            
                            rslt = Recurse2(ref ctx, next);
                            if (rslt == Result.noMatch) 
                                RestoreStateAndPos(ref ctx);
                            break;
                        }
                        else
#endif // BACKUP
                        {
                            state = next;
                            GetCode();
                        }
                    if (state <= maxAccept) 
                    {
                        MarkEnd();
#region ActionSwitch
#pragma warning disable 162
    switch (state)
    {
        case eofNum:
            switch (currentStart) {
                case 119:
return (int)Tokens.EOF;


/******Stuff to Ignore********/
                    break;
            }
            if (yywrap())
                return (int)Tokens.EOF;
            break;
        case 1:
Parser.LineNumber++; tokLin++;
            break;
        case 2:
        case 3:
        case 4:
        case 5:
        case 6:
        case 7:
        case 8:
        case 9:
        case 10:
        case 11:
        case 12:
        case 13:
        case 14:
        case 15:
        case 16:
        case 17:
        case 44:
        case 45:
        case 46:
        case 47:
        case 49:
        case 50:
        case 51:
        case 52:
        case 53:
        case 54:
        case 56:
        case 57:
        case 58:
        case 60:
        case 61:
        case 63:
        case 64:
        case 66:
        case 67:
        case 68:
        case 69:
        case 70:
        case 72:
        case 73:
        case 74:
        case 75:
        case 77:
        case 79:
        case 80:
        case 81:
        case 83:
        case 85:
        case 86:
        case 87:
        case 89:
        case 90:
        case 91:
        case 93:
        case 94:
        case 95:
        case 96:
        case 98:
        case 99:
        case 100:
        case 101:
        case 103:
        case 104:
        case 105:
        case 106:
        case 107:
        case 108:
        case 110:
        case 112:
        case 113:
        case 114:
        case 117:
yylval = new IdentifierNode(yytext,yyline);	return (int)Tokens.Identifier;


/*************EOF**************/
            break;
        case 18:
return (int)Tokens.Dot;
            break;
        case 19:
return (int)Tokens.AddOperator;
            break;
        case 20:
return (int)Tokens.SubtractOperator;
            break;
        case 21:
return (int)Tokens.MultiplyOperator;
            break;
        case 22:
return (int)Tokens.DivideOperator;
            break;
        case 23:
return (int)Tokens.EqualsOperator;
            break;
        case 24:
return (int)Tokens.LessThanOperator;
            break;
        case 25:
        case 38:
return (int)Tokens.Null;
            break;
        case 26:
return (int)Tokens.NotOperator;

/********Punctuation********/
            break;
        case 27:
return (int)Tokens.RoundBracketOpen;
            break;
        case 28:
return (int)Tokens.RoundBracketClose;
            break;
        case 29:
return (int)Tokens.CurlyBracketOpen;
            break;
        case 30:
return (int)Tokens.CurlyBracketClose;
            break;
        case 31:
return (int)Tokens.SquareBracketOpen;
            break;
        case 32:
return (int)Tokens.SquareBracketClose;
            break;
        case 33:
return (int)Tokens.SemiColon;
            break;
        case 34:
return (int)Tokens.Comma;

/*******Integer Constants********/
            break;
        case 35:
        case 36:
        case 39:
        case 40:
yylval = new IntegerConstantExpressionNode(int.Parse(yytext),yyline);  return (int)Tokens.IntegerConstant;


/***********Identifier***********/
            break;
        case 37:
/* Whitespace */
            break;
        case 41:
return (int)Tokens.AndAndOperator;
            break;
        case 42:
Parser.LineNumber++; tokLin++;
            break;
        case 43:
Parser.LineNumber++; tokLin++;
            break;
        case 48:
return (int)Tokens.ReturnKeyword;
            break;
        case 55:
return (int)Tokens.SystemOutPrintLnKeyword;
            break;
        case 59:
return (int)Tokens.StringKeyword;
            break;
        case 62:
return (int)Tokens.MainKeyword;
            break;
        case 65:
return (int)Tokens.VoidKeyword;
            break;
        case 71:
return (int)Tokens.BooleanKeyword;
            break;
        case 76:
return (int)Tokens.PublicKeyword;
            break;
        case 78:
return (int)Tokens.NewKeyword;
            break;
        case 82:
yylval = new BooleanConstantExpressionNode(true,yyline); return (int)Tokens.TrueKeyword;
            break;
        case 84:
return (int)Tokens.ThisKeyword;
            break;
        case 88:
return (int)Tokens.ClassKeyword;;
            break;
        case 92:
return (int)Tokens.WhileKeyword;
            break;
        case 97:
return (int)Tokens.StaticKeyword;
            break;
        case 102:
return (int)Tokens.LengthKeyword;


/**********Operators********/
            break;
        case 109:
return (int)Tokens.ExtendsKeyword;
            break;
        case 111:
return (int)Tokens.ElseKeyword;
            break;
        case 115:
yylval = new BooleanConstantExpressionNode(false,yyline); return (int)Tokens.FalseKeyword;
            break;
        case 116:
return (int)Tokens.IfKeyword;
            break;
        case 118:
return (int)Tokens.IntKeyword;
            break;
        default:
            break;
    }
#pragma warning restore 162
#endregion
                    }
                }
        }
Exemplo n.º 3
0
 public override void Visit(BooleanConstantExpressionNode node)
 {
     node.ExpressionType = BooleanType.Instance;
 }
Exemplo n.º 4
0
 public virtual void Visit(BooleanConstantExpressionNode node)
 {
 }
Exemplo n.º 5
0
 public override void Visit(BooleanConstantExpressionNode node)
 {
     Console.WriteLine(this.indentation + node.value);
 }