Skip to content

Support for Javascript Generator functions #118

@AdamantLife

Description

@AdamantLife

Issue

Javascript Generator Functions raise Syntax Error by the parser

Environment

Python 3.10 inside fresh venv virtual environment on Windows 10
slimit installed via a requirements.txt, using git+https://github.com/rspivak/slimit.git#egg=slimit

MVE

# test.py
import slimit
slimit.minify("function* test(){yield 1;}")

Traceback

Traceback (most recent call last):
  File "[...]\test.py", line 2, in <module>
    slimit.minify("function* test(){yield 1;}")
  File "[...]\lib\site-packages\slimit\minifier.py", line 38, in minify
    tree = parser.parse(text)
  File "[...]\lib\site-packages\slimit\parser.py", line 93, in parse
    return self.parser.parse(text, lexer=self.lexer, debug=debug)
  File "[...]\lib\site-packages\ply\yacc.py", line 333, in parse
    return self.parseopt_notrack(input, lexer, debug, tracking, tokenfunc)
  File "[...]\lib\site-packages\ply\yacc.py", line 1201, in parseopt_notrack
    tok = call_errorfunc(self.errorfunc, errtoken, self)
  File "[...]\lib\site-packages\ply\yacc.py", line 192, in call_errorfunc
    r = errorfunc(token)
  File "[...]lib\site-packages\slimit\parser.py", line 116, in p_error
    self._raise_syntax_error(token)
  File "[...]\lib\site-packages\slimit\parser.py", line 86, in _raise_syntax_error
    raise SyntaxError(
SyntaxError: Unexpected token (MULT, '*') at 1:9 between LexToken(FUNCTION,'function',1,1) and LexToken(ID,'test',1,11)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions