- Timestamp:
- 07/28/08 20:20:58 (16 months ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
trunk/ProjectFortress/src/com/sun/fortress/tools/FortressAstToConcrete.java
r2402 r2405 34 34 */ 35 35 36 /* indentation utilities *************************************************/ 36 37 private int indent = 0; 37 38 … … 59 60 60 61 /* utility methods ********************************************************/ 62 /* returns number copies of s */ 63 private String makeCopies(int number, String s) { 64 String result = s; 65 for (int index = 1; index < number; index++) { 66 result += s; 67 } 68 return result; 69 } 70 61 71 /* returns a string beginning with 'kind' followed by a sequence of elements 62 72 in 'list' separated by commas and enclosed by '{' and '}' … … 362 372 List<String> decls_result) { 363 373 StringBuilder s = new StringBuilder(); 364 374 365 375 increaseIndent(); 366 376 … … 386 396 s.append( indent(join(decls_result,"\n")) ); 387 397 s.append( "\nend" ).append( "\n" ); 388 398 389 399 decreaseIndent(); 390 400 … … 655 665 List<String> fronts_result) { 656 666 StringBuilder s = new StringBuilder(); 657 s.append( indent(join(fronts_result, " \n")) );667 s.append( indent(join(fronts_result, " also\n")) ); 658 668 s.append( "\nend" ); 659 669 return s.toString(); … … 1030 1040 StringBuilder s = new StringBuilder(); 1031 1041 1032 // s.append( op_result );1033 1042 s.append( join(args_result, " " + op_result + " ") ); 1034 1043 … … 1094 1103 // @Override public String forMathPrimaryOnly( that, 1095 1104 1096 @Override public String forArrayElementOnly(ArrayElement that, List<String> staticArgs_result, String element_result) { 1097 StringBuilder s = new StringBuilder(); 1098 1099 s.append( element_result ); 1100 s.append( inOxfordBrackets(staticArgs_result)); 1101 1102 return s.toString(); 1103 } 1104 1105 @Override public String forArrayElementsOnly(ArrayElements that, List<String> staticArgs_result, List<String> elements_result) { 1106 StringBuilder s = new StringBuilder(); 1107 1108 s.append( "[ " ); 1109 s.append( join(elements_result, ", ") ); 1110 s.append( inOxfordBrackets( staticArgs_result ) ); 1111 s.append( " ]" ); 1105 @Override public String forArrayElementOnly(ArrayElement that, 1106 List<String> staticArgs_result, 1107 String element_result) { 1108 return element_result; 1109 } 1110 1111 @Override public String forArrayElementsOnly(ArrayElements that, 1112 List<String> staticArgs_result, 1113 List<String> elements_result) { 1114 StringBuilder s = new StringBuilder(); 1115 1116 if ( that.isOutermost() ) { 1117 s.append( "[" ); 1118 s.append( inOxfordBrackets( staticArgs_result ) ); 1119 s.append( " " ); 1120 } 1121 String separator; 1122 if ( that.getDimension() == 1 ) 1123 separator = " "; 1124 else 1125 separator = makeCopies(that.getDimension()-1, ";"); 1126 s.append( join(elements_result, separator) ); 1127 if ( that.isOutermost() ) 1128 s.append( " ]" ); 1112 1129 1113 1130 return s.toString(); … … 1131 1148 // @Override public String for_RewriteGenericSingletonTypeOnly( that, 1132 1149 1133 @Override public String forArrayTypeOnly(ArrayType that, String type_result, String indices_result) { 1150 @Override public String forArrayTypeOnly(ArrayType that, 1151 String type_result, 1152 String indices_result) { 1134 1153 StringBuilder s = new StringBuilder(); 1135 1154 … … 1711 1730 @Override public String forAnonymousFnNameOnly(AnonymousFnName that, 1712 1731 Option<String> api_result) { 1713 StringBuilder s = new StringBuilder(); 1714 1715 return s.toString(); 1716 /* 1717 return bug(that, "Anonymous function names are not supported " + 1718 "in Fortress concrete syntax."); 1719 */ 1732 return ""; 1720 1733 } 1721 1734 … … 1812 1825 } 1813 1826 1814 @Override public String forExtentRangeOnly(ExtentRange that, Option<String> base_result, Option<String> size_result) { 1815 StringBuilder s = new StringBuilder(); 1816 1817 if ( base_result.isSome() ){ 1818 s.append( base_result.unwrap() ); 1819 } 1820 if ( size_result.isSome() ){ 1821 s.append( size_result.unwrap() ); 1822 } 1823 1824 return s.toString(); 1827 /* Possible differences in the original Fortress program and 1828 the unparsed program. 1829 In the Fortress source program, either "#" or ":" may be used. 1830 In AST, only "#" is used. 1831 In the Fortress source program, either "#size" or "size" may be used. 1832 In AST, only "#size" is used. 1833 */ 1834 @Override public String forExtentRangeOnly(ExtentRange that, 1835 Option<String> base_result, 1836 Option<String> size_result) { 1837 StringBuilder s = new StringBuilder(); 1838 1839 if ( base_result.isSome() ){ 1840 s.append( base_result.unwrap() ); 1841 } 1842 s.append( "#" ); 1843 if ( size_result.isSome() ){ 1844 s.append( size_result.unwrap() ); 1845 } 1846 1847 return s.toString(); 1825 1848 } 1826 1849 … … 1856 1879 // @Override public String forTraitTypeWhereOnly( that, 1857 1880 1858 @Override public String forIndicesOnly(Indices that, List<String> extents_result) { 1881 @Override public String forIndicesOnly(Indices that, 1882 List<String> extents_result) { 1859 1883 StringBuilder s = new StringBuilder(); 1860 1884

