Comments (7)
In PEG formalism, you can easily match until a terminator by using a predicate together with the .
metacharacter. Something like:
"OBJECT IDENTIFIER" (!"}" .)* "}"
Is that sufficient for you?
from pegjs.
#66 will fix this.
I think in the mean while you can use:
rule
= chars:(!"-suffix" c:. {return c})+ "-suffix"
from pegjs.
Update: This could be satisfied by a repetition count (which is a generalization of my initial thought) as suggested in Google Groups at: http://groups.google.com/group/pegjs/browse_thread/thread/2bea15581be45187
from pegjs.
Yes, that works perfectly. Thanks!
from pegjs.
@dmajda What's the recommended practice for stripping out the empty char returned by the !"}"
expression?
For example:
rule
= chars:(!"-suffix" .)+ "-suffix"
"foo-suffix" => [[ '', 'f' ], ['', 'o' ], ['', 'o' ]] // result
"foo-suffix" => ['f', 'o', 'o' ] // desired result
I was able to achieve this by breaking !"-suffix" .
into its own rule that just returns the .
result, but I'm curious if there's a better way.
from pegjs.
@islandr Please don't use issues as a place to ask questions about PEG.js usage. Especially when they are closed and especially when you are asking something that other people beside me can help you with. The proper channel is the Google Group.
from pegjs.
Sorry David. Thought this would have been a good place since it was
directly related to the example you'd given.
On Wed, Jan 9, 2013 at 9:51 PM, David Majda [email protected]:
@islandr https://github.com/islandr Please don't use issues as a place
to ask questions about PEG.js usage. Especially when they are closed and
especially when you are asking something that other people beside me can
help you with. The proper channel is the Google Grouphttp://groups.google.com/group/pegjs
.—
Reply to this email directly or view it on GitHubhttps://github.com//issues/57#issuecomment-12083927.
from pegjs.
Related Issues (20)
- Up-to-date JavaScript grammar HOT 2
- Using PEG.js at runtime works, but generated grammer fails to work? HOT 2
- Operator precedence tree compiling extremely slowly HOT 2
- Merging multiple single-character expressions
- Fork of the online editor with inline errors HOT 1
- Ignore me -- wrong project
- [composable, declarative, typescript] react-peg: parser generator based on pegjs
- Bug with context-sensitive grammar HOT 1
- option to generate an es module instead of commonjs module HOT 12
- Cannot use parseFloat inside grammar HOT 4
- literalEscape HOT 1
- Support for runtime context object? HOT 3
- [META] Switch to Peggy HOT 9
- Grammar action errors need to be more informative HOT 4
- Allow access to different rules in code blocks HOT 2
- Using same rule in pattern HOT 2
- Pegjs online can't parser parser.pegjs HOT 2
- Variables in parentheses can't be accessed
- Documentation should describe all features of the grammar specification language (e.g., dollar sign "$", "text()") HOT 3
- Deprecate/archive and recommend peggy.js as official successor project? HOT 4
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 pegjs.