pydsl
PyDSL is a grammar library written in Python. It includes parsers, validation tools and encoding tools.
The source code is hosted in github and the binary releases in pypi.
The basics
- Grammars: a set of rules that defines a language and can expand the meaning of an input
- Verbs: actions performed with grammars and input data
- Library
- Parsers
How to contribute
- submit or request the grammars/alphabet/translators you want to use!
- Get started with some issues.
- Writting adapters for other python parsing tools like pyparsing, ply or parsley
Blog posts
-
JsonSchema improvements
I have added format support to JsonSchema through pydsl. Here is a code snippet from the tests: schema = { "type" : "object", "required":["foo"], "properties" : { "foo" :...
-
random bugs in non random code
The last bug I had to fix took me 2 days to discover. I updated from python 3.2 to python 3.4. One of the tests failed randomly when it was executed with python 3.4 The error happened in the LR0 parser ====================================================================== FAIL: testArithmetic (tests.unit.test_Parser.TestLR0Parser) ----------------------------------------------------------------------...
-
Reviewing parsers implementations
Excluding external dependencies, PyDSL implements 4 parsers: 1.Backtracing Recusive Descent Parser It attempts every possible recursion and returns every valid parse tree. It supports the Null symbol, generates errors reports for the validator. It doesn’t support left recursion https://github.com/nesaro/pydsl/blob/master/pydsl/Parser/RecursiveDescent.py 2.Weighted Backtracing Recusive Descent Parser A small optimization...
-
spark library merged
I have merged a modified version of spark into. Syntax was quite old (python has evolved a lot in ten years) and I had to update a few syntax constructs, like dict.has_key, string.join or tuple expansion in function parameters. The spark integration into pydsl is still pending (see parser libraries...
-
Bounty added to pydsl
I have added a bounty for solving the task “Add parsley support” using bountysource. Hopefully this will speed things up a bit since I haven’t been able to spend time on pydsl :(.
-
Removed function support
During the last few months I’ve been deleting old code here and there. But this time I’ve deleted one of the main components of the pydsl core: The function module. That module included: PythonFunctions Boards SyntaxDirectedTranslators ExternalProgramFunction Agents The main reason is that all those functions didn’t add...
-
General diff
I’m working on a new feature to compare information according to an arbitrary grammar/alphabet. Alphabet Alphabet diff is similar to standard unix diff: using Longest Common Substring after calling the Lexer/Scanner. To some extend, this is an encoding aware diff. Grammar BNF Grammars generate a parse tree...
-
Tree module refactoring
The last few days have been mildly productive in regards of coding amount and quality. The module I have been working on is pydsl.Grammar.Tree. The code is now shorter and also more concise; AST is not a class anymore. The previous class hierarchy was: Tree AST ParseTree ...
-
PLY support
This weekend I’ve been reading about PLY. PLY is an implementation of lex and yacc parsing tools for Python. They are usually used together in Unix environments to generate parsers. I remember using them at university, but in a very limited way (and never studying its source code)....
-
ANTLR grammar format support
pydsl already has a BNF-like grammar support. Standard BNF features are almost the same for all implementations Symbol1 = Symbol2 | "terminalstr" Symbol2 = "anotherterminalstr" However the advanced features are more tricky and differs heavily between implementation. pydsl supports nested grammar with terminal rules.
-
Python DSL
Python DSL started 4 years ago as a alternative to OO development paradigm. As a slow learner, it took me a few years to realize that what I was trying is to implement a DSL framework. One of the books I’m currently reading is Language implementation patterns by Terence...