Comments (7)
https://hazel.org/ are doing some interesting work on running/analyzing incomplete programs using 'holes', could be a (longer term) direction to go in
from athens.
I've commented per sub topic:
Parsing
Instaparse is a way better option than regexp. It takes a bit to get used to, but eventually combining regexp's will just become a terrible fragile mess. So +1 on that.
Incomplete AST
What options do we have? In the backend I can imagine we would treat the incomplete AST just as normal next. On the front end we might have a special parser that has spelling-checker like behaviour, saying this like "you might want to fix this". We could also annotate (potentially) incomplete ASTs in the database I guess. This would allow one to fix incorrect AST's every now and then and improve the whole database.
Transformation
Like you said, Instaparse still needs a post-processing step to put it in the right data structure. I've used clojure.spec
for this in the past and it can work, but it also a bit tricky. I wouldn't say it's ideal.
For the json import (#31) I was already thinking of experimenting with https://github.com/noprompt/meander to support the transformation from nested maps to datoms. I still need to validate this approach, but I can imagine it can be useful for transforming the ASTs as well. Either way clojure.spec
should definitely be used to validate the shape of the end result. In the past I've worked with different layers of specs, like compiled form and dsl form. It doesn't have to be one spec layer that does everything.
from athens.
In addition to my comment about Meander, I just found this demo of an implementation of a hiccup parser here. Pretty impressive
from athens.
Either way clojure.spec should definitely be used to validate the shape of the end result. In the past I've worked with different layers of specs, like compiled form and dsl form. It doesn't have to be one spec layer that does everything.
Interesting. Gave me some ideas about incomplete ASTs:
- Base spec for valid ASTs or strings
- "Extended frontend spec" that is
(s/or :valid-ast ::valid-ast :ast-with-spell-check-suggest ::ast-with-spell-check-suggest)
(TODO better names)
from athens.
In the current implementation of the parser, I’ve handled incomplete syntax not with a special “incomplete” type of AST, but by interpreting the syntax as valid plaintext. This is the same way Markdown (at least CommonMark) handles syntax errors.
I can explain how it works with a simplified version of the parser:
block = ( block-link / any-char )*
block-link = <'[['> any-chars <']]'>
Within the *
repetition, block
uses ordered alternation /
to attempt to match the following characters to a block-link
– [[
and ]]
with character between them – first. If block-link
doesn’t match, the parser consumes one more character with any-char
and repeats.
That way, a string like [[foo]
is ultimately not parsed as a special unterminated link, which I imagine might look like this:
[:block [:error-unterminated [:block-link "foo]"]]]
Rather, it’s interpreted as the literal text “[[foo]”, like this:
[:block "[[foo]"]
Accepting the syntax as plain text is much easier to implement than trying to detect and correct errors. Accepting the syntax as plain text also ensures that the author’s punctuation will never be hidden by being misinterpreted as incomplete syntax. The downside is that this parser can’t be used to provide error messages in the case that the user truly wanted to use the link syntax.
from athens.
I'm currently playing around this this: https://github.com/teodorlu/athens/tree/parser-work/src/cljc/athens
from athens.
Generally agree with all your points. Interesting application of incomplete AST to provide user error messages.
Also curious about what you have in mind for meander. I haven't put much thought to AST transformations.
from athens.
Related Issues (20)
- Encrypted notes saved on dweb
- New bullet/block in existing list HOT 1
- Potential security issue
- (Personal CRM) Google & LinkedIn Contact Integration
- Crashing the parser
- Slash command menu clicks not working
- clicking the Autocomplete suggesion of an existing page not working
- Self-Hosting Backend docker compose it broken
- Show About information (version, etc.) in the Help screen
- 2.0.0. Regression: No longer works: from Search results, Shift+Enter to open page in sidebar
- API or tooling to make it easy to write scripts to modify database
- Could not import RoamResearch edn graph in Athens v2.0.0 HOT 5
- UI: Difficult to see saving animation HOT 1
- Extra blocks when creating a new daily page
- support TLS for athens workspaces
- Add a CTRL+F search like box for the page I have open.
- how to export the notes in markdown or other format?
- Advice:use “【【】】” to link the page as well
- can't open Athens in safari
- Integrate pull request preview environments
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 athens.