Comments (4)
It's difficult to diagnose without seeing the definition of quotedSegment
et al. If you can post a minimal complete example (i.e. one that compiles) that exhibits the problem, then I can take a look.
Also, can you elaborate on what you mean when you say it doesn't work. Do you get an error?
from funcj.
Hi Jon,
Thank you for your response. I have created a sample at https://github.com/kpadmasola/funcj-sample/tree/master
Yes, I get an error when I run the program. I'm not sure if I am making any mistake when defining the grammar.
The App.java has example paths that need to be parsed. It contains both single segment and multi segment paths.
When I use the singleSegmentPath
parser (https://github.com/kpadmasola/funcj-sample/blob/master/src/main/java/org/example/Grammar.java#L102), the single segment paths get parsed correctly and multi segment paths fail as expected.
I defined multi segment path parser here https://github.com/kpadmasola/funcj-sample/blob/master/src/main/java/org/example/Grammar.java#L110, which is supposed to handle both single and multi segment paths, but it is now failing right on the first single segment path test in App.java.
I'd like the grammar to be able to handle both single and multi segment paths. The only complexity is in the last segment -- it can be just a *
(wildcard segment) or "abc"*
(wildcard suffix segment) or xyz
(normal segment) or "pqr"
(quoted segment). I can manually handle the complexity of last segment in my application and simplify the grammar to include only normal segment and quoted segment. But before I take that route, I just want to understand why I am not able to handle it it the grammar.
Please let me know if you need any more details. Appreciate your help with this.
thanks,
Krishna
PS: for quoted segment, I used your code from json parser grammar for json string parsing.
from funcj.
I think the first issue is this:
choice(normalSegment, quotedSegment)
.andL(period).many()
This rule is saying that it will accept zero or more of a segment followed by a period. So these all parse:
Segment Period
Segment Period Segment Period
etc. However a Segment on its own does not parse because it's not followed by a period. So the first test in app ("a") fails for this reason.
from funcj.
thanks, that makes sense.
from funcj.
Related Issues (20)
- Add support for BigDecimal and related types
- Try/Option etc recursion scheme methods
- IList::flatmap does not assign result properly HOT 1
- Allow data to be serialised even if a ctor can't be found
- Add support for Avro
- Allow dynamic type tags to be disabled
- funcj.codec - add support for type aliases
- Codec support for configurable field naming
- Codec: registerAllowedPackage support for package wildcards
- Add support to JSON and XML streaming codecs for support pretty-printing
- `sepBy1` should return `NonEmpty<T>` HOT 1
- `choice` and `or` combinators do not work correctly with `string` HOT 2
- Strange behaviour for `choice` HOT 4
- Partial parsing fails HOT 5
- Calling many() on an uninitialized reference throws exception but it shouldn't. HOT 3
- Request: Change visibility of various parser fields in `JsonCombParser` to public HOT 7
- Example parsers with specific Token data structure vs Chr HOT 3
- how would you go about capturing a block comment? HOT 4
- Add support for MessagePack encoding HOT 1
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 funcj.