I started reading JavaScript: The Good Parts book and became confused at first pages (7 and 9 if be exact) by the railroad diagrams.
There are diagrams for the name and the string literal. (you can see the diagrams here)
As I know names in JavaScript can start with letters as well as with underscore or even '$' symbol. Following by the book's diagram it can starts only from letters.
For the string literal, imagine that you want to represent string like that: "\\".
Following by the diagram it's not possible(seems like after the "escaped character" the "any unicode character except " and \ and contol" is required.
Are those an errors in the book? Or I miss something?
The language described in the book "The Good Parts" is not JavaScript but a subset of it - you can call it "Crockford's JavaScript". Crockford introduces new syntax restrictions. One of those restrictions is that names cannot start with $
or _
.
It looks like the name railroad diagram definitely has problems. As you say, a name can start with underscore, but the diagram precludes it, and dollar signs seem to be completely missing.
You're wrong about the string literals though, since "\"
is properly not allowed.
One for you, one for Crockford.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With