[Nice-commit] Nice/src/bossa/parser Parser.jj,1.245,1.246 Loader.java,1.26,1.27
Brought to you by:
bonniot
From: Arjan B. <ar...@us...> - 2004-06-29 15:14:03
|
Update of /cvsroot/nice/Nice/src/bossa/parser In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8932/F:/nice/src/bossa/parser Modified Files: Parser.jj Loader.java Log Message: Make bossa.util not depend on bossa.parser. Index: Parser.jj =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/parser/Parser.jj,v retrieving revision 1.245 retrieving revision 1.246 diff -C2 -d -r1.245 -r1.246 *** Parser.jj 24 Jun 2004 14:01:29 -0000 1.245 --- Parser.jj 29 Jun 2004 15:13:48 -0000 1.246 *************** *** 39,43 **** private static IdentExp symb(String name, Token t, boolean quoted) { ! return new IdentExp(new LocatedString(name, Location.make(t),quoted)); } private static IdentExp symb(String name, Token t) --- 39,43 ---- private static IdentExp symb(String name, Token t, boolean quoted) { ! return new IdentExp(new LocatedString(name, makeLocation(t),quoted)); } private static IdentExp symb(String name, Token t) *************** *** 60,63 **** --- 60,75 ---- throw ex; } + + private static Location makeLocation(Token t) + { + return Location.make(t.beginLine, t.beginColumn, t.endLine, t.endColumn); + } + + private static Location makeLocation(Token start, Token end) + { + return Location.make(start.beginLine, start.beginColumn, end.endLine, end.endColumn); + } + + } PARSER_END(Parser) *************** *** 401,405 **** { t=<IDENT> ! { return new LocatedString(t.image, Location.make(t)); } } --- 413,417 ---- { t=<IDENT> ! { return new LocatedString(t.image, makeLocation(t)); } } *************** *** 420,424 **** name=<BACKQUOTEDSTRING> { res = new LocatedString(name.image.substring(1, name.image.length() - 1), ! Location.make(name), true); } | res = ident() --- 432,436 ---- name=<BACKQUOTEDSTRING> { res = new LocatedString(name.image.substring(1, name.image.length() - 1), ! makeLocation(name), true); } | res = ident() *************** *** 457,461 **** )* ! { return new LocatedString(image.toString(), Location.make(start, t)); } } --- 469,473 ---- )* ! { return new LocatedString(image.toString(), makeLocation(start, t)); } } *************** *** 473,477 **** { image.append(".").append(t.image); } )+ ! { return new LocatedString(image.toString(), Location.make(start, t)); } } --- 485,489 ---- { image.append(".").append(t.image); } )+ ! { return new LocatedString(image.toString(), makeLocation(start, t)); } } *************** *** 499,503 **** { t = <FLOATING_POINT_LITERAL> ! { return new LocatedString(t.image, Location.make(t)); } } --- 511,515 ---- { t = <FLOATING_POINT_LITERAL> ! { return new LocatedString(t.image, makeLocation(t)); } } *************** *** 506,510 **** { t = <INTEGER_LITERAL> ! { return new LocatedString(t.image, Location.make(t)); } } --- 518,522 ---- { t = <INTEGER_LITERAL> ! { return new LocatedString(t.image, makeLocation(t)); } } *************** *** 572,576 **** } | { boolean sure = false; } ! [ t="Any" { User.warning(Location.make(t), "The 'Any' keyword is deprecated, leave it away."); } | "!" { sure = true; } ] --- 584,588 ---- } | { boolean sure = false; } ! [ t="Any" { User.warning(makeLocation(t), "The 'Any' keyword is deprecated, leave it away."); } | "!" { sure = true; } ] *************** *** 660,664 **** return new MonotypeConstructor(t,new TypeParameters(p), ! Location.make(first, last)); } } --- 672,676 ---- return new MonotypeConstructor(t,new TypeParameters(p), ! makeLocation(first, last)); } } *************** *** 691,697 **** Monotype res; if (domain != null) ! res = new TupleType(domain, Location.make(start, end)); else ! res = new TypeIdent(new LocatedString("void",Location.make(start, end))); res.nullness = res.absent; --- 703,709 ---- Monotype res; if (domain != null) ! res = new TupleType(domain, makeLocation(start, end)); else ! res = new TypeIdent(new LocatedString("void",makeLocation(start, end))); res.nullness = res.absent; *************** *** 770,774 **** | start="alike" [ "<" p=monotypes() ">" ] ! { res=new Alike(p, Location.make(start)); } { res.nullness = res.absent; } | --- 782,786 ---- | start="alike" [ "<" p=monotypes() ">" ] ! { res=new Alike(p, makeLocation(start)); } { res.nullness = res.absent; } | *************** *** 824,828 **** ( "," part = ParameterTuplePart(statements, types) { parts.add(part); } )+ last=")" ! { Monotype t = new TupleType(types, Location.make(first, last)); t.nullness = Monotype.absent; monotypes.add(t); --- 836,840 ---- ( "," part = ParameterTuplePart(statements, types) { parts.add(part); } )+ last=")" ! { Monotype t = new TupleType(types, makeLocation(first, last)); t.nullness = Monotype.absent; monotypes.add(t); *************** *** 863,872 **** { if (id == null) { ident = new LocatedString("tuple_arg_" + first.beginLine + "_" + first.beginColumn, ! Location.make(first, last)); } else { ident = id; } Expression exp = AssignExp.create(new TupleExp(parts),new IdentExp(ident)); ! exp.setLocation(Location.make(first,last)); statements.add(new ExpressionStmt(exp)); ! t = new TupleType(types, Location.make(first, last)); t.nullness = Monotype.absent; if (val != null) --- 875,884 ---- { if (id == null) { ident = new LocatedString("tuple_arg_" + first.beginLine + "_" + first.beginColumn, ! makeLocation(first, last)); } else { ident = id; } Expression exp = AssignExp.create(new TupleExp(parts),new IdentExp(ident)); ! exp.setLocation(makeLocation(first,last)); statements.add(new ExpressionStmt(exp)); ! t = new TupleType(types, makeLocation(first, last)); t.nullness = Monotype.absent; if (val != null) *************** *** 1167,1171 **** if (prefix != Constraint.True && atoms.size() > 0) throw bossa.util.User.error ! (Location.make(start), "Constraints on type parameters should all be specified in the prefix constraint"); MonotypeVar[] b = (MonotypeVar[]) binders.toArray(new MonotypeVar[binders.size()]); --- 1179,1183 ---- if (prefix != Constraint.True && atoms.size() > 0) throw bossa.util.User.error ! (makeLocation(start), "Constraints on type parameters should all be specified in the prefix constraint"); MonotypeVar[] b = (MonotypeVar[]) binders.toArray(new MonotypeVar[binders.size()]); *************** *** 1593,1597 **** { t="null" ! { return NullExp.create(Location.make(t)); } } --- 1605,1609 ---- { t="null" ! { return NullExp.create(makeLocation(t)); } } *************** *** 1599,1604 **** { Token t; } { ! t = "true" { return ConstantExp.makeBoolean(true, Location.make(t)); } ! | t = "false" { return ConstantExp.makeBoolean(false, Location.make(t)); } } --- 1611,1616 ---- { Token t; } { ! t = "true" { return ConstantExp.makeBoolean(true, makeLocation(t)); } ! | t = "false" { return ConstantExp.makeBoolean(false, makeLocation(t)); } } *************** *** 1632,1636 **** { return ConstantExp.makeChar (new LocatedString(t.image.substring(1, t.image.length() - 1), ! Location.make(t))); } } --- 1644,1648 ---- { return ConstantExp.makeChar (new LocatedString(t.image.substring(1, t.image.length() - 1), ! makeLocation(t))); } } *************** *** 1683,1687 **** arguments = arguments(false) { e = new NewExp(classe, arguments); ! e.setLocation(Location.make(t)); return e; } --- 1695,1699 ---- arguments = arguments(false) { e = new NewExp(classe, arguments); ! e.setLocation(makeLocation(t)); return e; } *************** *** 1736,1745 **** { if (ident == null) { name = new LocatedString("tuple_arg_" + first.beginLine + "_" + first.beginColumn, ! Location.make(first, last)); } else { name = ident; } Expression exp = AssignExp.create(new TupleExp(parts),new IdentExp(name)); ! exp.setLocation(Location.make(first,last)); statements.add(new ExpressionStmt(exp)); ! type = new TupleType(types, Location.make(first, last)); type.nullness = Monotype.absent; return new MonoSymbol(name, type); --- 1748,1757 ---- { if (ident == null) { name = new LocatedString("tuple_arg_" + first.beginLine + "_" + first.beginColumn, ! makeLocation(first, last)); } else { name = ident; } Expression exp = AssignExp.create(new TupleExp(parts),new IdentExp(name)); ! exp.setLocation(makeLocation(first,last)); statements.add(new ExpressionStmt(exp)); ! type = new TupleType(types, makeLocation(first, last)); type.nullness = Monotype.absent; return new MonoSymbol(name, type); *************** *** 1918,1922 **** e1=ConditionalExpression() [ ! { e1.setLocation(Location.make(first, getToken(0))); } op=AssignmentOperator() e2=Expression() --- 1930,1934 ---- e1=ConditionalExpression() [ ! { e1.setLocation(makeLocation(first, getToken(0))); } op=AssignmentOperator() e2=Expression() *************** *** 1931,1935 **** { last=getToken(0); ! e1.setLocation(Location.make(first, last)); return e1; } --- 1943,1947 ---- { last=getToken(0); ! e1.setLocation(makeLocation(first, last)); return e1; } *************** *** 1963,1967 **** [ "?" e1=Expression() start=":" e2=ConditionalExpression() ! { e2.setLocation(Location.make(start, getToken(0))); res=new IfExp(res,e1,e2); } ] --- 1975,1979 ---- [ "?" e1=Expression() start=":" e2=ConditionalExpression() ! { e2.setLocation(makeLocation(start, getToken(0))); res=new IfExp(res,e1,e2); } ] *************** *** 2055,2059 **** e1=CallExp.create(symb("&&",t),e1,CallExp.create(symb(t),e3,e2)); if (t.image.charAt(0) != t_prev.image.charAt(0)) ! User.error(Location.make(t), "All chained comparisons should be in the same direction"); } e3 = e2; --- 2067,2071 ---- e1=CallExp.create(symb("&&",t),e1,CallExp.create(symb(t),e3,e2)); if (t.image.charAt(0) != t_prev.image.charAt(0)) ! User.error(makeLocation(t), "All chained comparisons should be in the same direction"); } e3 = e2; *************** *** 2174,2178 **** res=PrimaryPrefix() ( res=PrimarySuffix(res) )* ! { res.setLocation(Location.make(first, getToken(0))); return res; } } --- 2186,2190 ---- res=PrimaryPrefix() ( res=PrimarySuffix(res) )* ! { res.setLocation(makeLocation(first, getToken(0))); return res; } } *************** *** 2358,2362 **** ) { ! res.setLocation(Location.make(first, getToken(0))); return res; } --- 2370,2374 ---- ) { ! res.setLocation(makeLocation(first, getToken(0))); return res; } *************** *** 2395,2399 **** last = getToken(0); Statement res = new Block(statements); ! res.setLocation(Location.make(first, last)); return res; } --- 2407,2411 ---- last = getToken(0); Statement res = new Block(statements); ! res.setLocation(makeLocation(first, last)); return res; } *************** *** 2479,2483 **** "=" e=Expression() ";" { Expression exp = AssignExp.create(new TupleExp(parts), e); ! exp.setLocation(Location.make(first,last)); return new ExpressionStmt(exp); } } --- 2491,2495 ---- "=" e=Expression() ";" { Expression exp = AssignExp.create(new TupleExp(parts), e); ! exp.setLocation(makeLocation(first,last)); return new ExpressionStmt(exp); } } *************** *** 2587,2591 **** { last = getToken(0); ! e1.setLocation(Location.make(first, last)); return new ExpressionStmt(e1); } --- 2599,2603 ---- { last = getToken(0); ! e1.setLocation(makeLocation(first, last)); return new ExpressionStmt(e1); } *************** *** 2617,2621 **** { last = getToken(0); ! e1.setLocation(Location.make(first, last)); return new ExpressionStmt(e1); } --- 2629,2633 ---- { last = getToken(0); ! e1.setLocation(makeLocation(first, last)); return new ExpressionStmt(e1); } *************** *** 2632,2636 **** | { Token op; Expression e2; ! e1.setLocation(Location.make(first, getToken(0))); } op=AssignmentOperator() --- 2644,2648 ---- | { Token op; Expression e2; ! e1.setLocation(makeLocation(first, getToken(0))); } op=AssignmentOperator() *************** *** 2659,2663 **** ifExp = new IfExp(cond, new StatementExp(s1), (s2 == null ? null : new StatementExp(s2))); ! ifExp.setLocation(Location.make(first, getToken(0))); return new ExpressionStmt(ifExp); } --- 2671,2675 ---- ifExp = new IfExp(cond, new StatementExp(s1), (s2 == null ? null : new StatementExp(s2))); ! ifExp.setLocation(makeLocation(first, getToken(0))); return new ExpressionStmt(ifExp); } *************** *** 2677,2681 **** ifExp = new IfExp(cond, new StatementExp(s1), (s2 == null ? null : new StatementExp(s2))); ! ifExp.setLocation(Location.make(first, getToken(0))); return new ExpressionStmt(ifExp); } --- 2689,2693 ---- ifExp = new IfExp(cond, new StatementExp(s1), (s2 == null ? null : new StatementExp(s2))); ! ifExp.setLocation(makeLocation(first, getToken(0))); return new ExpressionStmt(ifExp); } *************** *** 2736,2740 **** t=":" container=Expression() ")" body=Statement() ! { return LoopStmt.forInLoop(vartype,var,Location.make(t),container,body); } } --- 2748,2752 ---- t=":" container=Expression() ")" body=Statement() ! { return LoopStmt.forInLoop(vartype,var,makeLocation(t),container,body); } } *************** *** 2779,2783 **** { Statement res = new ReturnStmt(val); ! res.setLocation(Location.make(t)); return res; } --- 2791,2795 ---- { Statement res = new ReturnStmt(val); ! res.setLocation(makeLocation(t)); return res; } Index: Loader.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/parser/Loader.java,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -d -r1.26 -r1.27 *** Loader.java 20 Feb 2004 13:10:30 -0000 1.26 --- Loader.java 29 Jun 2004 15:13:51 -0000 1.27 *************** *** 86,90 **** token = token.next; ! User.error(Location.make(token), removeLocation(e.getMessage())); } else --- 86,91 ---- token = token.next; ! User.error(Location.make(token.beginLine, token.beginColumn), ! removeLocation(e.getMessage())); } else |