Skip to content

Commit

Permalink
Merge pull request #6 from shamanas/patch-1
Browse files Browse the repository at this point in the history
Added => operator with no conflict to case :D
  • Loading branch information
Amos Wenger committed Apr 30, 2012
2 parents a2b5631 + 3e7be7f commit 2fcb1c2
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
19 changes: 17 additions & 2 deletions grammar/nagaqueen.leg
Expand Up @@ -287,6 +287,7 @@ void *nq_onFloatLiteral(void *this, char *value);
void *nq_onBoolLiteral(void *this, bool value);
void *nq_onNull(void *this);

void *nq_onDoubleArrow(void *this, void *left, void *right);
void *nq_onTernary(void *this, void *condition, void *ifTrue, void *ifFalse);
void *nq_onAssignAnd(void *this, void *left, void *right);
void *nq_onAssignOr(void *this, void *left, void *right);
Expand Down Expand Up @@ -508,7 +509,7 @@ GenericArguments =

OperatorDecl =
OPERATOR_KW { tokenPos; } -
- < ( "<=>"| ">>="| "<<="| ">>" | "<<"
- < ( "=>" | "<=>"| ">>="| "<<="| ">>" | "<<"
| ">=" | "<=" | "!=" | "==" | ">" | "<" | "!"
| "+=" | "-=" | "*=" | "**="| "/=" | "+" | "-" | "**" | "/" | "*" | "="
| "[]="| "[]" | "&&" | "||" | "%" | "as" | "implicit as"
Expand Down Expand Up @@ -1096,7 +1097,7 @@ Else = (
) { $$=nq_onElseEnd(core->this); }

Case = CASE_KW { tokenPos; nq_onCaseStart(core->this); }
(- v:Expr { nq_onCaseExpr(core->this, v); })?
(- v:CaseExpr { nq_onCaseExpr(core->this, v); })?
WS DOUBLE_ARROW
(WS
(s:Stmt { nq_onStatement(core->this, s) })
Expand Down Expand Up @@ -1158,9 +1159,23 @@ Return = (RETURN_KW &([^A-Za-z_]) { tokenPos; } - e:Expr { $$=nq_onReturn(core-


Expr = v:VariableDecl -
| d:DoubleArrow -
| b:BinaryOperation - (- '.' { tokenPos; } WS call:FunctionCall { $$=b=nq_onFunctionCallChain(core->this, b, call); })*
| AnonymousFunctionDecl

CaseExpr = ( v:VariableDecl -
| b:BinaryOperation - (- '.' { tokenPos; } WS call:FunctionCall { $$=b=nq_onFunctionCallChain(core->this, b, call); })*
| AnonymousFunctionDecl
)
|
( '(' -
Expr -
')'
)

DoubleArrow = l:Assignment
DOUBLE_ARROW { tokenPos; } WS r:Expr ~{ missingOp("=>") } { $$=l=nq_onDoubleArrow(core->this, l, r); }

#operators

BinaryOperation = Assignment
Expand Down
2 changes: 1 addition & 1 deletion source/nagaqueen/OocListener.ooc
Expand Up @@ -667,7 +667,7 @@ UnOpType: enum {
* Binary operators
*/
BinOpType: enum {
equals, notEquals, lessThan, moreThan, cmp, lessThanOrEqual, moreThanOrEqual
doubleArrow, equals, notEquals, lessThan, moreThan, cmp, lessThanOrEqual, moreThanOrEqual

assAnd, assOr, assXor, assRShift, assLShift, assDiv, assMul, assExp, assSub, assAdd, ass

Expand Down
2 changes: 2 additions & 0 deletions source/nagaqueen/callbacks.ooc
Expand Up @@ -244,6 +244,8 @@ nq_onCatchEnd: unmangled func (l: OocListener) { l onCatchEnd() }

/* Various operators */

nq_onDoubleArrow: unmangled func (l: OocListener, left, right: Object) -> Object { l onBinOp(BinOpType doubleArrow, left, right) }

nq_onLogicalNot: unmangled func (l: OocListener, inner: Object) -> Object { l onUnOp(UnOpType not, inner) }
nq_onBinaryNot: unmangled func (l: OocListener, inner: Object) -> Object { l onUnOp(UnOpType bNot, inner) }
nq_onUnaryMinus: unmangled func (l: OocListener, inner: Object) -> Object { l onUnOp(UnOpType uMinus, inner) }
Expand Down

0 comments on commit 2fcb1c2

Please sign in to comment.