Ejemplo n.º 1
0
//	Declarations -> Decl | Decls
Declarations *parseDeclarations( FILE *source )
{
    Token token = scanner(source);
	int i;
    Declaration decl;
    Declarations *decls;
    switch(token.type){
        case FloatDeclaration:
        case IntegerDeclaration:
            decl = parseDeclaration(source, token);
            decls = parseDeclarations(source);
            return makeDeclarationTree( decl, decls );
        case PrintOp:
        case Alphabet:
			for (i = strlen(token.tok) - 1; i >= 0; i--) {
                ungetc(token.tok[i], source);
            }
            return NULL;
        case EOFsymbol:
            return NULL;
        default:
            printf("Syntax Error: Expect declarations %s\n", token.tok);
            exit(1);
    }
}
Ejemplo n.º 2
0
Declarations *parseDeclarations( FILE *source )//changed
{
    Token token = scanner(source);
    Declaration decl;
    Declarations *decls;
    switch(token.type){
        case FloatDeclaration:
        case IntegerDeclaration:
            decl = parseDeclaration(source, token);
            decls = parseDeclarations(source);
            return makeDeclarationTree( decl, decls );
        case PrintOp:
        case Alphabet:
            //ungetc(token.tok[0], source);
			ungetstring(token.tok,source);
            return NULL;
        case EOFsymbol:
            return NULL;
        default:
            printf("Syntax Error: Expect declarations %s\n", token.tok);
            exit(1);
    }
}