Code Monkey home page Code Monkey logo

parser's People

Contributors

eddyw avatar equinusocio avatar jonathantneal avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

parser's Issues

Add req to package.json / readme

 "engines": {
    "node": ">= 14.0.0"
  }

I guess this version of rollup requires you to have 14 or greater, as I switch, this bit me.

Number is scientific notation can be followed by a sign

๐Ÿ‘‹ nice job with the tokenizer

Description

From specs: https://drafts.csswg.org/css-syntax/#consume-number

If the next 2 or 3 input code points are U+0045 LATIN CAPITAL LETTER E (E) or U+0065 LATIN SMALL LETTER E (e), optionally followed by U+002D HYPHEN-MINUS (-) or U+002B PLUS SIGN (+), followed by a digit, then:

  1. Consume them.
  2. Append them to repr.
  3. Set type to "number".
  4. While the next input code point is a digit, consume it and append it to repr.

The logic looks okay.. but I think you forgot to consume the sign:

&& isInteger(cssText.charCodeAt(shut + 1))

It should be .. I think:

&& isInteger(cssText.charCodeAt(shut + 2))

It's + 2 because you didn't consume the sign (didn't do ++shut, so shut still points to e|E). Otherwise the check is always false.

Steps to reproduce

  1. Open https://csstools.github.io/parser/
  2. Type
#c {
  border: 1e+1px
}
  1. see AST displays

Screen Shot 2020-07-30 at 2 04 26 PM

Additional

From specs, consume number (called by consume numeric token) should return 6. convert repl to number which is described here: https://drafts.csswg.org/css-syntax-3/#convert-string-to-number
Since the tokenizer is written in JS, you can pretty much ignore it all and just do parseFloat(this.value). Could CSSNumber return, for example:

CSSNumber {
   value: "12e+1",
   number: 120, // Result of parseFloat(value)
   unit: "px",
}

Anyways, this last thing is just a suggestion and I'm not sure how parseFloat would affect performance ๐Ÿ˜…

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.