787 Commits (a4a66a2e5be41832bcf23127a37515d155b700bc)
 

Author SHA1 Message Date
David Majda a4a66a2e5b Switch from first/rest to head/tail in the PEG.js grammar
In the past year I worked on various grammars where first/rest or
head/tail were used as labels for parts of lists. I found I associate
head/tail with a list immediately, while in case of first/rest I have to
"parse" grammar rules for a while before understanding their structure.

Moreover, I tend to assume that rest is a list of the same thigs as
first, but I don't have such assumption in case of head/tail. This
assumption was in conflict with the grammar structure.

I'm not sure how much these observations are applicable to others, but I
decided to act on them and switch from first/rest to head/tail.
9 years ago
David Majda e510ecc3d0 Switch from first/rest to head/tail in example grammars
In the past year I worked on various grammars where first/rest or
head/tail were used as labels for parts of lists. I found I associate
head/tail with a list immediately, while in case of first/rest I have to
"parse" grammar rules for a while before understanding their structure.

Moreover, I tend to assume that rest is a list of the same thigs as
first, but I don't have such assumption in case of head/tail. This
assumption was in conflict with the grammar structure.

I'm not sure how much these observations are applicable to others, but I
decided to act on them and switch from first/rest to head/tail.
9 years ago
David Majda 10d7a6aded Simplify the arithmetics example grammar
The arithmetics example grammar is the first thing everyone sees in the
online editor at the PEG.js website, but it begins with a complicated
|combine| function in the initializer. Without understanding it it is
impossible to understand code in the actions. This may be a barrier to
learning how PEG.js works.

This commit removes the |combine| function and gets rid of the whole
initializer, removing the learning obstacle and streamlining action
code. The only cost is a slight code duplication.
9 years ago
David Majda 69a0f769fc Use literal raw text in error messages
Fixes #127.
9 years ago
David Majda 36eb7b81b5 Use single quotes for |rawText| in parser specs
PEG.js convention is to use single quotes for code and |rawText| *is* a
piece of code (originally).
9 years ago
David Majda 25ab98027d Remove info about found string from syntax errors
The |found| property wasn't very useful as it mostly contained just one
character or |null| (the exception being syntax errors triggered by
|error| or |expected|). Similarly, the "but XXX found" part of the error
message (based on the |found| property) wasn't much useful and was
redundant in presence of location info.

For these reasons, this commit removes the |found| property and
corresponding part of the error message from syntax errors. It also
modifies error location info slightly to cover a range of 0 characters,
not 1 character (except when the error is triggered by |error| or
|expected|). This corresponds more precisely to the actual situation.

Fixes #372.
9 years ago
David Majda 4466265763 README.md: Remove link to Trello board
Trello board was replaced by development roadmap in the wiki.
9 years ago
David Majda bbb4f006cd Report full rule chain in recursive rule errors
The idea came from a PR by @Mingun:

  https://github.com/pegjs/pegjs/pull/307
9 years ago
David Majda 491106c347 Report left recursion and infinite loops only as "possible"
A semantic predicate can prevent the parser to actually enter infinite
recursion or loop. This is undetectable at compile-time.
9 years ago
David Majda ebf5d969b2 s/alwaysAdvancesOnSuccess/alwaysConsumesOnSuccess/
Matches terminology change from the previous commit.
9 years ago
David Majda 6ff005786c Talk about "consuming input", not "advancing parser position"
It's shorter, less technical, and more understandible.
9 years ago
David Majda 091e60112c Consistently use "matched text" to describe matched part of the input 9 years ago
David Majda 60ebd9e695 Simplify JSHint directives 9 years ago
David Majda efb420479e Tweak package.json 9 years ago
David Majda 48fe4d6580 Rename generate-javascript.js to generate-js.js
Short & sweet.
9 years ago
David Majda 575883586f Rename javascript.js to js.js
Short & sweet.
9 years ago
David Majda 20a4fb2e7f Update version to 0.9.0 9 years ago
David Majda 7aa4d519db Update CHANGELOG.md 9 years ago
David Majda 9e8cb04c81 examples/arithmetics.pegjs: Remove trailing whitespace 9 years ago
David Majda a2d6488dae CHANGELOG.md: Add header 9 years ago
David Majda cee0d6a60a README.md: Update the "Compatibility" section
* Added io.js.
  * Added Edge.
  * Spelled out IE.
