Skip to content

Commit

Permalink
solve the parsing problem spotted in #1329
Browse files Browse the repository at this point in the history
  • Loading branch information
gavinking committed Jun 3, 2015
1 parent aacb4a0 commit 6c37efb
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 20 deletions.
68 changes: 50 additions & 18 deletions Ceylon.g
Original file line number Diff line number Diff line change
Expand Up @@ -1680,22 +1680,66 @@ base returns [Primary primary]
{ $primary=$dynamicObject.dynamic; }
| objectExpression
{ $primary = $objectExpression.objectExpression; }
| selfReference
{ $primary=$selfReference.atom; }
| parExpression
{ $primary=$parExpression.expression; }
| baseReferenceOrParameterized
{ $primary=$baseReferenceOrParameterized.primary; }
;
baseReferenceOrParameterized returns [Primary primary]
@init { BaseMemberOrTypeExpression be=null;
QualifiedMemberOrTypeExpression qe=null;
ParameterizedExpression pe=null; }
: (LIDENTIFIER typeParameters? specifierParametersStart) =>
memberName
{ be = new BaseMemberExpression(null);
be.setTypeArguments(new InferredTypeArguments(null)); //yew!!
be.setIdentifier($memberName.identifier);
pe = new ParameterizedExpression(null);
pe.setPrimary(be); }
(
typeParameters
{ pe.setTypeParameterList($typeParameters.typeParameterList); }
)?
(
(specifierParametersStart) => parameters
{ pe.addParameterList($parameters.parameterList);
$primary = pe; }
)+
| baseReference
{ BaseMemberOrTypeExpression be;
if ($baseReference.isMember)
{ if ($baseReference.isMember)
be = new BaseMemberExpression(null);
else
be = new BaseTypeExpression(null);
be.setIdentifier($baseReference.identifier);
if ($baseReference.typeArgumentList!=null)
be.setTypeArguments($baseReference.typeArgumentList);
else
be.setTypeArguments( new InferredTypeArguments(null) );
be.setTypeArguments(new InferredTypeArguments(null));
$primary=be; }
| selfReference
{ $primary=$selfReference.atom; }
(
(MEMBER_OP LIDENTIFIER typeParameters? specifierParametersStart) =>
memberSelectionOperator
{ qe = new QualifiedMemberExpression(null);
qe.setMemberOperator($memberSelectionOperator.operator);
qe.setTypeArguments(new InferredTypeArguments(null)); }
memberName
{ qe.setIdentifier($memberName.identifier);
qe.setPrimary($primary);
pe = new ParameterizedExpression(null);
pe.setPrimary(qe); }
(
typeParameters
{ pe.setTypeParameterList($typeParameters.typeParameterList); }
)?
(
(specifierParametersStart) => parameters
{ pe.addParameterList($parameters.parameterList);
$primary = pe; }
)+
)?
;
baseReference returns [Identifier identifier,
Expand All @@ -1718,9 +1762,7 @@ primary returns [Primary primary]
: base
{ $primary=$base.primary; }
(
//TODO: re-enable:
/*inlineFunctionalArgument
|*/ qualifiedReference
qualifiedReference
{ QualifiedMemberOrTypeExpression qe;
if ($qualifiedReference.isMember)
qe = new QualifiedMemberExpression(null);
Expand All @@ -1737,16 +1779,6 @@ primary returns [Primary primary]
| indexOrIndexRange
{ $indexOrIndexRange.indexExpression.setPrimary($primary);
$primary = $indexOrIndexRange.indexExpression; }
| (specifierParametersStart)=> parameters
{ ParameterizedExpression pe;
if ($primary instanceof ParameterizedExpression) {
pe = (ParameterizedExpression) $primary;
} else {
pe = new ParameterizedExpression(null);
pe.setPrimary($primary);
}
pe.addParameterList($parameters.parameterList);
$primary = pe; }
| positionalArguments
{ InvocationExpression ie = new InvocationExpression(null);
ie.setPrimary($primary);
Expand Down
1 change: 1 addition & 0 deletions Ceylon.nodes
Original file line number Diff line number Diff line change
Expand Up @@ -673,6 +673,7 @@

^(PARAMETERIZED_EXPRESSION:PRIMARY
PRIMARY
TYPE_PARAMETER_LIST?
PARAMETER_LIST*
boolean leftTerm;)

Expand Down
4 changes: 2 additions & 2 deletions test/main/declarations/Parameters.ceylon
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ class Parameters() {
void withDefaultedCallableParams(Float f() => 0.5, Float g(Float x) => x) {}
void withDefaultedFunctionParams(Float() f = () => 0.5, Float(Float) g = (Float x) => x) {}

@error print(String({Character*} chars1));
@error value b1 = String({Character*} chars2);
//@error print(String({Character*} chars1));
//@error value b1 = String({Character*} chars2);
@error print(print(Any val1));
@error value b2 = print(Any val2);

Expand Down

1 comment on commit 6c37efb

@lucaswerkmeister
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.