Changeset 440
- Timestamp:
- Jun 21, 2010 12:11:57 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagnoliaPlugin/src/org/magnolialang/xatree/TreeImplodeVisitor.java
r439 r440 88 88 cons = cons != null ? cons : sort; 89 89 result = (IConstructor) ((IList) t.get(0)).get(0); 90 concrete = ((IList) result.getAnnotation("concrete")).insert(concrete.get(0)).append(concrete.get(2)); 90 IListWriter cst = vf.listWriter(Type_XaToken); 91 for(IValue tok : concrete) { 92 System.out.println(tok); 93 if(((IConstructor)tok).getConstructorType() == Type_Child) 94 cst.appendAll((IList)result.getAnnotation("concrete")); 95 else 96 cst.append(tok); 97 } 98 concrete = cst.done(); 99 //concrete = ((IList) result.getAnnotation("concrete")).insert(concrete.get(0)).append(concrete.get(2)); 91 100 } 92 101 else if(SymbolAdapter.isCf(rhs)) { … … 147 156 148 157 private final Pattern LAYOUT_PAT = Pattern.compile("^(\\s*)(\\S.*\\S)(\\s*)$", Pattern.DOTALL); 149 158 150 159 public ITuple visitChildren(Iterable<IValue> trees) throws FactTypeUseException, VisitorException { 151 160 IListWriter ast = vf.listWriter(Type_XaTree); … … 161 170 Matcher m = LAYOUT_PAT.matcher(chars); 162 171 if(m.matches()) { 163 cst.append(space(m.group(1)));172 splitSpaces(m.group(1), cst); 164 173 cst.append(comment(m.group(2))); 165 cst.append(space(m.group(3)));174 splitSpaces(m.group(3), cst); 166 175 } 167 176 else 168 cst.append(space(chars));177 splitSpaces(chars, cst); 169 178 } 170 179 } … … 182 191 return vf.tuple(ast.done(), cst.done()); 183 192 } 193 194 private final Pattern PAT_SPACE = Pattern.compile("^([^\r\n]*)([\r\n]+)(.*)$", Pattern.DOTALL); 195 196 private void splitSpaces(String chars, IListWriter cst) { 197 Matcher m = PAT_SPACE.matcher(chars); 198 while(m.matches()) { 199 if(m.group(1).length() > 0) 200 cst.append(space(m.group(1))); 201 cst.append(space(m.group(2))); 202 chars = m.group(3); 203 m = PAT_SPACE.matcher(chars); 204 } 205 206 if(chars.length() > 0) 207 cst.append(space(chars)); 208 } 184 209 @Override 185 210 public IConstructor visitTreeChar(IConstructor tree)
Note:
See TracChangeset
for help on using the changeset viewer.