Comments (2)
Hi, for situations like this I wrote the tracing capability of Pegged, see https://github.com/PhilippeSigaud/Pegged/wiki/Grammar-Debugging.
But let me try to parse your input with your grammar manually:
Typed
tries to parsea+b:A
, invokesList
.List
tries to parsea+b:A
, invokesTemplate
.Template
tries to parsea+b:A
, invokesTemplatePart
.TemplatePart
tries to parsea+b:A
, invokesVariable
.Variable
tries to parsea+b:A
, invokesidentifier
.identifier
tries to parsea+b:A
, matchesa
. Remaining input:+b:A
TemplatePart
matchesa
. Remaining input:+b:A
Template
tries to parse+b:A
, invokes anotherTemplatePart
.TemplatePart
tries to parse+b:A
, invokesVariable
.Variable
tries to parse+b:A
, invokesidentifier
.identifier
tries to parse+b:A
, fails.
TemplatePart
tries to parse+b:A
, invokesNumber
.Number
tries to parse+b:A
, fails.
TemplatePart
tries to parse+b:A
, invokesText
.Text
tries to parse+b:A
.Text
cannot match anything but the empty string because it only contains a negative lookahead, repeated 0 or more times. It succeeds on the empty string. Remaining input:+b:A
.
Template
has not advanced the input, gives up on trying anotherTemplatePart
.
List
succeeds witha
. Remaining input:+b:A
.
Typed
expects literal ":" afterList
, but the remaining input is+b:A
, and fails.
I assume you expect "+" to be matched by Text
, and it looks like you just forgot the "match anything parser" .
in
Text < (!(Variable / Number / ":" / ",") . )*
Hope this helps,
Bastiaan.
from pegged.
Hi, for situations like this I wrote the tracing capability of Pegged, see https://github.com/PhilippeSigaud/Pegged/wiki/Grammar-Debugging.
But let me try to parse your input with your grammar manually:
Typed
tries to parsea+b:A
, invokesList
.
List
tries to parsea+b:A
, invokesTemplate
.
Template
tries to parsea+b:A
, invokesTemplatePart
.
TemplatePart
tries to parsea+b:A
, invokesVariable
.
Variable
tries to parsea+b:A
, invokesidentifier
.
identifier
tries to parsea+b:A
, matchesa
. Remaining input:+b:A
TemplatePart
matchesa
. Remaining input:+b:A
Template
tries to parse+b:A
, invokes anotherTemplatePart
.
TemplatePart
tries to parse+b:A
, invokesVariable
.
Variable
tries to parse+b:A
, invokesidentifier
.
identifier
tries to parse+b:A
, fails.
TemplatePart
tries to parse+b:A
, invokesNumber
.
Number
tries to parse+b:A
, fails.
TemplatePart
tries to parse+b:A
, invokesText
.
Text
tries to parse+b:A
.Text
cannot match anything but the empty string because it only contains a negative lookahead, repeated 0 or more times. It succeeds on the empty string. Remaining input:+b:A
.
Template
has not advanced the input, gives up on trying anotherTemplatePart
.
List
succeeds witha
. Remaining input:+b:A
.
Typed
expects literal ":" afterList
, but the remaining input is+b:A
, and fails.I assume you expect "+" to be matched by
Text
, and it looks like you just forgot the "match anything parser".
inText < (!(Variable / Number / ":" / ",") . )*
Hope this helps,
Bastiaan.
@veelo Yes, that fixed it! :)
from pegged.
Related Issues (20)
- is it okay for the D grammar to compile in 10 minutes and use 45 gigs of ram? HOT 14
- Run-time parsing of Peg grammars HOT 1
- qualifiedIdentifier in dgrammar.d is not defined HOT 2
- Add equivalent of “important” blocks? HOT 3
- Release 0.4.5 HOT 2
- `pure` and `@safe` grammars/rules? HOT 3
- Grammar won't parse whole text, it stops short a few lines... HOT 1
- Comment syntax HOT 7
- Unwanted space consumption in rule parameter
- Syntax wrappers HOT 1
- How does one do Intellisense using a Pegged grammar? HOT 3
- Is there a way to break up a grammar into D classes, each with their own data to parse into & thus subgrammar? HOT 2
- I can't find the Wikipedia ParseTree handling code in the Pegged wiki any more... HOT 1
- Will there be a speed-up when using a Dlang switch-case and shorter pegged variable names? HOT 2
- Can we create a grammar induction algorithm based upon expected Pegged parsing failures? HOT 2
- How do you use dub + pegged + asModule? HOT 1
- Bump new version HOT 7
- Remove obsolete CI.
- How do you branch on complex names such as caseSensitiveLiteral!("let") (they get much more complicated) HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pegged.