[javascriptlint-commit] SF.net SVN: javascriptlint:[336] trunk/jsengine
Status: Beta
Brought to you by:
matthiasmiller
From: <mat...@us...> - 2013-10-09 19:41:05
|
Revision: 336 http://sourceforge.net/p/javascriptlint/code/336 Author: matthiasmiller Date: 2013-10-09 19:41:02 +0000 (Wed, 09 Oct 2013) Log Message: ----------- Change op.*, tok.*, and kind.* to not be derived from string. Modified Paths: -------------- trunk/jsengine/parser/__init__.py trunk/jsengine/parser/_constants_kind.py trunk/jsengine/parser/_constants_op.py trunk/jsengine/tokenizer/__init__.py Modified: trunk/jsengine/parser/__init__.py =================================================================== --- trunk/jsengine/parser/__init__.py 2013-10-09 13:52:50 UTC (rev 335) +++ trunk/jsengine/parser/__init__.py 2013-10-09 19:41:02 UTC (rev 336) @@ -785,7 +785,7 @@ elif x.tok not in (tok.LBRACE, tok.FUNCTION): expr = _expression(t, True) - if expr.kind == tok.NAME and t.peek().tok == tok.COLON: + if expr.kind == kind.NAME and t.peek().tok == tok.COLON: t.expect(tok.COLON) stmt = _statement(t) return ParseNode(kind.COLON, op.NAME, expr.start_offset, Modified: trunk/jsengine/parser/_constants_kind.py =================================================================== --- trunk/jsengine/parser/_constants_kind.py 2013-10-09 13:52:50 UTC (rev 335) +++ trunk/jsengine/parser/_constants_kind.py 2013-10-09 19:41:02 UTC (rev 336) @@ -65,15 +65,22 @@ 'STRING', 'YIELD', # TODO ] -class _Kind(str): +class _Kind(object): + def __init__(self, name): + self._name = name + + def __eq__(self, other): + assert isinstance(other, _Kind), repr(other) + return self is other + def __repr__(self): - return 'kind.%s' % self + return 'kind.%s' % self._name class _Kinds: def __init__(self): for kind in _KINDS: setattr(self, kind, _Kind(kind)) def contains(self, item): - return isinstance(item, _Kind) and \ - getattr(self, item) is item + return isinstance(item, _Kind) + kind = _Kinds() Modified: trunk/jsengine/parser/_constants_op.py =================================================================== --- trunk/jsengine/parser/_constants_op.py 2013-10-09 13:52:50 UTC (rev 335) +++ trunk/jsengine/parser/_constants_op.py 2013-10-09 19:41:02 UTC (rev 336) @@ -70,9 +70,18 @@ 'VOID', 'CALL', ] -class _Op(str): +class _Op(object): + def __init__(self, name): + self._name = name + + def __eq__(self, other): + if other is None: + return False + assert isinstance(other, _Op), repr(other) + return self is other + def __repr__(self): - return 'op.%s' % self + return 'op.%s' % self._name class _Ops: NOP = None # TODO! @@ -80,6 +89,6 @@ for op in _OPS: setattr(self, op, _Op(op)) def contains(self, item): - return isinstance(item, _Op) and \ - getattr(self, item) is item + return isinstance(item, _Op) + op = _Ops() Modified: trunk/jsengine/tokenizer/__init__.py =================================================================== --- trunk/jsengine/tokenizer/__init__.py 2013-10-09 13:52:50 UTC (rev 335) +++ trunk/jsengine/tokenizer/__init__.py 2013-10-09 19:41:02 UTC (rev 336) @@ -109,9 +109,17 @@ 'STRING', ] -class _Token(str): - pass +class _Token(object): + def __init__(self, name): + self._name = name + def __eq__(self, other): + assert isinstance(other, _Token) + return self is other + + def __repr__(self): + return 'tok.%s' % self._name + class _Tokens: def __init__(self): for token in _TOKENS: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |