Changeset 4129 for devel-tools/trunk


Ignore:
Timestamp:
Dec 20, 2009, 1:58:07 PM (11 years ago)
Author:
yura
Message:
  • Simplification.
Location:
devel-tools/trunk/eclipse/org.refal.rfpdt.core/src/org/refal/rfpdt/parser
Files:
2 deleted
5 edited

Legend:

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

    r4121 r4129  
    4242        followers |= expected;
    4343        while (!tkIn(followers)) {
    44             msgHandler.send(tkPos, MsgCode.UnexpectedToken, TkImages.getTkImage(tk));
     44            msgHandler.send(tkPos, MsgCode.UnexpectedToken, TkTags.getTkImage(tk));
    4545            nextTk();
    4646        }
     
    6161            return true;
    6262        } else {
    63             msgHandler.send(SrcPosition.fromExclusiveToExclusive(prevTkPos, tkPos), MsgCode.MissingToken, TkImages
     63            msgHandler.send(SrcPosition.fromExclusiveToExclusive(prevTkPos, tkPos), MsgCode.MissingToken, TkTags
    6464                    .getTkImage(expected));
    6565            return false;
  • devel-tools/trunk/eclipse/org.refal.rfpdt.core/src/org/refal/rfpdt/parser/Rf5Parser.java

    r4127 r4129  
    11package org.refal.rfpdt.parser;
    22
    3 import static org.refal.rfpdt.parser.TkFollowers.f_rf5_program;
     3import static org.refal.rfpdt.parser.TkStarters.f_eop;
    44import static org.refal.rfpdt.parser.TkStarters.s_rf5_block;
    55import static org.refal.rfpdt.parser.TkStarters.s_rf5_conditions;
     
    9797        SrcPosition start = tkPos;
    9898        ArrayList<AstTopNode> topNodes = new ArrayList<AstTopNode>();
    99         while (sync(s_rf5_program, f_rf5_program)) {
     99        while (sync(s_rf5_program, f_eop)) {
    100100            if (tkIs(EXTERNAL)) {
    101101                nextTk();
    102102                extern_defs(SC, topNodes);
    103                 accept(SC, s_rf5_program | f_rf5_program);
     103                accept(SC, s_rf5_program | f_eop);
    104104            } else {
    105                 func_def(s_rf5_maybe_sc | s_rf5_program | f_rf5_program, topNodes);
    106                 acceptWOError(SC, s_rf5_program | f_rf5_program);
     105                func_def(s_rf5_maybe_sc | s_rf5_program | f_eop, topNodes);
     106                acceptWOError(SC, s_rf5_program | f_eop);
    107107            }
    108108        }
  • devel-tools/trunk/eclipse/org.refal.rfpdt.core/src/org/refal/rfpdt/parser/RfpParser.java

    r4121 r4129  
    11package org.refal.rfpdt.parser;
    22
    3 import static org.refal.rfpdt.parser.TkFollowers.f_implem;
    4 import static org.refal.rfpdt.parser.TkFollowers.f_interf;
     3import static org.refal.rfpdt.parser.TkStarters.f_eop;
    54import static org.refal.rfpdt.parser.TkStarters.s_alt;
    65import static org.refal.rfpdt.parser.TkStarters.s_const_binding;
     
    158157        nextTk();
    159158        SrcPosition start = tkPos;
    160         AstName moduleName = module_name(s_imports | s_directives | f_implem);
    161         AstUse[] useList = imports(s_directives | f_implem);
    162         AstTopNode[] topNodeList = directives(f_implem);
     159        AstName moduleName = module_name(s_imports | s_directives | f_eop);
     160        AstUse[] useList = imports(s_directives | f_eop);
     161        AstTopNode[] topNodeList = directives(f_eop);
    163162        return new AstImplem(SrcPosition.fromToInclusive(start, prevTkPos), moduleName, useList, topNodeList);
    164163    }
     
    172171        nextTk();
    173172        SrcPosition start = tkPos;
    174         AstName moduleName = module_name(s_decls | f_interf);
    175         AstTopNode[] topNodeList = decls(f_interf, true);
     173        AstName moduleName = module_name(s_decls | f_eop);
     174        AstTopNode[] topNodeList = decls(f_eop, true);
    176175        return new AstInterf(SrcPosition.fromToInclusive(start, prevTkPos), moduleName, topNodeList);
    177176    }
  • devel-tools/trunk/eclipse/org.refal.rfpdt.core/src/org/refal/rfpdt/parser/TkStarters.java

    r4127 r4129  
    77import static org.refal.rfpdt.parser.TkTags.CONST;
    88import static org.refal.rfpdt.parser.TkTags.CUT;
     9import static org.refal.rfpdt.parser.TkTags.EOP;
    910import static org.refal.rfpdt.parser.TkTags.EQL;
    1011import static org.refal.rfpdt.parser.TkTags.ERROR;
     
    3940
    4041public final class TkStarters {
     42    public static final long f_eop = EOP;
    4143    public static final long s_implem = CONST | FUNC_DECL | MODULE | NATIVE | OBJ_DECL | PUBLIC | TRACE_ALL | USE
    4244            | WORD;
  • devel-tools/trunk/eclipse/org.refal.rfpdt.core/src/org/refal/rfpdt/parser/TkTags.java

    r4120 r4129  
    11package org.refal.rfpdt.parser;
     2
     3import java.util.HashMap;
    24
    35/**
     
    4345    public static final long ENTRY = (1L << 35); // For Refal 5
    4446    public static final long EXTERNAL = (1L << 36); // For Refal 5
     47
     48    private static final HashMap<Long, String> tkImages = new HashMap<Long, String>();
     49
     50    private static void tk (long tk, String image) {
     51        tkImages.put(tk, image);
     52    }
     53
     54    static {
     55        tk(CHAR, "[char]");
     56        tk(COL, ":");
     57        tk(COL_CURL, ":");
     58        tk(COMMA, "','");
     59        tk(CONST, "$const");
     60        tk(CUT, "\\!");
     61        tk(EOP, "[file end]");
     62        tk(EQL, "=");
     63        tk(ERROR, "$error");
     64        tk(FAIL, "$fail");
     65        tk(FENCE, "\\?");
     66        tk(FUNC_DECL, "[func decl]");
     67        tk(ITER, "$iter");
     68        tk(LANGU, "<");
     69        tk(LCURL, "\\{, {");
     70        tk(LET, "::");
     71        tk(LPAR, "(");
     72        tk(MATCH_DIR, "$l, $r");
     73        tk(MODULE, "$module");
     74        tk(NATIVE, "$native");
     75        tk(NOT, "#");
     76        tk(NUMB, "[number]");
     77        tk(OBJ_DECL, "[obj decl]");
     78        tk(PUBLIC, "$public");
     79        tk(RANGU, ">");
     80        tk(RCURL, "}");
     81        tk(REF, "&");
     82        tk(RPAR, ")");
     83        tk(SC, "';'");
     84        tk(TRACE_ALL, "$trace_all");
     85        tk(TRAP, "$trap");
     86        tk(USE, "$use");
     87        tk(VAR, "[variable]");
     88        tk(WITH, "$with");
     89        tk(WORD, "[word]");
     90        tk(ENTRY, "$ENTRY");
     91        tk(EXTERNAL, "$EXTERNAL");
     92    }
     93
     94    public static String getTkImage (long tk) {
     95        String image = tkImages.get(tk);
     96        return image == null ? "???" : image;
     97    }
    4598}
Note: See TracChangeset for help on using the changeset viewer.