-
Notifications
You must be signed in to change notification settings - Fork 3
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
Compiler #10
Open
sbryant
wants to merge
34
commits into
master
Choose a base branch
from
compiler
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…sequence into a string.
…ss, used in tests.
fix up the tests.
In the event we get a list of one we can just return it, since we have no tree to deal with. If we have a list of more than one, attempt to compound the statements until we rerun into a descendant token. If list of compounds greater than 1 wrap in a compound statement then wrap a subtree in descendants. If we do not have a list of compounds greater than one just cons token with the descendants. Examples: '((:SYMBOL :DIV)) => '((:SYMBOL :DIV)) '((:SYMBOL :DIV) :DESCENDANT (:SYMBOL :P) => '((SYMBOL :DIV) (:DESCENDANTS ((:SYMBOL :P)))) '((:SYMBOL :DIV) (:ID :MY-ID)) => '((:COMPOUND ((:SYMBOL :DIV) (:ID :MY-ID)))) '((:SYMBOL :DIV) (:ID :MY-ID) :DESCENDANT (:SYMBOL :P)) => '((:COMPOUND ((:SYMBOL :DIV) (:ID :MY-ID))) (:DESCENDANTS ((:SYMBOL :P)))) '((:SYMBOL :DIV) (:ID :MY-ID) :DESCENDANT (:SYMBOL :P) (:CLASS :MY-CLASS)) => '((:COMPOUND ((:SYMBOL :DIV) (:ID :MY-ID))) (:DESCENDANTS ((:COMPOUND ((:SYMBOL :P) (:CLASS :MY-CLASS))))))
This seems strange but it makes sense. Instead of generating a form like ((:compound (:symbol :a) (:class :b))) generate a form that looks like: (:compound (:symbol :a) (:class :b)) This requires a tree to be a tree with a single root rather than something evil.
(matches-p (make-path-matcher "p.b") *lhtml-nodes*) where lhtml nodes looks something like: (:HTML NIL (:HEAD NIL (:TITLE NIL "lol")) (:BODY NIL (:P ((:ID "a") (:CLASS "b")) "Test")))
Specifically, the problem was with descending without compound predicates. This lead to strange behavior when descendants weren't forms but just random tokens.
My approach is a little annoying and not really clear. I'll need to redo this in very near future because of the complexity of adding attribute and content selector support.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is the beginnings of a compiler that'll generate compiled CSS expression matchers for CSS paths.
Right now it's very simple and the only things supported are:
div
.my-class
#my-id
div p
And compound expressions built from any of the above.
div#my-id.my-class p
Limitations
Only a single reference is returned from the matcher. The matcher actually recurs already I just return the first match I encounter. The correct behavior would be to build a list of references.