[Nice-commit] Nice/src/bossa/parser Parser.jj,1.269,1.270
Brought to you by:
bonniot
From: Arjan B. <ar...@us...> - 2004-10-13 20:42:30
|
Update of /cvsroot/nice/Nice/src/bossa/parser In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23250/F:/nice/src/bossa/parser Modified Files: Parser.jj Log Message: Parser cleanup. Index: Parser.jj =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/parser/Parser.jj,v retrieving revision 1.269 retrieving revision 1.270 diff -C2 -d -r1.269 -r1.270 *** Parser.jj 13 Oct 2004 18:28:47 -0000 1.269 --- Parser.jj 13 Oct 2004 20:42:21 -0000 1.270 *************** *** 73,76 **** --- 73,80 ---- } + private static boolean isDocStringToken(Token t) + { + return t.specialToken != null && t.specialToken.kind == FORMAL_COMMENT; + } } *************** *** 851,855 **** FormalParameters.Parameter formalParameter(List statements): { ! Monotype t = null; LocatedString id = null; Expression val = null; --- 855,859 ---- FormalParameters.Parameter formalParameter(List statements): { ! Monotype t; LocatedString id = null; Expression val = null; *************** *** 858,871 **** ( LOOKAHEAD(monotype()) ! t = monotype() ! [ ! id = ident() ! [ ! "=" val = Expression() ! { return new FormalParameters.OptionalParameter(t, id, val); } ! ] ! { return new FormalParameters.NamedParameter(t, id); } ! ] ! { return new FormalParameters.Parameter(t); } | { Token first,last; --- 862,867 ---- ( LOOKAHEAD(monotype()) ! t=monotype() [ id=ident() [ "=" val=Expression() ]] ! { return FormalParameters.createParameter(t, id ,val); } | { Token first,last; *************** *** 888,895 **** t = new TupleType(types, makeLocation(first, last)); t.nullness = Monotype.absent; - if (val != null) - return new FormalParameters.OptionalParameter(t, ident, val); ! return new FormalParameters.NamedParameter(t, ident); } ) --- 884,889 ---- t = new TupleType(types, makeLocation(first, last)); t.nullness = Monotype.absent; ! return FormalParameters.createParameter(t, ident ,val); } ) *************** *** 983,987 **** { { ! if (storeDocString && t.specialToken != null && t.specialToken.kind == FORMAL_COMMENT) docString = t.specialToken.image; } --- 977,981 ---- { { ! if (storeDocString && isDocStringToken(t)) docString = t.specialToken.image; } *************** *** 1004,1012 **** { if (isOverride) ! { ! if (overrides == null) ! overrides = new LinkedList(); ! overrides.add(c.makeOverride(field, value)); ! } else fields.add(c.makeField(field, value, isFinal, isTransient, isVolatile, docString)); --- 998,1002 ---- { if (isOverride) ! overrides.add(c.makeOverride(field, value)); else fields.add(c.makeField(field, value, isFinal, isTransient, isVolatile, docString)); *************** *** 1063,1077 **** { NiceClass impl = new NiceClass(res); } // internal fields and methods ! { List fields = new LinkedList(), overrides = null, ! methods = null, initializers = null; } ( // Initializer { Statement init; } init = Block() ! { ! if (initializers == null) ! initializers = new LinkedList(); ! initializers.add(init); ! } | LOOKAHEAD( fieldLookahead() ) --- 1053,1063 ---- { NiceClass impl = new NiceClass(res); } // internal fields and methods ! { List fields = new LinkedList(), overrides = new LinkedList(), ! methods = new ArrayList(5), initializers = new LinkedList(); } ( // Initializer { Statement init; } init = Block() ! { initializers.add(init); } | LOOKAHEAD( fieldLookahead() ) *************** *** 1086,1096 **** | m = internalMethodOrFunction(res, isOverride) ! { ! if (methods == null) ! methods = new ArrayList(5); ! methods.add(m); ! } ) ! { if (storeDocString && t.specialToken != null && t.specialToken.kind == FORMAL_COMMENT) m.docString = t.specialToken.image; } --- 1072,1078 ---- | m = internalMethodOrFunction(res, isOverride) ! { methods.add(m); } ) ! { if (storeDocString && isDocStringToken(t)) m.docString = t.specialToken.image; } *************** *** 1100,1110 **** impl.setFields(fields); impl.setOverrides(overrides); ! if (initializers != null) ! impl.setInitializers(initializers); ! res.setImplementation(impl); ! ! if (methods != null) ! definitions.addAll(methods); } | --- 1082,1088 ---- impl.setFields(fields); impl.setOverrides(overrides); ! impl.setInitializers(initializers); res.setImplementation(impl); ! definitions.addAll(methods); } | *************** *** 1559,1575 **** void contractElement(Contract contract, boolean precond) : ! { ! Expression condition, name=null; ! } { condition = SideEffectFreeExpression() [ ":" name = SideEffectFreeExpression() ] ! { if (precond) ! if (name == null) contract.addRequire(condition); ! else contract.addRequire(condition, name); ! else ! if (name == null) contract.addEnsure(condition); ! else contract.addEnsure(condition, name); ! } } --- 1537,1545 ---- void contractElement(Contract contract, boolean precond) : ! { Expression condition, name=null; } { condition = SideEffectFreeExpression() [ ":" name = SideEffectFreeExpression() ] ! { contract.addElement(condition, name, precond); } } *************** *** 1612,1616 **** ( d = definition(definitions, storeDocString) { ! if (storeDocString && t.specialToken != null && t.specialToken.kind == FORMAL_COMMENT) d.docString = t.specialToken.image; --- 1582,1586 ---- ( d = definition(definitions, storeDocString) { ! if (storeDocString && isDocStringToken(t)) d.docString = t.specialToken.image; *************** *** 1652,1657 **** { "-" representation=integerLiteral() ! { return ConstantExp.makeNumber( ! new LocatedString("-"+representation.toString(), representation.location())); } } --- 1622,1628 ---- { "-" representation=integerLiteral() ! { ! representation.prepend("-"); ! return ConstantExp.makeNumber(representation); } } *************** *** 1830,1836 **** Statement ShortStatement() : ! { ! Statement res; ! } { ( res = RootShortStatement() --- 1801,1805 ---- Statement ShortStatement() : ! { Statement res; } { ( res = RootShortStatement() *************** *** 2105,2125 **** { Expression e1 = null,e2 = null; Token t = null; } { ! ((e1=ShiftExpression() ! [(t=<RANGE>) [e2=ShiftExpression()]]) ! | ! ((t = <RANGE>) [e2 = ShiftExpression()])) ! { ! if (t != null) ! { ! if (e1 == null) ! e1 = ConstantExp.makeNumber( ! new LocatedString("0", makeLocation(t))); ! if (e2 == null) ! e2 = bossa.syntax.dispatch.createNullExp(makeLocation(t)); ! e1=bossa.syntax.dispatch.createCallExp(symb(t),e1,e2); ! } ! } ! ! { return e1; } } --- 2074,2096 ---- { Expression e1 = null,e2 = null; Token t = null; } { ! ( ! e1=ShiftExpression() [ t=".." [e2=ShiftExpression()]] ! | ! t=".." [e2 = ShiftExpression()] ! ) ! { ! if (t != null) ! { ! if (e1 == null) ! e1 = ConstantExp.makeNumber(new LocatedString("0", makeLocation(t))); ! ! if (e2 == null) ! e2 = bossa.syntax.dispatch.createNullExp(makeLocation(t)); ! ! e1=bossa.syntax.dispatch.createCallExp(symb(t),e1,e2); ! } ! ! return e1; ! } } *************** *** 2164,2168 **** } - Expression ExponentialExpression() : { Expression e1,e2; Token t; } --- 2135,2138 ---- *************** *** 2253,2257 **** } - Expression PrimarySuffix(Expression start) : { --- 2223,2226 ---- *************** *** 2274,2284 **** if (args == null) ! { ! List l = new LinkedList(); ! l.add(new Arguments.Argument(start)); ! args = new Arguments(l); ! } else args.addReceiver(start); return bossa.syntax.dispatch.createCallExp(res, args, true, hasBrackets); } --- 2243,2250 ---- if (args == null) ! args = Arguments.singleArgument(start); else args.addReceiver(start); + return bossa.syntax.dispatch.createCallExp(res, args, true, hasBrackets); } *************** *** 2322,2334 **** Expression atExpression() : { ! Token t; ! } ! { ! (t = <AT>) { return bossa.syntax.dispatch.createCallExp(symb(t), Arguments.noArguments()); } } - ConstantExp patternLiteral() : //restricted literal for use in dispatch patterns --- 2288,2297 ---- Expression atExpression() : + { Token t; } { ! (t="@") { return bossa.syntax.dispatch.createCallExp(symb(t), Arguments.noArguments()); } } ConstantExp patternLiteral() : //restricted literal for use in dispatch patterns *************** *** 2776,2786 **** [ cond=Expression() ] ";" [ update=StatementExpressionList() ] ")" body=Statement() ! { ! loop=bossa.syntax.dispatch.createForLoop(cond,update,body); ! List l = new LinkedList(); ! l.addAll(init); ! l.add(loop); ! loop = bossa.syntax.dispatch.createBlock(l); ! } ) { return loop; } --- 2739,2743 ---- [ cond=Expression() ] ";" [ update=StatementExpressionList() ] ")" body=Statement() ! { loop=bossa.syntax.dispatch.createForLoop(cond,update,body,init); } ) { return loop; } *************** *** 2801,2805 **** List LocalDeclarationList() : ! { Statement d; List declarations = new ArrayList(); } { d=LocalDeclaration() {declarations.add(d);} --- 2758,2762 ---- List LocalDeclarationList() : ! { Statement d; List declarations = new LinkedList(); } { d=LocalDeclaration() {declarations.add(d);} |