Skip to content

Commit

Permalink
Remove case functions implementation
Browse files Browse the repository at this point in the history
We're removing this feature as per RFC 51.

Closes ponylang#2540.
  • Loading branch information
Benoit Vey committed Feb 8, 2018
1 parent d34dce6 commit 796f3b5
Show file tree
Hide file tree
Showing 8 changed files with 55 additions and 1,700 deletions.
18 changes: 13 additions & 5 deletions pony.g
Original file line number Diff line number Diff line change
Expand Up @@ -208,8 +208,8 @@ nextatom
| LPAREN_NEW rawseq tuple? ')'
| LSQUARE_NEW ('as' type ':')? rawseq? ']'
| 'object' ('\\' ID (',' ID)* '\\')? cap? ('is' type)? members 'end'
| '{' ('\\' ID (',' ID)* '\\')? cap? ID? typeparams? ('(' | LPAREN_NEW) params? ')' lambdacaptures? (':' type)? '?'? '=>' rawseq '}' cap?
| '@{' ('\\' ID (',' ID)* '\\')? cap? ID? typeparams? ('(' | LPAREN_NEW) params? ')' lambdacaptures? (':' type)? '?'? '=>' rawseq '}' cap?
| '{' ('\\' ID (',' ID)* '\\')? cap? ID? typeparams? ('(' | LPAREN_NEW) lambdaparams? ')' lambdacaptures? (':' type)? '?'? '=>' rawseq '}' cap?
| '@{' ('\\' ID (',' ID)* '\\')? cap? ID? typeparams? ('(' | LPAREN_NEW) lambdaparams? ')' lambdacaptures? (':' type)? '?'? '=>' rawseq '}' cap?
| '@' (ID | STRING) typeargs? ('(' | LPAREN_NEW) positional? named? ')' '?'?
| '__loc'
;
Expand All @@ -221,8 +221,8 @@ atom
| ('(' | LPAREN_NEW) rawseq tuple? ')'
| ('[' | LSQUARE_NEW) ('as' type ':')? rawseq? ']'
| 'object' ('\\' ID (',' ID)* '\\')? cap? ('is' type)? members 'end'
| '{' ('\\' ID (',' ID)* '\\')? cap? ID? typeparams? ('(' | LPAREN_NEW) params? ')' lambdacaptures? (':' type)? '?'? '=>' rawseq '}' cap?
| '@{' ('\\' ID (',' ID)* '\\')? cap? ID? typeparams? ('(' | LPAREN_NEW) params? ')' lambdacaptures? (':' type)? '?'? '=>' rawseq '}' cap?
| '{' ('\\' ID (',' ID)* '\\')? cap? ID? typeparams? ('(' | LPAREN_NEW) lambdaparams? ')' lambdacaptures? (':' type)? '?'? '=>' rawseq '}' cap?
| '@{' ('\\' ID (',' ID)* '\\')? cap? ID? typeparams? ('(' | LPAREN_NEW) lambdaparams? ')' lambdacaptures? (':' type)? '?'? '=>' rawseq '}' cap?
| '@' (ID | STRING) typeargs? ('(' | LPAREN_NEW) positional? named? ')' '?'?
| '__loc'
;
Expand All @@ -239,6 +239,14 @@ lambdacapture
: ID (':' type)? ('=' infix)?
;

lambdaparams
: lambdaparam (',' lambdaparam)*
;

lambdaparam
: parampattern (':' type)? ('=' infix)?
;

positional
: rawseq (',' rawseq)*
;
Expand Down Expand Up @@ -340,7 +348,7 @@ literal
;

param
: parampattern (':' type)? ('=' infix)?
: ID (':' type)? ('=' infix)?
;

antlr_0
Expand Down
40 changes: 28 additions & 12 deletions src/libponyc/ast/parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,11 @@ DEF(defaultarg);
RULE("default value", infix);
DONE();

// postfix [COLON type] [ASSIGN defaultarg]
// ID [COLON type] [ASSIGN defaultarg]
DEF(param);
AST_NODE(TK_PARAM);
RULE("name", parampattern);
IF(TK_COLON,
RULE("parameter type", type);
UNWRAP(0, TK_REFERENCE);
);
TOKEN("parameter name", TK_ID);
IF(TK_COLON, RULE("parameter type", type));
IF(TK_ASSIGN, RULE("default value", defaultarg));
DONE();

Expand Down Expand Up @@ -344,6 +341,24 @@ DEF(object);
SET_CHILD_FLAG(2, AST_FLAG_PRESERVE); // Members
DONE();

// parampattern [COLON type] [ASSIGN defaultarg]
DEF(lambdaparam);
AST_NODE(TK_PARAM);
RULE("name", parampattern);
IF(TK_COLON,
RULE("parameter type", type);
UNWRAP(0, TK_REFERENCE);
);
IF(TK_ASSIGN, RULE("default value", defaultarg));
DONE();

// lambdaparam {COMMA lambdaparam}
DEF(lambdaparams);
AST_NODE(TK_PARAMS);
RULE("parameter", lambdaparam);
WHILE(TK_COMMA, RULE("parameter", lambdaparam));
DONE();

// ID [COLON type] [ASSIGN infix]
DEF(lambdacapture);
AST_NODE(TK_LAMBDACAPTURE);
Expand All @@ -362,8 +377,9 @@ DEF(lambdacaptures);
SKIP(NULL, TK_RPAREN);
DONE();

// LBRACE [annotations] [CAP] [ID] [typeparams] (LPAREN | LPAREN_NEW) [params]
// RPAREN [lambdacaptures] [COLON type] [QUESTION] ARROW rawseq RBRACE [CAP]
// LBRACE [annotations] [CAP] [ID] [typeparams] (LPAREN | LPAREN_NEW)
// [lambdaparams] RPAREN [lambdacaptures] [COLON type] [QUESTION] ARROW rawseq
// RBRACE [CAP]
DEF(lambda);
PRINT_INLINE();
AST_NODE(TK_LAMBDA);
Expand All @@ -373,7 +389,7 @@ DEF(lambda);
OPT TOKEN("function name", TK_ID);
OPT RULE("type parameters", typeparams);
SKIP(NULL, TK_LPAREN, TK_LPAREN_NEW);
OPT RULE("parameters", params);
OPT RULE("parameters", lambdaparams);
SKIP(NULL, TK_RPAREN);
OPT RULE("captures", lambdacaptures);
IF(TK_COLON, RULE("return type", type));
Expand All @@ -389,8 +405,8 @@ DEF(lambda);
DONE();

// AT_LBRACE [annotations] [CAP] [ID] [typeparams] (LPAREN | LPAREN_NEW)
// [params] RPAREN [lambdacaptures] [COLON type] [QUESTION] ARROW rawseq RBRACE
// [CAP]
// [lambdaparams] RPAREN [lambdacaptures] [COLON type] [QUESTION] ARROW rawseq
// RBRACE [CAP]
DEF(barelambda);
PRINT_INLINE();
AST_NODE(TK_BARELAMBDA);
Expand All @@ -400,7 +416,7 @@ DEF(barelambda);
OPT TOKEN("function name", TK_ID);
OPT RULE("type parameters", typeparams);
SKIP(NULL, TK_LPAREN, TK_LPAREN_NEW);
OPT RULE("parameters", params);
OPT RULE("parameters", lambdaparams);
SKIP(NULL, TK_RPAREN);
OPT RULE("captures", lambdacaptures);
IF(TK_COLON, RULE("return type", type));
Expand Down
Loading

0 comments on commit 796f3b5

Please sign in to comment.