%type <blk> Exp Term MkDict MkDictPair ExpD ElseBody QQString
%type <blk> FuncDef FuncDefs String Import Imports Param Params
%type <blk> Arg Args Module
+%type <literal> Keyword
%{
#include "lexer.h"
struct lexer_param {
$$ = gen_lambda($1);
}
+Keyword:
+"as" {
+ $$ = jv_string("as");
+} |
+"def" {
+ $$ = jv_string("def");
+} |
+"module" {
+ $$ = jv_string("module");
+} |
+"import" {
+ $$ = jv_string("import");
+} |
+"if" {
+ $$ = jv_string("if");
+} |
+"then" {
+ $$ = jv_string("then");
+} |
+"else" {
+ $$ = jv_string("else");
+} |
+"elif" {
+ $$ = jv_string("elif");
+} |
+"reduce" {
+ $$ = jv_string("reduce");
+} |
+"foreach" {
+ $$ = jv_string("foreach");
+} |
+"end" {
+ $$ = jv_string("end");
+} |
+"and" {
+ $$ = jv_string("and");
+} |
+"or" {
+ $$ = jv_string("or");
+} |
+"try" {
+ $$ = jv_string("try");
+} |
+"catch" {
+ $$ = jv_string("catch");
+} |
+"label" {
+ $$ = jv_string("label");
+} |
+"break" {
+ $$ = jv_string("break");
+} |
+"__loc__" {
+ $$ = jv_string("__loc__");
+}
+
MkDict:
%empty {
$$=gen_noop();
| MkDictPair ',' MkDict { $$=block_join($1, $3); }
| error ',' MkDict { $$ = $3; }
-MkDictPair
-: IDENT ':' ExpD {
+MkDictPair:
+IDENT ':' ExpD {
$$ = gen_dictpair(gen_const($1), $3);
}
+| Keyword ':' ExpD {
+ $$ = gen_dictpair(gen_const($1), $3);
+ }
| String ':' ExpD {
$$ = gen_dictpair($1, $3);
}
["1","2",{"a":{"b":{"c":33}}}]
"string (\",\") and object ({\"a\":{\"b\":{...) cannot be added"
+{if:0,and:1,or:2,then:3,else:4,elif:5,end:6,as:7,def:8,reduce:9,foreach:10,try:11,catch:12,label:13,import:14,module:15}
+null
+{"if":0,"and":1,"or":2,"then":3,"else":4,"elif":5,"end":6,"as":7,"def":8,"reduce":9,"foreach":10,"try":11,"catch":12,"label":13,"import":14,"module":15}
+