Changeset 3364 for devel-tools/trunk


Ignore:
Timestamp:
Feb 4, 2008, 11:29:36 PM (13 years ago)
Author:
yura
Message:
Location:
devel-tools/trunk/eclipse/org.refal.plus.rfpdt/src/org/refal/plus/rfpdt/comp
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • devel-tools/trunk/eclipse/org.refal.plus.rfpdt/src/org/refal/plus/rfpdt/comp/SrcPosition.java

    r3329 r3364  
    5252        return charStart <= offset && offset <= charEnd;
    5353    }
     54   
     55    public int length () {
     56        return charEnd - charStart;
     57    }
    5458
    5559    @Override
  • devel-tools/trunk/eclipse/org.refal.plus.rfpdt/src/org/refal/plus/rfpdt/comp/ast/AstCut.java

    r3329 r3364  
    1919        v.visit(this, e);
    2020    }
     21
     22    @Override
     23    public String toString () {
     24        return "\\!";
     25    }
    2126}
  • devel-tools/trunk/eclipse/org.refal.plus.rfpdt/src/org/refal/plus/rfpdt/comp/ast/AstFence.java

    r3361 r3364  
    2121        v.visit(this, e);
    2222    }
     23
     24    @Override
     25    public String toString () {
     26        return "\\?";
     27    }
    2328}
  • devel-tools/trunk/eclipse/org.refal.plus.rfpdt/src/org/refal/plus/rfpdt/comp/ast/AstName.java

    r3329 r3364  
    1010        this.identifier = identifier;
    1111    }
     12
     13    @Override
     14    public String toString () {
     15        return pos.length() > identifier.length() ? "\"" + identifier + "\"" : identifier;
     16    }
    1217}
  • devel-tools/trunk/eclipse/org.refal.plus.rfpdt/src/org/refal/plus/rfpdt/comp/ast/AstVar.java

    r3329 r3364  
    3636    }
    3737
    38     public String getTypeAsString () {
    39         return type.name().toLowerCase();
    40     }
    41 
    4238    public boolean isHard () {
    4339        return this.type == VarType.S || this.type == VarType.T;
     
    5349        v.visit(this, e);
    5450    }
     51
     52    @Override
     53    public String toString () {
     54        if (name != null)
     55            return type.name().toLowerCase() + (pos.charStart + 1 < name.pos.charStart ? "." : "") + name.identifier;
     56        else
     57            return type.name().toLowerCase() + (pos.length() > 1 ? "." : "");
     58    }
    5559}
  • devel-tools/trunk/eclipse/org.refal.plus.rfpdt/src/org/refal/plus/rfpdt/comp/ast/AstWordSymbol.java

    r3329 r3364  
    2020        v.visit(this, e);
    2121    }
     22
     23    @Override
     24    public String toString () {
     25        return pos.length() > word.length() ? "\"" + word + "\"" : word;
     26    }
    2227}
  • devel-tools/trunk/eclipse/org.refal.plus.rfpdt/src/org/refal/plus/rfpdt/comp/ast/ImageBuilder.java

    r3329 r3364  
    22
    33public final class ImageBuilder implements ProgramVisitor, SentenceVisitor, ExpVisitor {
    4     private static boolean isIdentifier (String word) {
    5         if (word.length() == 0)
    6             return false;
    7 
    8         if (!isIdStartChar(word.charAt(0)))
    9             return false;
    10 
    11         for (int i = 1; i < word.length(); i++) {
    12             if (!isIdTailChar(word.charAt(i)))
    13                 return false;
    14         }
    15         return true;
    16     }
    17 
    18     private static boolean isIdStartChar (int c) {
    19         return ('A' <= c && c <= 'Z') || c == '_';
    20     }
    21 
    22     private static boolean isIdTailChar (int c) {
    23         return ('A' <= c && c <= 'Z') || ('a' <= c && c <= 'z') || (c == '_') || ('0' <= c && c <= '9');
    24     }
    25    
    264    public static String getImage (AstInterf astInterf) {
    275        ImageBuilder imageBuilder = new ImageBuilder();
     
    3715
    3816    private final StringBuilder sb = new StringBuilder();
    39    
     17
    4018    private ImageBuilder () {}
    4119
     
    4725        sb.append(astName != null ? astName.identifier + " " : "$NONAME$ ");
    4826    }
    49    
     27
    5028    // ProgramVisitor
    51    
     29
    5230    public void visit (AstConstBinding astConstBinding) {
    5331        if (astConstBinding.isPublic)
     
    126104
    127105    // SentenceVisitor
    128    
     106
    129107    public void visit (AstAlt astAlt) {
    130108        append(astAlt.failMode.select("\\{ ", "{ "));
     
    137115
    138116    public void visit (AstCut astCut) {
    139         append("\\! ");
     117        append(astCut + " ");
    140118    }
    141119
     
    154132
    155133    public void visit (AstFence astFence) {
    156         append("\\? ");
     134        append(astFence + " ");
    157135    }
    158136
     
    230208
    231209    public void visit (AstVar astVar) {
    232         append(astVar.getTypeAsString());
    233         if (astVar.name != null) {
    234             append(".");
    235             append(astVar.name);
    236         } else
    237             append(" ");
     210        append(astVar + " ");
    238211    }
    239212
    240213    public void visit (AstWordSymbol astWordSymbol) {
    241         if (isIdentifier(astWordSymbol.word))
    242             append(astWordSymbol.word + " ");
    243         else
    244             append("\"" + astWordSymbol.word + "\" ");
     214        append(astWordSymbol + " ");
    245215    }
    246216}
Note: See TracChangeset for help on using the changeset viewer.