Changeset 4132


Ignore:
Timestamp:
Dec 20, 2009, 4:53:10 PM (11 years ago)
Author:
yura
Message:
  • Refactoring.
Location:
devel-tools/trunk/eclipse
Files:
10 edited
1 moved

Legend:

Unmodified
Added
Removed
  • devel-tools/trunk/eclipse/org.refal.rfpdt.core/src/org/refal/rfpdt/ast/AstName.java

    r3572 r4132  
    22
    33import org.refal.rfpdt.compiler.SrcPosition;
    4 import org.refal.rfpdt.parser.RfpCharacter;
     4import org.refal.rfpdt.parser.RefalCharacter;
    55
    66public final class AstName extends AstNode {
     
    1414
    1515    public boolean isIdenifier () {
    16         if (identifier.length() == 0 || !RfpCharacter.isIdStartChar(identifier.charAt(0)))
     16        if (identifier.length() == 0 || !RefalCharacter.isIdStartChar(identifier.charAt(0)))
    1717            return false;
    1818        for (int i = 1; i < identifier.length(); i++)
    19             if (!RfpCharacter.isIdInternalChar(identifier.charAt(i)))
     19            if (!RefalCharacter.isIdInternalChar(identifier.charAt(i)))
    2020                return false;
    2121        return true;
  • devel-tools/trunk/eclipse/org.refal.rfpdt.core/src/org/refal/rfpdt/parser/AbstractScanner.java

    r4131 r4132  
    1515import org.refal.rfpdt.compiler.SrcPosition;
    1616
    17 public abstract class AbstractScanner {
     17abstract class AbstractScanner {
    1818    /* keyword table */
    1919    protected static final class KwEntry {
  • devel-tools/trunk/eclipse/org.refal.rfpdt.core/src/org/refal/rfpdt/parser/RefalCharacter.java

    r4131 r4132  
    11package org.refal.rfpdt.parser;
    22
    3 public final class RfpCharacter {
     3public final class RefalCharacter {
    44    public static boolean isIdStartChar (int c) {
    55        return ('A' <= c && c <= 'Z') || c == '_';
  • devel-tools/trunk/eclipse/org.refal.rfpdt.core/src/org/refal/rfpdt/parser/Rf5Scanner.java

    r4131 r4132  
    2929
    3030public final class Rf5Scanner extends AbstractScanner {
    31     public Rf5Scanner (RfpResource rfpResource, Reader reader, MsgHandler msgHandler) {
    32         super(rfpResource, reader, msgHandler);
    33     }
    34 
    3531    // init kerword table
    3632    static {
     
    3935        kw("EXTERN", EXTERNAL, null);
    4036        kw("EXTRN", EXTERNAL, null);
     37    }
     38
     39    public Rf5Scanner (RfpResource rfpResource, Reader reader, MsgHandler msgHandler) {
     40        super(rfpResource, reader, msgHandler);
    4141    }
    4242
     
    117117                default:
    118118                    // Other cases with more sophisticated predicates
    119                     if (RfpCharacter.isDigit(ch)) {
     119                    if (RefalCharacter.isDigit(ch)) {
    120120                        tk = NUMB;
    121121                        tkBigInteger = scanNumber();
     
    123123                        return;
    124124                    }
    125                     if (RfpCharacter.isLetter(ch)) {
     125                    if (RefalCharacter.isLetter(ch)) {
    126126                        tkChar = (char) ch;
    127127                        nextCh();
     
    129129                            tk = VAR;
    130130                            nextCh();
    131                             if (RfpCharacter.isDigit(ch))
     131                            if (RefalCharacter.isDigit(ch))
    132132                                tkString = scanNumber().toString();
    133133                            else
     
    152152    private String scanIdentifier () throws IOException {
    153153        StringBuilder sb = new StringBuilder();
    154         while (RfpCharacter.isRf5IdInternalChar(ch)) {
     154        while (RefalCharacter.isRf5IdInternalChar(ch)) {
    155155            sb.append((char) ch);
    156156            nextCh();
     
    161161    private BigInteger scanNumber () throws IOException {
    162162        StringBuffer sb = new StringBuffer();
    163         while (RfpCharacter.isDigit(ch)) {
     163        while (RefalCharacter.isDigit(ch)) {
    164164            sb.append((char) ch);
    165165            nextCh();
    166166        }
    167         if (RfpCharacter.isAlphanum(ch)) {
     167        if (RefalCharacter.isAlphanum(ch)) {
    168168            scanError(tkLine, tkLineStart, tkCharStart, chPosition,
    169169                    MsgCode.NumberImmediatelyFollowedByIdentifierOrVariable); // TODO: change message
     
    175175        for (;;) {
    176176            // Skipping whitespace.
    177             while (RfpCharacter.isWhitespace(ch))
     177            while (RefalCharacter.isWhitespace(ch))
    178178                nextCh();
    179179            if (ch == '*' && chPosition == chLineStart) { // Single line comment.
  • devel-tools/trunk/eclipse/org.refal.rfpdt.core/src/org/refal/rfpdt/parser/RfpScanner.java

    r4131 r4132  
    248248                default:
    249249                    // Other cases with more sophisticated predicates
    250                     if (RfpCharacter.isDigit(ch)) {
     250                    if (RefalCharacter.isDigit(ch)) {
    251251                        tk = NUMB;
    252252                        tkBigInteger = scanNumber();
     
    254254                        return;
    255255                    }
    256                     if (RfpCharacter.isIdStartChar(ch)) {
     256                    if (RefalCharacter.isIdStartChar(ch)) {
    257257                        tk = WORD;
    258258                        tkString = scanIdentifier();
     
    271271        for (;;) {
    272272            // Skipping whitespace.
    273             while (RfpCharacter.isWhitespace(ch))
     273            while (RefalCharacter.isWhitespace(ch))
    274274                nextCh();
    275275            if (ch != '/')
     
    313313    private String scanVarIndex () throws IOException {
    314314        StringBuilder sb = new StringBuilder();
    315         while (RfpCharacter.isAlphanum(ch)) {
     315        while (RefalCharacter.isAlphanum(ch)) {
    316316            sb.append((char) ch);
    317317            nextCh();
     
    321321
    322322    private String scanIdentifier () throws IOException {
    323         assert RfpCharacter.isIdStartChar(ch);
     323        assert RefalCharacter.isIdStartChar(ch);
    324324        StringBuilder sb = new StringBuilder();
    325325        sb.append((char) ch);
    326326        nextCh();
    327         while (RfpCharacter.isIdInternalChar(ch)) {
     327        while (RefalCharacter.isIdInternalChar(ch)) {
    328328            sb.append((char) ch);
    329329            nextCh();
     
    334334    private String scanKeyword () throws IOException {
    335335        StringBuilder sb = new StringBuilder();
    336         while (RfpCharacter.isAlphanum(ch) || ch == '?') {
     336        while (RefalCharacter.isAlphanum(ch) || ch == '?') {
    337337            sb.append((char) ch);
    338338            nextCh();
     
    359359        }
    360360        if (radix == 10) {
    361             if (!RfpCharacter.isDigit(ch)) {
     361            if (!RefalCharacter.isDigit(ch)) {
    362362                scanError(tkLine, tkLineStart, tkCharStart, chPosition, MsgCode.InvalidNumber);
    363363                sb.append('0');
     
    366366                    sb.append((char) ch);
    367367                    nextCh();
    368                 } while (RfpCharacter.isDigit(ch));
     368                } while (RefalCharacter.isDigit(ch));
    369369            }
    370370        } else { // radix == 16
    371             if (!RfpCharacter.isHexDigit(ch)) {
     371            if (!RefalCharacter.isHexDigit(ch)) {
    372372                scanError(tkLine, tkLineStart, tkCharStart, chPosition, MsgCode.InvalidHexLiteralNumber);
    373373                sb.append('0');
     
    376376                    sb.append((char) ch);
    377377                    nextCh();
    378                 } while (RfpCharacter.isHexDigit(ch));
    379             }
    380         }
    381         if (RfpCharacter.isAlphanum(ch)) {
     378                } while (RefalCharacter.isHexDigit(ch));
     379            }
     380        }
     381        if (RefalCharacter.isAlphanum(ch)) {
    382382            scanError(tkLine, tkLineStart, tkCharStart, chPosition,
    383383                    MsgCode.NumberImmediatelyFollowedByIdentifierOrVariable); // TODO: change message
  • devel-tools/trunk/eclipse/org.refal.rfpdt.ui/src/org/refal/rfpdt/ui/scanner/IdentifierDetector.java

    r3869 r4132  
    22
    33import org.eclipse.jface.text.rules.IWordDetector;
    4 import org.refal.rfpdt.parser.RfpCharacter;
     4import org.refal.rfpdt.parser.RefalCharacter;
    55
    66class IdentifierDetector implements IWordDetector {
    77    public boolean isWordPart (char c) {
    8         return RfpCharacter.isIdInternalChar(c);
     8        return RefalCharacter.isIdInternalChar(c);
    99    }
    1010
    1111    public boolean isWordStart (char c) {
    12         return RfpCharacter.isIdStartChar(c);
     12        return RefalCharacter.isIdStartChar(c);
    1313    }
    1414}
  • devel-tools/trunk/eclipse/org.refal.rfpdt.ui/src/org/refal/rfpdt/ui/scanner/KeywordDetector.java

    r3869 r4132  
    22
    33import org.eclipse.jface.text.rules.IWordDetector;
    4 import org.refal.rfpdt.parser.RfpCharacter;
     4import org.refal.rfpdt.parser.RefalCharacter;
    55
    66class KeywordDetector implements IWordDetector {
     
    1010
    1111    public boolean isWordPart (char c) {
    12         return RfpCharacter.isAlphanum(c) || c == '?';
     12        return RefalCharacter.isAlphanum(c) || c == '?';
    1313    }
    1414
  • devel-tools/trunk/eclipse/org.refal.rfpdt.ui/src/org/refal/rfpdt/ui/scanner/NumberDetector.java

    r3869 r4132  
    22
    33import org.eclipse.jface.text.rules.IWordDetector;
    4 import org.refal.rfpdt.parser.RfpCharacter;
     4import org.refal.rfpdt.parser.RefalCharacter;
    55
    66class NumberDetector implements IWordDetector {
     
    1515        }           
    1616        start = 0;
    17         return isHex ? RfpCharacter.isHexDigit(c) : RfpCharacter.isDigit(c);
     17        return isHex ? RefalCharacter.isHexDigit(c) : RefalCharacter.isDigit(c);
    1818    }
    1919
     
    2121        start = c;
    2222        isHex = false;
    23         return RfpCharacter.isDigit(c) || c == '+' || c == '-';
     23        return RefalCharacter.isDigit(c) || c == '+' || c == '-';
    2424    }
    2525}
  • devel-tools/trunk/eclipse/org.refal.rfpdt.ui/src/org/refal/rfpdt/ui/scanner/VariableDetector.java

    r3869 r4132  
    22
    33import org.eclipse.jface.text.rules.IWordDetector;
    4 import org.refal.rfpdt.parser.RfpCharacter;
     4import org.refal.rfpdt.parser.RefalCharacter;
    55
    66class VariableDetector implements IWordDetector {
     
    1010        boolean mayBeDot = isAfterType;
    1111        isAfterType = false;
    12         return RfpCharacter.isAlphanum(c) || (mayBeDot && c == '.');
     12        return RefalCharacter.isAlphanum(c) || (mayBeDot && c == '.');
    1313    }
    1414
    1515    public boolean isWordStart (char c) {
    1616        isAfterType = true;
    17         return RfpCharacter.isVarType(c);
     17        return RefalCharacter.isVarType(c);
    1818    }
    1919}
  • devel-tools/trunk/eclipse/org.refal.rfpdt.ui/src/org/refal/rfpdt/ui/scanner/WhitespaceDetector.java

    r3869 r4132  
    22
    33import org.eclipse.jface.text.rules.IWhitespaceDetector;
    4 import org.refal.rfpdt.parser.RfpCharacter;
     4import org.refal.rfpdt.parser.RefalCharacter;
    55
    66class WhitespaceDetector implements IWhitespaceDetector {
    77    public boolean isWhitespace (char c) {
    8         return RfpCharacter.isWhitespace(c);
     8        return RefalCharacter.isWhitespace(c);
    99    }
    1010}
  • devel-tools/trunk/eclipse/org.refal.rfpdt.ui/src/org/refal/rfpdt/ui/wizards/NewRfpModuleWizardPage.java

    r4055 r4132  
    3131import org.eclipse.swt.widgets.Composite;
    3232import org.refal.rfpdt.core.RfpCore;
    33 import org.refal.rfpdt.parser.RfpCharacter;
     33import org.refal.rfpdt.parser.RefalCharacter;
    3434import org.refal.rfpdt.ui.RfpUI;
    3535
     
    125125            moduleName += '.';
    126126        moduleName += getTypeName();
    127         if (!RfpCharacter.isIdStartChar(moduleName.charAt(0)))
     127        if (!RefalCharacter.isIdStartChar(moduleName.charAt(0)))
    128128            moduleName = '\"' + moduleName + '\"';
    129129        buf.append(moduleName);
Note: See TracChangeset for help on using the changeset viewer.