9 years ago
David Majda 787239e15c Update copyright years 9 years ago
David Majda be5d14eb27 Update jQuery.scrollTo's LICENSE file
I forgot to do that after upgrading jQuery.scrollTo itself.
9 years ago
David Majda a4b4a57569 Custom tracers specs: s/'/"/
The convention is to use single quotes only for strings containing code.
9 years ago
David Majda 1d38b973ee Custom tracers specs: Simplify code slightly 9 years ago
David Majda 671c22e80f Avoid using |console| in default tracer and its tests when not defined
This makes default tracer and its tests work in IE 8-10.
9 years ago
David Majda e8b379f945 Rewrite |trace| option tests to avoid using |console|
This makes them cleaner and also makes them work in IE 8-10.
9 years ago
David Majda cca41e6618 Quote |class| object literal key
It broke IE 8.
9 years ago
David Majda 6d82422045 Remove trailing comma in an array literal
It caused an additional newline in generated parsers in IE 8.
9 years ago
David Majda 969d39e8d9 Remove trailing commas in object literals
They broke IE 8-9.
9 years ago
David Majda 2d0ab55fa2 Use jQuery.scrollTo 2.1.1 9 years ago
David Majda b929f6ed97 Use jQuery 1.11.3 9 years ago
David Majda ae407572e6 Use jshint 2.8.0 9 years ago
David Majda 9cea4502f0 Use uglify-js 2.4.24 9 years ago
David Majda 698dba299a Use jasmine-node 1.14.5 9 years ago
David Majda d5f93a8282 Fix comment typo 9 years ago
David Majda a4772376fb Renumber bytecode instructions sequentially 9 years ago
David Majda ad27a300a8 Fix left recursion detection in sequences
Report left recursion also in cases where the recursive rule invocation
is not a direct element of a sequence, but is wrapped inside an
expression.

Fixes #359.
9 years ago
David Majda 9eb62051be package.json: Add the "license" attribute
Based on a pull request by Peter deHaan (@pdehaan):

  https://github.com/pegjs/pegjs/pull/338
9 years ago
David Majda cdeecf750f reportLeftRecursion: Change handling of the |visitedRules| array
Before this commit, the |reportLeftRecursion| pass was written in
functional style, passing the |visitedRules| array around as a parameter
and making a new copy each time a rule was visited. This apparently
caused performance problems in some deeply recursive grammars.

This commit makes it so that there is just one array which is shared
across all the visitor functions via a closure and modified as rules are
visited.

I don't like losing the functional style (it was elegant) but
performance is more important.

Fixes #203.
9 years ago
David Majda de1704f007 Replace |util.{puts,error}| by |console.{log,error}|
The |util.puts| and |util.error| functions are deprecated in Node.js
0.12.x.

Based on a pull request by Jan Stránský (@burningtree):

  https://github.com/pegjs/pegjs/pull/334
9 years ago
David Majda 4b154e177f Update character categories in grammars to Unicode 8.0.0 9 years ago
David Majda 703a352985 Change few testcase descriptions
Reaction to changes in 130cbcfaa3.
9 years ago
David Majda d7d7e87874 Make infinite loop and left recursion detectors work with named rules
Add missing |named| case to the visitor in lib/compiler/asts.js, which
makes the infinite loop and left recursion detectors work correctly with
named rules.

The missing case caused |make parser| to fail with:

  140:34: Infinite loop detected.
  make: *** [parser] Error 1
9 years ago
David Majda 130cbcfaa3 Rename asts.matchesEmpty to alwaysAdvancesOnSuccess and negate it
This makes it more clear that the function isn't about the input the
expression *matched* but about the input it *consumed* when it matched.

Based on a comment by @Mingun:

  https://github.com/pegjs/pegjs/pull/307#issuecomment-89512575
9 years ago
David Majda 317059760a Fix incorrect pass name in a spec description 9 years ago
David Majda 373f48c10f Fix small error in two testcases
Pointed out by @Mingun:

  6ce97457bf (commitcomment-10548605)
9 years ago
David Majda 6f2c75f7d8 Label specs: Improve structure and descriptions 9 years ago
David Majda 8487c9a0ff Label specs: Add missing test case 9 years ago
David Majda f4385da177 Label specs: Unify formatting with other code 9 years ago