-
Notifications
You must be signed in to change notification settings - Fork 30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Python binding #42
Closed
Closed
Python binding #42
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Just in case cython treats POD-types differently (apparently it does).
This is intended for both support of `Pire::Regexp` class from pire/easy.h and simpler enum-based interface to features and encodings. `Pire::Option<...>` and all the `Pire::Options::Proxy` magic classes proved to be too hard to wrap in Cython, so `Pire::Option` is replaced with integer enum `OptionFlag`, and `Pire::Options` is represented literally as set of `OptionFlag`'s, which is converted to `Pire::Options` where needed. Mako provides a way to manage the set of available options/`Feature`s/`Encoding`s: once a new option is needed, it should suffice to add a corresponding `OptionSpec` to render.py and probably an `#include` to options.h.mako.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is a cython-based python binding of PIRE. Mako template engine is used heavily to address repetitiveness of similar interfaces.
What is not wrapped:
Feature
s andScanner
s in python and pass the extension back to C++;mmap
- andAction
-related methods and functions;Run
for pair of scanners;Feature
andEncoding
classes.Interface of the binding is similar to the original one. Differences:
Fsm::operator * ()
is wrapped asFsm.Iterated()
.Pire::RunHelper
.Encoding
,Feature
andOption
abstractions are replaced with singleOptions
abstraction, which is used to tweak Lexer behavior.Options
can be either parsed from string such as"aiyu"
or composed of predefined constants such asI
andUTF8
.lexer::AddFeature(Capture(42))
you uselexer.AddCapturing(42)
.OverflowError
is raised on unsuccessful glue operation instead of returning empty scanner.