Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor to fully tokenize before formatting #530

Merged
merged 3 commits into from
Sep 24, 2014

Conversation

bitwiseman
Copy link
Member

We've been dealing with limitations from incomplete parsing (#200) for ages.

Instead attempting full parsing, this change only tokenizes fully before starting formatting. This should open the door to simplifying parsing and formatting rules.

For example, to find an object literal currently, we have to check repeatedly later on for a matching pattern. With this change we could determine as a block is opened whether to treat it as on object-literal or not (for features like #114, #315, #370).

Next steps could also include cleaning up the factoring for the recognizers for each token, adding a parse-ish pass, and refactoring the beautification rules to make use of the information now available to them.

@evocateur, @einars - please take a look when you have a chance. Any feedback welcome.

@bitwiseman bitwiseman changed the title Initial refactor to fully tokenize before formatting Refactor to fully tokenize before formatting Sep 17, 2014
@bitwiseman bitwiseman force-pushed the tokens-first branch 2 times, most recently from 43d7684 to 945fab5 Compare September 17, 2014 18:54
We've been dealing with limitations from incomplete parsing (beautifier#200) for ages.

Instead of parsing fully this change tokenizes fully before starting formatting.  This should open the door to simplifying parsing and formatting rules.

For example, to find an object literal currently, we have to check repeatedly later on for a matching pattern.  With this change we could determine as a block is opened whether to treat it as on object-literal or not.
It is hard to see the changes here because of brain-dead diff diff tools.
Created a Tokenizer class/scope and moved all tokenizing into it.
There are a few cases where sharing data makes sense, so the
beautifier references Tokenizer when needed.
bitwiseman added a commit that referenced this pull request Sep 24, 2014
Refactor to fully tokenize before formatting
@bitwiseman bitwiseman merged commit 2170184 into beautifier:master Sep 24, 2014
@bitwiseman bitwiseman added this to the v1.5.2 milestone Sep 24, 2014
@bitwiseman bitwiseman deleted the tokens-first branch September 25, 2014 03:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant