Changeset 4121 for devel-tools


Ignore:
Timestamp:
Dec 15, 2009, 1:43:26 PM (11 years ago)
Author:
yura
Message:
  • RfpParser? is split into two classes: general tk-functions and building AST.
Location:
devel-tools/trunk/eclipse/org.refal.rfpdt.core/src/org/refal/rfpdt/parser
Files:
1 added
1 edited

Legend:

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

    r3846 r4121  
    118118import org.refal.rfpdt.compiler.SrcPosition;
    119119
    120 public final class RfpParser {
     120public final class RfpParser extends RParser {
    121121    /** May return <code>null</code>! */
    122122    public static AstInterf parseInterf (String moduleName, Reader reader, MsgHandler msgHandler) {
     
    146146    }
    147147
    148     private final RfpScanner scanner;
    149     private final MsgHandler msgHandler;
    150 
    151     /** The tag and position of the current token */
    152     private long tk;
    153     private SrcPosition tkPos;
    154     private SrcPosition prevTkPos;
    155 
    156148    private RfpParser (RfpResource rfpResource, Reader reader, MsgHandler msgHandler) {
    157         this.scanner = new RfpScanner(rfpResource, reader, msgHandler);
    158         this.msgHandler = msgHandler;
    159     }
    160 
    161     private void nextTk () {
    162         scanner.getNextToken();
    163         prevTkPos = tkPos;
    164         tk = scanner.tk;
    165         tkPos = scanner.tkPos;
    166     }
    167 
    168     /* A test at the beginning of non-terminals */
    169 
    170     private boolean tkIs (long x) {
    171         return tk == x;
    172     }
    173 
    174     private boolean tkIn (long x) {
    175         return (tk & x) != 0L;
    176     }
    177 
    178     private boolean sync (long expected, long followers) {
    179         followers |= expected;
    180         while (!tkIn(followers)) {
    181             msgHandler.send(tkPos, MsgCode.UnexpectedToken, TkImages.getTkImage(tk));
    182             nextTk();
    183         }
    184         return tkIn(expected);
    185     }
    186 
    187     private boolean acceptWOError (long expected, long followers) {
    188         if (sync(expected, followers)) {
    189             nextTk();
    190             return true;
    191         } else
    192             return false;
    193     }
    194 
    195     private boolean accept (long expected, long followers) {
    196         if (sync(expected, followers)) {
    197             nextTk();
    198             return true;
    199         } else {
    200             msgHandler.send(SrcPosition.fromExclusiveToExclusive(prevTkPos, tkPos), MsgCode.MissingToken, TkImages
    201                     .getTkImage(expected));
    202             return false;
    203         }
     149        super(rfpResource, reader, msgHandler);
    204150    }
    205151
Note: See TracChangeset for help on using the changeset viewer.