Changeset 3255


Ignore:
Timestamp:
Jun 3, 2013, 8:20:01 AM (6 years ago)
Author:
bhull
Message:

Negated character class fix.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • proto/RE/src/codeGenerator/Visitor.java

    r3113 r3255  
    1111import ast.CharNode;
    1212import ast.CharacterClassNode;
     13import ast.NegatedCharacterClassNode;
    1314
    1415// DNE
     
    133134        return defaultVisitLeave(node);
    134135    }
     136    public ASTNode visitLeave(NegatedCharacterClassNode node, List<ASTNode> childresults) {
     137        NodeState currState = nodeStates.get(node);
     138        currState.setCharacterClass(true);
     139        currState.setCharacterClassRepresentation(generateCharacterClassRepresentation(node));
     140        return defaultVisitLeave(node);
     141    }
    135142    public ASTNode visitLeave(AnyNode node, List<ASTNode> childresults) {
    136143        NodeState currState = nodeStates.get(node);
     
    202209        Boolean[] result;
    203210        result = mergeCharacterClassRepresentations(node.getChildren());
    204         if (getAttributeValue(node, "complemented").equals("true")){
    205                 for (int i = 0;i < 256;i++) {
     211       
     212        return result;
     213    }
     214    private Boolean[] generateCharacterClassRepresentation(NegatedCharacterClassNode node) {
     215        Boolean[] result;
     216        result = mergeCharacterClassRepresentations(node.getChildren());
     217        for (int i = 0;i < 256;i++) {
    206218                       
    207                         result[i]=!result[i];
    208                 }
    209         }
    210        
    211         return result;
    212     }
     219                result[i]=!result[i];
     220        }
     221       
     222        return result;
     223    }
     224
     225
     226
    213227    private Boolean[] generateCharacterClassRepresentation(AnyNode node) {
    214228        Boolean[] result = new Boolean[256];
Note: See TracChangeset for help on using the changeset viewer.