Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ python:

install:
- pip install sly coverage coveralls
- git clone https://github.com/spyoungtech/json5-tests.git
- git clone https://github.com/json5/json5-tests.git

script:
- coverage run -m pytest tests
Expand Down
31 changes: 0 additions & 31 deletions json5/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,37 +291,6 @@ def value(self, p):
node = p[0]
return node

@_('BREAK',
'DO',
'INSTANCEOF',
'TYPEOF',
'CASE',
'ELSE',
'NEW',
'VAR',
'CATCH',
'FINALLY',
'RETURN',
'VOID',
'CONTINUE',
'FOR',
'SWITCH',
'WHILE',
'DEBUGGER',
'FUNCTION',
'THIS',
'WITH',
'DEFAULT',
'IF',
'THROW',
'DELETE',
'IN',
'TRY',)
def identifier(self, p):
err = JSON5DecodeError(f"Illegal name ({p[0]}) is a reserved keyword and may not be used", p._slice[0])
self.errors.append(err)
return Identifier(name=p[0])

def error(self, token):
if token:
self.errors.append(JSON5DecodeError('Syntax Error', token))
Expand Down
31 changes: 0 additions & 31 deletions json5/tokenizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,6 @@ class JSONLexer(Lexer):
TRUE, FALSE, NULL,
COLON,

# RESERVED KEYWORDS
BREAK, DO, INSTANCEOF, TYPEOF, CASE, ELSE, NEW, VAR, CATCH, FINALLY, RETURN, VOID, CONTINUE, FOR, SWITCH, WHILE, DEBUGGER, FUNCTION, THIS, WITH, DEFAULT, IF, THROW, DELETE, IN, TRY,

# Numbers
PLUS, MINUS,
FLOAT, INTEGER,
Expand Down Expand Up @@ -87,34 +84,6 @@ def WHITESPACE(self, tok):
NAME['Infinity'] = INFINITY
NAME['NaN'] = NAN

# RESERVED KEYWORDS
NAME['break'] = BREAK
NAME['do'] = DO
NAME['instanceof'] = INSTANCEOF
NAME['typeof'] = TYPEOF
NAME['case'] = CASE
NAME['else'] = ELSE
NAME['new'] = NEW
NAME['var'] = VAR
NAME['catch'] = CATCH
NAME['finally'] = FINALLY
NAME['return'] = RETURN
NAME['void'] = VOID
NAME['continue'] = CONTINUE
NAME['for'] = FOR
NAME['switch'] = SWITCH
NAME['while'] = WHILE
NAME['debugger'] = DEBUGGER
NAME['function'] = FUNCTION
NAME['this'] = THIS
NAME['with'] = WITH
NAME['default'] = DEFAULT
NAME['if'] = IF
NAME['throw'] = THROW
NAME['delete'] = DELETE
NAME['in'] = IN
NAME['try'] = TRY

def error(self, t):
raise JSON5DecodeError(f'Illegal character {t.value[0]!r} at index {self.index}', None)

Expand Down
6 changes: 0 additions & 6 deletions tests/test_errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,6 @@ class Foo(object):
DefaultLoader().load(f)


def test_reserved_keywords_raise_error():
json_string = """{break: "not good!"}"""
with pytest.raises(JSON5DecodeError):
loads(json_string)


def test_dumping_unknown_node_raises_error():
class Foo(object):
...
Expand Down