Package pascalcompiler.scanner

Examples of pascalcompiler.scanner.PascalToken


     * @param dNode
     * @return
     */
    DeclarationsNode declarations(DeclarationsNode dNode) {
        ArrayList<String> idList = new ArrayList<String>();
        PascalToken type;
        if (token == PascalToken.VAR) {
            match(PascalToken.VAR);
            idList.addAll(identifier_list());
            match(PascalToken.COLON);
            type = type();
View Full Code Here


     * @param subProgram
     * @return
     */
    SubProgramNode subprogram_head(SubProgramNode subProgram) {
        String name;
        PascalToken type;
        ArgumentsNode args;
        if (token == PascalToken.FUNCTION) {
            match(PascalToken.FUNCTION);
            name = (String)ps.getAttribute();
            subProgram = new FunctionDeclarationNode(name);
View Full Code Here

     * @return
     */
    ArgumentsNode parameter_list(ArgumentsNode aNode) {
        ArrayList<String> idList = new ArrayList<String>();
        ArgumentsNode args = new ArgumentsNode();
        PascalToken type;
        if (token == PascalToken.ID) {
            idList = identifier_list();
            match(PascalToken.COLON);
            type = type();
            args.setDeclarations(idList, type );
View Full Code Here

     * @return
     */
    StatementNode statement() {
        StatementNode statement;
        String id;
        PascalToken idKind;
        if (token == PascalToken.ID) {
            id = (String)ps.getAttribute();
            if (!idTable.containsId(id)) {
                System.out.println(ps.getLineNumber() + ": " +
                        id + " was not declared");
View Full Code Here

        String beginWhile = "BeginWhile" + this.whileNumber;
        String endWhile = "EndWhile" + this.whileNumber++;
        code += beginWhile + ":\n";
        EquationNode expression = statement.getExpression();
        if (expression instanceof OperationNode) {
            PascalToken relop = ((OperationNode)expression).getOperation();
            if (isRelationalOperator(relop)){
                EquationNode left = ((OperationNode)expression).getLeft();
                EquationNode right = ((OperationNode)expression).getRight();
                int temp = this.currentTRegister;
                tReg1 += this.currentTRegister++;
View Full Code Here

        String code = "\n", tReg1 = "$t", tReg2 = "$t";
        String ifElse = "Else" + this.ifNumber;
        String ifExit = "Exit" + this.ifNumber++;
        EquationNode expression = statement.getExpression();
        if (expression instanceof OperationNode) {
            PascalToken relop = ((OperationNode)expression).getOperation();
            if (isRelationalOperator(relop)){
                EquationNode left = ((OperationNode)expression).getLeft();
                EquationNode right = ((OperationNode)expression).getRight();
                int temp = this.currentTRegister;
                tReg1 += this.currentTRegister++;
View Full Code Here

        String leftRegister = "$t" + currentTRegister++;
        code = writeCode( left, leftRegister);
        EquationNode right = opNode.getRight();
        String rightRegister = "$t" + currentTRegister++;
        code += writeCode( right, rightRegister);
        PascalToken kindOfOp = opNode.getOperation();
        if( kindOfOp == PascalToken.PLUS)
        {
            // add resultregister, left, right
            code += "add    " + resultRegister + ",   " + leftRegister +
                    ",   " + rightRegister + "\n";
View Full Code Here

TOP

Related Classes of pascalcompiler.scanner.PascalToken

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.