Comments (7)
I agree that we should try to get away w/o preprocessing if at all possible.
As to anyOf
and noneOf
: If these only contain 7-bit ASCII chars you should replace them with CharPredicate
instances defined on the companion object. Performance will be much better.
See the CharacterClasses definition in the akka-http header parser for inspiration.
is there any way to override the parsing over every single character or string
Yes, you can override the implicit converstion from String
and/or Char
.
See the Handling Whitespace section of the README for an example.
from fastparse.
This might be difficult to get right given that Unicode escaping is a
pre-process step in the compiler. How would you parse this, for example?
"\u005c"
Scalac equates it to a single backslash before parsing, which escapes the
"closing" double-quote, and thus it fails to parse.
Though "\u005c" parses just fine, and is equal to """\u005c""". But I can
only say that because Unicode escapes are the only kinds of escape that
work inside triple-quoted strings...
Incidentally, Erik Osheim did some work removing Unicode escaping as a
pre-processor step in the compiler, and moving it into the single-quoted
string parser to try to remove most of the unintuitive corner cases. This
should make it into the Typelevel fork at some point...
Cheers,
Jon
On 29 November 2014 at 20:51, Mathias [email protected] wrote:
I agree that we should try to get away w/o preprocessing if at all
possible.As to anyOf and noneOf: If these only contain 7-bit ASCII chars you
should replace them with CharPredicate instances defined on the companion
object. Performance will be much better.
See the CharacterClasses definition
https://github.com/akka/akka/blob/release-2.3-dev/akka-http-core/src/main/scala/akka/http/model/parser/CharacterClasses.scala
in the akka-http header parser for inspiration.is there any way to override the parsing over every single character or
stringYes, you can override the implicit converstion from String and/or Char.
See the Handling Whitespace
https://github.com/sirthias/parboiled2#handling-whitespace section of
the README for an example.—
Reply to this email directly or view it on GitHub
#2 (comment).
Jon Pretty | @propensive
from fastparse.
Maybe the right thing to do is to preprocess unicode escapes, and purposely leave the source positions all wrong.
from fastparse.
If you implement that simple pre-processing at the ParserInput
level building a simple translation map you might be able to get the cake and eat it too.
from fastparse.
My approach was to honor unicode escapes where I must (that is, it won't parse if I don't) and ignore them otherwise (in strings and comments.) That's much closer to the behavior I think is sane, and I am doubtful the power of unicode escapes to open and close strings and comments is something which requires support.
Not claiming this is especially performant or anything, just a point of reference. https://github.com/paulp/scala-parser/blob/0a1e476c712d2ba/parser/src/main/scala/Basic.scala#L24
from fastparse.
Unicode escapes are now supported in strings. I'm going to just punt on this in general as a #wontfix. In all the dozen projects I parsed, I think I found exactly 4 unicode escapes that dont fall in a string, all of which are in Scalac test files. Not worth my time to support this ^_^
from fastparse.
Are they supported in characters, e.g. '\u0000'
? That, I think, would clear up all of the other useful cases.
from fastparse.
Related Issues (20)
- Mention fix for scala 2.13.7 HOT 4
- Capture success on failure if type is annotated or infered to `P[Unit]`
- SBT version conflict error when fastparse and os-lib are used together HOT 5
- Python argument typing is not supported in pythonparse HOT 1
- Warning about whitespace equality inside rep macro HOT 1
- Handle errors found in .map
- scala3 tracing failing to detect name of method HOT 1
- @nowarn annotation does not suppress any warnings (200USD Bounty) HOT 18
- Failure `msg` reports incorrect line number on Windows HOT 3
- Python 2.7 support dropped from actions/setup-python HOT 1
- Easily produced stacktrace HOT 1
- easy stacktrace redux HOT 1
- Parser that succeeds when run in its home project, but fails when used through a dependency
- How to detect invalid utf-8 sequences in scala fastparse?
- Fail ignores its argument and uses "fail" HOT 3
- Unexpected parsing behavior when composing parsers programmatically HOT 2
- Unexpected GitHub Workflow Inconsistency
- How to fix an exponential slowness due to backtracking? HOT 1
- Add `filterNot` as an opposite of `filter`
- Some tests need update for `\r\n` on windows
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 fastparse.