/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * This file is part of SimpleC. * * See the file "SimpleC-LICENSE" for Copyright information and * * the terms and conditions for copying, distribution and * * modification of SimpleC. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ package org.sablecc.simplec; import org.sablecc.simplec.analysis.*; import org.sablecc.simplec.node.*; // Reintroduce in the AST the "identifier" alternative of "type specifier" and // the first "value" element of the "binary_expression" production. // This removes the modifications done to the grammar in order to make it LALR(1). class ModifyAST extends DepthFirstAdapter { public void outAIdentifierParameterDeclaration(AIdentifierParameterDeclaration node) { node.replaceBy(new AParameterDeclaration( new ATypedefTypeSpecifier(node.getIdentifier()), node.getDeclarator())); } public void outAAbstractIdentifierParameterDeclaration(AAbstractIdentifierParameterDeclaration node) { node.replaceBy(new AAbstractParameterDeclaration( new ATypedefTypeSpecifier(node.getIdentifier()), node.getAbstractDeclarator())); } public void outAIdentifierTypedefDeclaration(AIdentifierTypedefDeclaration node) { node.replaceBy(new ATypedefDeclaration( node.getTypedef(), new ATypedefTypeSpecifier(node.getIdentifier()), node.getDeclarator(), node.getSemicolon())); } public void outAIdentifierFunctionDeclaration(AIdentifierFunctionDeclaration node) { node.replaceBy(new AFunctionDeclaration( new ATypedefTypeSpecifier(node.getIdentifier()), node.getFunctionDeclarator(), node.getSemicolon())); } public void outAIdentifierVariableDeclaration(AIdentifierVariableDeclaration node) { node.replaceBy(new AVariableDeclaration( new ATypedefTypeSpecifier(node.getIdentifier()), node.getDeclarator(), node.getAdditionalDeclarator(), node.getSemicolon())); } public void outAIdentifierFunctionDefinition(AIdentifierFunctionDefinition node) { node.replaceBy(new AFunctionDefinition( new ATypedefTypeSpecifier(node.getIdentifier()), node.getFunctionDeclarator(), node.getFunctionBody())); } public void outAIdentifierTypeName(AIdentifierTypeName node) { node.replaceBy(new ATypeName( new ATypedefTypeSpecifier(node.getIdentifier()), node.getAbstractDeclarator())); } public void outAIdentifierBinaryExpression(AIdentifierBinaryExpression node) { node.replaceBy(new ABinaryExpression( node.getLPar(), new AIdentifierValue(node.getIdentifier()), node.getBinop(), node.getValue(), node.getRPar())); } public void outAConstantBinaryExpression(AConstantBinaryExpression node) { node.replaceBy(new ABinaryExpression( node.getLPar(), new AConstantValue(node.getConstant()), node.getBinop(), node.getValue(), node.getRPar())); } public void outADead1BasicStatement(ADead1BasicStatement node) { node.replaceBy(null); } public void outADead2BasicStatement(ADead2BasicStatement node) { node.replaceBy(null); } public void outADead3BasicStatement(ADead3BasicStatement node) { node.replaceBy(null); } public void outADead4BasicStatement(ADead4BasicStatement node) { node.replaceBy(null); } public void outADead5BasicStatement(ADead5BasicStatement node) { System.out.println(node); } public void outADead6BasicStatement(ADead6BasicStatement node) { System.out.println(node); } public void outADead7BasicStatement(ADead7BasicStatement node) { System.out.println(node); } public void outADead1DeadCode(ADead1DeadCode node) { node.replaceBy(null); } public void outADead2DeadCode(ADead2DeadCode node) { node.replaceBy(null); } public void outADead3DeadCode(ADead3DeadCode node) { node.replaceBy(null); } public void outADead4DeadCode(ADead4DeadCode node) { node.replaceBy(null); } public void outADead5DeadCode(ADead5DeadCode node) { node.replaceBy(null); } public void outADead6DeadCode(ADead6DeadCode node) { node.replaceBy(null); } }