Changeset 422


Ignore:
Timestamp:
Jun 12, 2010 11:07:43 PM (14 years ago)
Author:
Anya Helene Bagge
Message:

Update to new Rascal version

Location:
MetaXa/src
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • MetaXa/src/MagnoliaCxxBack.rsc

    r379 r422  
    66public XaTree cxxFormat(XaTree tree) {
    77        return visit(tree) {
    8                 case d: cons("Param", [ID, TYPE], s) => d[@concrete=[token("const"), layout(" "), child(1), token("&"), layout(" "), child(0)]]
     8                case d: cons("Param", [ID, TYPE], s) => d[@concrete=[token("const"), space(" "), child(1), token("&"), space(" "), child(0)]]
    99                case d: cons("FunClause", [NAME, ARGS, TYPE], s) =>
    10                                 d[@concrete = [child(2), layout(" "), child(0), child(1)]]
     10                                d[@concrete = [child(2), space(" "), child(0), child(1)]]
    1111//              case d: cons("PredClause", [NAME, ARGS], s) =>
    12 //                              d[@concrete = [token("predicate"), layout(" "), child(0), token("("), child(1), token(")")]]
     12//                              d[@concrete = [token("predicate"), space(" "), child(0), token("("), child(1), token(")")]]
    1313//              case d: cons("AxiomClause", [NAME, ARGS], s) =>
    14 //                              d[@concrete = [token("axiom"), layout(" "), child(0), token("("), child(1), token(")")]]
     14//                              d[@concrete = [token("axiom"), space(" "), child(0), token("("), child(1), token(")")]]
    1515                case d: cons("ProcClause", [NAME, ARGS], s) =>
    16                                 d[@concrete = [token("void"), layout(" "), child(0), child(1)]]
     16                                d[@concrete = [token("void"), space(" "), child(0), child(1)]]
    1717                case d: cons("TypeClause", [NAME], s) =>
    18                                 d[@concrete = [token("struct"), layout(" "), child(0)]]
     18                                d[@concrete = [token("struct"), space(" "), child(0)]]
    1919                case d: cons("VarClause", [NAME, TYPE], s) =>
    20                                 d[@concrete = [child(1), layout(" "), child(0)]]
     20                                d[@concrete = [child(1), space(" "), child(0)]]
    2121                case n: cons("Name",[leaf(op, "ID")], "Identifier"):
    2222                                if([opname] := getOpName(op))
  • MetaXa/src/MetaXa.rsc

    r396 r422  
    120120                                }
    121121                                default:
    122                                         println("Unknown section '<S>'");
     122                                        println("Unknown section \'<S>\'");
    123123                        }
    124124                }
     
    168168
    169169/** Compile a list of sugar definitions to Rascal desugar/ensugar rules */
    170 public str compileSugar(list[Tree] ss, str lang, bool concrete, str to, str from) {
     170public str compileSugar(list[Tree] ss, str language, bool concrete, str to, str from) {
    171171        str treeType = concrete ? "Tree" : "XaTree";
    172         str desugar = "/** Returns a desugared tree. */\npublic <treeType> <to><lang>(<treeType> tree) {\n\treturn visit(tree) {\n";
    173         str ensugar = "/** Returns an ensugared tree. */\npublic <treeType> <from><lang>(<treeType> tree) {\n\treturn visit(tree) {\n";
     172        str desugar = "/** Returns a desugared tree. */\npublic <treeType> <to><language>(<treeType> tree) {\n\treturn visit(tree) {\n";
     173        str ensugar = "/** Returns an ensugared tree. */\npublic <treeType> <from><language>(<treeType> tree) {\n\treturn visit(tree) {\n";
    174174        str sdf = "";
    175175        int ruleCount = 0;
     
    257257                        return;
    258258                else
    259                         throw UnboundVariable("Unbound variables in rule '<r>'", ["<v>" | v <- rhsVars-lhsVars]);
     259                        throw UnboundVariable("Unbound variables in rule \'<r>\'", ["<v>" | v <- rhsVars-lhsVars]);
    260260        }
    261261        else if(arrow == "\<-") {
     
    263263                        return;
    264264                else
    265                         throw UnboundVariable("Unbound variables in rule '<r>'",  ["<v>" | v <- rhsVars-lhsVars]);
     265                        throw UnboundVariable("Unbound variables in rule \'<r>\'",  ["<v>" | v <- rhsVars-lhsVars]);
    266266        }
    267267        else
    268                 throw UnboundVariable("Unbound variables in rule '<r>'",  ["<v>" | v <- (lhsVars-rhsVars)+(rhsVars-lhsVars)]);
     268                throw UnboundVariable("Unbound variables in rule \'<r>\'",  ["<v>" | v <- (lhsVars-rhsVars)+(rhsVars-lhsVars)]);
    269269}
    270270
     
    313313        for(Tree t <- ts) {
    314314                //if(i > 0)
    315                 //      ss += [layout(" ")];
     315                //      ss += [space(" ")];
    316316                switch(t) {
    317317                        case (MXaToken)`<VarToken v>`:  { ss +=  [child(i)]; i += 1; }
     
    319319                        case (MXaToken)`"<MXaSYMBOL s>"`: ss += [token("<s>")];
    320320                        case MXaToken _: ss += [token("<t>")];
    321                         default:        ss += [layout("<t>")];
     321                        default:        ss += [space("<t>")];
    322322                }
    323323        }
  • MetaXa/src/RascalAbstractBackend.rsc

    r392 r422  
    1616                        return ""; // "public " + rt + " " + n + "(" + strJoin([p | p <- ps], ", ") + ");";
    1717                default:
    18                         throw IllegalASTFormat("Don't know what to do with decl '<d>'");
     18                        throw IllegalASTFormat("Don\'t know what to do with decl \'<d>\'");
    1919        }
    2020}
     
    4848                        return "throw Failure();\n";
    4949                default:
    50                         throw IllegalASTFormat("Don't know what to do with clause '<s>'");
     50                        throw IllegalASTFormat("Don\'t know what to do with clause \'<s>\'");
    5151        }
    5252}
     
    7777                        return "[" + pp(r) + " | " + pp(v) + " \<- " + s + "]";
    7878                default:
    79                         throw IllegalASTFormat("Don't know what to do with expr '<e>'");
     79                        throw IllegalASTFormat("Don\'t know what to do with expr \'<e>\'");
    8080        }
    8181}
  • MetaXa/src/RascalBackend.rsc

    r360 r422  
    1515                        return ""; // "public " + rt + " " + n + "(" + strJoin([p | p <- ps], ", ") + ");";
    1616                default:
    17                         throw IllegalASTFormat("Don't know what to do with decl '<d>'");
     17                        throw IllegalASTFormat("Don\'t know what to do with decl \'<d>\'");
    1818        }
    1919}
     
    4747                        return "throw Failure();\n";
    4848                default:
    49                         throw IllegalASTFormat("Don't know what to do with clause '<s>'");
     49                        throw IllegalASTFormat("Don\'t know what to do with clause \'<s>\'");
    5050        }
    5151}
     
    7676                        return "[" + pp(r) + " | " + pp(v) + " \<- " + s + "]";
    7777                default:
    78                         throw IllegalASTFormat("Don't know what to do with expr '<e>'");
     78                        throw IllegalASTFormat("Don\'t know what to do with expr \'<e>\'");
    7979        }
    8080}
  • MetaXa/src/XaLib.rsc

    r413 r422  
    127127        assert notAmb(t);
    128128        for(i <- [0 .. size(t.prod.lhs)])
    129                 if(cf(opt(layout())) := t.prod.lhs[i])
     129                if(cf(opt(\layout())) := t.prod.lhs[i])
    130130                        ;
    131131                else if(cf(_) := t.prod.lhs[i]) {
     
    172172
    173173public str varRename(str n) {
    174         return replaceAll(n, "'", "_");
     174        return replaceAll(n, "\'", "_");
    175175}
    176176
     
    182182
    183183public str varUnrename(str n) {
    184         return replaceAll(n, "_", "'");
     184        return replaceAll(n, "_", "\'");
    185185}
    186186
     
    243243                }
    244244                a = getOneFrom(alts);
    245                 println("  In sentence: '<a>'");
     245                println("  In sentence: \'<a>\'");
    246246                return false;
    247247        }
  • MetaXa/src/XaRules.rsc

    r396 r422  
    1515
    1616        visit(rules) {
    17                 case cf(sort(s)):
     17                case \cf(sort(s)):
    1818                        sorts += {s};
    1919        }
     
    2525                        case (MXaOpDecl)`<NAME>: <{MXaType ","}* TYPES> -> <TYPE>`:
    2626                                rs += opDecl("<NAME>", "<TYPE>", ["<t>" | t <- TYPES]);
    27                         case appl(prod(_,cf(opt(layout())),_),_):
     27                        case appl(prod(_,\cf(opt(\layout())),_),_):
    2828                                ;
    2929                        default:
     
    9494                        case appl(prod(_,lit(_),_),_):
    9595                                ;
    96                         case appl(prod(_,cf(opt(layout())),_),_):
     96                        case appl(prod(_,\cf(opt(\layout())),_),_):
    9797                                ;
    9898                        default:
     
    120120                }
    121121                case ruleDef(ps,c): {
    122                         throw IllegalASTFormat("Don't know what to do with rule conclusion <c>");
     122                        throw IllegalASTFormat("Don\'t know what to do with rule conclusion <c>");
    123123                }
    124124        }
     
    299299                        return c1;
    300300                default:
    301                         throw IllegalASTFormat("Don't know what to do with <d>");
     301                        throw IllegalASTFormat("Don\'t know what to do with <d>");
    302302        }
    303303}
     
    352352        }
    353353        else
    354                 throw IllegalASTFormat("Don't know what to do with <d>");
     354                throw IllegalASTFormat("Don\'t know what to do with <d>");
    355355}
    356356
     
    362362
    363363                        if(!typeEq(ptype, etype, ())[0])
    364                                 println("Pattern type doesn't match expression: <ptype> := <etype> in <pat> := <expr>");
     364                                println("Pattern type doesn\'t match expression: <ptype> := <etype> in <pat> := <expr>");
    365365
    366366                        env1 = env + envOf(pat);
     
    404404                        return <failure(), "?">;
    405405                default:
    406                         throw IllegalASTFormat("Don't know what to do with clause <c>");
     406                        throw IllegalASTFormat("Don\'t know what to do with clause <c>");
    407407        }
    408408}
     
    426426                }
    427427                default:
    428                         throw IllegalASTFormat("Don't know what to do with expr <e>");
     428                        throw IllegalASTFormat("Don\'t know what to do with expr <e>");
    429429
    430430        }
     
    461461                }
    462462                default:
    463                         throw IllegalASTFormat("Don't know what to do with expr <e>");
     463                        throw IllegalASTFormat("Don\'t know what to do with expr <e>");
    464464        }
    465465}
  • MetaXa/src/XaTree.rsc

    r420 r422  
    2020data XaToken =
    2121          token(str chars)    // a literal
    22         | layout(str chars)   // whitespace
     22        | space(str chars)   // whitespace
    2323        | comment(str chars)  // non-whitespace layout
    2424        | child(int index);   // reference to child node
     
    4040        switch(t) {
    4141                // leaf nodes
    42                 case appl(prod([\lex(_)], cf(s), _), args): {
     42                case \appl(\prod([\lex(_)], \cf(s), _), args): {
    4343                        result = leaf(unparse(args[0]), sortName(s));
    4444                        concrete = [token(unparse(args[0]))];
     
    4646                // injection
    4747                // TODO: should deal with attributes
    48                 case appl(prod([cf(_)], cf(s), \no-attrs()), args): {
     48                case \appl(\prod([\cf(_)], \cf(s), \no-attrs()), args): {
    4949                        result = implodeTree(args[0], opts);
    5050                        if(!opts.foldInjections) {
     
    5454                }
    5555                // an injection which gets the type of the outer production
    56                 case appl(prod([cf(_)], cf(s), attrs([_*,term(abstract()),_*])), args): {
     56                case \appl(\prod([\cf(_)], \cf(s), \attrs([_*,\term(\abstract()),_*])), args): {
    5757                        result = implodeTree(args[0], opts);
    5858                        if(opts.foldInjections)
     
    6464                }
    6565                // alternative choice
    66                 case appl(prod(_, cf(alt(_,_)), _), [arg]): {
     66                case \appl(\prod(_, \cf(\alt(_,_)), _), [arg]): {
    6767                        return implodeTree(arg, opts);
    6868                }
    6969                // option -- none
    70                 case appl(prod([], cf(opt(s)), _), []): {
     70                case \appl(\prod([], \cf(\opt(s)), _), []): {
    7171                        result = seq([], sortName(s));
    7272                        concrete = [];
    7373                }
    7474                // option -- some
    75                 case appl(prod([_], cf(opt(s)), _), [arg]): {
     75                case \appl(\prod([_], \cf(\opt(s)), _), [arg]): {
    7676                        result = seq([implodeTree(arg, opts)], sortName(s));
    7777                        concrete = [child(0)];
    7878                }
    7979                // normal node
    80                 case appl(prod(lhs,cf(s),_), args): {
     80                case \appl(\prod(\lhs,\cf(s),_), args): {
    8181                        name = consOf(t) ? sortName(s);
    8282                        if(name in opts.varConses) {
     
    9494                }
    9595                // list/sequence
    96                 case appl(list(s), args): {
     96                case \appl(\list(s), args): {
    9797                        <astArgs, concrete> = implodeArgList(args);
    9898                        result = seq(astArgs, sortOfList(s));
     
    100100                // ambiguity
    101101                // TODO: don't use println for reporting
    102                 case amb(alts): {
     102                case \amb(alts): {
    103103                        println("Ambiguity detected:");
    104104                        for(a <- alts) {
     
    106106                        }
    107107                        a = getOneFrom(alts);
    108                         println("  In sentence: '<a>'");
     108                        println("  In sentence: \'<a>\'");
    109109                        println("  Proceeding with:\n    <a.prod.rhs> ::= <a.prod.lhs ? a.prod>");
    110110                        result = implodeTree(getOneFrom(alts), opts);
     
    136136                try {
    137137                        switch(ts[i].prod.rhs ? []) {
    138                                 case cf(opt(layout())): {
     138                                case \cf(opt(\layout())): {
    139139                                        l = unparse(ts[i]);
    140140                                        if(false && /^<before:\s*><com:\S(.|\r|\n)*\S><after:\s*>$/ := l) {
    141141                                                if(before != "")
    142                                                         cstArgs += layout(before);
     142                                                        cstArgs += space(before);
    143143                                                if(com != "")
    144144                                                        cstArgs += comment(com);
    145145                                                if(after != "")
    146                                                         cstArgs += layout(after);
     146                                                        cstArgs += space(after);
    147147                                        }
    148148                                        else
    149                                                         cstArgs += layout(l);
     149                                                        cstArgs += space(l);
    150150                                }
    151151                                case lit(_):
     
    174174                        return toTerm(a);
    175175                case leaf(l, _):
    176                         return "'" + l + "'";
     176                        return "\'" + l + "\'";
    177177        }
    178178}
     
    196196                        case token(t):
    197197                                result += t;
    198                         case layout(l):
     198                        case space(l):
    199199                                result += l;
    200200                        case comment(c):
     
    233233                        return <tree, substring(l, 0, 1) ? "", substring(l, size(l)-1) ? lastChar>;
    234234                default:
    235                         tree@concrete = [x | x <- tree@concrete, layout(_) !:= x];
     235                        tree@concrete = [x | x <- tree@concrete, space(_) !:= x];
    236236        }
    237237       
     
    243243        for(tok <- tree@concrete) {
    244244                if(concPat != [])
    245                         space = [layout(" ")];
     245                        space = [space(" ")];
    246246                if(lastChar == "\n") {
    247247                        if(indent != "")
    248                                 concPat += [layout(indent)];
     248                                concPat += [space(indent)];
    249249                        space = [];
    250250                        lastChar = "\t";
     
    256256
    257257                switch(tok) {
    258                         case layout(l):
     258                        case space(l):
    259259                                        space = [];
    260260                        case comment(c): {
    261261                                firstChar = firstChar ? "#";
    262262                                chars += "#";
    263                                 toks += layout("\n");
     263                                toks += space("\n");
    264264                                lastChar = "\n";
    265265                        }
     
    280280                                if(seq(_,s) := tree.args[i] && s in vertSorts) {
    281281                                        if(s in sectSorts)
    282                                                 toks = [layout("\n"), tok];
     282                                                toks = [space("\n"), tok];
    283283                                        <tree.args[i], fc, lastChar> = reindent(tree.args[i], indent + "\t", lastChar);
    284284                                }
    285285                                else if(cons(_,_,s) := tree.args[i] && s in vertSorts) {
    286286                                        if(lastChar != "\t") { // add newline and indent
    287                                                 toks = [layout((lastChar == "\n") ? indent : "\n" + indent), tok];
     287                                                toks = [space((lastChar == "\n") ? indent : "\n" + indent), tok];
    288288                                                space = [];
    289289                                        }
    290290                                        <tree.args[i], fc, _> = reindent(tree.args[i], indent, "\t");
    291                                         toks += layout("\n");
     291                                        toks += space("\n");
    292292                                        if(s in sectSorts)
    293                                                 toks += layout("\n");
     293                                                toks += space("\n");
    294294                                        lastChar = "\n";
    295295                                }
Note: See TracChangeset for help on using the changeset viewer.