David Majda
4f7145e360
Improve location info available in action code
...
Replace |line|, |column|, and |offset| functions with the |location|
function. It returns an object like this:
{
start: { offset: 23, line: 5, column: 6 },
end: { offset: 25, line: 5, column: 8 }
}
In actions, |start| refers to the position at the beginning of action's
expression and |end| refers to the position after the end of action's
expression. This allows one to easily add location info e.g. to AST
nodes created in actions.
In predicates, both |start| and |end| refer to the current position.
Fixes #246 .
10 years ago
David Majda
fb5f6c6ee9
Make labels behave like block-scoped variables
...
Action and predicate code can now see variables defined in expressions
"above" them.
Based on a pull request by Bryon Vandiver (@asterick):
https://github.com/pegjs/pegjs/pull/180
Fixes #316 .
10 years ago
David Majda
73795a65cc
Behavior specs cleanup: Add group specs
...
While groups don't create separate nodes on the AST level, they exist
as concept on the user level, so they should be specified.
10 years ago
David Majda
e306b58443
Behavior specs cleanup: Improve error reporting specs
10 years ago
David Majda
e9d038547d
Behavior specs cleanup: Improve semantic predicate specs
...
Note that use of |text| inside semantic predicate code is no longer
tested and officially supported.
10 years ago
David Majda
3d9600b81b
Behavior specs cleanup: Improve action specs
10 years ago
David Majda
b623396cb8
Behavior specs cleanup: Improve initializer specs
...
Note that use of |text|, |offset|, |line|, and |column| inside
initializer code is no longer tested and officially supported.
10 years ago
David Majda
fee58d0806
Behavior specs cleanup: Improve rule specs
10 years ago
David Majda
fa70e70ddf
Behavior specs cleanup: Improve choice specs
10 years ago
David Majda
b3828919e2
Behavior specs cleanup: Improve sequence specs
10 years ago
David Majda
548209b48b
Behavior specs cleanup: Improve simple predicate specs
10 years ago
David Majda
52144e48cb
Behavior specs cleanup: Improve label specs
10 years ago
David Majda
c5c44b9d0c
Behavior specs cleanup: Improve text specs
10 years ago
David Majda
bb708490a0
Behavior specs cleanup: Improve one or more specs
10 years ago
David Majda
b9a3b44cf2
Behavior specs cleanup: Improve zero or more specs
10 years ago
David Majda
c377eff876
Behavior specs cleanup: Improve optional specs
10 years ago
David Majda
ade2c249f2
Behavior specs cleanup: Improve rule reference specs
10 years ago
David Majda
936d6453a5
Behavior specs cleanup: Improve dot specs
10 years ago
David Majda
74be12c657
Behavior specs cleanup: Improve character class specs
10 years ago
David Majda
54191fbf12
Behavior specs cleanup: Improve literal specs
10 years ago
David Majda
2faff0000e
Behavior specs cleanup: Make |toParse| work without expected value
...
This means we can assert just "this string parses" and ignore the
returned value.
10 years ago
David Majda
ce91921a1d
Behavior specs cleanup: Don't describe named rules separately
...
While naming a rule creates a separate node on the AST level, it's not a
new concept on the user level, so its specs should be a part of rule
specs.
10 years ago
David Majda
a597e65a66
Behavior specs cleanup: Reorder toplevel |describe| blocks
...
Reorder toplevel |describe| blocks to more closely match ordering used
in the PEG.js grammar and elsewhere in PEG.js.
10 years ago
David Majda
3308807d22
Behavior specs cleanup: Move spec/api/generated-parser-behavior.spec.js
...
Move spec/api/generated-parser-behavior.spec.js to
spec/behavior/generated-parser-behavior.spec.js. It's not an API test,
strictly speaking.
10 years ago