Changeset 3170
- Timestamp:
- 12/08/08 10:06:33 (12 months ago)
- Location:
- trunk/ProjectFortress
- Files:
-
- 5 modified
-
astgen/Fortress.ast (modified) (1 diff)
-
src/com/sun/fortress/nodes_util/ErrorMsgMaker.java (modified) (1 diff)
-
src/com/sun/fortress/nodes_util/NodeFactory.java (modified) (1 diff)
-
src/com/sun/fortress/parser/MayNewlineHeader.rats (modified) (3 diffs)
-
src/com/sun/fortress/tools/FortressAstToConcrete.java (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ProjectFortress/astgen/Fortress.ast
r3169 r3170 1347 1347 /** 1348 1348 * unit expression with an operator 1349 */ 1350 abstract UnitOpExpr(UnitExpr left, UnitExpr right); 1351 /** 1352 * unit multiplication 1353 * UnitExpr ::= UnitExpr UnitExpr 1354 * | UnitExpr DOT UnitExpr 1355 * e.g.) m DOT n 1356 */ 1357 ProductUnit(); 1358 /* unit division 1359 * UnitExpr ::= UnitExpr / UnitExpr 1360 * | UnitExpr per UnitExpr 1361 * e.g.) meter / second 1362 */ 1363 QuotientUnit(); 1364 /** 1365 * unit exponentiation 1366 * UnitExpr ::= UnitExpr caret UnitExpr 1367 * e.g.) meter^2 1368 */ 1369 ExponentUnit(); 1349 * 1350 * unit multiplication 1351 * UnitExpr ::= UnitExpr UnitExpr 1352 * | UnitExpr DOT UnitExpr 1353 * e.g.) m DOT n 1354 * 1355 * unit division 1356 * UnitExpr ::= UnitExpr / UnitExpr 1357 * | UnitExpr per UnitExpr 1358 * e.g.) meter / second 1359 * 1360 * unit exponentiation 1361 * UnitExpr ::= UnitExpr caret UnitExpr 1362 * e.g.) meter^2 1363 */ 1364 UnitBinaryOp(UnitExpr left, UnitExpr right, Op op); 1370 1365 /** 1371 1366 * where clause used in trait, object, and functional declarations -
trunk/ProjectFortress/src/com/sun/fortress/nodes_util/ErrorMsgMaker.java
r3169 r3170 196 196 } 197 197 198 private String forUnitOpExpr(UnitOpExpr node, String op) { 199 return "(" + node.getLeft().accept(this) + op + node.getRight().accept(this) + ")"; 200 } 201 202 public String forProductUnit(ProductUnit node) { 203 return forUnitOpExpr(node, " "); 204 } 205 206 public String forQuotientUnit(QuotientUnit node) { 207 return forUnitOpExpr(node, "/"); 208 } 209 210 public String forExponentUnit(ExponentUnit node) { 211 return forUnitOpExpr(node, "^"); 198 public String forUnitBinaryOp(UnitBinaryOp node) { 199 return "(" + node.getLeft().accept(this) + 200 node.getOp().accept(this) + 201 node.getRight().accept(this) + ")"; 212 202 } 213 203 -
trunk/ProjectFortress/src/com/sun/fortress/nodes_util/NodeFactory.java
r3169 r3170 1205 1205 return new UnitRef(b.getSpan(), true, b.getName()); 1206 1206 } 1207 public UnitExpr forProductUnit(ProductUnit i) { 1208 return new ProductUnit(i.getSpan(), true, i.getLeft(), 1209 i.getRight()); 1210 } 1211 public UnitExpr forQuotientUnit(QuotientUnit t) { 1212 return new QuotientUnit(t.getSpan(), true, t.getLeft(), 1213 t.getRight()); 1214 } 1215 public UnitExpr forExponentUnit(ExponentUnit i) { 1216 return new ExponentUnit(i.getSpan(), true, i.getLeft(), 1217 i.getRight()); 1207 public UnitExpr forUnitBinaryOp(UnitBinaryOp i) { 1208 return new UnitBinaryOp(i.getSpan(), true, i.getLeft(), 1209 i.getRight(), i.getOp()); 1218 1210 } 1219 1211 public UnitExpr defaultCase(Node x) { -
trunk/ProjectFortress/src/com/sun/fortress/parser/MayNewlineHeader.rats
r3169 r3170 399 399 { yyValue = new Action<UnitExpr>() { 400 400 public UnitExpr run(UnitExpr base) { 401 return new ProductUnit(createSpan(yyStart,yyCount), 402 (UnitExpr)base, a1); 401 Op product = NodeFactory.makeOpInfix(a1.getSpan(), " "); 402 return new UnitBinaryOp(createSpan(yyStart,yyCount), 403 (UnitExpr)base, a1, product); 403 404 }}; 404 405 }; … … 408 409 { yyValue = new Action<UnitExpr>() { 409 410 public UnitExpr run(UnitExpr base) { 410 return new QuotientUnit(createSpan(yyStart,yyCount), 411 (UnitExpr)base, a1); 411 Op quotient = NodeFactory.makeOpInfix(a1.getSpan(), "/"); 412 return new UnitBinaryOp(createSpan(yyStart,yyCount), 413 (UnitExpr)base, a1, quotient); 412 414 }}; 413 415 }; … … 417 419 { yyValue = new Action<UnitExpr>() { 418 420 public UnitExpr run(UnitExpr base) { 419 return new ExponentUnit(createSpan(yyStart,yyCount), 420 (UnitExpr)base, a1); 421 Op exponent = NodeFactory.makeOpInfix(a1.getSpan(), "^"); 422 return new UnitBinaryOp(createSpan(yyStart,yyCount), 423 (UnitExpr)base, a1, exponent); 421 424 }}; 422 425 }; -
trunk/ProjectFortress/src/com/sun/fortress/tools/FortressAstToConcrete.java
r3169 r3170 2300 2300 } 2301 2301 2302 @Override public String forProductUnitOnly(ProductUnit that, 2303 String left_result, 2304 String right_result) { 2305 return handleParen( left_result + " " + right_result, 2306 that.isParenthesized() ); 2307 } 2308 2309 @Override public String forQuotientUnitOnly(QuotientUnit that, 2302 @Override public String forUnitBinaryOpOnly(UnitBinaryOp that, 2310 2303 String left_result, 2311 String right_result) { 2312 return handleParen( left_result + "/" + right_result, 2313 that.isParenthesized() ); 2314 } 2315 2316 @Override public String forExponentUnitOnly(ExponentUnit that, 2317 String left_result, 2318 String right_result) { 2319 return handleParen( left_result + "^" + right_result, 2304 String right_result, 2305 String op_result) { 2306 return handleParen( left_result + op_result + right_result, 2320 2307 that.isParenthesized() ); 2321 2308 }

