@Diego >>congratulations for the code and the achievements. The code is clear >>and well written. The video is good too. Thanks Diego :) That's high praise coming from you.
As to your issues, I think I will definitely look into those and fix them. @Jarek >>Are you sure it is a good idea to use RegExps for something as complex >>as CSS3 selectors? I don't know that CSS selectors are as complicated as you're making them out to be. If you comment your RegExs carefully they can be maintainable. On Mon, Oct 3, 2011 at 4:20 AM, Diego Perini <[email protected]> wrote: > Nathan, > congratulations for the code and the achievements. The code is clear > and well written. The video is good too. > > This is a minimal list of minor problems I quickly noticed in the code: > > 1) the range [\u00c0-\uffff] is incorrect, it should be [\u00a0-\uffff] > > characters [a-zA-Z0-9] and ISO 10646 characters U+00A0 and higher > > 2) there is no distinction between syntax errors and non-matching nodes > > examples that should return "SYNTAX_ERR" instead of no matches (empty > result set): > > a[href=#] > img[class=8mm] > > 3) identifiers are not parsed correctly, needs a more specific RegExp > > Related to points 1,3 the CSS specifications says: > > *** > In CSS, identifiers (including element names, classes, and IDs in > selectors) can contain only the characters [a-zA-Z0-9] and ISO 10646 > characters U+00A0 and higher, plus the hyphen (-) and the underscore > (_); they cannot start with a digit, two hyphens, or a hyphen followed > by a digit. Identifiers can also contain escaped characters and any > ISO 10646 character as a numeric code (see next item). For instance, > the identifier "B&W?" may be written as "B\&W\?" or "B\26 W\3F". > *** > > so for CSS identifiers I use the following RegExp: > > identifier = '(?:-?[_a-zA-Z]{1}[-\\w]*|[^\\x00-\\xa0]+|\\\\.+)+' > > this should be quite in line with the complex specifications requirements. > > I hope this can help in case you want to improve your project. > > Again, keep up with the good coding ! > > > -- > Diego > > > On Sun, Oct 2, 2011 at 11:40 PM, nathanJsweet <[email protected]> > wrote: > > Hey all, > > I just posted a blog post on how to parse a css selector as part of a > > series I'm doing on building a selector engine. I would recommend you > > watch it only if you're a beginner or intermediate developer (advanced > > developers will likely not learn anything new). It can be found at > > http://nathansweet.me/selector-engine-css-parsing. Somewhat related, > > the code for the selector engine that I built for this blog series I'm > > doing can be found on my github account at > https://github.com/nathanjsweet/Punch. > > If anybody is interested in offering me a review I would appreciate > > it, but I by no means expect it for the following reasons: 1. The code > > will never see the light of day, it was purely an academic exercise 2. > > It is incomplete and will remain so (it doesn't fully mimic the full > > range of possible selectors) 3. It doesn't take querySelector into > > account 4. It takes very few cross-browser bugs into account. For what > > is there though, I would be interested in somebody's opinion. Finally, > > I've updated a test suite for selectors for this project that can be > > found at http://nathansweet.me/queryselectorall-rundown. I will be > > continually updating that page. Thanks in advance. > > -Nate > > > > -- > > To view archived discussions from the original JSMentors Mailman list: > http://www.mail-archive.com/[email protected]/ > > > > To search via a non-Google archive, visit here: > http://www.mail-archive.com/[email protected]/ > > > > To unsubscribe from this group, send email to > > [email protected] > > > > -- > To view archived discussions from the original JSMentors Mailman list: > http://www.mail-archive.com/[email protected]/ > > To search via a non-Google archive, visit here: > http://www.mail-archive.com/[email protected]/ > > To unsubscribe from this group, send email to > [email protected] > -- To view archived discussions from the original JSMentors Mailman list: http://www.mail-archive.com/[email protected]/ To search via a non-Google archive, visit here: http://www.mail-archive.com/[email protected]/ To unsubscribe from this group, send email to [email protected]
