Comments (4)
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 seq
s. You can use the join
function to coalesce those seq
s 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.
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.
I guess there should be a "add result after previous result" operator like ><
. ( because &
is not satisfies my need )
from honeycomb.
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
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 honeycomb.