Comments (6)
There is no explicit support for indentation parsing in the generator, so the best thing you could do is preparse your text, and replace the indentation with special {INDENT}
and {DEDENT}
strings, and then do the parsing with peginator
. The algorithm itself should look something like this: https://stackoverflow.com/a/40960461
I guess newlines will be important in your grammar, so you should probably replace those with a special {NEWLINE}
string too, or use custom whitespace handling (by default newlines will be dropped between tokens).
Maybe some day peginator
will have out-of-box support for these, but not currently.
from peginator.
Can you show how ii can "pre-parse" Not the entire code, just how to handle the pre parsing in peginator.
from peginator.
Will "@extern" do the job ig?
from peginator.
To pre-parse, before giving your String
to peginator
, you first transform it with your own code:
let content = load_file("in.txt");
let transformed_content = detect_indent_dedent(&content); // <= You have to write this function, it's not part of peginator
let ast = GeneratedParser::parse(&transformed_content);
@extern
is for calling a specific parser while parsing. It's mostly for handling special-form literals or tokens that would be hard to describe in EBNF.
from peginator.
Alright i get it now thank you.
from peginator.
Closed.
from peginator.
Related Issues (20)
- How to use custom char check? HOT 7
- Add case insensitive string literals HOT 1
- Generalized position HOT 1
- Precedence climbing HOT 12
- Flattened enums HOT 5
- Dead code elimination
- Left recursion
- Cannot add @position to external rules HOT 2
- Extension name? HOT 3
- How to force-include a char? HOT 15
- Automatic rule inlining and type deduction HOT 5
- Confusing error message in case of a syntax error HOT 4
- Later processing errors should give error position information
- Bug: non-overridden choice in all-choices rule creates struct and not enum HOT 8
- Duplicated rule names are allowed
- Referencing non-existent rules in fields are allowed
- Allow the names "state", "global", "result", etc. in field names
- Handle fields (and rules) that have a rust keyword name
- '--railroad' doesn't get included in the cli? HOT 2
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 peginator.