kgscialdone / honeycomb Goto Github PK
View Code? Open in Web Editor NEWA dead simple, no-nonsense parser combinator library written in pure Nim.
Home Page: https://katrinakitten.github.io/honeycomb/
License: Mozilla Public License 2.0
A dead simple, no-nonsense parser combinator library written in pure Nim.
Home Page: https://katrinakitten.github.io/honeycomb/
License: Mozilla Public License 2.0
Hey!
I'm confused on writing a "command line argument" parser with honeycomb
.
here's my code:
import honeycomb, print
const text = "make global -orient RXY -name vff"
let parser = (
(many(letter) << whitespace) &
many((many(c('-') | alphanumeric) << whitespace) & (many(letter) << optional(whitespace))) <<
eof
)
print parser.parse text
I was trying to parse a command line input like make global -orient RXY -name vff
and expected to get something like this:
["make", "global" , "-orient", "RXY", "-name", "vff"] # or
["make", "global" , @["-orient", "RXY"], @["-name", "vff"]]
but I get:
ParseResult[seq[seq[char]]](
kind: "success",
value: @[
@['m', 'a', 'k', 'e'],
@['g', 'l', 'o', 'b', 'a', 'l'],
@['-', 'o', 'r', 'i', 'e', 'n', 't', 'R', 'X', 'Y'],
@['-', 'n', 'a', 'm', 'e', 'v', 'f', 'f']
],
tail: "",
fromInput: "make global -orient RXY -name vff"
)
I tried to read the tests, but it lacks more advanced examples like this.
I expected to be able to parse a (non-delimited) group of digits, grouped into some clusters. as follows:
digit.atMost(3).atLeast(4).parse("255314")
As a result, I expected a grouping of the digit clusters like "2", "5","53","14"; but the parser hangs (or at least, runs for 5 minutes without any result).
Environment:
Additional context
I am a new user and might be missing something. If so, a pointer would be appreciated, as well as any other way to achieve what I'm trying to do.
Related: #3
Is your feature request related to a problem? Please describe.
I'd like to compile my library which uses honeycomb to JavaScript, but that's currently not possible because of the dependency on std/re
.
Describe the solution you'd like
Make honeycomb use std/jsre
instead when compiling to JavaScript.
Describe alternatives you've considered
Make the regex functionality optional (since I'm not using it in my library anyway).
Additional context
My library which uses honeycomb
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.