Ejemplo n.º 1
0
void Pipe::Draw(CDC *pDc, WorkSpaceRef &ref)
{
	int nPipeStyle = PS_SOLID;
	int nPipeThick = ref.GetPipeThick();
	COLORREF pipeColor = ref.GetPipeColor();
	COLORREF textColor;
	if(IsDefine(ref.Trans()))
	{
		textColor = ref.GetPipeText();
	}
	else
	{
		textColor = ref.GetUndefineText();
	}
	pDc->SetTextColor(textColor);
	GetGarph()->Draw(pDc,pipeColor,nPipeStyle,nPipeThick);
}
Ejemplo n.º 2
0
void NextRawTok (void)
/* Read the next raw token from the input stream */
{
    /* If we've a forced end of assembly, don't read further */
    if (ForcedEnd) {
     	Tok = TOK_EOF;
     	return;
    }

Restart:
    /* Check if we have tokens from another input source */
    if (InputFromStack ()) {
     	return;
    }

Again:
    /* Skip whitespace, remember if we had some */
    if ((WS = IsBlank (C)) != 0) {
	do {
     	    NextChar ();
        } while (IsBlank (C));
    }

    /* Mark the file position of the next token */
    Source->Func->MarkStart (Source);

    /* Clear the string attribute */
    SB_Clear (&SVal);

    /* Hex number or PC symbol? */
    if (C == '$') {
     	NextChar ();

     	/* Hex digit must follow or DollarIsPC must be enabled */
     	if (!IsXDigit (C)) {
	    if (DollarIsPC) {
	     	Tok = TOK_PC;
		return;
	    } else {
     	     	Error ("Hexadecimal digit expected");
	    }
     	}

      	/* Read the number */
     	IVal = 0;
     	while (IsXDigit (C)) {
     	    if (IVal & 0xF0000000) {
     	    	Error ("Overflow in hexadecimal number");
     		IVal = 0;
     	    }
     	    IVal = (IVal << 4) + DigitVal (C);
     	    NextChar ();
     	}

     	/* This is an integer constant */
    	Tok = TOK_INTCON;
    	return;
    }

    /* Binary number? */
    if (C == '%') {
	NextChar ();

	/* 0 or 1 must follow */
	if (!IsBDigit (C)) {
	    Error ("Binary digit expected");
	}

      	/* Read the number */
	IVal = 0;
	while (IsBDigit (C)) {
	    if (IVal & 0x80000000) {
	      	Error ("Overflow in binary number");
	      	IVal = 0;
	    }
	    IVal = (IVal << 1) + DigitVal (C);
	    NextChar ();
 	}

	/* This is an integer constant */
	Tok = TOK_INTCON;
	return;
    }

    /* Number? */
    if (IsDigit (C)) {

        char Buf[16];
        unsigned Digits;
        unsigned Base;
        unsigned I;
        long     Max;
        unsigned DVal;

        /* Ignore leading zeros */
        while (C == '0') {
            NextChar ();
        }

        /* Read the number into Buf counting the digits */
        Digits = 0;
        while (IsXDigit (C)) {

            /* Buf is big enough to allow any decimal and hex number to
             * overflow, so ignore excess digits here, they will be detected
             * when we convert the value.
             */
            if (Digits < sizeof (Buf)) {
                Buf[Digits++] = C;
            }

            NextChar ();
        }

        /* Allow zilog/intel style hex numbers with a 'h' suffix */
        if (C == 'h' || C == 'H') {
            NextChar ();
            Base = 16;
            Max  = 0xFFFFFFFFUL / 16;
        } else {
            Base = 10;
            Max  = 0xFFFFFFFFUL / 10;
        }

        /* Convert the number using the given base */
	IVal = 0;
        for (I = 0; I < Digits; ++I) {
       	    if (IVal > Max) {
       	       	Error ("Number out of range");
	       	IVal = 0;
                break;
	    }
            DVal = DigitVal (Buf[I]);
            if (DVal > Base) {
                Error ("Invalid digits in number");
                IVal = 0;
                break;
            }
	    IVal = (IVal * Base) + DVal;
        }

	/* This is an integer constant */
       	Tok = TOK_INTCON;
      	return;
    }

    /* Control command? */
    if (C == '.') {

	/* Remember and skip the dot */
	NextChar ();

    	/* Check if it's just a dot */
       	if (!IsIdStart (C)) {

	    /* Just a dot */
	    Tok = TOK_DOT;

	} else {

	    /* Read the remainder of the identifier */
            SB_AppendChar (&SVal, '.');
	    ReadIdent ();

	    /* Dot keyword, search for it */
	    Tok = FindDotKeyword ();
	    if (Tok == TOK_NONE) {

      	    	/* Not found */
		if (!LeadingDotInIdents) {
		    /* Invalid pseudo instruction */
		    Error ("`%m%p' is not a recognized control command", &SVal);
		    goto Again;
		}

		/* An identifier with a dot. Check if it's a define style
		 * macro.
		 */
       	       	if (IsDefine (&SVal)) {
 		    /* This is a define style macro - expand it */
		    MacExpandStart ();
		    goto Restart;
		}

		/* Just an identifier with a dot */
		Tok = TOK_IDENT;
	    }

	}
	return;
    }

    /* Indirect op for sweet16 cpu. Must check this before checking for local
     * symbols, because these may also use the '@' symbol.
     */
    if (CPU == CPU_SWEET16 && C == '@') {
        NextChar ();
        Tok = TOK_AT;
        return;
    }

    /* Local symbol? */
    if (C == LocalStart) {

    	/* Read the identifier. */
    	ReadIdent ();

     	/* Start character alone is not enough */
        if (SB_GetLen (&SVal) == 1) {
	    Error ("Invalid cheap local symbol");
       	    goto Again;
	}

       	/* A local identifier */
	Tok = TOK_LOCAL_IDENT;
	return;
    }


    /* Identifier or keyword? */
    if (IsIdStart (C)) {

    	/* Read the identifier */
    	ReadIdent ();

       	/* Check for special names. Bail out if we have identified the type of
	 * the token. Go on if the token is an identifier.
	 */
        if (SB_GetLen (&SVal) == 1) {
    	    switch (toupper (SB_AtUnchecked (&SVal, 0))) {

    	     	case 'A':
                    if (C == ':') {
                        NextChar ();
                        Tok = TOK_OVERRIDE_ABS;
                    } else {
    	     	        Tok = TOK_A;
                    }
    	            return;

                case 'F':
                    if (C == ':') {
                        NextChar ();
                        Tok = TOK_OVERRIDE_FAR;
		       	return;
                    }
		    break;

	        case 'S':
                    if (CPU == CPU_65816) {
                        Tok = TOK_S;
                        return;
                    }
                    break;

    	     	case 'X':
     	     	    Tok = TOK_X;
	     	    return;

 	      	case 'Y':
	     	    Tok = TOK_Y;
	     	    return;

                case 'Z':
                    if (C == ':') {
                        NextChar ();
                        Tok = TOK_OVERRIDE_ZP;
		       	return;
                    }
                    break;

      	      	default:
	     	    break;
   	    }

	} else if (CPU == CPU_SWEET16 && (IVal = Sweet16Reg (&SVal)) >= 0) {

            /* A sweet16 register number in sweet16 mode */
            Tok = TOK_REG;
            return;

        }

	/* Check for define style macro */
       	if (IsDefine (&SVal)) {
	    /* Macro - expand it */
	    MacExpandStart ();
	    goto Restart;
	} else {
	    /* An identifier */
	    Tok = TOK_IDENT;
	}
	return;
    }

    /* Ok, let's do the switch */
CharAgain:
    switch (C) {

	case '+':
	    NextChar ();
	    Tok = TOK_PLUS;
	    return;

	case '-':
	    NextChar ();
     	    Tok = TOK_MINUS;
	    return;

	case '/':
	    NextChar ();
            if (C != '*') {
                Tok = TOK_DIV;
            } else if (CComments) {
                /* Remember the position, then skip the '*' */
                FilePos Pos = CurPos;
                NextChar ();
                do {
                    while (C !=  '*') {
                        if (C == EOF) {
                            PError (&Pos, "Unterminated comment");
                            goto CharAgain;
                        }
                        NextChar ();
                    }
                    NextChar ();
                } while (C != '/');
                NextChar ();
                goto Again;
            }
	    return;

	case '*':
	    NextChar ();
	    Tok = TOK_MUL;
	    return;

	case '^':
	    NextChar ();
      	    Tok = TOK_XOR;
	    return;

	case '&':
   	    NextChar ();
	    if (C == '&') {
	    	NextChar ();
	    	Tok = TOK_BOOLAND;
	    } else {
	        Tok = TOK_AND;
	    }
       	    return;

	case '|':
	    NextChar ();
	    if (C == '|') {
	    	NextChar ();
	     	Tok = TOK_BOOLOR;
	    } else {
	        Tok = TOK_OR;
	    }
	    return;

	case ':':
	    NextChar ();
      	    switch (C) {

		case ':':
		    NextChar ();
		    Tok = TOK_NAMESPACE;
		    break;

		case '-':
		    IVal = 0;
		    do {
     		     	--IVal;
	  	     	NextChar ();
		    } while (C == '-');
		    Tok = TOK_ULABEL;
		    break;

		case '+':
		    IVal = 0;
		    do {
		     	++IVal;
	     	     	NextChar ();
	       	    } while (C == '+');
	 	    Tok = TOK_ULABEL;
		    break;

                case '=':
                    NextChar ();
                    Tok = TOK_ASSIGN;
                    break;

		default:
	            Tok = TOK_COLON;
		    break;
	    }
	    return;

	case ',':
	    NextChar ();
	    Tok = TOK_COMMA;
	    return;

	case ';':
	    NextChar ();
	    while (C != '\n' && C != EOF) {
	    	NextChar ();
	    }
	    goto CharAgain;

	case '#':
	    NextChar ();
      	    Tok = TOK_HASH;
	    return;

	case '(':
	    NextChar ();
	    Tok = TOK_LPAREN;
	    return;

	case ')':
       	    NextChar ();
            Tok = TOK_RPAREN;
	    return;

	case '[':
	    NextChar ();
	    Tok = TOK_LBRACK;
	    return;

	case ']':
	    NextChar ();
	    Tok = TOK_RBRACK;
	    return;

	case '{':
	    NextChar ();
      	    Tok = TOK_LCURLY;
	    return;

	case '}':
	    NextChar ();
	    Tok = TOK_RCURLY;
	    return;

	case '<':
 	    NextChar ();
	    if (C == '=') {
	     	NextChar ();
	      	Tok = TOK_LE;
	    } else if (C == '<') {
		NextChar ();
		Tok = TOK_SHL;
	    } else if (C == '>') {
	      	NextChar ();
		Tok = TOK_NE;
	    } else {
		Tok = TOK_LT;
	    }
	    return;

	case '=':
      	    NextChar ();
       	    Tok = TOK_EQ;
	    return;

	case '!':
	    NextChar ();
	    Tok = TOK_BOOLNOT;
   	    return;

	case '>':
     	    NextChar ();
	    if (C == '=') {
		NextChar ();
		Tok = TOK_GE;
       	    } else if (C == '>') {
		NextChar ();
	       	Tok = TOK_SHR;
	    } else {
	       	Tok = TOK_GT;
	    }
	    return;

        case '~':
	    NextChar ();
	    Tok = TOK_NOT;
      	    return;

 	case '\'':
	    /* Hack: If we allow ' as terminating character for strings, read
	     * the following stuff as a string, and check for a one character
	     * string later.
	     */
	    if (LooseStringTerm) {
		ReadStringConst ('\'');
                if (SB_GetLen (&SVal) == 1) {
		    IVal = SB_AtUnchecked (&SVal, 0);
	      	    Tok = TOK_CHARCON;
		} else {
		    Tok = TOK_STRCON;
		}
	    } else {
		/* Always a character constant */
	     	NextChar ();
	     	if (C == EOF || IsControl (C)) {
	     	    Error ("Illegal character constant");
	     	    goto CharAgain;
	     	}
	     	IVal = C;
	     	Tok = TOK_CHARCON;
	     	NextChar ();
	     	if (C != '\'') {
                    if (!MissingCharTerm) {
                        Error ("Illegal character constant");
                    }
	     	} else {
	     	    NextChar ();
	     	}
	    }
	    return;

	case '\"':
     	    ReadStringConst ('\"');
	    Tok = TOK_STRCON;
	    return;

	case '\\':
	    /* Line continuation? */
	    if (LineCont) {
	    	NextChar ();
	    	if (C == '\n') {
     		    /* Handle as white space */
     		    NextChar ();
     		    C = ' ';
     	     	    goto Again;
     	       	}
     	    }
      	    break;

        case '\n':
     	    NextChar ();
     	    Tok = TOK_SEP;
     	    return;

        case EOF:
            CheckInputStack ();
            /* In case of the main file, do not close it, but return EOF. */
            if (Source && Source->Next) {
                DoneCharSource ();
                goto Again;
            } else {
     	     	Tok = TOK_EOF;
            }
            return;
    }

    /* If we go here, we could not identify the current character. Skip it
     * and try again.
     */
    Error ("Invalid input character: 0x%02X", C & 0xFF);
    NextChar ();
    goto Again;
}