Skip to content
Myr

Keywords should be OK as object keys (fix #794)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

With this change it's now OK to use keywords as object keys like so: {if:0}

authored by Nicolas Williams · committed by Nicolas Williams · parent 454a9dc · Browse files · 2 files+66 added−2 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+66 added−2 removed

  • tests:+4 added−0 removed
  • other:+62 added−2 removed

2 files+66 added−2 removed

modified:tests/all.test+4 added
1183 unmodified lines
1184try join(",") catch .1185["1","2",{"a":{"b":{"c":33}}}]1186"string (\",\") and object ({\"a\":{\"b\":{...) cannot be added"11871188{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}1189null1190{"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}1191
modified:parser.y+62 added-2 removed
106 unmodified lines
107108%type <blk> Exp Term MkDict MkDictPair ExpD ElseBody QQString109%type <blk> FuncDef FuncDefs String Import Imports Param Params110%type <blk> Arg Args Module111%type <literal> Keyword112%{113#include "lexer.h"114struct lexer_param {115 yyscan_t lexer;
619 unmodified lines
735Exp {736 $$ = gen_lambda($1);737}738739Keyword:740"as" {741 $$ = jv_string("as");742} |743"def" {744 $$ = jv_string("def");745} |746"module" {747 $$ = jv_string("module");748} |749"import" {750 $$ = jv_string("import");751} |752"if" {753 $$ = jv_string("if");754} |755"then" {756 $$ = jv_string("then");757} |758"else" {759 $$ = jv_string("else");760} |761"elif" {762 $$ = jv_string("elif");763} |764"reduce" {765 $$ = jv_string("reduce");766} |767"foreach" {768 $$ = jv_string("foreach");769} |770"end" {771 $$ = jv_string("end");772} |773"and" {774 $$ = jv_string("and");775} |776"or" {777 $$ = jv_string("or");778} |779"try" {780 $$ = jv_string("try");781} |782"catch" {783 $$ = jv_string("catch");784} |785"label" {786 $$ = jv_string("label");787} |788"break" {789 $$ = jv_string("break");790} |791"__loc__" {792 $$ = jv_string("__loc__");793}794795MkDict:796%empty { 797 $$=gen_noop(); 798} |799 MkDictPair { $$ = $1; }800| MkDictPair ',' MkDict { $$=block_join($1, $3); }801| error ',' MkDict { $$ = $3; }802746MkDictPair747: IDENT ':' ExpD { 803MkDictPair:804IDENT ':' ExpD { 805 $$ = gen_dictpair(gen_const($1), $3);806 }807| Keyword ':' ExpD {808 $$ = gen_dictpair(gen_const($1), $3);809 }810| String ':' ExpD {811 $$ = gen_dictpair($1, $3);812 }813| String {
40 unmodified lines