Mirror of the Rel4tion website/wiki source, view at <http://rel4tion.org>
Clone
HTTPS:
git clone https://vervis.peers.community/repos/yEzqv
SSH:
git clone USERNAME@vervis.peers.community:yEzqv
Branches
Tags
notes.mdwn
Basic detail suggestions:
- Programming language: [[/languages/Haskell]]
- Main module:
Language.Idan
- Package name:
language-idan
- License: I’ve been using GPLv3+ until now, but as the code probably won’t reuse anything else and won’t call any GPL library functions, it’s a good chance to use CC0 here. But make sure it’s not a pseudo-not-taking-side CC0, but an anti-law-anti-violence-anti-copyright CC0. Otherwise it will cause harm in the indirect ways BSD, MIT, etc. do
The main focus for the beginning is the parser.
Process idea: lexical analysis -> parsing -> syntax tree -> semantic analysis
Component/module/data ideas:
- Lexemes for emitting by lexer
- Token hierarchy for emitting by parser
- Model components for syntax tree
- Things for semantic analysis? (e.g. linking references and labels of anchors)
Plan idea:
- Tokenize using [[!hackage alex]]
- Parse using [[!hackage parsec]]
- Code the remaining tree traversals (huge case statements)
- The library may have a SAX-like API in which it exposes things in various levels of abstraction/features/model, and on top of that data models that use them (like DOM). There can be an Idan-specific model, and there are 2 more models that are generally useful (think the graph-based file conversion tool): statement block based model, and plain quads model
- Note that “callbacks” don’t just work like in C/C++. Perhaps just building a model is ok, since Haskell is lazy. But if not, use class/type for “templates” the user fills (like letting the user derive a Parser class) or let it be a monad the user supplies (as in
model >>= insertStatement
) - Look at existing parsers (e.g. for Turtle, JSON, XML) in Haskell
Notes:
- After reading a bit about using alex and parsec I found [[this|https://ro-che.info/articles/2015-01-02-lexical-analysis]]. Since Idan has all those tricky things like indentation and multi-line strings, the arguments there probably apply. Instead of Alex, I will start by using [[!hackage regex-applicative]] as a lexical analyzer.
- [[!hackage rdf4h]]’s parsers, including a Turtle one, use plain parsec without alex etc.