- Modified existing
setup.py
hook from an install hook to a build hook to ensure the generated module files are present. Should any of those modules are missing and the required dependencies for are not present (i.e.ply
andsetuptools
), the build will result in a non-zero exit status and the documented error message should reflect which of the required dependencies are missing.
- Introduce the extractor unparser - an unparser that will unparse a
valid AST into a
dict
. [ #35 #38 ] - Correct the JoinAttr ruletype such that the intended empty definition value is passed to walk if it was defined as such to avoid an unintended infinite recursion. [ #36 ]
- Will now import Iterable from the Python 3.3+ location as the previous location is marked for removal in Python 3.9. The import will still have a fallback to the previous location in order to maintain support for Python 2.7. [ #31 ]
- Provide a test case helper to ensure that the generic
Program
repr signature is provided to assist with test case portability. [ #33 ] - In the
calmjs.parse.vlq
module, implemented thedecode_vlq
helper for completeness/symmetry to theencode_vlq
helper. [ #33 ]
- Correct usage of
__doc__
to support level 2 optimized mode. [ #29 #30 ] - Corrected some minor string definition syntax, where raw string prefix should be used but was not previously.
- Correctly include LICENSE file in sdist. [ #27 #28 ]
- Include the correct test data general form for some previously added test cases to better accommodate already planned future features.
- Fix the issue of failures with regex statement that occur due to lexer being in a state where the disambiguation between REGEX or DIV token types is not immediately possible, as tokens such as RBRACE, PLUSPLUS or MINUSMINUS must be consumed by parser in order to be disambiguated, but due to the lookahead nature done by yacc, the DIV token will be prematurely produced and the only way to achieve this is during the error handling stage. [ #25 #26 ]
- Part of the previous fix also removed newline or comment tokens from being reported as part of parsing error messages.
- Partial support for parsing of comments. Currently not all comments
will be captured during parsing, due to the desire to simplify access
of them through the
asttypes.Node
instances with the genericcomments
attribute provided by it. [ #24 ]- Enabled by passing
with_comments=True
to the parser.. - The limitation lies in the fact that if a node has multiple token
slots (e.g.
if...else
), the comments that lie immediate before the first will be captured, while the comments that lie immediate to the subsequent ones will be omitted. The fix would involve providing a full syntax tree node types, and that the parser rules would need to be implemented in a more amenable manner such that the generation of such could be done. - All comments that lie immediately before the node are accessible
using the
comments
attribute. - These comments nodes will not be yielded via the children() method.
- Various features and methods have been updated to account for comments. Notably, sourcemap generation will be able to deal with source fragments that contain newlines provided that both colno and lineno are provided.
- Enabled by passing
- Correctly fail on incorrect hexadecimal/unicode escape sequences while reporting the specific character location; also report on the starting position of an unterminated string literal. [ #23 ]
- Correct issues with certain non-optional spaces being omitted for the minify print cases, which caused malformed outputs. [ #22 ]
- Default repr on synthetic nodes or nodes without column or row number assigned should no longer error. [ #20 ]
- The same line terminator regex introduced in 1.1.0 used for line continuation in strings now applied to the line terminator pattern to the lexer, such that the line numbering is corrected for the Windows specific <CR><LF> sequence. [ #21 ]
- Ensure that the accounting of layout rule chunks is done correctly in
the case where layout handlers specified a tuple of layout rules for
combined handling. [
#19
]
- The issue caused by this error manifest severely in the case where multiple layout rule tokens are produced in a manner that repeats a pattern that also have a layout handler rule for them, which does not typically happen for normal code with the standard printers (as layout chunks are many and they generally do not result in a repeated pattern that gets consumed). However this is severely manifested in the case of minified output with semicolons dropped, as that basically guarantee that any series of closing blocks that fit the pattern to be simply dropped.
- Correct the implementation of line continuation in strings. This also meant a change in the minify unparser so that it will continue to remove the line continuation sequences. [ #16 ]
- Correct the implementation of ASI (automatic semicolon insertion) by introducing a dedicated token type, such that the production of empty statement can no longer happen and that distinguishes it from production of statements that should not have ASI applied, such that incorrectly successful parsing due to this issue will no longer result. [ #18 rspivak/slimit#29 rspivak/slimit#101 ]
- Ensure that the es5 Unparser pass on the prewalk_hooks argument in its constructor.
- Minor packaging fixes; also include optimization modules for ply-3.11.
Full support for sourcemaps; changes that make it possible follows:
- High level read/write functionality provided by a new
io
module. - There is now a
Deferrable
rule type for marking certain Tokens that need extra handling. The support for this has changed the various API that deals with setting up of this. - For support of the sourcemap generation, a number of new ruletypes have been added.
- The sourcemap write function had its argument order modified to better support the sourcepath tracking feature of input Nodes. Its return value also now match the ordering of the encode_sourcemap function.
- The chunk types in ruletypes have been renamed, and also a new type called StreamFragment is introduced, so that multiple sources output to a single stream can be properly tracked by the source mapping processes.
- rspivak/slimit#66 should be fully supported now.
Minify printer now has ability to shorten/obfuscate identifiers:
- Provide a name obfuscation function for shortening identifiers, to
further achieve minified output. Note that this does not yet fully
achieve the level of minification
slimit
had; future versions may implement this functionality as various AST transformations. - Also provided ability to drop unneeded semicolons.
Other significant changes:
Various changes to internal class and function names for the 1.0.0 release. A non exhaustive listing of changes to modules relative to the root of this package name as compared to previous major release follows:
asttypes
- All
slimit
compatibility features removed. Switch
(the incorrect version) removed.SwitchStatement
->Switch
SetPropAssign
constructor:parameters
->parameter
UnaryOp
->UnaryExpr
- Other general deprecated features also removed.
- All
factory
Factory
->SRFactory
visitors
- Removed (details follow).
walkers
visitors.generic.ReprVisitor
->walkers.ReprWalker
layouts
- Module was split and reorganised; the simple base ones can be
found in
handlers.core
, the indentation related features are now inhandlers.indentation
.
- Module was split and reorganised; the simple base ones can be
found in
unparsers.base
.default_layout_handlers
->handlers.core.default_rules
.minimum_layout_handlers
->handlers.core.minimum_rules
unparsers.prettyprint
- Renamed to
unparsers.walker
. - The implementation was actually standard tree walking, no correctly implemented visitor functions/classes were ever present.
- Renamed to
vlq
.create_sourcemap
->sourcemap.create_sourcemap
Broke up the visitors class as they weren't really visitors as described. The new implementations (calmjs.parse-0.9.0) were really walkers, so move them to that name and leave it at that. Methods were also renamed to better reflect their implementation and purpose.
Many slimit compatibility modules, classes and incorrectly implemented functionalities removed.
The usage of the Python 3
str
type (unicode
in Python 2) is now enforced for the parser, to avoid various failure cases where mismatch types occur.The base Node asttype has a sourcepath attribute which is to be used for tracking the original source of the node; if assigned, all its subnodes without sourcepath defined should be treated as from that source.
Also provide an even higher level function for usage with streams through the
calmjs.parse.io
module.Semicolons and braces added as structures to be rendered.
Bug fixes:
- Functions starting with a non-word character will now always have a whitespace rendered before it to avoid syntax error.
- Correct an incorrect iterator usage in the walk function.
- Ensure List separators don't use the rowcol positions of a subsequent Elision node.
- Lexer will only report real lexer tokens on errors (ASI generated tokens are now dropped as they don't exist in the original source which results in confusing rowcol reporting).
- rspivak/slimit#57,
as it turns out
'\0'
is not considered to be octal, but is a <NUL> character, which the rule to parse was not actually included in the lexer patches that were pulled in previous to this version. - rspivak/slimit#75, Option for shadowing of names of named closures, which is now disabled by default (obfuscated named closures will not be shadowed by other obfuscated names in children).
- Expressions can no longer contain an unnamed function.
- Corrected the line number reporting for the lexer, and correct the propagation of that to the parser and the Node subclasses. Fixes the incorrect implementation added by moses-palmer/slimit@8f9a39c7769 (where the line numbers are tabulated incorrectly when comments are present, and also the yacc tracking added by moses-palmer/slimit@6aa92d68e0 (where the custom lexer class does not provide the position attributes required by ply).
- Implemented bookkeeping of column numbers.
- Made other various changes to AST but for compatibility reasons (to not force a major semver bump) they are only enabled with a flag to the ES5 parser.
- Corrected a fault with how switch/case statements are handled in a way that may break compatibility; fixes are only enabled when flagged. rspivak/slimit#94
- The repr form of Node now shows the line/col number info by default; the visit method of the ReprVisitor class have not been changed, only the invocation of it via the callable form has as that is the call target for __repr__. This is a good time to mention that named methods afford the most control for usage as documented already.
- Parsers now accept an asttypes module during its construction.
- Provide support for source map generation classes.
- Introduced a flexible visitor function/state class that accepts a definition of rules for the generation of chunk tuples that are compatible for the source map generation. A new way for pretty printing and minification can be achieved using this module.
- Initial release of the fork of
slimit.parser
and its parent modules ascalmjs.parse
. - This release brings in a number of bug fixes that were available via
other forks of
slimit
, with modifications or even a complete revamp. - Issues addressed includes:
- rspivak/slimit#52, rspivak/slimit#59, rspivak/slimit#81, rspivak/slimit#90 (relating to conformance of ecma-262 7.6 identifier names)
- rspivak/slimit#54 (fixed by tracking scope and executable current token in lexer)
- rspivak/slimit#57, rspivak/slimit#70 (octal encoding (e.g 0), from redapple/slimit@a93204577f)
- rspivak/slimit#62 (formalized into a unittest that passed)
- rspivak/slimit#73 (specifically the desire for a better repr; the minifier bits are not relevant to this package)
- rspivak/slimit#79 (tab module handling was completely reimplemented)
- rspivak/slimit#82 (formalized into a unittest that passed)
- Include various changes gathered by rspivak/slimit#65, which may be the source of some of the fixes listed above.