Changeset 2658
- Timestamp:
- Nov 19, 2012, 7:51:17 PM (6 years ago)
- Location:
- proto/pablo
- Files:
-
- 9 added
- 11 deleted
- 28 edited
- 3 copied
- 12 moved
Legend:
- Unmodified
- Added
- Removed
-
proto/pablo/input/grammar/antlr/pablo.g
r2583 r2658 34 34 // f u n c t i o n d e f i n i t i o n 35 35 functionDef 36 : FUNCTION functionReturnTypeSpecifier functionName LROUND parameterList? RROUND blockSt atement36 : FUNCTION functionReturnTypeSpecifier functionName LROUND parameterList? RROUND blockStmt 37 37 ; 38 38 … … 57 57 ; 58 58 59 blockSt atement60 : LCURLY statementList RCURLY61 ; 62 63 statementList64 : statement*59 blockStmt 60 : LCURLY StmtList RCURLY 61 ; 62 63 StmtList 64 : Stmt* 65 65 ; 66 66 67 67 // s t a t e m e n t s 68 statement69 : (variableDefinition | assignmentSt atement | ifStatement | functionCall | whileStatement | returnStatement) (TERMINATOR)?68 Stmt 69 : (variableDefinition | assignmentStmt | ifStmt | functionCall | whileStmt | returnStmt) (TERMINATOR)? 70 70 ; 71 71 … … 78 78 ; 79 79 80 assignmentSt atement80 assignmentStmt 81 81 : compoundVariable assignmentOperator expression 82 82 ; … … 90 90 ; 91 91 92 ifSt atement93 : IF LROUND expression RROUND blockSt atement (ELSE blockStatement)?92 ifStmt 93 : IF LROUND expression RROUND blockStmt (ELSE blockStmt)? 94 94 ; 95 95 … … 98 98 ; 99 99 100 whileSt atement101 : WHILE LROUND expression RROUND DO blockSt atement102 ; 103 104 returnSt atement100 whileStmt 101 : WHILE LROUND expression RROUND DO blockStmt 102 ; 103 104 returnStmt 105 105 : RETURN identifier // expression ? 106 106 ; -
proto/pablo/input/grammar/scatter/pablo.scatter
r2641 r2658 65 65 unaryOperator {} [expression2],// expression5], 66 66 assignment {} [assignmentRest], 67 functionInvocation {} [functionInvocationRest],67 FuncCall {} [FuncCallRest], 68 68 integerConstant{intValued;} [], 69 69 } 70 70 71 71 grammar { 72 program -> (declarations | functionDef) *;72 program -> (declarations | FuncDef) *; 73 73 74 74 // … … 85 85 typeDef -> TYPEDEF type identifier ; 86 86 87 declaratorList -> identifier (COMMA identifier)* ; // TODO - support or support via 'source' functiondefinitions87 declaratorList -> identifier (COMMA identifier)* ; // TODO - support or support via 'source' Func definitions 88 88 89 89 … … 91 91 // f u n c t i o n d e f i n i t i o n s 92 92 // 93 functionDef -> FUNCTION type functionName LROUND parameterList? RROUND blockStatement TERMINATOR?;93 FuncDef -> FUNCTION type FuncName LROUND parameterList? RROUND blockStmt TERMINATOR?; 94 94 95 95 returnType #-> type ; // Note: Strictly not required. … … 97 97 parameterList -> parameter (COMMA parameter)*; 98 98 99 functionName #-> identifier ;99 FuncName #-> identifier ; 100 100 101 101 parameter -> type parameterName ; … … 110 110 // s t a t e m e n t s 111 111 // 112 statement #-> (functionInvocationOrAssignmentStatement | ifStatement | whileStatement | returnStatement | localVarDecl) (TERMINATOR)? ;112 Stmt #-> (FuncCallOrAssignmentStmt | ifStmt | whileStmt | returnStmt | localVarDecl) (TERMINATOR)? ; 113 113 114 functionInvocationOrAssignmentStatement -> compoundVariable ((functionInvocationRest _promote_) | (assignmentRest _promote_)) TERMINATOR ;115 116 functionInvocationRest -> LROUND^ functionInvocationArgumentList RROUND ;117 118 functionInvocationArgumentList-> (expression (COMMA expression)*)? ;119 120 assignmentOperator 121 122 assignmentRest 123 124 ifSt atement -> IF LROUND expression RROUND blockStatement (ELSE blockStatement)? ;114 FuncCallOrAssignmentStmt -> compoundVariable ((FuncCallRest _promote_) | (assignmentRest _promote_)) TERMINATOR ; 115 116 FuncCallRest -> LROUND^ FuncCallArgList RROUND ; 117 118 FuncCallArgList -> (expression (COMMA expression)*)? ; 119 120 assignmentOperator -> ASSIGN | AND_ASSIGN | OR_ASSIGN | XOR_ASSIGN ; 121 122 assignmentRest -> assignmentOperator^! expression ; 123 124 ifStmt -> IF LROUND expression RROUND blockStmt (ELSE blockStmt)? ; 125 125 126 whileSt atement -> WHILE LROUND expression RROUND blockStatement ;126 whileStmt -> WHILE LROUND expression RROUND blockStmt ; 127 127 128 returnSt atement -> RETURN (expression)? TERMINATOR;128 returnStmt -> RETURN (expression)? TERMINATOR; 129 129 130 localVarDecl 131 132 variableName 133 134 blockSt atement -> LCURLY statement* RCURLY ;130 localVarDecl -> VAR type variableName (assignmentOperator^! expression) ?; 131 132 variableName #-> identifier; 133 134 blockStmt -> LCURLY Stmt* RCURLY ; 135 135 136 136 // … … 145 145 expression3 #-> LROUND expression RROUND 146 146 | constant 147 | compoundVariable ( functionInvocationRest _promote_)?147 | compoundVariable (FuncCallRest _promote_)? 148 148 ; 149 149 150 151 //(functionInvocationRest _promote_)?152 153 154 155 156 157 158 150 //( 151 //(FuncCallRest _promote_)? 152 //| (expression4 _promote_)? 153 //| (expression5 _promote_)? 154 //)? 155 // ; 156 //expression4 -> DOT expression3 ; 157 //expression5 -> (LSQUARE INTEGER_CONST^ RSQUARE) (expression5Rest)? ; 158 //expression5Rest -> DOT expression3 ; 159 159 160 160 constant #-> stringConstant | signedIntegerConstant ; -
proto/pablo/input/grammar/scatter/pablo.scatter.alpha
r2387 r2658 66 66 binaryOperator {} [expression, expression1, expression3], 67 67 unaryOperator {} [expression2], 68 assignment {} [assignmentSt atementTail],69 // ifSt atement {} [ifStatementBulk],68 assignment {} [assignmentStmtTail], 69 // ifStmt {} [ifStmtBulk], 70 70 functionCall {} [functionCallTail], 71 71 tupleIdentifier {} [tupleTail], 72 // ASTNode [variableFunctionCall], //[assignmentOrFunction Invocation, variableOrFunctionInvocation],72 // ASTNode [variableFunctionCall], //[assignmentOrFunctionCall, variableOrFunctionCall], 73 73 } 74 74 … … 91 91 // f u n c t i o n d e f i n i t i o n s 92 92 // 93 functionDef -> FUNCTION functionReturnType functionName LROUND (parameter (COMMA parameter)*)? RROUND blockSt atement TERMINATOR ?;93 functionDef -> FUNCTION functionReturnType functionName LROUND (parameter (COMMA parameter)*)? RROUND blockStmt TERMINATOR ?; 94 94 95 95 functionReturnType -> typeSpecifier | VOID ; … … 101 101 parameterName #-> identifier ; 102 102 103 blockSt atement -> LCURLY statement* RCURLY ;103 blockStmt -> LCURLY Stmt* RCURLY ; 104 104 105 105 // 106 106 // s t a t e m e n t s 107 107 // 108 statement #-> (assignmentStatementOrFunctionCall | ifStatement | whileStatement | returnStatement) (TERMINATOR)? ;108 Stmt #-> (assignmentStmtOrFunctionCall | ifStmt | whileStmt | returnStmt) (TERMINATOR)? ; 109 109 110 110 //variableDefinition … … 112 112 //variableName #-> identifier ; 113 113 114 assignmentSt atementOrFunctionCall -> compoundVariable (assignmentStatementTail _promote_ | functionCallTail _promote_) ;115 116 assignmentSt atementTail -> assignmentOperator^! expression ;114 assignmentStmtOrFunctionCall -> compoundVariable (assignmentStmtTail _promote_ | functionCallTail _promote_) ; 115 116 assignmentStmtTail -> assignmentOperator^! expression ; 117 117 118 118 functionCallTail -> LROUND (argumentList)? RROUND ; … … 131 131 assignmentOperator -> ASSIGN | AND_ASSIGN | OR_ASSIGN | NOT_ASSIGN | XOR_ASSIGN ; 132 132 133 ifSt atement -> IF LROUND ifCondition RROUND ifBlock (ELSE elseBlock)? ;133 ifStmt -> IF LROUND ifCondition RROUND ifBlock (ELSE elseBlock)? ; 134 134 135 135 ifCondition -> expression ; 136 136 137 ifBlock -> blockSt atement ;138 139 elseBlock -> blockSt atement ; // TODO - dangling else problems?137 ifBlock -> blockStmt ; 138 139 elseBlock -> blockStmt ; // TODO - dangling else problems? 140 140 141 whileSt atement -> WHILE LROUND whileCondition RROUND blockStatement ;141 whileStmt -> WHILE LROUND whileCondition RROUND blockStmt ; 142 142 143 143 whileCondition -> expression ; 144 144 145 returnSt atement -> RETURN (identifier)? ; // TODO - return an expression145 returnStmt -> RETURN (identifier)? ; // TODO - return an expression 146 146 147 147 // -
proto/pablo/input/grammar/scatter/pablo.scatter.beta
r2370 r2658 54 54 binaryOperator {} [expression, expression1, expression3], 55 55 unaryOperator {} [expression2], 56 assignment {} [assignmentSt atementRest],57 ifSt atement {} [ifStatementBulk],58 functionInvocation {} [functionInvocationRest],59 ASTNode [assignmentOrFunction Invocation, variableOrFunctionInvocation],56 assignment {} [assignmentStmtRest], 57 ifStmt {} [ifStmtBulk], 58 FunctionCall {} [FunctionCallRest], 59 ASTNode [assignmentOrFunctionCall, variableOrFunctionCall], 60 60 } 61 61 … … 70 70 // We need to put curly braces {} around body of class delcaration. 71 71 // this grammar only allows simple initialization of fields as class 72 // body statements. Verfiy this as a property of the input.72 // body Stmts. Verfiy this as a property of the input. 73 73 //////////////////////////////////////////////////////////////////////// 74 74 75 75 structDeclaration â CLASS structName LEFTROUND RIGHTROUND COLON structBody ; 76 structBody â LEFTCURLY structBodySt atement* RIGHTCURLY ;77 structBodySt atement Ê â variableName ASSIGN value TERMINATOR? ;76 structBody â LEFTCURLY structBodyStmt* RIGHTCURLY ; 77 structBodyStmt Ê â variableName ASSIGN value TERMINATOR? ; 78 78 value â INTEGER_CONST ; 79 79 … … 87 87 //////////////////////////////////////////////////////////////////////// 88 88 89 functionDef â DEF functionName LEFTROUND parameterList RIGHTROUND COLON blockSt atement ;89 functionDef â DEF functionName LEFTROUND parameterList RIGHTROUND COLON blockStmt ; 90 90 parameterList â identifier ( COMMA identifier )* ; 91 91 92 statement Ê â (assignmentOrFunctionInvocation | ifStatement | whileStatement | blockStatement) TERMINATOR?;93 blockSt atement â LEFTCURLY statement* RIGHTCURLY ;92 Stmt Ê â (assignmentOrFunctionCall | ifStmt | whileStmt | blockStmt) TERMINATOR?; 93 blockStmt â LEFTCURLY Stmt* RIGHTCURLY ; 94 94 95 assignmentOrFunction Invocation â compoundVariable ( assignmentStatementRest â² | functionInvocationRest â² ) ;96 assignmentSt atementRest â assignOp^! expression ;95 assignmentOrFunctionCall â compoundVariable ( assignmentStmtRest â² | FunctionCallRest â² ) ; 96 assignmentStmtRest â assignOp^! expression ; 97 97 assignOp -> AND_EQUAL | OR_EQUAL | XOR_EQUAL | ASSIGN ; 98 98 99 ifSt atement Ê â IF ifStatementBulk ;100 ifSt atementBulk â expression COLON? blockStatement (ELIF COLON? ifStatementBulk | ELSE COLON? blockStatement)? ;101 whileSt atement â WHILE expression COLON? blockStatement ;102 expressionSt atement â expression;99 ifStmt Ê â IF ifStmtBulk ; 100 ifStmtBulk â expression COLON? blockStmt (ELIF COLON? ifStmtBulk | ELSE COLON? blockStmt)? ; 101 whileStmt â WHILE expression COLON? blockStmt ; 102 expressionStmt â expression; 103 103 104 104 expression Ê â expression1 ( (OR^ | XOR^) expression )? ; // lowest precedence: OR, XOR … … 108 108 expression4 Ê â LEFTROUND expression RIGHTROUND 109 109 110 | variableOrFunction Invocation110 | variableOrFunctionCall 111 111 112 112 | constant ; 113 113 114 variableOrFunction Invocation Ê â compoundVariable (functionInvocationRest â²)? ;115 functionInvocationRest â LEFTROUND^ expression (COMMA expression)* RIGHTROUND ;114 variableOrFunctionCall Ê â compoundVariable (FunctionCallRest â²)? ; 115 FunctionCallRest â LEFTROUND^ expression (COMMA expression)* RIGHTROUND ; 116 116 117 117 compoundVariable Ê â identifier (DOT^ identifier)* ; -
proto/pablo/input/test/visitors/Bitwise2IDISAXFormer/bitwise2IDISA.pablo
r2600 r2658 28 28 r = ~x; // Actual 29 29 30 /* Additional transformations not under test.30 /* Additional XFormations not under test. 31 31 32 32 -
proto/pablo/src/ast/ASTNode.java
r2641 r2658 125 125 } 126 126 } 127 public void insertAfterChild(ASTNode node, ASTNode successor) { 128 int index = children.indexOf(node); 129 insertChildAfter(index, successor); 130 successor.setParent(this); 131 } 132 133 private void insertChildAfter(int index, ASTNode successor) { 134 if(index == children.size()-1) { 135 children.add(successor); 136 } else { 137 children.add(index+1, successor); 138 } 139 } 127 public void insertAfterChild(ASTNode node, ASTNode successor) { 128 int index = children.indexOf(node); 129 insertChildAfter(index, successor); 130 successor.setParent(this); 131 } 132 private void insertChildAfter(int index, ASTNode successor) { 133 if(index == children.size()-1) { 134 children.add(successor); 135 } else { 136 children.add(index+1, successor); 137 } 138 } 140 139 141 140 //////////////////////////////////////////////////////////////////////////////////// -
proto/pablo/src/ast/ASTTransformer.java
r2621 r2658 18 18 public ASTNode visit(BinaryOperatorNode node); 19 19 20 public ASTNode visit(BlockSt atementNode node);20 public ASTNode visit(BlockStmtNode node); 21 21 22 22 public ASTNode visit(CompoundVariableNode node); … … 32 32 public ASTNode visit(FieldWidthNode node); 33 33 34 public ASTNode visit(Func tionDefNode node);35 36 public ASTNode visit(Func tionInvocationArgumentListNode node);37 38 public ASTNode visit(Func tionInvocationNode node);39 40 public ASTNode visit(Func tionInvocationOrAssignmentStatementNode node);34 public ASTNode visit(FuncCallArgListNode node); 35 36 public ASTNode visit(FuncCallNode node); 37 38 public ASTNode visit(FuncCallOrAssignmentStmtNode node); 39 40 public ASTNode visit(FuncDefNode node); 41 41 42 42 public ASTNode visit(IdentifierNode node); 43 43 44 public ASTNode visit(IfSt atementNode node);44 public ASTNode visit(IfStmtNode node); 45 45 46 46 public ASTNode visit(IntegerConstantNode node); … … 54 54 public ASTNode visit(ProgramNode node); 55 55 56 public ASTNode visit(ReturnSt atementNode node);56 public ASTNode visit(ReturnStmtNode node); 57 57 58 58 public ASTNode visit(StreamTypeNode node); … … 74 74 public ASTNode visit(VoidNode node); 75 75 76 public ASTNode visit(WhileSt atementNode node);76 public ASTNode visit(WhileStmtNode node); 77 77 78 78 … … 99 99 } 100 100 101 public ASTNode visit(BlockSt atementNode node) {101 public ASTNode visit(BlockStmtNode node) { 102 102 return defaultVisit(node); 103 103 } … … 127 127 } 128 128 129 public ASTNode visit(Func tionDefNode node) {130 return defaultVisit(node); 131 } 132 133 public ASTNode visit(Func tionInvocationArgumentListNode node) {134 return defaultVisit(node); 135 } 136 137 public ASTNode visit(Func tionInvocationNode node) {138 return defaultVisit(node); 139 } 140 141 public ASTNode visit(Func tionInvocationOrAssignmentStatementNode node) {129 public ASTNode visit(FuncCallArgListNode node) { 130 return defaultVisit(node); 131 } 132 133 public ASTNode visit(FuncCallNode node) { 134 return defaultVisit(node); 135 } 136 137 public ASTNode visit(FuncCallOrAssignmentStmtNode node) { 138 return defaultVisit(node); 139 } 140 141 public ASTNode visit(FuncDefNode node) { 142 142 return defaultVisit(node); 143 143 } … … 147 147 } 148 148 149 public ASTNode visit(IfSt atementNode node) {149 public ASTNode visit(IfStmtNode node) { 150 150 return defaultVisit(node); 151 151 } … … 171 171 } 172 172 173 public ASTNode visit(ReturnSt atementNode node) {173 public ASTNode visit(ReturnStmtNode node) { 174 174 return defaultVisit(node); 175 175 } … … 211 211 } 212 212 213 public ASTNode visit(WhileSt atementNode node) {213 public ASTNode visit(WhileStmtNode node) { 214 214 return defaultVisit(node); 215 215 } -
proto/pablo/src/ast/ASTVisitor.java
r2621 r2658 23 23 public T visitLeave(BinaryOperatorNode node, List<T> childResults); 24 24 25 public void visitEnter(BlockSt atementNode node);26 public T visitLeave(BlockSt atementNode node, List<T> childResults);25 public void visitEnter(BlockStmtNode node); 26 public T visitLeave(BlockStmtNode node, List<T> childResults); 27 27 28 28 public void visitEnter(CompoundVariableNode node); … … 44 44 public T visitLeave(FieldWidthNode node, List<T> childResults); 45 45 46 public void visitEnter(Func tionDefNode node);47 public T visitLeave(Func tionDefNode node, List<T> childResults);48 49 public void visitEnter(Func tionInvocationArgumentListNode node);50 public T visitLeave(Func tionInvocationArgumentListNode node, List<T> childResults);51 52 public void visitEnter(Func tionInvocationNode node);53 public T visitLeave(Func tionInvocationNode node, List<T> childResults);54 55 public void visitEnter(Func tionInvocationOrAssignmentStatementNode node);56 public T visitLeave(Func tionInvocationOrAssignmentStatementNode node, List<T> childResults);46 public void visitEnter(FuncCallArgListNode node); 47 public T visitLeave(FuncCallArgListNode node, List<T> childResults); 48 49 public void visitEnter(FuncCallNode node); 50 public T visitLeave(FuncCallNode node, List<T> childResults); 51 52 public void visitEnter(FuncCallOrAssignmentStmtNode node); 53 public T visitLeave(FuncCallOrAssignmentStmtNode node, List<T> childResults); 54 55 public void visitEnter(FuncDefNode node); 56 public T visitLeave(FuncDefNode node, List<T> childResults); 57 57 58 58 public void visitEnter(IdentifierNode node); 59 59 public T visitLeave(IdentifierNode node, List<T> childResults); 60 60 61 public void visitEnter(IfSt atementNode node);62 public T visitLeave(IfSt atementNode node, List<T> childResults);61 public void visitEnter(IfStmtNode node); 62 public T visitLeave(IfStmtNode node, List<T> childResults); 63 63 64 64 public void visitEnter(IntegerConstantNode node); … … 77 77 public T visitLeave(ProgramNode node, List<T> childResults); 78 78 79 public void visitEnter(ReturnSt atementNode node);80 public T visitLeave(ReturnSt atementNode node, List<T> childResults);79 public void visitEnter(ReturnStmtNode node); 80 public T visitLeave(ReturnStmtNode node, List<T> childResults); 81 81 82 82 public void visitEnter(StreamTypeNode node); … … 107 107 public T visitLeave(VoidNode node, List<T> childResults); 108 108 109 public void visitEnter(WhileSt atementNode node);110 public T visitLeave(WhileSt atementNode node, List<T> childResults);109 public void visitEnter(WhileStmtNode node); 110 public T visitLeave(WhileStmtNode node, List<T> childResults); 111 111 112 112 … … 155 155 } 156 156 157 public void visitEnter(BlockSt atementNode node) {158 defaultVisitEnter(node); 159 } 160 public T visitLeave(BlockSt atementNode node, List<T> childResults) {157 public void visitEnter(BlockStmtNode node) { 158 defaultVisitEnter(node); 159 } 160 public T visitLeave(BlockStmtNode node, List<T> childResults) { 161 161 return defaultVisitLeave(node); 162 162 } … … 204 204 } 205 205 206 public void visitEnter(Func tionDefNode node) {207 defaultVisitEnter(node); 208 } 209 public T visitLeave(Func tionDefNode node, List<T> childResults) {210 return defaultVisitLeave(node); 211 } 212 213 public void visitEnter(Func tionInvocationArgumentListNode node) {214 defaultVisitEnter(node); 215 } 216 public T visitLeave(Func tionInvocationArgumentListNode node, List<T> childResults) {217 return defaultVisitLeave(node); 218 } 219 220 public void visitEnter(Func tionInvocationNode node) {221 defaultVisitEnter(node); 222 } 223 public T visitLeave(Func tionInvocationNode node, List<T> childResults) {224 return defaultVisitLeave(node); 225 } 226 227 public void visitEnter(Func tionInvocationOrAssignmentStatementNode node) {228 defaultVisitEnter(node); 229 } 230 public T visitLeave(Func tionInvocationOrAssignmentStatementNode node, List<T> childResults) {206 public void visitEnter(FuncCallArgListNode node) { 207 defaultVisitEnter(node); 208 } 209 public T visitLeave(FuncCallArgListNode node, List<T> childResults) { 210 return defaultVisitLeave(node); 211 } 212 213 public void visitEnter(FuncCallNode node) { 214 defaultVisitEnter(node); 215 } 216 public T visitLeave(FuncCallNode node, List<T> childResults) { 217 return defaultVisitLeave(node); 218 } 219 220 public void visitEnter(FuncCallOrAssignmentStmtNode node) { 221 defaultVisitEnter(node); 222 } 223 public T visitLeave(FuncCallOrAssignmentStmtNode node, List<T> childResults) { 224 return defaultVisitLeave(node); 225 } 226 227 public void visitEnter(FuncDefNode node) { 228 defaultVisitEnter(node); 229 } 230 public T visitLeave(FuncDefNode node, List<T> childResults) { 231 231 return defaultVisitLeave(node); 232 232 } … … 239 239 } 240 240 241 public void visitEnter(IfSt atementNode node) {242 defaultVisitEnter(node); 243 } 244 public T visitLeave(IfSt atementNode node, List<T> childResults) {241 public void visitEnter(IfStmtNode node) { 242 defaultVisitEnter(node); 243 } 244 public T visitLeave(IfStmtNode node, List<T> childResults) { 245 245 return defaultVisitLeave(node); 246 246 } … … 281 281 } 282 282 283 public void visitEnter(ReturnSt atementNode node) {284 defaultVisitEnter(node); 285 } 286 public T visitLeave(ReturnSt atementNode node, List<T> childResults) {283 public void visitEnter(ReturnStmtNode node) { 284 defaultVisitEnter(node); 285 } 286 public T visitLeave(ReturnStmtNode node, List<T> childResults) { 287 287 return defaultVisitLeave(node); 288 288 } … … 351 351 } 352 352 353 public void visitEnter(WhileSt atementNode node) {354 defaultVisitEnter(node); 355 } 356 public T visitLeave(WhileSt atementNode node, List<T> childResults) {353 public void visitEnter(WhileStmtNode node) { 354 defaultVisitEnter(node); 355 } 356 public T visitLeave(WhileStmtNode node, List<T> childResults) { 357 357 return defaultVisitLeave(node); 358 358 } -
proto/pablo/src/ast/SimpleVisitor.java
r2621 r2658 19 19 public void visit(BinaryOperatorNode node); 20 20 21 public void visit(BlockSt atementNode node);21 public void visit(BlockStmtNode node); 22 22 23 23 public void visit(CompoundVariableNode node); … … 33 33 public void visit(FieldWidthNode node); 34 34 35 public void visit(Func tionDefNode node);36 37 public void visit(Func tionInvocationArgumentListNode node);38 39 public void visit(Func tionInvocationNode node);40 41 public void visit(Func tionInvocationOrAssignmentStatementNode node);35 public void visit(FuncCallArgListNode node); 36 37 public void visit(FuncCallNode node); 38 39 public void visit(FuncCallOrAssignmentStmtNode node); 40 41 public void visit(FuncDefNode node); 42 42 43 43 public void visit(IdentifierNode node); 44 44 45 public void visit(IfSt atementNode node);45 public void visit(IfStmtNode node); 46 46 47 47 public void visit(IntegerConstantNode node); … … 55 55 public void visit(ProgramNode node); 56 56 57 public void visit(ReturnSt atementNode node);57 public void visit(ReturnStmtNode node); 58 58 59 59 public void visit(StreamTypeNode node); … … 75 75 public void visit(VoidNode node); 76 76 77 public void visit(WhileSt atementNode node);77 public void visit(WhileStmtNode node); 78 78 79 79 … … 100 100 } 101 101 102 public void visit(BlockSt atementNode node) {102 public void visit(BlockStmtNode node) { 103 103 defaultVisit(node); 104 104 } … … 128 128 } 129 129 130 public void visit(Func tionDefNode node) {131 defaultVisit(node); 132 } 133 134 public void visit(Func tionInvocationArgumentListNode node) {135 defaultVisit(node); 136 } 137 138 public void visit(Func tionInvocationNode node) {139 defaultVisit(node); 140 } 141 142 public void visit(Func tionInvocationOrAssignmentStatementNode node) {130 public void visit(FuncCallArgListNode node) { 131 defaultVisit(node); 132 } 133 134 public void visit(FuncCallNode node) { 135 defaultVisit(node); 136 } 137 138 public void visit(FuncCallOrAssignmentStmtNode node) { 139 defaultVisit(node); 140 } 141 142 public void visit(FuncDefNode node) { 143 143 defaultVisit(node); 144 144 } … … 148 148 } 149 149 150 public void visit(IfSt atementNode node) {150 public void visit(IfStmtNode node) { 151 151 defaultVisit(node); 152 152 } … … 172 172 } 173 173 174 public void visit(ReturnSt atementNode node) {174 public void visit(ReturnStmtNode node) { 175 175 defaultVisit(node); 176 176 } … … 212 212 } 213 213 214 public void visit(WhileSt atementNode node) {214 public void visit(WhileStmtNode node) { 215 215 defaultVisit(node); 216 216 } -
proto/pablo/src/ast/VoidVisitor.java
r2621 r2658 21 21 public void visitLeave(BinaryOperatorNode node); 22 22 23 public void visitEnter(BlockSt atementNode node);24 public void visitLeave(BlockSt atementNode node);23 public void visitEnter(BlockStmtNode node); 24 public void visitLeave(BlockStmtNode node); 25 25 26 26 public void visitEnter(CompoundVariableNode node); … … 42 42 public void visitLeave(FieldWidthNode node); 43 43 44 public void visitEnter(Func tionDefNode node);45 public void visitLeave(Func tionDefNode node);46 47 public void visitEnter(Func tionInvocationArgumentListNode node);48 public void visitLeave(Func tionInvocationArgumentListNode node);49 50 public void visitEnter(Func tionInvocationNode node);51 public void visitLeave(Func tionInvocationNode node);52 53 public void visitEnter(Func tionInvocationOrAssignmentStatementNode node);54 public void visitLeave(Func tionInvocationOrAssignmentStatementNode node);44 public void visitEnter(FuncCallArgListNode node); 45 public void visitLeave(FuncCallArgListNode node); 46 47 public void visitEnter(FuncCallNode node); 48 public void visitLeave(FuncCallNode node); 49 50 public void visitEnter(FuncCallOrAssignmentStmtNode node); 51 public void visitLeave(FuncCallOrAssignmentStmtNode node); 52 53 public void visitEnter(FuncDefNode node); 54 public void visitLeave(FuncDefNode node); 55 55 56 56 public void visitEnter(IdentifierNode node); 57 57 public void visitLeave(IdentifierNode node); 58 58 59 public void visitEnter(IfSt atementNode node);60 public void visitLeave(IfSt atementNode node);59 public void visitEnter(IfStmtNode node); 60 public void visitLeave(IfStmtNode node); 61 61 62 62 public void visitEnter(IntegerConstantNode node); … … 75 75 public void visitLeave(ProgramNode node); 76 76 77 public void visitEnter(ReturnSt atementNode node);78 public void visitLeave(ReturnSt atementNode node);77 public void visitEnter(ReturnStmtNode node); 78 public void visitLeave(ReturnStmtNode node); 79 79 80 80 public void visitEnter(StreamTypeNode node); … … 105 105 public void visitLeave(VoidNode node); 106 106 107 public void visitEnter(WhileSt atementNode node);108 public void visitLeave(WhileSt atementNode node);107 public void visitEnter(WhileStmtNode node); 108 public void visitLeave(WhileStmtNode node); 109 109 110 110 … … 152 152 } 153 153 154 public void visitEnter(BlockSt atementNode node) {155 defaultVisitEnter(node); 156 } 157 public void visitLeave(BlockSt atementNode node) {154 public void visitEnter(BlockStmtNode node) { 155 defaultVisitEnter(node); 156 } 157 public void visitLeave(BlockStmtNode node) { 158 158 defaultVisitLeave(node); 159 159 } … … 201 201 } 202 202 203 public void visitEnter(Func tionDefNode node) {204 defaultVisitEnter(node); 205 } 206 public void visitLeave(Func tionDefNode node) {207 defaultVisitLeave(node); 208 } 209 210 public void visitEnter(Func tionInvocationArgumentListNode node) {211 defaultVisitEnter(node); 212 } 213 public void visitLeave(Func tionInvocationArgumentListNode node) {214 defaultVisitLeave(node); 215 } 216 217 public void visitEnter(Func tionInvocationNode node) {218 defaultVisitEnter(node); 219 } 220 public void visitLeave(Func tionInvocationNode node) {221 defaultVisitLeave(node); 222 } 223 224 public void visitEnter(Func tionInvocationOrAssignmentStatementNode node) {225 defaultVisitEnter(node); 226 } 227 public void visitLeave(Func tionInvocationOrAssignmentStatementNode node) {203 public void visitEnter(FuncCallArgListNode node) { 204 defaultVisitEnter(node); 205 } 206 public void visitLeave(FuncCallArgListNode node) { 207 defaultVisitLeave(node); 208 } 209 210 public void visitEnter(FuncCallNode node) { 211 defaultVisitEnter(node); 212 } 213 public void visitLeave(FuncCallNode node) { 214 defaultVisitLeave(node); 215 } 216 217 public void visitEnter(FuncCallOrAssignmentStmtNode node) { 218 defaultVisitEnter(node); 219 } 220 public void visitLeave(FuncCallOrAssignmentStmtNode node) { 221 defaultVisitLeave(node); 222 } 223 224 public void visitEnter(FuncDefNode node) { 225 defaultVisitEnter(node); 226 } 227 public void visitLeave(FuncDefNode node) { 228 228 defaultVisitLeave(node); 229 229 } … … 236 236 } 237 237 238 public void visitEnter(IfSt atementNode node) {239 defaultVisitEnter(node); 240 } 241 public void visitLeave(IfSt atementNode node) {238 public void visitEnter(IfStmtNode node) { 239 defaultVisitEnter(node); 240 } 241 public void visitLeave(IfStmtNode node) { 242 242 defaultVisitLeave(node); 243 243 } … … 278 278 } 279 279 280 public void visitEnter(ReturnSt atementNode node) {281 defaultVisitEnter(node); 282 } 283 public void visitLeave(ReturnSt atementNode node) {280 public void visitEnter(ReturnStmtNode node) { 281 defaultVisitEnter(node); 282 } 283 public void visitLeave(ReturnStmtNode node) { 284 284 defaultVisitLeave(node); 285 285 } … … 348 348 } 349 349 350 public void visitEnter(WhileSt atementNode node) {351 defaultVisitEnter(node); 352 } 353 public void visitLeave(WhileSt atementNode node) {350 public void visitEnter(WhileStmtNode node) { 351 defaultVisitEnter(node); 352 } 353 public void visitLeave(WhileStmtNode node) { 354 354 defaultVisitLeave(node); 355 355 } -
proto/pablo/src/compiler/OptionsConfig.java
r2655 r2658 52 52 OptionBuilder.isRequired(false); 53 53 OptionBuilder.withLongOpt("dump"); 54 OptionBuilder.withDescription("Add SIMD register dump statements.");54 OptionBuilder.withDescription("Add SIMD register dump Stmts."); 55 55 option = OptionBuilder.create("d"); 56 56 options.addOption(option); … … 59 59 OptionBuilder.isRequired(false); 60 60 OptionBuilder.withLongOpt("align"); 61 OptionBuilder.withDescription("Add ASSERT_BITBLOCK_ALIGN statements.");61 OptionBuilder.withDescription("Add ASSERT_BITBLOCK_ALIGN Stmts."); 62 62 option = OptionBuilder.create("a"); 63 63 options.addOption(option); -
proto/pablo/src/compiler/PabloCompiler.java
r2657 r2658 39 39 private static String errorRoutine; 40 40 41 private static boolean addDumpSt atements = false;42 private static boolean addAssertBitBlockAlignSt atements = false;41 private static boolean addDumpStmts = false; 42 private static boolean addAssertBitBlockAlignStmts = false; 43 43 44 44 public static void main(String[] args) throws FileNotFoundException { … … 54 54 errorRoutine = cmd.getOptionValue("e", "assert_0_error"); 55 55 56 if(cmd.hasOption("d")) { addDumpSt atements = true; }57 if(cmd.hasOption("a")) { addAssertBitBlockAlignSt atements = true; }56 if(cmd.hasOption("d")) { addDumpStmts = true; } 57 if(cmd.hasOption("a")) { addAssertBitBlockAlignStmts = true; } 58 58 59 59 } catch (Exception e) { … … 75 75 ASTNode syntaxTree = Parser.parse(lexController); 76 76 77 StreamFunc tionVisitor streamFunctionVisitor = new StreamFunctionVisitor(syntaxTree);78 Map<String, ASTNode> streamFunc tionMap = streamFunctionVisitor.makeStreamFunctionMap();77 StreamFuncVisitor streamFuncVisitor = new StreamFuncVisitor(syntaxTree); 78 Map<String, ASTNode> streamFuncMap = streamFuncVisitor.makeStreamFuncMap(); 79 79 80 80 Builtins2Lang builtins2CPP = new Builtins2CPP(); 81 81 CarrySet2Lang carrySet2CPP = new CarrySet2CPP(); 82 82 83 for (Map.Entry<String, ASTNode> entry : streamFunc tionMap.entrySet()) {83 for (Map.Entry<String, ASTNode> entry : streamFuncMap.entrySet()) { 84 84 85 85 ASTNode value = entry.getValue(); 86 86 87 AdvanceCombiner Transformer advanceCombiner = new AdvanceCombinerTransformer(value);88 advanceCombiner. transform();87 AdvanceCombinerXFormer advanceCombiner = new AdvanceCombinerXFormer(value); 88 advanceCombiner.XForm(); 89 89 90 90 /* … … 98 98 */ 99 99 100 Aug mentedAssignmentTransformer augmentedAssignment = new AugmentedAssignmentTransformer(value);101 augmentedAssignment.transform();100 AugAssignmentXFormer AugAssignment = new AugAssignmentXFormer(value); 101 AugAssignment.XForm(); 102 102 103 CarryIntro Transformer carryQIntro = new CarryIntroTransformer(value, carrySet2CPP);104 carryQIntro. transform(true, false);103 CarryIntroXFormer carryQIntro = new CarryIntroXFormer(value, carrySet2CPP); 104 carryQIntro.XForm(true, false); 105 105 106 Pablo2Carry Transformer pablo2CarryQ = new Pablo2CarryTransformer(value, builtins2CPP, carrySet2CPP);107 pablo2CarryQ. transform(true, false);106 Pablo2CarryXFormer pablo2CarryQ = new Pablo2CarryXFormer(value, builtins2CPP, carrySet2CPP); 107 pablo2CarryQ.XForm(true, false); 108 108 109 Bitwise2IDISATransformer bitwiseToIDISA = new Bitwise2IDISATransformer(value); 110 bitwiseToIDISA.transform(); 109 AssertZeroXFormer assertZeroXFormer = new AssertZeroXFormer(value, builtins2CPP); 110 assertZeroXFormer.XForm(); 111 112 Bitwise2IDISAXFormer bitwiseToIDISA = new Bitwise2IDISAXFormer(value); 113 bitwiseToIDISA.XForm(); 111 114 112 if(PabloCompiler.addDumpStatements) { 113 DumpAssignmentStatementsTransformer dumpAssignmentStatementsTransformer 114 = new DumpAssignmentStatementsTransformer(value, builtins2CPP); 115 dumpAssignmentStatementsTransformer.transform(); 115 if(PabloCompiler.addDumpStmts) { 116 DumpAssignmentStmtsXFormer dumpAssignmentStmtsXFormer = new DumpAssignmentStmtsXFormer(value, builtins2CPP); 117 dumpAssignmentStmtsXFormer.XForm(); 116 118 } 117 119 118 if(PabloCompiler.addAssertBitBlockAlignStatements) { 119 AssertBitBlockAlignStatementsTransformer assertBitBlockAlignStatementsTransformer 120 = new AssertBitBlockAlignStatementsTransformer(value, builtins2CPP, carrySet2CPP); 121 assertBitBlockAlignStatementsTransformer.transform(); 120 if(PabloCompiler.addAssertBitBlockAlignStmts) { 121 AssertBitBlockAlignStmtsXFormer assertBitBlockAlignStmtsXFormer = new AssertBitBlockAlignStmtsXFormer(value, builtins2CPP, carrySet2CPP); 122 assertBitBlockAlignStmtsXFormer.XForm(); 122 123 } 123 124 -
proto/pablo/src/compiler/PabloCompilerTestHarness.java
r2657 r2658 36 36 37 37 public enum Test { 38 ADVANCECOMBINER("AdvanceCombiner Transformer", true),38 ADVANCECOMBINER("AdvanceCombinerXFormer", true), 39 39 ADVANCENCOUNTER("AdvanceNCounterVisitor", true), 40 A UGMENTEDASSIGNMENT("AugmentedAssignmentTransformer", true),41 BITWISE2IDISA("Bitwise2IDISA Transformer", true),40 AugASSIGNMENT("AugAssignmentXFormer", true), 41 BITWISE2IDISA("Bitwise2IDISAXFormer", true), 42 42 CARRYCOUNTER("CarryCounterVisitor", true), 43 PABLO2CARRYQCICO("Pablo2CarryQCiCo Transformer", true),44 PABLO2CARRYQCI("Pablo2CarryQCi Transformer", true),43 PABLO2CARRYQCICO("Pablo2CarryQCiCoXFormer", true), 44 PABLO2CARRYQCI("Pablo2CarryQCiXFormer", true), 45 45 CARRYINITTOONELIST("CarryInitToOneListVisitor", true), 46 STREAMFUNCTIONVISITOR("StreamFunctionVisitor", true); 47 //CARRYQINTROTRANSFORMER("",true); // TODO 46 STREAMFuncVISITOR("StreamFuncVisitor", true); 47 //CARRYQINTROXFORMER("",true); // TODO 48 //ASSERTZERO("",true);// TODO 48 49 49 50 private final String directoryName; … … 66 67 public static void main(String[] args) throws FileNotFoundException { 67 68 68 checkArg uments(args, "PabloCompilerTestHarness");69 checkArgs(args, "PabloCompilerTestHarness"); 69 70 Tokens.setPrintLevel(Tokens.Level.FULL); 70 71 File testBase = new File(testDirectoryName); … … 89 90 case ADVANCENCOUNTER: 90 91 break; 91 case A UGMENTEDASSIGNMENT:92 augmentedAssignmentTest(fileAbsolutePath);92 case AugASSIGNMENT: 93 AugAssignmentTest(fileAbsolutePath); 93 94 break; 94 95 case BITWISE2IDISA: … … 105 106 case CARRYINITTOONELIST: 106 107 break; 107 case STREAMF UNCTIONVISITOR:108 case STREAMFuncVISITOR: 108 109 break; 109 110 default: … … 126 127 ASTNode syntaxTree = Parser.parse(lexController); 127 128 128 StreamFunc tionVisitor streamFunctionVisitor = new StreamFunctionVisitor(syntaxTree);129 Map<String, ASTNode> streamFunc tionMap = streamFunctionVisitor.makeStreamFunctionMap();130 131 for (Map.Entry<String, ASTNode> entry : streamFunc tionMap.entrySet()) {132 AdvanceCombiner Transformer advanceCombiner = new AdvanceCombinerTransformer(entry.getValue());133 advanceCombiner. transform();129 StreamFuncVisitor streamFuncVisitor = new StreamFuncVisitor(syntaxTree); 130 Map<String, ASTNode> streamFuncMap = streamFuncVisitor.makeStreamFuncMap(); 131 132 for (Map.Entry<String, ASTNode> entry : streamFuncMap.entrySet()) { 133 AdvanceCombinerXFormer advanceCombiner = new AdvanceCombinerXFormer(entry.getValue()); 134 advanceCombiner.XForm(); 134 135 } 135 136 … … 147 148 ASTNode syntaxTree = Parser.parse(lexController); 148 149 149 StreamFunc tionVisitor streamFunctionVisitor = new StreamFunctionVisitor(syntaxTree);150 Map<String, ASTNode> streamFunc tionMap = streamFunctionVisitor.makeStreamFunctionMap();151 152 for (Map.Entry<String, ASTNode> entry : streamFunc tionMap.entrySet()) {153 Bitwise2IDISA Transformer bitwiseToIDISA = new Bitwise2IDISATransformer(entry.getValue());154 bitwiseToIDISA. transform();150 StreamFuncVisitor streamFuncVisitor = new StreamFuncVisitor(syntaxTree); 151 Map<String, ASTNode> streamFuncMap = streamFuncVisitor.makeStreamFuncMap(); 152 153 for (Map.Entry<String, ASTNode> entry : streamFuncMap.entrySet()) { 154 Bitwise2IDISAXFormer bitwiseToIDISA = new Bitwise2IDISAXFormer(entry.getValue()); 155 bitwiseToIDISA.XForm(); 155 156 } 156 157 … … 164 165 * @throws FileNotFoundException 165 166 */ 166 public static void augmentedAssignmentTest(String fileAbsolutePath) throws FileNotFoundException {167 public static void AugAssignmentTest(String fileAbsolutePath) throws FileNotFoundException { 167 168 168 169 LexicalController lexController = LexicalController.make(fileAbsolutePath); 169 170 ASTNode syntaxTree = Parser.parse(lexController); 170 171 171 StreamFunc tionVisitor streamFunctionVisitor = new StreamFunctionVisitor(syntaxTree);172 Map<String, ASTNode> streamFunc tionMap = streamFunctionVisitor.makeStreamFunctionMap();173 174 for (Map.Entry<String, ASTNode> entry : streamFunc tionMap.entrySet()) {175 Aug mentedAssignmentTransformer augmentedAssignment = new AugmentedAssignmentTransformer(entry.getValue());176 augmentedAssignment.transform();172 StreamFuncVisitor streamFuncVisitor = new StreamFuncVisitor(syntaxTree); 173 Map<String, ASTNode> streamFuncMap = streamFuncVisitor.makeStreamFuncMap(); 174 175 for (Map.Entry<String, ASTNode> entry : streamFuncMap.entrySet()) { 176 AugAssignmentXFormer AugAssignment = new AugAssignmentXFormer(entry.getValue()); 177 AugAssignment.XForm(); 177 178 } 178 179 … … 190 191 191 192 192 StreamFunc tionVisitor streamFunctionVisitor = new StreamFunctionVisitor(syntaxTree);193 Map<String, ASTNode> streamFunc tionMap = streamFunctionVisitor.makeStreamFunctionMap();193 StreamFuncVisitor streamFuncVisitor = new StreamFuncVisitor(syntaxTree); 194 Map<String, ASTNode> streamFuncMap = streamFuncVisitor.makeStreamFuncMap(); 194 195 195 196 Builtins2Lang builtins2CPP = new Builtins2CPP(); 196 197 197 for (Map.Entry<String, ASTNode> entry : streamFunc tionMap.entrySet()) {198 for (Map.Entry<String, ASTNode> entry : streamFuncMap.entrySet()) { 198 199 ASTNode value = entry.getValue(); 199 200 CarrySet2Lang carrySet2CPP = new CarrySet2CPP(); 200 Pablo2Carry Transformer pablo2CarryQ = new Pablo2CarryTransformer(value, builtins2CPP, carrySet2CPP);201 pablo2CarryQ. transform(ciMode, coMode);201 Pablo2CarryXFormer pablo2CarryQ = new Pablo2CarryXFormer(value, builtins2CPP, carrySet2CPP); 202 pablo2CarryQ.XForm(ciMode, coMode); 202 203 203 204 } … … 246 247 } 247 248 248 protected static void checkArg uments(String[] args, String applicationName) {249 protected static void checkArgs(String[] args, String applicationName) { 249 250 int length = args.length; 250 251 boolean inputDirectoryFound = false; -
proto/pablo/src/compiler/ReadMe.txt
r2657 r2658 54 54 (c) Code generation phases. Dependent on the target language and hardware. 55 55 56 (d) Name Visitors SomeNameVisitor, InnerSomeNameVisitor; and Name SomeName Transformer, InnerSomeNameTransformer.56 (d) Name Visitors SomeNameVisitor, InnerSomeNameVisitor; and Name SomeNameXFormer, InnerSomeNameXFormer. 57 57 58 58 Work in progress. 59 59 60 3. Visitor dependency. Tree transformation, e.g. carry counter depends on60 3. Visitor dependency. Tree XFormation, e.g. carry counter depends on 61 61 'Advance(x)' function name and argument count. 62 62 … … 80 80 Done. 81 81 82 5. Verify function call expressions versus function call statements. Go over code82 5. Verify function call expressions versus function call Stmts. Go over code 83 83 generation scheme. 84 84 -
proto/pablo/src/compiler/ast/Accessors.java
r2641 r2658 35 35 36 36 //////////////////////////////////////////////////////////////////////////// 37 // Assignment St atements37 // Assignment Stmts 38 38 //////////////////////////////////////////////////////////////////////////// 39 39 public static ASTNode lhs(AssignmentNode node) { … … 50 50 51 51 //////////////////////////////////////////////////////////////////////////// 52 // Func tion Invocation Statements52 // Func Invocation Stmts 53 53 //////////////////////////////////////////////////////////////////////////// 54 54 55 public static String assignmentOperator(Func tionInvocationNode node) {56 return node.getToken().getLexeme(); 57 } 58 59 //////////////////////////////////////////////////////////////////////////// 60 // Local Variable Declaration St atements55 public static String assignmentOperator(FuncCallNode node) { 56 return node.getToken().getLexeme(); 57 } 58 59 //////////////////////////////////////////////////////////////////////////// 60 // Local Variable Declaration Stmts 61 61 //////////////////////////////////////////////////////////////////////////// 62 62 … … 123 123 124 124 //////////////////////////////////////////////////////////////////////////// 125 // IfSt atementNode helpers125 // IfStmtNode helpers 126 126 //////////////////////////////////////////////////////////////////////////// 127 public static ASTNode ifTest(IfSt atementNode node) {127 public static ASTNode ifTest(IfStmtNode node) { 128 128 return (ASTNode) node.child(0); 129 129 } 130 130 131 public static BlockSt atementNode ifBlockStatement(IfStatementNode node) {132 return (BlockSt atementNode) node.child(1);133 } 134 135 public static boolean hasElseBlockSt atement(IfStatementNode node) {131 public static BlockStmtNode ifBlockStmt(IfStmtNode node) { 132 return (BlockStmtNode) node.child(1); 133 } 134 135 public static boolean hasElseBlockStmt(IfStmtNode node) { 136 136 return node.nChildren() > 2; 137 137 } 138 138 139 public static BlockSt atementNode elseBlockStatement(IfStatementNode node) {140 return (BlockSt atementNode) node.child(2);141 } 142 143 //////////////////////////////////////////////////////////////////////////// 144 // WhileSt atementNode helpers139 public static BlockStmtNode elseBlockStmt(IfStmtNode node) { 140 return (BlockStmtNode) node.child(2); 141 } 142 143 //////////////////////////////////////////////////////////////////////////// 144 // WhileStmtNode helpers 145 145 //////////////////////////////////////////////////////////////////////////// 146 public static ASTNode whileCondition(WhileSt atementNode node) {147 return node.child(0); 148 } 149 150 //////////////////////////////////////////////////////////////////////////// 151 // Func tionDefinitionNode helpers152 //////////////////////////////////////////////////////////////////////////// 153 public static IdentifierNode functionName(FunctionDefNode node) {146 public static ASTNode whileCondition(WhileStmtNode node) { 147 return node.child(0); 148 } 149 150 //////////////////////////////////////////////////////////////////////////// 151 // FuncDefinitionNode helpers 152 //////////////////////////////////////////////////////////////////////////// 153 public static IdentifierNode FuncName(FuncDefNode node) { 154 154 return (IdentifierNode) node.child(1); 155 155 } 156 156 157 public static boolean hasParameters(Func tionDefNode node) {157 public static boolean hasParameters(FuncDefNode node) { 158 158 ASTNode child2 = node.child(2); 159 159 … … 164 164 } 165 165 166 public static BlockSt atementNode blockStatementNode(FunctionDefNode node) {167 int blockSt atementNodeIndex;166 public static BlockStmtNode blockStmtNode(FuncDefNode node) { 167 int blockStmtNodeIndex; 168 168 169 169 if(Accessors.hasParameters(node)) { 170 blockSt atementNodeIndex = 3;170 blockStmtNodeIndex = 3; 171 171 } else { 172 blockSt atementNodeIndex = 2;173 } 174 175 ASTNode child = node.child(blockSt atementNodeIndex);176 assert child instanceof BlockSt atementNode;177 return (BlockSt atementNode) child;178 } 179 180 //////////////////////////////////////////////////////////////////////////// 181 // WhileSt atement helpers182 //////////////////////////////////////////////////////////////////////////// 183 public static ASTNode whileTest(WhileSt atementNode node) {184 return node.child(0); 185 } 186 187 //////////////////////////////////////////////////////////////////////////// 188 // Func tionInvocationNode helpers189 //////////////////////////////////////////////////////////////////////////// 190 public static ASTNode functionInvocationName(FunctionInvocationNode node) {191 return node.child(0); 192 } 193 194 public static ASTNode functionInvocationArgumentsListNode(FunctionInvocationNode node) {172 blockStmtNodeIndex = 2; 173 } 174 175 ASTNode child = node.child(blockStmtNodeIndex); 176 assert child instanceof BlockStmtNode; 177 return (BlockStmtNode) child; 178 } 179 180 //////////////////////////////////////////////////////////////////////////// 181 // WhileStmt helpers 182 //////////////////////////////////////////////////////////////////////////// 183 public static ASTNode whileTest(WhileStmtNode node) { 184 return node.child(0); 185 } 186 187 //////////////////////////////////////////////////////////////////////////// 188 // FuncCallNode helpers 189 //////////////////////////////////////////////////////////////////////////// 190 public static ASTNode FuncCallName(FuncCallNode node) { 191 return node.child(0); 192 } 193 194 public static ASTNode FuncCallArgsListNode(FuncCallNode node) { 195 195 return node.child(1); 196 196 } 197 197 198 public static int functionInvocationArgumentCount(FunctionInvocationNode node) {199 ASTNode argList = Accessors. functionInvocationArgumentsListNode(node);198 public static int FuncCallArgCount(FuncCallNode node) { 199 ASTNode argList = Accessors.FuncCallArgsListNode(node); 200 200 if (argList == null) { 201 201 return 0; … … 204 204 } 205 205 206 public static ASTNode functionInvocationArgument(FunctionInvocationNode node, int index) { 207 208 if((index + 1) > Accessors.functionInvocationArgumentsList(node).getChildren().size()) { 209 throw new RuntimeException("Function invocation argument out of range."); 210 } 211 return Accessors.functionInvocationArgumentsList(node).child(index); 212 } 213 214 public static List<ASTNode> functionInvocationArgList(FunctionInvocationNode node) { 215 return Accessors.functionInvocationArgumentsList(node).getChildren(); 216 } 217 218 public static ASTNode functionInvocationArgumentsList(FunctionInvocationNode node) { 219 return node.child(1); 220 } 221 222 public static String functionInvocationName(ASTNode node) { 206 public static ASTNode FuncCallArg(FuncCallNode node, int index) { 207 208 if((index + 1) > Accessors.FuncCallArgsListNode(node).getChildren().size()) { 209 throw new RuntimeException("Func invocation Arg out of range."); 210 } 211 return Accessors.FuncCallArgsListNode(node).child(index); 212 } 213 214 public static List<ASTNode> FuncCallArgsList(FuncCallNode node) { 215 return Accessors.FuncCallArgsListNode(node).getChildren(); 216 } 217 218 public static String FuncCallName(ASTNode node) { 223 219 String name = new String(); 224 220 if(node instanceof IdentifierNode) { -
proto/pablo/src/compiler/ast/Generators.java
r2621 r2658 19 19 // Static factories for various nodes 20 20 // 21 // TODO - refactor makeFunctionInvocationNode code 22 //////////////////////////////////////////////////////////////////////////// 23 24 /** Makes a new FunctionInvocationNode with a function identifier string and the TextLocation taken from token. 21 //////////////////////////////////////////////////////////////////////////// 22 23 /** Makes a new FuncCallNode with a Func identifier string and the TextLocation taken from token. 25 24 * @param identifier 26 25 * @param locationToken 27 * @return Func tionInvocationNode28 */ 29 public static Func tionInvocationNode makeFunctionInvocationNode(String identifier, Token locationToken) {26 * @return FuncCallNode 27 */ 28 public static FuncCallNode makeFuncCallNode(String identifier, Token locationToken) { 30 29 IdentifierNode identifierNode = Generators.makeIdentifierNode(identifier, locationToken); 31 return Generators.makeFunc tionInvocationNode(identifierNode, locationToken);32 } 33 34 /** Makes a new compound Func tionInvocationNode with a array of identifiers string and the TextLocation taken from token.30 return Generators.makeFuncCallNode(identifierNode, locationToken); 31 } 32 33 /** Makes a new compound FuncCallNode with a array of identifiers string and the TextLocation taken from token. 35 34 * @param identifiers - a compound identifier a.b() 36 35 * @param locationToken 37 36 * @return 38 37 */ 39 public static Func tionInvocationNode makeFunctionInvocationNode(String[] identifiers, Token locationToken) {38 public static FuncCallNode makeFuncCallNode(String[] identifiers, Token locationToken) { 40 39 41 40 CompoundVariableNode identifierNode = Generators.makeCompoundVariableNode(identifiers, locationToken); 42 return Generators.makeFunc tionInvocationNode(identifierNode, locationToken);43 } 44 45 public static Func tionInvocationNode makeFunctionInvocationNode(String identifier, Token locationToken, ASTNode[] arguments) {46 47 Func tionInvocationNode node = Generators.makeFunctionInvocationNode(identifier, locationToken);48 Generators.addFunc tionInvocationArguments(node, arguments);49 return node; 50 } 51 52 public static Func tionInvocationNode makeFunctionInvocationNode(String identifier, Token locationToken, List<ASTNode> arguments) {53 54 Func tionInvocationNode node = Generators.makeFunctionInvocationNode(identifier, locationToken);55 Generators.addFunc tionInvocationsArguments(node, arguments);56 return node; 57 } 58 59 private static void addFunc tionInvocationArguments(FunctionInvocationNode node, ASTNode[] arguments) {60 if( arguments.length > 0) {61 for(ASTNode child: arguments) {62 Accessors. functionInvocationArgumentsListNode(node).appendChild(child);41 return Generators.makeFuncCallNode(identifierNode, locationToken); 42 } 43 44 public static FuncCallNode makeFuncCallNode(String identifier, Token locationToken, ASTNode[] Args) { 45 46 FuncCallNode node = Generators.makeFuncCallNode(identifier, locationToken); 47 Generators.addFuncCallArgs(node, Args); 48 return node; 49 } 50 51 public static FuncCallNode makeFuncCallNode(String identifier, Token locationToken, List<ASTNode> Args) { 52 53 FuncCallNode node = Generators.makeFuncCallNode(identifier, locationToken); 54 Generators.addFuncCallsArgs(node, Args); 55 return node; 56 } 57 58 private static void addFuncCallArgs(FuncCallNode node, ASTNode[] Args) { 59 if(Args.length > 0) { 60 for(ASTNode child: Args) { 61 Accessors.FuncCallArgsListNode(node).appendChild(child); 63 62 } 64 Accessors. functionInvocationArgumentsListNode(node).setToken(arguments[0].getToken());63 Accessors.FuncCallArgsListNode(node).setToken(Args[0].getToken()); 65 64 } 66 65 } 67 66 68 public static Func tionInvocationNode makeFunctionInvocationNode(String[] identifiers, Token locationToken, ASTNode[] arguments) {69 70 Func tionInvocationNode node = Generators.makeFunctionInvocationNode(identifiers, locationToken);67 public static FuncCallNode makeFuncCallNode(String[] identifiers, Token locationToken, ASTNode[] Args) { 68 69 FuncCallNode node = Generators.makeFuncCallNode(identifiers, locationToken); 71 70 List<ASTNode> list = new ArrayList<ASTNode>(); 72 for(ASTNode arg: arguments) {71 for(ASTNode arg: Args) { 73 72 list.add(arg); 74 73 } 75 Generators.addFunc tionInvocationsArguments(node, list);76 return node; 77 } 78 79 public static Func tionInvocationNode makeFunctionInvocationNode(String[] identifiers, Token locationToken, List<ASTNode> arguments) {80 81 Func tionInvocationNode node = Generators.makeFunctionInvocationNode(identifiers, locationToken);82 Generators.addFunc tionInvocationsArguments(node, arguments);83 return node; 84 } 85 86 private static void addFunc tionInvocationsArguments(FunctionInvocationNode node, List<ASTNode> arguments) {87 88 if( arguments.size() > 0) {89 for(ASTNode child: arguments) {90 Accessors. functionInvocationArgumentsListNode(node).appendChild(child);74 Generators.addFuncCallsArgs(node, list); 75 return node; 76 } 77 78 public static FuncCallNode makeFuncCallNode(String[] identifiers, Token locationToken, List<ASTNode> Args) { 79 80 FuncCallNode node = Generators.makeFuncCallNode(identifiers, locationToken); 81 Generators.addFuncCallsArgs(node, Args); 82 return node; 83 } 84 85 private static void addFuncCallsArgs(FuncCallNode node, List<ASTNode> Args) { 86 87 if(Args.size() > 0) { 88 for(ASTNode child: Args) { 89 Accessors.FuncCallArgsListNode(node).appendChild(child); 91 90 } 92 Accessors. functionInvocationArgumentsListNode(node).setToken(arguments.get(0).getToken());91 Accessors.FuncCallArgsListNode(node).setToken(Args.get(0).getToken()); 93 92 } 94 93 } 95 94 96 private static Func tionInvocationNode makeFunctionInvocationNode(ASTNode identifier, Token locationToken) {95 private static FuncCallNode makeFuncCallNode(ASTNode identifier, Token locationToken) { 97 96 assert identifier instanceof IdentifierNode || identifier instanceof CompoundVariableNode; 98 97 99 98 LextantToken token = Generators.makeLextantToken(Lextant.LROUND, locationToken); 100 Func tionInvocationNode functionInvocationNode = new FunctionInvocationNode(token);101 functionInvocationNode.appendChild(identifier);102 functionInvocationNode.appendChild(new FunctionInvocationArgumentListNode(locationToken));103 104 return functionInvocationNode;99 FuncCallNode FuncCallNode = new FuncCallNode(token); 100 FuncCallNode.appendChild(identifier); 101 FuncCallNode.appendChild(new FuncCallArgListNode(locationToken)); 102 103 return FuncCallNode; 105 104 } 106 105 … … 199 198 } 200 199 201 public static BlockStatementNode makeBlockStatementNode(Token tokenLocation) { 202 LextantToken token = Generators.makeLextantToken(Lextant.WHILE, tokenLocation); 203 return new BlockStatementNode(token); 200 public static BlockStmtNode makeBlockStmtNode(Token tokenLocation) { 201 LextantToken token = Generators.makeLextantToken(Lextant.LCURLY, tokenLocation); 202 return new BlockStmtNode(token); 203 } 204 205 public static IfStmtNode makeIfStmtNode(Token tokenLocation, ASTNode expression, BlockStmtNode blockStmt) { 206 LextantToken token = Generators.makeLextantToken(Lextant.LCURLY, tokenLocation); 207 IfStmtNode ifStmtNode = new IfStmtNode(token); 208 ifStmtNode.appendChild(expression); 209 ifStmtNode.appendChild((ASTNode)blockStmt); 210 return ifStmtNode; 204 211 } 205 212 } -
proto/pablo/src/compiler/codeGeneration/templates/applications/pablo_dummy.template
r2422 r2658 7 7 @decl 8 8 9 // Stream St atements9 // Stream Stmts 10 10 @stream_stmts 11 11 12 // Block St atements12 // Block Stmts 13 13 @block_stmts 14 14 15 // Final Block St atements15 // Final Block Stmts 16 16 @final_block_stmts 17 17 -
proto/pablo/src/compiler/lang/idisa/BITBLOCK.java
r2657 r2658 10 10 private int argCount; 11 11 12 private BITBLOCK(String functionName, int argCount) {13 this.name = functionName;12 private BITBLOCK(String FuncName, int argCount) { 13 this.name = FuncName; 14 14 this.argCount = argCount; 15 15 } -
proto/pablo/src/compiler/lang/pablo/Builtins.java
r2657 r2658 21 21 ATEOF(Carry.None, "atEOF", 1), 22 22 INFILE(Carry.None, "inFile", 1), 23 ASSERTZERO(Carry.None, "assert_0", 2), 23 24 EOFMASK(Carry.None, "EOF_mask", 0), // deprecated 24 25 -
proto/pablo/src/compiler/lang/pablo/Builtins2CPP.java
r2657 r2658 3 3 import java.util.HashMap; 4 4 import java.util.Map; 5 6 import compiler.lang.pablo.Builtins.Carry; 5 7 6 8 public class Builtins2CPP extends Builtins2Lang { … … 27 29 pablo2CPPCode.put(Builtins.ATEOF, "atEOF"); 28 30 pablo2CPPCode.put(Builtins.INFILE, "inFile"); 31 pablo2CPPCode.put(Builtins.ASSERTZERO, "assert_0_error"); 29 32 pablo2CPPCode.put(Builtins.EOFMASK, "EOF_mask"); 30 33 -
proto/pablo/src/compiler/lang/pablo/BuiltinsUtil.java
r2657 r2658 14 14 } 15 15 16 if (!(node instanceof Func tionInvocationNode)) {16 if (!(node instanceof FuncCallNode)) { 17 17 return false; 18 18 } 19 19 20 Func tionInvocationNode fNode = (FunctionInvocationNode)node;21 ASTNode nameNode = Accessors. functionInvocationName(fNode);22 ASTNode argumentsListNode = (ASTNode)Accessors.functionInvocationArgumentsListNode(fNode);20 FuncCallNode fNode = (FuncCallNode)node; 21 ASTNode nameNode = Accessors.FuncCallName(fNode); 22 ASTNode ArgsListNode = (ASTNode)Accessors.FuncCallArgsListNode(fNode); 23 23 24 24 // Advance(X) 25 25 if (isQualifiedName(nameNode, BuiltinsUtil.BUILTIN_PACKAGE_NAME, Builtins.ADVANCE.pabloName()) 26 && argumentsListNode.nChildren() == 1) {26 && ArgsListNode.nChildren() == 1) { 27 27 return true; 28 28 } … … 30 30 // Advance(X,n) 31 31 if (isQualifiedName(nameNode, BuiltinsUtil.BUILTIN_PACKAGE_NAME, Builtins.ADVANCE.pabloName()) 32 && argumentsListNode.nChildren() == 2) {32 && ArgsListNode.nChildren() == 2) { 33 33 return true; 34 34 } … … 52 52 for (Builtins carryOneOperation : Builtins.carryOneOperations()) { 53 53 54 ASTNode identifier = Accessors. functionInvocationName((FunctionInvocationNode) node);55 int argCount = Accessors. functionInvocationArgumentCount((FunctionInvocationNode)node);54 ASTNode identifier = Accessors.FuncCallName((FuncCallNode) node); 55 int argCount = Accessors.FuncCallArgCount((FuncCallNode)node); 56 56 57 57 if (isQualifiedName(identifier, BuiltinsUtil.BUILTIN_PACKAGE_NAME, carryOneOperation.pabloName()) … … 66 66 67 67 for (Builtins carryNOperation : Builtins.carryNOperations()) { 68 ASTNode identifier = Accessors. functionInvocationName((FunctionInvocationNode) node);69 int argCount = Accessors. functionInvocationArgumentCount((FunctionInvocationNode) node);68 ASTNode identifier = Accessors.FuncCallName((FuncCallNode) node); 69 int argCount = Accessors.FuncCallArgCount((FuncCallNode) node); 70 70 71 71 if (isQualifiedName(identifier, BuiltinsUtil.BUILTIN_PACKAGE_NAME, carryNOperation.pabloName()) … … 80 80 81 81 /** Returns true if the node represents a call to the 82 * given built-in function.82 * given built-in Func. 83 83 * 84 84 * @param node node to be checked 85 * @return whether the node is a call of the function85 * @return whether the node is a call of the Func 86 86 */ 87 87 public static boolean isBuiltInCallNoArgCount(ASTNode node) { 88 if(!(node instanceof Func tionInvocationNode)) {88 if(!(node instanceof FuncCallNode)) { 89 89 return false; 90 90 } 91 91 92 Func tionInvocationNode fNode = (FunctionInvocationNode)node;93 ASTNode nameNode = Accessors. functionInvocationName(fNode);92 FuncCallNode fNode = (FuncCallNode)node; 93 ASTNode nameNode = Accessors.FuncCallName(fNode); 94 94 95 95 for (Builtins builtin : Builtins.values()) { … … 103 103 104 104 /** Returns true if the node represents a call to the 105 * given built-in function with the given number of arguments.105 * given built-in Func with the given number of Args. 106 106 * 107 107 * @param node node to be checked 108 * @return whether the node is a call of the function with argNumToMatch arguments108 * @return whether the node is a call of the Func with argNumToMatch Args 109 109 */ 110 110 public static boolean isBuiltInCall(ASTNode node) { … … 120 120 121 121 /** Returns true if the node represents a call to the 122 * given function with the given number of arguments.122 * given Func with the given number of Args. 123 123 * If node does not have a packageName attached, it is assumed to match the given packageName. 124 124 * 125 125 * @param node node to be checked 126 126 * @param packageName package name that must be matched. 127 * @param functionName name of functionto be matched128 * @param numArgs number of arguments to be matched129 * @return whether the node is a call of the function with argNumToMatch arguments127 * @param FuncName name of Func to be matched 128 * @param numArgs number of Args to be matched 129 * @return whether the node is a call of the Func with argNumToMatch Args 130 130 */ 131 public static boolean isCall(ASTNode node, String packageName, String functionName, int numArgs) {132 if(!(node instanceof Func tionInvocationNode)) {131 public static boolean isCall(ASTNode node, String packageName, String FuncName, int numArgs) { 132 if(!(node instanceof FuncCallNode)) { 133 133 return false; 134 134 } 135 135 136 Func tionInvocationNode fNode = (FunctionInvocationNode)node;137 ASTNode nameNode = Accessors. functionInvocationName(fNode);136 FuncCallNode fNode = (FuncCallNode)node; 137 ASTNode nameNode = Accessors.FuncCallName(fNode); 138 138 139 boolean nameMatches = isQualifiedName(nameNode, packageName, functionName);140 boolean numArgsMatches = Accessors. functionInvocationArgumentsListNode(fNode).nChildren() == numArgs;139 boolean nameMatches = isQualifiedName(nameNode, packageName, FuncName); 140 boolean numArgsMatches = Accessors.FuncCallArgsListNode(fNode).nChildren() == numArgs; 141 141 142 142 return nameMatches && numArgsMatches; 143 143 } 144 144 145 /** Determines if node represents the name of the function described by packageName, functionName.146 * In particular, if node represents a simple (non-qualified) name, then it is compared with functionName.145 /** Determines if node represents the name of the Func described by packageName, FuncName. 146 * In particular, if node represents a simple (non-qualified) name, then it is compared with FuncName. 147 147 * (Essentially, this assumes that the packageName is correct.) 148 * If node represents a compound (qualified) name, then it is compared with 'packageName. functionName'.148 * If node represents a compound (qualified) name, then it is compared with 'packageName.FuncName'. 149 149 * 150 150 * @param node 151 151 * @param packageName 152 * @param functionName153 * @return True if the node matches packageName. functionName.152 * @param FuncName 153 * @return True if the node matches packageName.FuncName. 154 154 */ 155 public static boolean isQualifiedName(ASTNode node, String packageName, String functionName) {155 public static boolean isQualifiedName(ASTNode node, String packageName, String FuncName) { 156 156 if(node instanceof IdentifierNode) { 157 return Accessors.identifierLexeme(node) == functionName;157 return Accessors.identifierLexeme(node) == FuncName; 158 158 } 159 159 else if (node instanceof CompoundVariableNode) { … … 162 162 163 163 return (Accessors.identifierLexeme(pckage) == packageName) && 164 (Accessors.identifierLexeme(member) == functionName);164 (Accessors.identifierLexeme(member) == FuncName); 165 165 } 166 166 return false; -
proto/pablo/src/compiler/test/ASTTest.java
r2621 r2658 12 12 } 13 13 14 public void compareFunc tionInvocationNodes() {15 ASTFunc tionInvocationTestVisitor visitor = new ASTFunctionInvocationTestVisitor();14 public void compareFuncCallNodes() { 15 ASTFuncCallTestVisitor visitor = new ASTFuncCallTestVisitor(); 16 16 ASTTree.accept(visitor); 17 17 visitor.assertComplete(); … … 50 50 } 51 51 52 private class ASTFunc tionInvocationTestVisitor extends ASTTestVisitor {52 private class ASTFuncCallTestVisitor extends ASTTestVisitor { 53 53 54 ASTFunc tionInvocationTestVisitor() {54 ASTFuncCallTestVisitor() { 55 55 super(); 56 56 } 57 57 58 public void visitEnter(Func tionInvocationNode node) {58 public void visitEnter(FuncCallNode node) { 59 59 60 60 if(this.ASTTree1 == null) { -
proto/pablo/src/compiler/visitors/AdvanceCombinerXFormer.java
r2657 r2658 9 9 import ast.*; 10 10 11 public class AdvanceCombiner Transformer {11 public class AdvanceCombinerXFormer { 12 12 13 13 private ASTNode ASTTree; 14 14 15 public AdvanceCombiner Transformer(ASTNode astTree) {15 public AdvanceCombinerXFormer(ASTNode astTree) { 16 16 this.ASTTree = astTree; 17 17 } 18 18 19 public void transform() {19 public void XForm() { 20 20 AdvanceCombinerVisitor visitor = new AdvanceCombinerVisitor(); 21 21 ASTTree.accept(visitor); … … 32 32 private class AdvanceCombinerVisitor extends VoidVisitor.Default { 33 33 34 public void visitEnter(IfSt atementNode node) {35 // Additional carry logic req'd to support carry combine within If statements34 public void visitEnter(IfStmtNode node) { 35 // Additional carry logic req'd to support carry combine within If Stmts 36 36 node.skipChildren(); 37 37 } 38 public void visitEnter(WhileSt atementNode node) {39 // Additional carry logic req'd to support carry combine within While statements38 public void visitEnter(WhileStmtNode node) { 39 // Additional carry logic req'd to support carry combine within While Stmts 40 40 node.skipChildren(); 41 41 } 42 42 43 public void visitLeave(Func tionInvocationNode node) {43 public void visitLeave(FuncCallNode node) { 44 44 45 45 if(!isAdvanceOfAdvance(node)) { … … 47 47 } 48 48 49 ASTNode argumentsList = Accessors.functionInvocationArgumentsList((FunctionInvocationNode) node);50 Func tionInvocationNode child = (FunctionInvocationNode)argumentsList.child(0);49 ASTNode ArgsList = Accessors.FuncCallArgsListNode((FuncCallNode) node); 50 FuncCallNode child = (FuncCallNode)ArgsList.child(0); 51 51 52 52 int amount1 = advanceAmount(node); … … 63 63 } 64 64 65 private int advanceAmount(Func tionInvocationNode node) {65 private int advanceAmount(FuncCallNode node) { 66 66 assert BuiltinsUtil.isAdvance(node); 67 if(Accessors. functionInvocationArgumentsList(node).nChildren()==1) {67 if(Accessors.FuncCallArgsListNode(node).nChildren()==1) { 68 68 return 1; 69 69 } 70 assert Accessors. functionInvocationArgumentsList(node).nChildren()==2;71 return valueOf(Accessors. functionInvocationArgumentsList(node).child(1));70 assert Accessors.FuncCallArgsListNode(node).nChildren()==2; 71 return valueOf(Accessors.FuncCallArgsListNode(node).child(1)); 72 72 } 73 73 … … 77 77 } 78 78 79 ASTNode argumentsList = Accessors.functionInvocationArgumentsList((FunctionInvocationNode) node);79 ASTNode ArgsList = Accessors.FuncCallArgsListNode((FuncCallNode) node); 80 80 81 return BuiltinsUtil.isAdvance( argumentsList.child(0));81 return BuiltinsUtil.isAdvance(ArgsList.child(0)); 82 82 } 83 83 84 84 private void translateAdvanceNode( 85 Func tionInvocationNode node,86 Func tionInvocationNode child,85 FuncCallNode node, 86 FuncCallNode child, 87 87 int amount1, int amount2) { 88 88 89 node.replaceChild( Accessors. functionInvocationArgumentsList(node),90 Accessors. functionInvocationArgumentsList(child));89 node.replaceChild( Accessors.FuncCallArgsListNode(node), 90 Accessors.FuncCallArgsListNode(child)); 91 91 92 92 IntegerConstantNode integerConstantNode = Generators.makeIntegerConstantNode(amount1+amount2, node.getToken()); 93 if(Accessors. functionInvocationArgumentsList(node).nChildren()==1) {94 Accessors. functionInvocationArgumentsList(child).appendChild(integerConstantNode);93 if(Accessors.FuncCallArgsListNode(node).nChildren()==1) { 94 Accessors.FuncCallArgsListNode(child).appendChild(integerConstantNode); 95 95 } 96 assert Accessors. functionInvocationArgumentsList(node).nChildren()==2;97 Accessors. functionInvocationArgumentsList(node).replaceChild(98 Accessors. functionInvocationArgumentsList(node).child(1),96 assert Accessors.FuncCallArgsListNode(node).nChildren()==2; 97 Accessors.FuncCallArgsListNode(node).replaceChild( 98 Accessors.FuncCallArgsListNode(node).child(1), 99 99 integerConstantNode); 100 100 } -
proto/pablo/src/compiler/visitors/AdvanceNCounterVisitor.java
r2657 r2658 24 24 } 25 25 26 public void visitLeave(Func tionInvocationNode node) {26 public void visitLeave(FuncCallNode node) { 27 27 if(BuiltinsUtil.isCarryN(node)) { 28 28 this.advNCount += 1; -
proto/pablo/src/compiler/visitors/AssertBitBlockAlignStmtsXFormer.java
r2657 r2658 8 8 import compiler.lang.carry.CarrySet2Lang; 9 9 10 public class AssertBitBlockAlignSt atementsTransformer {10 public class AssertBitBlockAlignStmtsXFormer { 11 11 private ASTNode ASTree; 12 12 … … 14 14 private CarrySet2Lang carrySet2Lang; 15 15 16 public AssertBitBlockAlignSt atementsTransformer(ASTNode ASTree, Builtins2Lang builtins2Lang, CarrySet2Lang carrySet2Lang) {16 public AssertBitBlockAlignStmtsXFormer(ASTNode ASTree, Builtins2Lang builtins2Lang, CarrySet2Lang carrySet2Lang) { 17 17 this.ASTree = ASTree; 18 18 this.builtins2Lang = builtins2Lang; … … 20 20 } 21 21 22 public ASTNode transform() {23 Transformer transformer = new Transformer();24 ASTree.accept( transformer);22 public ASTNode XForm() { 23 XFormer XFormer = new XFormer(); 24 ASTree.accept(XFormer); 25 25 return ASTree; 26 26 } 27 27 28 private class Transformer extends VoidVisitor.Default {28 private class XFormer extends VoidVisitor.Default { 29 29 30 public Transformer () {}30 public XFormer () {} 31 31 32 32 public void visitEnter(LocalVarDeclNode node) { 33 addDumpSt atement(node, Accessors.lhs(node));33 addDumpStmt(node, Accessors.lhs(node)); 34 34 } 35 35 36 36 public void visitEnter(AssignmentNode node) { 37 addDumpSt atement(node, Accessors.lhs(node));37 addDumpStmt(node, Accessors.lhs(node)); 38 38 } 39 39 40 private void addDumpSt atement(ASTNode node, ASTNode lhs) {41 Func tionInvocationNode printRegisterStatement =42 Generators.makeFunc tionInvocationNode( builtins2Lang.getCode(Builtins.ASSERTBITBLOCKALIGN),40 private void addDumpStmt(ASTNode node, ASTNode lhs) { 41 FuncCallNode printRegisterStmt = 42 Generators.makeFuncCallNode( builtins2Lang.getCode(Builtins.ASSERTBITBLOCKALIGN), 43 43 node.getToken(), 44 44 new ASTNode [] {lhs}); 45 45 46 (node.getParent()).insertAfterChild(node, printRegisterSt atement);46 (node.getParent()).insertAfterChild(node, printRegisterStmt); 47 47 } 48 48 } -
proto/pablo/src/compiler/visitors/AugAssignmentXFormer.java
r2644 r2658 11 11 import tokens.*; 12 12 13 public class Aug mentedAssignmentTransformer {13 public class AugAssignmentXFormer { 14 14 15 private static Map<Lextant, Lextant> augmentedAssignmentMap = new HashMap<Lextant, Lextant>();15 private static Map<Lextant, Lextant> AugAssignmentMap = new HashMap<Lextant, Lextant>(); 16 16 17 17 static { 18 augmentedAssignmentMap.put(Lextant.AND_ASSIGN, Lextant.AND);19 augmentedAssignmentMap.put(Lextant.OR_ASSIGN, Lextant.OR);20 augmentedAssignmentMap.put(Lextant.XOR_ASSIGN, Lextant.XOR);21 // augmentedAssignmentMap.put(Lextant.NOT_ASSIGN, Lextant.NOT);18 AugAssignmentMap.put(Lextant.AND_ASSIGN, Lextant.AND); 19 AugAssignmentMap.put(Lextant.OR_ASSIGN, Lextant.OR); 20 AugAssignmentMap.put(Lextant.XOR_ASSIGN, Lextant.XOR); 21 //AugAssignmentMap.put(Lextant.NOT_ASSIGN, Lextant.NOT); 22 22 }; 23 23 24 24 private ASTNode ASTree; 25 25 26 public Aug mentedAssignmentTransformer(ASTNode ASTree) {26 public AugAssignmentXFormer(ASTNode ASTree) { 27 27 this.ASTree = ASTree; 28 28 } 29 29 30 public void transform() {31 VoidVisitor visitor = new Aug mentedAssignmentRemovalVisitor();30 public void XForm() { 31 VoidVisitor visitor = new AugAssignmentRemovalVisitor(); 32 32 ASTree.accept(visitor); 33 33 } 34 34 35 private class Aug mentedAssignmentRemovalVisitor extends VoidVisitor.Default {35 private class AugAssignmentRemovalVisitor extends VoidVisitor.Default { 36 36 37 37 public void visitLeave(AssignmentNode node) { 38 transformAugmentedAssignment(node, Accessors.lhs(node), Accessors.rhs(node));38 XFormAugAssignment(node, Accessors.lhs(node), Accessors.rhs(node)); 39 39 } 40 40 41 41 public void visitLeave(LocalVarDeclNode node) { 42 42 if(Accessors.hasInitializationAssignment(node)) { 43 transformAugmentedAssignment(node, Accessors.lhs(node), Accessors.rhs(node));43 XFormAugAssignment(node, Accessors.lhs(node), Accessors.rhs(node)); 44 44 } 45 45 } 46 46 47 private void transformAugmentedAssignment(ASTNode node, ASTNode lhs, ASTNode rhs) {48 if(isAug mentedAssignmentLextant(node.getToken())) {47 private void XFormAugAssignment(ASTNode node, ASTNode lhs, ASTNode rhs) { 48 if(isAugAssignmentLextant(node.getToken())) { 49 49 50 50 // TODO: bug here, simply use node.child(0) as lhs may fail if side effect exists. … … 66 66 } 67 67 68 private boolean isAug mentedAssignmentLextant(Token token) {69 for (Lextant key : augmentedAssignmentMap.keySet()) {68 private boolean isAugAssignmentLextant(Token token) { 69 for (Lextant key : AugAssignmentMap.keySet()) { 70 70 if (token.isLextant(key)) { 71 71 return true; … … 76 76 77 77 private Lextant getMappedLextant(Token token) { 78 for (Lextant key : augmentedAssignmentMap.keySet()) {78 for (Lextant key : AugAssignmentMap.keySet()) { 79 79 if (token.isLextant(key)) { 80 return augmentedAssignmentMap.get(key);80 return AugAssignmentMap.get(key); 81 81 } 82 82 } -
proto/pablo/src/compiler/visitors/Bitwise2IDISAXFormer.java
r2657 r2658 8 8 import compiler.lang.idisa.*; 9 9 10 public class Bitwise2IDISA Transformer {10 public class Bitwise2IDISAXFormer { 11 11 private ASTNode ASTree; 12 12 13 public Bitwise2IDISA Transformer(ASTNode ASTree) {13 public Bitwise2IDISAXFormer(ASTNode ASTree) { 14 14 this.ASTree = ASTree; 15 15 } 16 16 17 public ASTNode transform() {17 public ASTNode XForm() { 18 18 Bitwise2IDISAVisitor visitor = new Bitwise2IDISAVisitor(); 19 19 ASTree.accept(visitor); … … 26 26 if(op.isLextant(Lextant.NOT)) { 27 27 28 Func tionInvocationNode functionInvocationNode =29 Generators.makeFunc tionInvocationNode(SIMD.NOT.idisaName(),28 FuncCallNode FuncCallNode = 29 Generators.makeFuncCallNode(SIMD.NOT.idisaName(), 30 30 op, 31 31 new ASTNode [] {Accessors.operand(node)}); 32 node.updateSelf( functionInvocationNode);32 node.updateSelf(FuncCallNode); 33 33 } 34 34 } … … 37 37 Token op = node.getToken(); 38 38 if(op.isLextant(Lextant.AND, Lextant.OR, Lextant.XOR)) { 39 String functionName;39 String FuncName; 40 40 if(op.isLextant(Lextant.AND)) { 41 functionName = SIMD.AND.idisaName();41 FuncName = SIMD.AND.idisaName(); 42 42 } else if(op.isLextant(Lextant.OR)) { 43 functionName = SIMD.OR.idisaName();43 FuncName = SIMD.OR.idisaName(); 44 44 } else { 45 functionName = SIMD.XOR.idisaName();45 FuncName = SIMD.XOR.idisaName(); 46 46 } 47 47 48 Func tionInvocationNode functionInvocationNode =49 Generators.makeFunc tionInvocationNode(functionName,48 FuncCallNode FuncCallNode = 49 Generators.makeFuncCallNode(FuncName, 50 50 op, 51 51 new ASTNode [] {Accessors.leftOperand(node), Accessors.rightOperand(node)}); 52 node.updateSelf( functionInvocationNode);52 node.updateSelf(FuncCallNode); 53 53 } 54 54 } … … 67 67 68 68 name = SIMD.CONSTANT.idisaConstantName(fieldWidth, constant); 69 Func tionInvocationNode functionInvocationNode = Generators.makeFunctionInvocationNode(name, node.getToken());70 node.updateSelf( functionInvocationNode);69 FuncCallNode FuncCallNode = Generators.makeFuncCallNode(name, node.getToken()); 70 node.updateSelf(FuncCallNode); 71 71 } 72 72 } … … 95 95 96 96 String name = SIMD.CONSTANT.idisaConstantName(fieldWidth, constant); 97 Func tionInvocationNode functionInvocationNode = Generators.makeFunctionInvocationNode(name, node.getToken());98 rhs.updateSelf( functionInvocationNode);97 FuncCallNode FuncCallNode = Generators.makeFuncCallNode(name, node.getToken()); 98 rhs.updateSelf(FuncCallNode); 99 99 } 100 100 } … … 107 107 // ifNode.test = makeCall('bitblock::any', [ifNode.test]) 108 108 // return ifNode 109 public void visitLeave(IfSt atementNode node) {109 public void visitLeave(IfStmtNode node) { 110 110 ASTNode ifTest = Accessors.ifTest(node); 111 String functionName = BITBLOCK.ANY.IDISAName();112 Func tionInvocationNode functionInvocationNode = Generators.makeFunctionInvocationNode(functionName,111 String FuncName = BITBLOCK.ANY.IDISAName(); 112 FuncCallNode FuncCallNode = Generators.makeFuncCallNode(FuncName, 113 113 node.getToken(), 114 114 new ASTNode [] {ifTest}); 115 node.replaceChild(ifTest, functionInvocationNode);115 node.replaceChild(ifTest, FuncCallNode); 116 116 } 117 117 … … 120 120 // whileNode.test = makeCall('bitblock::any', [whileNode.test]) 121 121 // return whileNode 122 public void visitLeave(WhileStatementNode node) { 123 ASTNode whileTest = Accessors.whileCondition(node); 124 String functionName = BITBLOCK.ANY.IDISAName(); 125 122 public void visitLeave(WhileStmtNode node) { 123 ASTNode whileTest = Accessors.whileCondition(node); 126 124 127 FunctionInvocationNode functionInvocationNode = Generators.makeFunctionInvocationNode(functionName, 125 FuncCallNode FuncCallNode = Generators.makeFuncCallNode( 126 BITBLOCK.ANY.IDISAName(), 128 127 node.getToken(), 129 128 new ASTNode [] {whileTest}); 130 129 131 node.replaceChild(whileTest, functionInvocationNode);130 node.replaceChild(whileTest, FuncCallNode); 132 131 } 133 132 } -
proto/pablo/src/compiler/visitors/CPPUnparser.java
r2657 r2658 76 76 77 77 //////////////////////////////////////////////////////////////////////////// 78 // Stream Func tions79 //////////////////////////////////////////////////////////////////////////// 80 public CodeStore visitLeave(Func tionDefNode node, List<CodeStore> childResults) {78 // Stream Funcs 79 //////////////////////////////////////////////////////////////////////////// 80 public CodeStore visitLeave(FuncDefNode node, List<CodeStore> childResults) { 81 81 CodeStore code = new CodeStore(); 82 82 83 83 CodeStore returnType = childResults.get(0); 84 CodeStore functionName = childResults.get(1);85 CodeStore blockSt atement;84 CodeStore FuncName = childResults.get(1); 85 CodeStore blockStmt; 86 86 87 87 String parameters = new String(); 88 88 if(Accessors.hasParameters(node)) { 89 89 parameters = childResults.get(2).getResultVariableName(); 90 blockSt atement = childResults.get(3);90 blockStmt = childResults.get(3); 91 91 } else { 92 blockSt atement = childResults.get(2);92 blockStmt = childResults.get(2); 93 93 } 94 94 95 95 code.addFormattedLine("%s %s(%s)", 96 96 returnType.getResultVariableName(), 97 functionName.getResultVariableName(),97 FuncName.getResultVariableName(), 98 98 parameters); 99 99 100 100 code.addLine("{"); 101 code.addAll(blockSt atement, 1);101 code.addAll(blockStmt, 1); 102 102 code.dedentedLine("}"); 103 103 return code; … … 117 117 String type = childResults.get(0).getResultVariableName(); 118 118 String identifier = childResults.get(1).getResultVariableName(); 119 code.setResultVariableName(type + " " + identifier);120 121 return code; 122 } 123 124 //////////////////////////////////////////////////////////////////////////// 125 // St atements119 code.setResultVariableName(type + " & " + identifier); 120 121 return code; 122 } 123 124 //////////////////////////////////////////////////////////////////////////// 125 // Stmts 126 126 //////////////////////////////////////////////////////////////////////////// 127 127 128 // assignment statement128 // assignment Stmt 129 129 public CodeStore visitLeave(AssignmentNode node, List<CodeStore> childResults) { 130 130 CodeStore code = new CodeStore(); … … 138 138 } 139 139 140 // functioninvocation140 // Func invocation 141 141 // 142 142 // TODO - Verify correctness, both returns variable and code line. 143 143 // 144 public CodeStore visitLeave(Func tionInvocationNode node, List<CodeStore> childResults) {144 public CodeStore visitLeave(FuncCallNode node, List<CodeStore> childResults) { 145 145 CodeStore code = new CodeStore(); 146 146 … … 152 152 resultVariable.append(")"); 153 153 154 code.setResultVariableName(resultVariable.toString()); // functioninvocation as an expression155 156 code.addFormattedLine("%s;", resultVariable.toString()); // function invocation as a statement157 158 return code; 159 } 160 161 public CodeStore visitLeave(Func tionInvocationArgumentListNode node, List<CodeStore> childResults) {154 code.setResultVariableName(resultVariable.toString()); // Func invocation as an expression 155 156 code.addFormattedLine("%s;", resultVariable.toString()); // Func invocation as a Stmt 157 158 return code; 159 } 160 161 public CodeStore visitLeave(FuncCallArgListNode node, List<CodeStore> childResults) { 162 162 CodeStore code = new CodeStore(); 163 163 Iterator<CodeStore> iter = childResults.iterator(); … … 166 166 } 167 167 168 // if statement169 public CodeStore visitLeave(IfSt atementNode node, List<CodeStore> childResults) {168 // if Stmt 169 public CodeStore visitLeave(IfStmtNode node, List<CodeStore> childResults) { 170 170 CodeStore code = new CodeStore(); 171 171 CodeStore ifTest = childResults.get(0); 172 CodeStore ifBlockSt atement = childResults.get(1);172 CodeStore ifBlockStmt = childResults.get(1); 173 173 code.addFormattedLine("if (%s)", ifTest.getResultVariableName()); 174 174 code.addLine("{"); 175 code.addAll(ifBlockSt atement, 1);175 code.addAll(ifBlockStmt, 1); 176 176 code.dedentedLine("}"); 177 if(Accessors.hasElseBlockSt atement(node)) {178 CodeStore elseBlockSt atement = childResults.get(2);177 if(Accessors.hasElseBlockStmt(node)) { 178 CodeStore elseBlockStmt = childResults.get(2); 179 179 code.addLine("else"); 180 180 code.addLine("{"); 181 code.addAll(elseBlockSt atement, 1);181 code.addAll(elseBlockStmt, 1); 182 182 code.dedentedLine("}"); 183 183 } … … 185 185 } 186 186 187 // while statement188 public CodeStore visitLeave(WhileSt atementNode node, List<CodeStore> childResults) {187 // while Stmt 188 public CodeStore visitLeave(WhileStmtNode node, List<CodeStore> childResults) { 189 189 CodeStore code = new CodeStore(); 190 190 CodeStore ifTest = childResults.get(0); 191 CodeStore blockSt atement = childResults.get(1);191 CodeStore blockStmt = childResults.get(1); 192 192 code.addFormattedLine("while (%s)", ifTest.getResultVariableName()); 193 193 code.addLine("{"); 194 code.addAll(blockSt atement, 1);194 code.addAll(blockStmt, 1); 195 195 code.dedentedLine("}"); 196 196 return code; 197 197 } 198 198 199 // return statement200 public CodeStore visitLeave(ReturnSt atementNode node, List<CodeStore> childResults) {199 // return Stmt 200 public CodeStore visitLeave(ReturnStmtNode node, List<CodeStore> childResults) { 201 201 CodeStore code = new CodeStore(); 202 202 CodeStore child = childResults.get(0); … … 232 232 } 233 233 234 // public CodeStore visitLeave(AssignmentSt atementNode node, List<CodeStore> childResults) {234 // public CodeStore visitLeave(AssignmentStmtNode node, List<CodeStore> childResults) { 235 235 // CodeStore code = new CodeStore(); 236 236 // code.setResultVariableName(Accessors.assignmentOperator(node)); … … 238 238 // } 239 239 240 // block statements241 public CodeStore visitLeave(BlockSt atementNode node, List<CodeStore> childResults) {240 // block Stmts 241 public CodeStore visitLeave(BlockStmtNode node, List<CodeStore> childResults) { 242 242 CodeStore code = new CodeStore(); 243 243 -
proto/pablo/src/compiler/visitors/CarryCounterVisitor.java
r2657 r2658 25 25 } 26 26 27 public void visitLeave(Func tionInvocationNode node) {27 public void visitLeave(FuncCallNode node) { 28 28 if(BuiltinsUtil.isCarryOne(node)) { 29 29 carryCount += 1; -
proto/pablo/src/compiler/visitors/CarryIntroXFormer.java
r2657 r2658 11 11 import ast.*; 12 12 13 public class CarryIntro Transformer {13 public class CarryIntroXFormer { 14 14 15 private ASTNode ASTTree; // Func tionDefNode15 private ASTNode ASTTree; // FuncDefNode 16 16 17 17 private CarrySet2Lang carrySet2Lang; 18 18 19 public CarryIntro Transformer(ASTNode node, CarrySet2Lang carrySet2Lang) {20 assert node instanceof Func tionDefNode;19 public CarryIntroXFormer(ASTNode node, CarrySet2Lang carrySet2Lang) { 20 assert node instanceof FuncDefNode; 21 21 this.ASTTree = node; 22 22 this.carrySet2Lang = carrySet2Lang; 23 23 } 24 24 25 /** Appends carry information to Pablo AST 'If' 'While' statement nodes.25 /** Appends carry information to Pablo AST 'If' 'While' Stmt nodes. 26 26 * 27 27 * @param ci carry in mode 28 28 * @param co carry out mode 29 29 */ 30 public void transform(boolean ci, boolean co) {30 public void XForm(boolean ci, boolean co) { 31 31 CarryIntroVisitor visitor = new CarryIntroVisitor(ci, co); 32 32 ASTTree.accept(visitor); … … 64 64 // # fndef.body.insert(0, mkCallStmt('CarryDeclare', [self.carryvar, ast.Num(carry_count)])) 65 65 // return fndef 66 public void visitEnter(Func tionDefNode node) {66 public void visitEnter(FuncDefNode node) { 67 67 this.currentCarry = 0; 68 68 //this.currentAdvN = 0; … … 74 74 IntegerConstantNode carryCountNode = Generators.makeIntegerConstantNode(carryCount, node.getToken()); 75 75 76 Func tionInvocationNode carryAdjustFunctionInvocation = (FunctionInvocationNode) Generators.makeFunctionInvocationNode(76 FuncCallNode carryAdjustFuncCall = (FuncCallNode) Generators.makeFuncCallNode( 77 77 new String [] {CarrySet.CarryQ_IDENTIFIER, carrySet2Lang.getCode(CarrySet.CARRYQADJUST)}, 78 78 node.getToken(), 79 79 new ASTNode [] {carryCountNode}); 80 80 81 BlockSt atementNode blockStatementNode = Accessors.blockStatementNode(node);82 blockSt atementNode.appendChild(carryAdjustFunctionInvocation);81 BlockStmtNode blockStmtNode = Accessors.blockStmtNode(node); 82 blockStmtNode.appendChild(carryAdjustFuncCall); 83 83 } 84 84 } 85 85 86 public void visitLeave(Func tionInvocationNode node) {86 public void visitLeave(FuncCallNode node) { 87 87 if(BuiltinsUtil.isCarryOne(node)) { 88 88 this.currentCarry += 1; … … 102 102 //return ast.If(new_test, ifNode.body, new_else_part) 103 103 104 public void visitEnter(IfSt atementNode node) { // Current if strategy does not test any_carry() on n bits104 public void visitEnter(IfStmtNode node) { // Current if strategy does not test any_carry() on n bits 105 105 assert (new AdvanceNCounterVisitor(node).count() == 0): "Advance(x,n) within if: illegal\n"; 106 106 … … 121 121 IntegerConstantNode carryCountNode = Generators.makeIntegerConstantNode(carryCount, node.getToken()); 122 122 123 Func tionInvocationNode rhs = (FunctionInvocationNode) Generators.makeFunctionInvocationNode(123 FuncCallNode rhs = (FuncCallNode) Generators.makeFuncCallNode( 124 124 new String [] {CarrySet.CarryQ_IDENTIFIER, carrySet2Lang.getCode(CarrySet.CARRYTEST)}, 125 125 node.getToken(), … … 133 133 134 134 // else part, append CarryDequeueEnqueue call 135 Func tionInvocationNode carryDequeueEnqueue = (FunctionInvocationNode) Generators.makeFunctionInvocationNode(135 FuncCallNode carryDequeueEnqueue = (FuncCallNode) Generators.makeFuncCallNode( 136 136 new String [] {CarrySet.CarryQ_IDENTIFIER, carrySet2Lang.getCode(CarrySet.CARRYDEQUEUEENQUEUE)}, 137 137 node.getToken(), … … 139 139 140 140 141 if (Accessors.hasElseBlockSt atement(node)) {142 Accessors.elseBlockSt atement(node).appendChild(carryDequeueEnqueue);141 if (Accessors.hasElseBlockStmt(node)) { 142 Accessors.elseBlockStmt(node).appendChild(carryDequeueEnqueue); 143 143 } else { 144 BlockSt atementNode blockStatementNode =145 Generators.makeBlockSt atementNode(LextantToken.make(node.getToken().getLocation(),144 BlockStmtNode blockStmtNode = 145 Generators.makeBlockStmtNode(LextantToken.make(node.getToken().getLocation(), 146 146 Lextant.LCURLY.getPrimaryLexeme(), 147 147 Lextant.LCURLY)); 148 blockSt atementNode.appendChild(carryDequeueEnqueue);149 node.appendChild(blockSt atementNode);148 blockStmtNode.appendChild(carryDequeueEnqueue); 149 node.appendChild(blockStmtNode); 150 150 } 151 151 … … 154 154 } 155 155 156 //class CarryIntro(ast.Node Transformer):156 //class CarryIntro(ast.NodeXFormer): 157 157 158 158 // def generic_xfrm(self, node): -
proto/pablo/src/compiler/visitors/DumpAssignmentStmtsXFormer.java
r2657 r2658 7 7 import compiler.lang.pablo.Builtins2Lang; 8 8 9 public class DumpAssignmentSt atementsTransformer {9 public class DumpAssignmentStmtsXFormer { 10 10 private ASTNode ASTree; 11 11 private Builtins2Lang builtins2Lang; 12 12 13 public DumpAssignmentSt atementsTransformer(ASTNode ASTree, Builtins2Lang builtins2Lang) {13 public DumpAssignmentStmtsXFormer(ASTNode ASTree, Builtins2Lang builtins2Lang) { 14 14 this.ASTree = ASTree; 15 15 this.builtins2Lang = builtins2Lang; 16 16 } 17 17 18 public ASTNode transform() {19 Transformer transformer = new Transformer();20 ASTree.accept( transformer);18 public ASTNode XForm() { 19 XFormer XFormer = new XFormer(); 20 ASTree.accept(XFormer); 21 21 return ASTree; 22 22 } 23 23 24 private class Transformer extends VoidVisitor.Default {24 private class XFormer extends VoidVisitor.Default { 25 25 26 public Transformer () {}26 public XFormer () {} 27 27 28 28 public void visitEnter(LocalVarDeclNode node) { 29 addDumpSt atement(node, Accessors.lhs(node));29 addDumpStmt(node, Accessors.lhs(node)); 30 30 } 31 31 32 32 public void visitEnter(AssignmentNode node) { 33 addDumpSt atement(node, Accessors.lhs(node));33 addDumpStmt(node, Accessors.lhs(node)); 34 34 } 35 35 36 private void addDumpSt atement(ASTNode node, ASTNode lhs) {37 Func tionInvocationNode printRegisterStatement =38 Generators.makeFunc tionInvocationNode( builtins2Lang.getCode(Builtins.PRINTBITBLOCK),36 private void addDumpStmt(ASTNode node, ASTNode lhs) { 37 FuncCallNode printRegisterStmt = 38 Generators.makeFuncCallNode( builtins2Lang.getCode(Builtins.PRINTBITBLOCK), 39 39 node.getToken(), 40 40 new ASTNode [] {lhs}); 41 41 42 (node.getParent()).insertAfterChild(node, printRegisterSt atement);42 (node.getParent()).insertAfterChild(node, printRegisterStmt); 43 43 } 44 44 } -
proto/pablo/src/compiler/visitors/Pablo2CarryXFormer.java
r2657 r2658 14 14 import ast.*; 15 15 16 public class Pablo2Carry Transformer {16 public class Pablo2CarryXFormer { 17 17 18 18 private Builtins2Lang builtins2Lang; 19 19 private CarrySet2Lang carrySet2Lang; 20 20 21 private ASTNode ASTTree; // Func tionDefNode21 private ASTNode ASTTree; // FuncDefNode 22 22 23 23 // def __init__(self, carryvar="carryQ", carryin = "_ci", carryout = "_co"): … … 26 26 // self.carryout = carryout 27 27 28 public Pablo2Carry Transformer(ASTNode node, Builtins2Lang builtins2Lang, CarrySet2Lang carrySet2Lang) {29 assert node instanceof Func tionDefNode;28 public Pablo2CarryXFormer(ASTNode node, Builtins2Lang builtins2Lang, CarrySet2Lang carrySet2Lang) { 29 assert node instanceof FuncDefNode; 30 30 this.ASTTree = node; 31 31 this.builtins2Lang = builtins2Lang; … … 33 33 } 34 34 35 /** Transforms FunctionDefNode AST sub-trees w.r.t. ci/co modes.36 * Augments AST with 'CarryQ' functioncalls.35 /** XForms FuncDefNode AST sub-trees w.r.t. ci/co modes. 36 * Augments AST with 'CarryQ' Func calls. 37 37 * 38 38 * @param ci carry in mode 39 39 * @param co carry out mode 40 40 */ 41 public void transform(boolean ci, boolean co) { // ci - carry in xformation mode, co - carry out mode xformation mode41 public void XForm(boolean ci, boolean co) { // ci - carry in xformation mode, co - carry out mode xformation mode 42 42 CarryIntroVisitor visitor = new CarryIntroVisitor(ci, co); 43 43 ASTTree.accept(visitor); … … 75 75 // # fndef.body.insert(0, mkCallStmt('CarryDeclare', [self.carryvar, ast.Num(carry_count)])) 76 76 // return fndef 77 public void visitEnter(Func tionDefNode node) { // TODO - CarryIf duplicates77 public void visitEnter(FuncDefNode node) { // TODO - CarryIf duplicates 78 78 this.currentCarry = 0; 79 79 this.currentAdvN = 0; … … 81 81 } 82 82 83 public void visitLeave(Func tionInvocationNode node) {83 public void visitLeave(FuncCallNode node) { 84 84 85 85 ASTNode replacementNode; … … 98 98 // adv_n_args = [mkCall('simd<1>::constant<0>', []), ast.Num(self.current_adv_n)] 99 99 if(ciMode) { 100 carryCall = Generators.makeFunc tionInvocationNode(100 carryCall = Generators.makeFuncCallNode( 101 101 new String [] {CarrySet.CarryQ_IDENTIFIER, carrySet2Lang.getCode(CarrySet.GETCARRYIN)}, 102 102 node.getToken(), 103 103 new ASTNode [] {currentCarry}); 104 104 105 advNCall = Generators.makeFunc tionInvocationNode(105 advNCall = Generators.makeFuncCallNode( 106 106 new String [] {CarrySet.CarryQ_IDENTIFIER, carrySet2Lang.getCode(CarrySet.GETPENDING64)}, 107 107 node.getToken(), … … 120 120 // return c 121 121 if (BuiltinsUtil.isCall(node, BuiltinsUtil.BUILTIN_PACKAGE_NAME, Builtins.ADVANCE.pabloName(), Builtins.ADVANCE.argCount())) { 122 replaceFunc tionInvocationNode(node,122 replaceFuncCallNode(node, 123 123 CarrySet.CarryQ_IDENTIFIER, 124 124 builtins2Lang.getCode(Builtins.ADVANCE), … … 135 135 // return c 136 136 else if (BuiltinsUtil.isCall(node, BuiltinsUtil.BUILTIN_PACKAGE_NAME, Builtins.SCANTHRU.pabloName(), Builtins.SCANTHRU.argCount())) { 137 replaceFunc tionInvocationNode(node,137 replaceFuncCallNode(node, 138 138 CarrySet.CarryQ_IDENTIFIER, 139 139 builtins2Lang.getCode(Builtins.SCANTHRU), … … 150 150 // return c 151 151 else if (BuiltinsUtil.isCall(node, BuiltinsUtil.BUILTIN_PACKAGE_NAME, Builtins.ADVANCETHENSCANTHRU.pabloName(), Builtins.ADVANCETHENSCANTHRU.argCount())) { 152 replaceFunc tionInvocationNode(node,152 replaceFuncCallNode(node, 153 153 CarrySet.CarryQ_IDENTIFIER, 154 154 builtins2Lang.getCode(Builtins.ADVANCETHENSCANTHRU), … … 165 165 // return c 166 166 else if (BuiltinsUtil.isCall(node, BuiltinsUtil.BUILTIN_PACKAGE_NAME, Builtins.SPANUPTO.pabloName(), Builtins.SPANUPTO.argCount())) { 167 replaceFunc tionInvocationNode(node,167 replaceFuncCallNode(node, 168 168 CarrySet.CarryQ_IDENTIFIER, 169 169 builtins2Lang.getCode(Builtins.SPANUPTO), … … 182 182 // return c 183 183 else if (BuiltinsUtil.isCall(node, BuiltinsUtil.BUILTIN_PACKAGE_NAME, Builtins.ADVANCETHENSCANTO.pabloName(), Builtins.ADVANCETHENSCANTO.argCount())) { 184 replaceFunc tionInvocationNode(node,184 replaceFuncCallNode(node, 185 185 CarrySet.CarryQ_IDENTIFIER, 186 186 builtins2Lang.getCode(Builtins.ADVANCETHENSCANTO), … … 200 200 201 201 else if (BuiltinsUtil.isCall(node, BuiltinsUtil.BUILTIN_PACKAGE_NAME, Builtins.INCLUSIVESPAN.pabloName(), Builtins.INCLUSIVESPAN.argCount())) { 202 replaceFunc tionInvocationNode(node,202 replaceFuncCallNode(node, 203 203 CarrySet.CarryQ_IDENTIFIER, 204 204 builtins2Lang.getCode(Builtins.INCLUSIVESPAN), … … 218 218 219 219 else if (BuiltinsUtil.isCall(node, BuiltinsUtil.BUILTIN_PACKAGE_NAME, Builtins.EXCLUSIVESPAN.pabloName(), Builtins.EXCLUSIVESPAN.argCount())) { 220 replaceFunc tionInvocationNode(node,220 replaceFuncCallNode(node, 221 221 CarrySet.CarryQ_IDENTIFIER, 222 222 builtins2Lang.getCode(Builtins.EXCLUSIVESPAN), … … 238 238 239 239 else if (BuiltinsUtil.isCall(node, BuiltinsUtil.BUILTIN_PACKAGE_NAME, Builtins.SCANTO.pabloName(), Builtins.SCANTO.argCount())) { 240 replaceFunc tionInvocationNode(node,240 replaceFuncCallNode(node, 241 241 CarrySet.CarryQ_IDENTIFIER, 242 242 builtins2Lang.getCode(Builtins.SCANTO), … … 255 255 256 256 else if (BuiltinsUtil.isCall(node, BuiltinsUtil.BUILTIN_PACKAGE_NAME, Builtins.SCANTOFIRST.pabloName(), Builtins.SCANTOFIRST.argCount())) { 257 replaceFunc tionInvocationNode(node,257 replaceFuncCallNode(node, 258 258 CarrySet.CarryQ_IDENTIFIER, 259 259 builtins2Lang.getCode(Builtins.SCANTOFIRST), … … 270 270 // return c 271 271 else if (BuiltinsUtil.isCall(node, BuiltinsUtil.BUILTIN_PACKAGE_NAME, Builtins.ADVANCE32.pabloName(), Builtins.ADVANCE32.argCount())) { 272 //replaceFunc tionInvocationNode(node, CarryQ.CarryQ_PACKAGE_NAME, BuiltinOperations.ADVANCE32.cPPCode(), carryCall, currentAdvN);272 //replaceFuncCallNode(node, CarryQ.CarryQ_PACKAGE_NAME, BuiltinOperations.ADVANCE32.cPPCode(), carryCall, currentAdvN); 273 273 // TODO ==> verify advNCall 274 replaceFunc tionInvocationNode(node,274 replaceFuncCallNode(node, 275 275 CarrySet.CarryQ_IDENTIFIER, 276 276 builtins2Lang.getCode(Builtins.ADVANCE32), … … 287 287 // return c 288 288 else if (BuiltinsUtil.isCall(node, BuiltinsUtil.BUILTIN_PACKAGE_NAME, Builtins.ADVANCEN.pabloName(), Builtins.ADVANCEN.argCount())) { 289 //replaceFunc tionInvocationNode(node, CarryQ.CarryQ_PACKAGE_NAME, BuiltinOperations.ADVANCEN.cPPCode(), carryCall, currentAdvN);289 //replaceFuncCallNode(node, CarryQ.CarryQ_PACKAGE_NAME, BuiltinOperations.ADVANCEN.cPPCode(), carryCall, currentAdvN); 290 290 // TODO ==> verify advNCall 291 replaceFunc tionInvocationNode(node,291 replaceFuncCallNode(node, 292 292 CarrySet.CarryQ_IDENTIFIER, 293 293 builtins2Lang.getCode(Builtins.ADVANCE32), … … 307 307 if(!this.coMode) { // if not final block 308 308 List<ASTNode> args = new ArrayList<ASTNode>(); 309 for(ASTNode arg : Accessors. functionInvocationArgumentsListNode(node).getChildren()) {309 for(ASTNode arg : Accessors.FuncCallArgsListNode(node).getChildren()) { 310 310 args.add(arg); 311 311 } 312 312 args.add(Generators.makeIdentifierNode(builtins2Lang.getCode(Builtins.EOFMASK), node.getToken())); 313 replacementNode = Generators.makeFunc tionInvocationNode(SIMD.ANDC.idisaName(), node.getToken(), args);313 replacementNode = Generators.makeFuncCallNode(SIMD.ANDC.idisaName(), node.getToken(), args); 314 314 315 315 } else { 316 replacementNode = Generators.makeFunc tionInvocationNode(SIMD.CONSTANT.idisaConstantName(1, 0), node.getToken());316 replacementNode = Generators.makeFuncCallNode(SIMD.CONSTANT.idisaConstantName(1, 0), node.getToken()); 317 317 } 318 318 node.updateSelf(replacementNode); … … 330 330 List<ASTNode> args = new ArrayList<ASTNode>(); 331 331 332 for(ASTNode arg : Accessors. functionInvocationArgumentsListNode(node).getChildren()) {332 for(ASTNode arg : Accessors.FuncCallArgsListNode(node).getChildren()) { 333 333 args.add(arg); 334 334 } 335 335 args.add(Generators.makeIdentifierNode(builtins2Lang.getCode(Builtins.EOFMASK), node.getToken())); 336 replacementNode = Generators.makeFunc tionInvocationNode(SIMD.AND.idisaName(), node.getToken(), args);336 replacementNode = Generators.makeFuncCallNode(SIMD.AND.idisaName(), node.getToken(), args); 337 337 338 338 } else { 339 replacementNode = Accessors. functionInvocationArgument(node,0);339 replacementNode = Accessors.FuncCallArg(node,0); 340 340 } 341 341 node.updateSelf(replacementNode); … … 352 352 // 353 353 // else if (Builtins.isCall(node, Builtins.BUILTIN_PACKAGE_NAME, NoCarry.STREAMSCAN.pabloName(), NoCarry.STREAMSCAN.argCount())) { 354 // replacementNode = Generators.makeFunc tionInvocationNode(NoCarry.STREAMSCAN.cPPCode(), node.getToken());354 // replacementNode = Generators.makeFuncCallNode(NoCarry.STREAMSCAN.cPPCode(), node.getToken()); 355 355 // 356 // ASTNode arg0 = Generators.makeIdentifierNode("(ScanBlock *) &" + Accessors.identifierLexeme(Accessors. functionInvocationArg(node, 0)), node.getToken());356 // ASTNode arg0 = Generators.makeIdentifierNode("(ScanBlock *) &" + Accessors.identifierLexeme(Accessors.FuncCallArg(node, 0)), node.getToken()); 357 357 // ASTNode arg1 = Generators.makeIdentifierNode("sizeof(BitBlock)/sizeof(ScanBlock)", node.getToken()); 358 // ASTNode arg2 = Accessors. functionInvocationArg(node, 1);358 // ASTNode arg2 = Accessors.FuncCallArg(node, 1); 359 359 // 360 360 // replacementNode.appendChild(arg0); … … 367 367 // return callnode 368 368 else { 369 // do nothing // TODO - Dump: allow functioncalls to pass through the compiler.369 // do nothing // TODO - Dump: allow Func calls to pass through the compiler. 370 370 } 371 371 … … 373 373 374 374 // Helpers 375 private void replaceFunc tionInvocationNode(FunctionInvocationNode node, String targetPackage, String targetName,375 private void replaceFuncCallNode(FuncCallNode node, String targetPackage, String targetName, 376 376 ASTNode call, IntegerConstantNode carry) { 377 Func tionInvocationNode replacementNode;377 FuncCallNode replacementNode; 378 378 379 379 List<ASTNode> args = new ArrayList<ASTNode>(); 380 380 381 for(ASTNode arg : Accessors. functionInvocationArgumentsListNode(node).getChildren()) {381 for(ASTNode arg : Accessors.FuncCallArgsListNode(node).getChildren()) { 382 382 args.add(arg); 383 383 } … … 385 385 args.add(carry); 386 386 387 replacementNode = Generators.makeFunc tionInvocationNode(387 replacementNode = Generators.makeFuncCallNode( 388 388 new String [] {targetPackage, targetName}, 389 389 node.getToken(), … … 395 395 } 396 396 397 //class CarryIntro(ast.Node Transformer):397 //class CarryIntro(ast.NodeXFormer): 398 398 399 399 // def generic_xfrm(self, node): -
proto/pablo/src/compiler/visitors/StreamFuncVisitor.java
r2651 r2658 9 9 import compiler.ast.Accessors; 10 10 11 //class StreamFunc tionVisitor(ast.NodeVisitor):11 //class StreamFuncVisitor(ast.NodeVisitor): 12 12 // def __init__(self,node): 13 // self.streamFunc tionNode = {}13 // self.streamFuncNode = {} 14 14 // self.generic_visit(node) 15 15 // 16 // def visit_Func tionDef(self, node):16 // def visit_FuncDef(self, node): 17 17 // key = node.name[0].upper() + node.name[1:] 18 // self.streamFunc tionNode[key] = node18 // self.streamFuncNode[key] = node 19 19 20 public class StreamFunc tionVisitor {20 public class StreamFuncVisitor { 21 21 22 22 private ASTNode ASTree; 23 23 24 public StreamFunc tionVisitor(ASTNode ASTree) {24 public StreamFuncVisitor(ASTNode ASTree) { 25 25 this.ASTree = ASTree; 26 26 } 27 27 28 28 public void visit() { 29 StreamFunc tionVisitor1 visitor = new StreamFunctionVisitor1();29 StreamFuncVisitor1 visitor = new StreamFuncVisitor1(); 30 30 ASTree.accept(visitor); 31 31 } 32 32 33 public Map<String, ASTNode> makeStreamFunc tionMap() {34 StreamFunc tionVisitor1 visitor = new StreamFunctionVisitor1();33 public Map<String, ASTNode> makeStreamFuncMap() { 34 StreamFuncVisitor1 visitor = new StreamFuncVisitor1(); 35 35 ASTree.accept(visitor); 36 return ((StreamFunc tionVisitor1)visitor).streamFunctionMap();36 return ((StreamFuncVisitor1)visitor).streamFuncMap(); 37 37 } 38 38 39 private class StreamFunc tionVisitor1 extends VoidVisitor.Default {39 private class StreamFuncVisitor1 extends VoidVisitor.Default { 40 40 41 private LinkedHashMap<String, ASTNode> streamFunc tionMap = new LinkedHashMap<String, ASTNode>();41 private LinkedHashMap<String, ASTNode> streamFuncMap = new LinkedHashMap<String, ASTNode>(); 42 42 43 public Map<String, ASTNode> streamFunc tionMap() {44 return streamFunc tionMap;43 public Map<String, ASTNode> streamFuncMap() { 44 return streamFuncMap; 45 45 } 46 46 47 public void visitLeave(Func tionDefNode node) {47 public void visitLeave(FuncDefNode node) { 48 48 49 ASTNode functionNameNode = Accessors.functionName(node);50 String functionName = functionNameNode.getToken().getLexeme();51 functionName = capitalize(functionName);52 IdentifierToken newNameToken = IdentifierToken.make(LexicalType.IDENTIFIER, functionNameNode.getToken().getLocation(), functionName);49 ASTNode FuncNameNode = Accessors.FuncName(node); 50 String FuncName = FuncNameNode.getToken().getLexeme(); 51 FuncName = capitalize(FuncName); 52 IdentifierToken newNameToken = IdentifierToken.make(LexicalType.IDENTIFIER, FuncNameNode.getToken().getLocation(), FuncName); 53 53 54 functionNameNode.setToken(newNameToken);55 streamFunc tionMap.put(functionName, node);54 FuncNameNode.setToken(newNameToken); 55 streamFuncMap.put(FuncName, node); 56 56 57 57 } -
proto/pablo/src/grammar/PabloApplication.java
r2410 r2658 18 18 19 19 20 protected static void checkArg uments(String[] args, String applicationName) {20 protected static void checkArgs(String[] args, String applicationName) { 21 21 int length = args.length; 22 22 boolean inputDirFound = false; -
proto/pablo/src/grammar/TestPabloAbstractSyntaxTree.java
r2438 r2658 27 27 28 28 /** 29 * Recursive functionto descend into the directory tree and find all the files29 * Recursive Func to descend into the directory tree and find all the files 30 30 * that end with ".mp3" 31 31 * @param dir A file object defining the top directory … … 39 39 */ 40 40 public static void main(String[] args) throws FileNotFoundException { 41 PabloApplication.checkArg uments(args, "SampleAbstractSyntaxTree");41 PabloApplication.checkArgs(args, "SampleAbstractSyntaxTree"); 42 42 43 43 ASTPrinter.setPrintLevel(ASTPrinter.Level.FULL); -
proto/pablo/src/parser/Parser.java
r2625 r2658 58 58 else if( nowReading.isLextant(Lextant.FUNCTION) ) { 59 59 { 60 ASTNode child = parseFunc tionDef();60 ASTNode child = parseFuncDef(); 61 61 result.appendChild(child); 62 62 allChildren.add(child); … … 181 181 } 182 182 183 public ASTNode parseFunc tionDef() {183 public ASTNode parseFuncDef() { 184 184 if( !(nowReading.isLextant(Lextant.FUNCTION)) ) { 185 return syntaxErrorNode(" functionDef² [FUNCTION¹]");186 } 187 188 boolean allowCompression = true; 189 ASTNode result = new Func tionDefNode(nowReading);185 return syntaxErrorNode("FuncDef² [FUNCTION¹]"); 186 } 187 188 boolean allowCompression = true; 189 ASTNode result = new FuncDefNode(nowReading); 190 190 result.setProductionTag(6); 191 191 RevList<ASTNode> allChildren = new ReverseAccessibleArrayList<ASTNode>(); … … 197 197 } 198 198 { 199 ASTNode child = parseFunc tionName();199 ASTNode child = parseFuncName(); 200 200 result.appendChild(child); 201 201 allChildren.add(child); … … 211 211 expect(Lextant.RROUND); 212 212 { 213 ASTNode child = parseBlockSt atement();213 ASTNode child = parseBlockStmt(); 214 214 result.appendChild(child); 215 215 allChildren.add(child); … … 272 272 } 273 273 274 public ASTNode parseFunc tionName() {274 public ASTNode parseFuncName() { 275 275 if( !((nowReading.isLexicalType(LexicalType.IDENTIFIER))) ) { 276 return syntaxErrorNode(" functionName² [IDENTIFIER¹]");276 return syntaxErrorNode("FuncName² [IDENTIFIER¹]"); 277 277 } 278 278 … … 337 337 } 338 338 339 public ASTNode parseSt atement() {339 public ASTNode parseStmt() { 340 340 if( !(nowReading.isLextant(Lextant.IF, Lextant.RETURN, Lextant.VAR, Lextant.WHILE) || (nowReading.isLexicalType(LexicalType.IDENTIFIER))) ) { 341 return syntaxErrorNode(" statement² [IDENTIFIER¹, IF¹, RETURN¹, VAR¹, WHILE¹]");341 return syntaxErrorNode("Stmt² [IDENTIFIER¹, IF¹, RETURN¹, VAR¹, WHILE¹]"); 342 342 } 343 343 … … 348 348 if( (nowReading.isLexicalType(LexicalType.IDENTIFIER)) ) { 349 349 { 350 ASTNode child = parseFunc tionInvocationOrAssignmentStatement();350 ASTNode child = parseFuncCallOrAssignmentStmt(); 351 351 result.appendChild(child); 352 352 allChildren.add(child); … … 355 355 else if( nowReading.isLextant(Lextant.IF) ) { 356 356 { 357 ASTNode child = parseIfSt atement();357 ASTNode child = parseIfStmt(); 358 358 result.appendChild(child); 359 359 allChildren.add(child); … … 362 362 else if( nowReading.isLextant(Lextant.WHILE) ) { 363 363 { 364 ASTNode child = parseWhileSt atement();364 ASTNode child = parseWhileStmt(); 365 365 result.appendChild(child); 366 366 allChildren.add(child); … … 369 369 else if( nowReading.isLextant(Lextant.RETURN) ) { 370 370 { 371 ASTNode child = parseReturnSt atement();371 ASTNode child = parseReturnStmt(); 372 372 result.appendChild(child); 373 373 allChildren.add(child); … … 390 390 } 391 391 392 public ASTNode parseFunc tionInvocationOrAssignmentStatement() {392 public ASTNode parseFuncCallOrAssignmentStmt() { 393 393 if( !((nowReading.isLexicalType(LexicalType.IDENTIFIER))) ) { 394 return syntaxErrorNode(" functionInvocationOrAssignmentStatement² [IDENTIFIER¹]");395 } 396 397 boolean allowCompression = true; 398 ASTNode result = new Func tionInvocationOrAssignmentStatementNode(nowReading);394 return syntaxErrorNode("FuncCallOrAssignmentStmt² [IDENTIFIER¹]"); 395 } 396 397 boolean allowCompression = true; 398 ASTNode result = new FuncCallOrAssignmentStmtNode(nowReading); 399 399 result.setProductionTag(13); 400 400 RevList<ASTNode> allChildren = new ReverseAccessibleArrayList<ASTNode>(); … … 406 406 if( nowReading.isLextant(Lextant.LROUND) ) { 407 407 { 408 ASTNode child = parseFunc tionInvocationRest();408 ASTNode child = parseFuncCallRest(); 409 409 result.appendChild(child); 410 410 allChildren.add(child); … … 429 429 } 430 430 431 public ASTNode parseFunc tionInvocationRest() {431 public ASTNode parseFuncCallRest() { 432 432 if( !(nowReading.isLextant(Lextant.LROUND)) ) { 433 return syntaxErrorNode(" functionInvocationRest² [LROUND¹]");434 } 435 436 boolean allowCompression = true; 437 ASTNode result = new Func tionInvocationNode(nowReading);433 return syntaxErrorNode("FuncCallRest² [LROUND¹]"); 434 } 435 436 boolean allowCompression = true; 437 ASTNode result = new FuncCallNode(nowReading); 438 438 result.setProductionTag(14); 439 439 RevList<ASTNode> allChildren = new ReverseAccessibleArrayList<ASTNode>(); … … 441 441 expect(Lextant.LROUND); 442 442 { 443 ASTNode child = parseFunc tionInvocationArgumentList();443 ASTNode child = parseFuncCallArgList(); 444 444 result.appendChild(child); 445 445 allChildren.add(child); … … 452 452 } 453 453 454 public ASTNode parseFunc tionInvocationArgumentList() {455 boolean allowCompression = true; 456 ASTNode result = new Func tionInvocationArgumentListNode(nowReading);454 public ASTNode parseFuncCallArgList() { 455 boolean allowCompression = true; 456 ASTNode result = new FuncCallArgListNode(nowReading); 457 457 result.setProductionTag(15); 458 458 RevList<ASTNode> allChildren = new ReverseAccessibleArrayList<ASTNode>(); … … 531 531 } 532 532 533 public ASTNode parseIfSt atement() {533 public ASTNode parseIfStmt() { 534 534 if( !(nowReading.isLextant(Lextant.IF)) ) { 535 return syntaxErrorNode("ifSt atement² [IF¹]");536 } 537 538 boolean allowCompression = true; 539 ASTNode result = new IfSt atementNode(nowReading);535 return syntaxErrorNode("ifStmt² [IF¹]"); 536 } 537 538 boolean allowCompression = true; 539 ASTNode result = new IfStmtNode(nowReading); 540 540 result.setProductionTag(18); 541 541 RevList<ASTNode> allChildren = new ReverseAccessibleArrayList<ASTNode>(); … … 549 549 expect(Lextant.RROUND); 550 550 { 551 ASTNode child = parseBlockSt atement();551 ASTNode child = parseBlockStmt(); 552 552 result.appendChild(child); 553 553 allChildren.add(child); … … 556 556 expect(Lextant.ELSE); 557 557 { 558 ASTNode child = parseBlockSt atement();559 result.appendChild(child); 560 allChildren.add(child); 561 } 562 } 563 if(allowCompression) { 564 return result; 565 } 566 return result; 567 } 568 569 public ASTNode parseWhileSt atement() {558 ASTNode child = parseBlockStmt(); 559 result.appendChild(child); 560 allChildren.add(child); 561 } 562 } 563 if(allowCompression) { 564 return result; 565 } 566 return result; 567 } 568 569 public ASTNode parseWhileStmt() { 570 570 if( !(nowReading.isLextant(Lextant.WHILE)) ) { 571 return syntaxErrorNode("whileSt atement² [WHILE¹]");572 } 573 574 boolean allowCompression = true; 575 ASTNode result = new WhileSt atementNode(nowReading);571 return syntaxErrorNode("whileStmt² [WHILE¹]"); 572 } 573 574 boolean allowCompression = true; 575 ASTNode result = new WhileStmtNode(nowReading); 576 576 result.setProductionTag(19); 577 577 RevList<ASTNode> allChildren = new ReverseAccessibleArrayList<ASTNode>(); … … 585 585 expect(Lextant.RROUND); 586 586 { 587 ASTNode child = parseBlockSt atement();588 result.appendChild(child); 589 allChildren.add(child); 590 } 591 if(allowCompression) { 592 return result; 593 } 594 return result; 595 } 596 597 public ASTNode parseReturnSt atement() {587 ASTNode child = parseBlockStmt(); 588 result.appendChild(child); 589 allChildren.add(child); 590 } 591 if(allowCompression) { 592 return result; 593 } 594 return result; 595 } 596 597 public ASTNode parseReturnStmt() { 598 598 if( !(nowReading.isLextant(Lextant.RETURN)) ) { 599 return syntaxErrorNode("returnSt atement² [RETURN¹]");600 } 601 602 boolean allowCompression = true; 603 ASTNode result = new ReturnSt atementNode(nowReading);599 return syntaxErrorNode("returnStmt² [RETURN¹]"); 600 } 601 602 boolean allowCompression = true; 603 ASTNode result = new ReturnStmtNode(nowReading); 604 604 result.setProductionTag(20); 605 605 RevList<ASTNode> allChildren = new ReverseAccessibleArrayList<ASTNode>(); … … 678 678 } 679 679 680 public ASTNode parseBlockSt atement() {680 public ASTNode parseBlockStmt() { 681 681 if( !(nowReading.isLextant(Lextant.LCURLY)) ) { 682 return syntaxErrorNode("blockSt atement² [LCURLY¹]");683 } 684 685 boolean allowCompression = true; 686 ASTNode result = new BlockSt atementNode(nowReading);682 return syntaxErrorNode("blockStmt² [LCURLY¹]"); 683 } 684 685 boolean allowCompression = true; 686 ASTNode result = new BlockStmtNode(nowReading); 687 687 result.setProductionTag(23); 688 688 RevList<ASTNode> allChildren = new ReverseAccessibleArrayList<ASTNode>(); … … 690 690 while( nowReading.isLextant(Lextant.IF, Lextant.RETURN, Lextant.VAR, Lextant.WHILE) || (nowReading.isLexicalType(LexicalType.IDENTIFIER)) ) { 691 691 { 692 ASTNode child = parseSt atement();692 ASTNode child = parseStmt(); 693 693 result.appendChild(child); 694 694 allChildren.add(child); … … 825 825 if( nowReading.isLextant(Lextant.LROUND) ) { 826 826 { 827 ASTNode child = parseFunc tionInvocationRest();827 ASTNode child = parseFuncCallRest(); 828 828 result.appendChild(child); 829 829 allChildren.add(child);
Note: See TracChangeset
for help on using the changeset viewer.