Giter Site home page Giter Site logo

Comments (4)

kgscialdone avatar kgscialdone commented on July 17, 2024 1

The many function doesn't know you want the characters it's parsing to end up as a string; it only knows how to make seqs. You can use the join function to coalesce those seqs into strings, and the asSeq function to wrap as needed so & doesn't complain about mismatched result types.

If you'd like some more complex examples than the admittedly limited ones in the documentation site, you can check out the integrations test suite towards the bottom of tests/tests.nim.

import honeycomb, print

const text = "make global -orient RXY -name vff"

let parser = (
  (many(letter).join << whitespace).asSeq &
  many((many(c('-') | alphanumeric).join << whitespace) & (many(letter).join << optional(whitespace))) <<
  eof
)

print parser.parse text
ParseResult[seq[seq[string]]](
  kind: success, 
  value: @[
    @["make"], 
    @["global", ""], 
    @["-orient", "RXY"], 
    @["-name", "vff"]
  ], 
  tail: "", 
  fromInput: "make global -orient RXY -name vff"
)

from honeycomb.

kgscialdone avatar kgscialdone commented on July 17, 2024 1

You absolutely can, while it's not using Honeycomb specifically you can check out the parser I wrote for my language SeekWhence, which uses a very similar library in Python called parsy.

from honeycomb.

hamidb80 avatar hamidb80 commented on July 17, 2024

I guess there should be a "add result after previous result" operator like ><. ( because & is not satisfies my need )

from honeycomb.

hamidb80 avatar hamidb80 commented on July 17, 2024

If you'd like some more complex examples than the admittedly limited ones in the documentation site, you can check out the integrations test suite towards the bottom of tests/tests.nim.

sorry for interruption,
can I use honeycomb to parse nested things? [like arrays or objects in JSON]
I couldn't find any examples

from honeycomb.

Related Issues (4)

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.