GithubHelp home page GithubHelp logo

Comments (7)

dmajda avatar dmajda commented on May 28, 2024 3

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.

curvedmark avatar curvedmark commented on May 28, 2024 1

#66 will fix this.

I think in the mean while you can use:

rule
    = chars:(!"-suffix" c:. {return c})+ "-suffix"

from pegjs.

richb-hanover avatar richb-hanover commented on May 28, 2024

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.

richb-hanover avatar richb-hanover commented on May 28, 2024

Yes, that works perfectly. Thanks!

from pegjs.

rymohr avatar rymohr commented on May 28, 2024

@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.

dmajda avatar dmajda commented on May 28, 2024

@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.

rymohr avatar rymohr commented on May 28, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.