Update of /cvsroot/nice/Nice/src/bossa/parser
In directory sc8-pr-cvs1:/tmp/cvs-serv20812/src/bossa/parser
Modified Files:
Parser.jj Loader.java
Log Message:
Refactored bossa.util.Location, to provide a higher-level view on locations,
using several subclasses for the different cases.
Index: Parser.jj
===================================================================
RCS file: /cvsroot/nice/Nice/src/bossa/parser/Parser.jj,v
retrieving revision 1.189
retrieving revision 1.190
diff -C2 -d -r1.189 -r1.190
*** Parser.jj 19 Jun 2003 15:57:23 -0000 1.189
--- Parser.jj 24 Jun 2003 15:28:19 -0000 1.190
***************
*** 38,42 ****
private static IdentExp symb(String name, Token t, boolean quoted)
{
! return new IdentExp(new LocatedString(name,new Location(t),quoted));
}
private static IdentExp symb(String name, Token t)
--- 38,42 ----
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)
***************
*** 370,374 ****
{
t=<IDENT>
! { return new LocatedString(t.image,new Location(t)); }
}
--- 370,374 ----
{
t=<IDENT>
! { return new LocatedString(t.image, Location.make(t)); }
}
***************
*** 391,395 ****
name=<BACKQUOTEDSTRING>
{ res = new LocatedString(name.image.substring(1, name.image.length() - 1),
! new Location(name),
true); }
|
--- 391,395 ----
name=<BACKQUOTEDSTRING>
{ res = new LocatedString(name.image.substring(1, name.image.length() - 1),
! Location.make(name),
true); }
|
***************
*** 420,438 ****
LocatedString doted_string():
{
! Token t;
StringBuffer image;
- Location loc;
}
{
! t = <IDENT>
! { image = new StringBuffer(t.image); loc = new Location(t); }
( LOOKAHEAD(2) // needed to distinguish with ".class"
"." t=doted_string_component()
! { image.append(".").append(t.image);
! loc.englobe(new Location(t)); }
)*
! { return new LocatedString(image.toString(), loc); }
}
--- 420,436 ----
LocatedString doted_string():
{
! Token start, t;
StringBuffer image;
}
{
! start = <IDENT>
! { t = start; image = new StringBuffer(start.image); }
( LOOKAHEAD(2) // needed to distinguish with ".class"
"." t=doted_string_component()
! { image.append(".").append(t.image); }
)*
! { return new LocatedString(image.toString(), Location.make(start, t)); }
}
***************
*** 440,458 ****
LocatedString fullyQualifiedName():
{
! Token t;
StringBuffer image;
- Location loc;
}
{
! t = <IDENT>
! { image = new StringBuffer(t.image); loc = new Location(t); }
( LOOKAHEAD(2) // needed to distinguish with ".class"
"." t=doted_string_component()
! { image.append(".").append(t.image);
! loc.englobe(new Location(t)); }
)+
! { return new LocatedString(image.toString(), loc); }
}
--- 438,454 ----
LocatedString fullyQualifiedName():
{
! Token start, t;
StringBuffer image;
}
{
! start = <IDENT>
! { t = start; image = new StringBuffer(t.image); }
( LOOKAHEAD(2) // needed to distinguish with ".class"
"." t=doted_string_component()
! { image.append(".").append(t.image); }
)+
! { return new LocatedString(image.toString(), Location.make(start, t)); }
}
***************
*** 484,488 ****
{
t = <FLOATING_POINT_LITERAL>
! { return new LocatedString(t.image, new Location(t)); }
}
--- 480,484 ----
{
t = <FLOATING_POINT_LITERAL>
! { return new LocatedString(t.image, Location.make(t)); }
}
***************
*** 493,497 ****
{
t = <INTEGER_LITERAL>
! { return new LocatedString(t.image, new Location(t)); }
}
--- 489,493 ----
{
t = <INTEGER_LITERAL>
! { return new LocatedString(t.image, Location.make(t)); }
}
***************
*** 708,712 ****
return new MonotypeConstructor(t,new TypeParameters(p),
! new Location(first, last));
}
}
--- 704,708 ----
return new MonotypeConstructor(t,new TypeParameters(p),
! Location.make(first, last));
}
}
***************
*** 739,745 ****
Monotype res;
if (domain != null)
! res = new TupleType(domain, new Location(start, end));
else
! res = new TypeIdent(new LocatedString("void",new Location(start, end)));
res.nullness = res.absent;
--- 735,741 ----
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;
***************
*** 751,755 ****
{ Monotype res; }
{
-
res = simpleMonotype()
res = arrayMonotype(res)
--- 747,750 ----
***************
*** 797,801 ****
List tp = new LinkedList();
tp.add(res);
! Location loc = res.location().englobe(new Location(end));
res = new MonotypeConstructor
(new TypeIdent(new LocatedString("nice.lang.Array", loc)),
--- 792,796 ----
List tp = new LinkedList();
tp.add(res);
! Location loc = res.location();
res = new MonotypeConstructor
(new TypeIdent(new LocatedString("nice.lang.Array", loc)),
***************
*** 824,828 ****
|
start="alike" [ "<" p=monotypes() ">" ]
! { res=new Alike(p, new Location(start)); }
{ res.nullness = res.absent; }
|
--- 819,823 ----
|
start="alike" [ "<" p=monotypes() ">" ]
! { res=new Alike(p, Location.make(start)); }
{ res.nullness = res.absent; }
|
***************
*** 880,884 ****
( "," part = ParameterTuplePart(statements, types) { parts.add(part); } )+
last=")"
! { Monotype t = new TupleType(types, new Location(first, last));
t.nullness = Monotype.absent;
monotypes.add(t);
--- 875,879 ----
( "," part = ParameterTuplePart(statements, types) { parts.add(part); } )+
last=")"
! { Monotype t = new TupleType(types, Location.make(first, last));
t.nullness = Monotype.absent;
monotypes.add(t);
***************
*** 919,928 ****
{ if (id == null) {
ident = new LocatedString("tuple_arg_" + first.beginLine + "_" +
first.beginColumn,
! new Location(first, last));
} else { ident = id; }
Expression exp = AssignExp.create(new TupleExp(parts),new
IdentExp(ident));
! exp.setLocation(new Location(first,last));
statements.add(new ExpressionStmt(exp));
! t = new TupleType(types, new Location(first, last));
t.nullness = Monotype.absent;
if (val != null)
--- 914,923 ----
{ 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)
***************
*** 1026,1030 ****
{ isFinal=true;
if (t!=null)
! User.warning(new Location(t),
"'const' is deprecated. Use 'final' instead.");
}
--- 1021,1025 ----
{ isFinal=true;
if (t!=null)
! User.warning(Location.make(t),
"'const' is deprecated. Use 'final' instead.");
}
***************
*** 1359,1363 ****
[ { Token t; }
t="<" binders=strings() ">"
! { User.warning(new Location(t),
"This syntax is deprecated.\n" +
"Type parameters should now be placed in front of the method
implementation.");
--- 1354,1358 ----
[ { Token t; }
t="<" binders=strings() ">"
! { User.warning(Location.make(t),
"This syntax is deprecated.\n" +
"Type parameters should now be placed in front of the method
implementation.");
***************
*** 1606,1611 ****
}
{
! t = "true" { return ConstantExp.makeBoolean(true, new Location(t)); }
! | t = "false" { return ConstantExp.makeBoolean(false, new Location(t)); }
}
--- 1601,1606 ----
}
{
! t = "true" { return ConstantExp.makeBoolean(true, Location.make(t)); }
! | t = "false" { return ConstantExp.makeBoolean(false, Location.make(t)); }
}
***************
*** 1636,1640 ****
{ return ConstantExp.makeChar
(new LocatedString(t.image.substring(1, t.image.length() - 1),
! new Location(t)));
}
}
--- 1631,1635 ----
{ return ConstantExp.makeChar
(new LocatedString(t.image.substring(1, t.image.length() - 1),
! Location.make(t)));
}
}
***************
*** 1671,1675 ****
arguments = arguments(false)
{ e = new NewExp(classe, arguments);
! e.setLocation(new Location(t));
return e;
}
--- 1666,1670 ----
arguments = arguments(false)
{ e = new NewExp(classe, arguments);
! e.setLocation(Location.make(t));
return e;
}
***************
*** 1721,1730 ****
{ if (ident == null) {
name = new LocatedString("tuple_arg_" + first.beginLine + "_" +
first.beginColumn,
! new Location(first, last));
} else { name = ident; }
Expression exp = AssignExp.create(new TupleExp(parts),new IdentExp(name));
! exp.setLocation(new Location(first,last));
statements.add(new ExpressionStmt(exp));
! type = new TupleType(types, new Location(first, last));
type.nullness = Monotype.absent;
return new MonoSymbol(name, type);
--- 1716,1725 ----
{ 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);
***************
*** 1921,1925 ****
{
last=getToken(0);
! e1.setLocation(new Location(first, last));
return e1;
}
--- 1916,1920 ----
{
last=getToken(0);
! e1.setLocation(Location.make(first, last));
return e1;
}
***************
*** 1931,1935 ****
e1=ConditionalExpression()
[
! { e1.setLocation(new Location(start, getToken(0))); }
op=AssignmentOperator()
e2=Expression()
--- 1926,1930 ----
e1=ConditionalExpression()
[
! { e1.setLocation(Location.make(start, getToken(0))); }
op=AssignmentOperator()
e2=Expression()
***************
*** 1971,1975 ****
[
"?" e1=Expression() start=":" e2=ConditionalExpression()
! { e2.setLocation(new Location(start, getToken(0)));
res=new IfExp(res,e1,e2); }
]
--- 1966,1970 ----
[
"?" e1=Expression() start=":" e2=ConditionalExpression()
! { e2.setLocation(Location.make(start, getToken(0)));
res=new IfExp(res,e1,e2); }
]
***************
*** 2455,2459 ****
{
last = getToken(0);
! res.setLocation(new Location(first, last));
}
return res;
--- 2450,2454 ----
{
last = getToken(0);
! res.setLocation(Location.make(first, last));
}
return res;
***************
*** 2489,2493 ****
last = getToken(0);
Statement res = new Block(statements);
! res.setLocation(new Location(first, last));
return res;
}
--- 2484,2488 ----
last = getToken(0);
Statement res = new Block(statements);
! res.setLocation(Location.make(first, last));
return res;
}
***************
*** 2541,2545 ****
(
(t="final" | t="const")
! {User.warning(new Location(t),
"'"+t.toString()+"' is deprecated. Use 'let' instead.");
}
--- 2536,2540 ----
(
(t="final" | t="const")
! {User.warning(Location.make(t),
"'"+t.toString()+"' is deprecated. Use 'let' instead.");
}
***************
*** 2581,2585 ****
(
(t="final" | t="const")
! {User.warning(new Location(t),
"'"+t.toString()+"' is deprecated. Use 'let' instead.");
}
--- 2576,2580 ----
(
(t="final" | t="const")
! {User.warning(Location.make(t),
"'"+t.toString()+"' is deprecated. Use 'let' instead.");
}
***************
*** 2609,2613 ****
"=" e=Expression() ";"
{ Expression exp = AssignExp.create(new TupleExp(parts), e);
! exp.setLocation(new Location(first,last));
return new ExpressionStmt(exp); }
}
--- 2604,2608 ----
"=" e=Expression() ";"
{ Expression exp = AssignExp.create(new TupleExp(parts), e);
! exp.setLocation(Location.make(first,last));
return new ExpressionStmt(exp); }
}
***************
*** 2683,2687 ****
{ Token t; }
{
! t=";" { return new EmptyStmt(new Location(t)); }
}
--- 2678,2682 ----
{ Token t; }
{
! t=";" { return new EmptyStmt(Location.make(t)); }
}
***************
*** 2707,2711 ****
|
{ Token op; Expression e2;
! e1.setLocation(new Location(first, getToken(0)));
}
op=AssignmentOperator()
--- 2702,2706 ----
|
{ Token op; Expression e2;
! e1.setLocation(Location.make(first, getToken(0)));
}
op=AssignmentOperator()
***************
*** 2721,2725 ****
{
last = getToken(0);
! e1.setLocation(new Location(first, last));
return new ExpressionStmt(e1);
}
--- 2716,2720 ----
{
last = getToken(0);
! e1.setLocation(Location.make(first, last));
return new ExpressionStmt(e1);
}
***************
*** 2756,2760 ****
ifExp = new IfExp(cond, new StatementExp(s1),
(s2 == null ? null : new StatementExp(s2)));
! ifExp.setLocation(new Location(first, getToken(0)));
return new ExpressionStmt(ifExp);
}
--- 2751,2755 ----
ifExp = new IfExp(cond, new StatementExp(s1),
(s2 == null ? null : new StatementExp(s2)));
! ifExp.setLocation(Location.make(first, getToken(0)));
return new ExpressionStmt(ifExp);
}
***************
*** 2774,2778 ****
ifExp = new IfExp(cond, new StatementExp(s1),
(s2 == null ? null : new StatementExp(s2)));
! ifExp.setLocation(new Location(first, getToken(0)));
return new ExpressionStmt(ifExp);
}
--- 2769,2773 ----
ifExp = new IfExp(cond, new StatementExp(s1),
(s2 == null ? null : new StatementExp(s2)));
! ifExp.setLocation(Location.make(first, getToken(0)));
return new ExpressionStmt(ifExp);
}
***************
*** 2826,2830 ****
vartype=monotype() var=ident() t=":" container=Expression() ")"
body=Statement()
! {return LoopStmt.forInLoop(vartype,var,new Location(t),container,body); }
}
--- 2821,2825 ----
vartype=monotype() var=ident() t=":" container=Expression() ")"
body=Statement()
! { return LoopStmt.forInLoop(vartype,var,Location.make(t),container,body); }
}
***************
*** 2869,2873 ****
{
Statement res = new ReturnStmt(val);
! res.setLocation(new Location(t));
return res;
}
--- 2864,2868 ----
{
Statement res = new ReturnStmt(val);
! res.setLocation(Location.make(t));
return res;
}
Index: Loader.java
===================================================================
RCS file: /cvsroot/nice/Nice/src/bossa/parser/Loader.java,v
retrieving revision 1.18
retrieving revision 1.19
diff -C2 -d -r1.18 -r1.19
*** Loader.java 8 Mar 2003 14:27:12 -0000 1.18
--- Loader.java 24 Jun 2003 15:28:19 -0000 1.19
***************
*** 44,48 ****
catch(ParseException e){
if(e.currentToken!=null)
! User.error(new Location(e.currentToken.next),
removeLocation(e.getMessage()));
else
--- 44,48 ----
catch(ParseException e){
if(e.currentToken!=null)
! User.error(Location.make(e.currentToken.next),
removeLocation(e.getMessage()));
else
***************
*** 70,74 ****
catch(ParseException e){
if(e.currentToken!=null)
! User.error(new Location(e.currentToken.next),
removeLocation(e.getMessage()));
else
--- 70,74 ----
catch(ParseException e){
if(e.currentToken!=null)
! User.error(Location.make(e.currentToken.next),
removeLocation(e.getMessage()));
else
-------------------------------------------------------
This SF.Net email is sponsored by: INetU
Attention Web Developers & Consultants: Become An INetU Hosting Partner.
Refer Dedicated Servers. We Manage Them. You Get 10% Monthly Commission!
INetU Dedicated Managed Hosting http://www.inetu.net/partner/index.php
|