Updated documentation, added tree-sitter experiment
This commit is contained in:
6
experiments/package.json
Normal file
6
experiments/package.json
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"devDependencies": {
|
||||||
|
"tree-sitter": "^0.25.0",
|
||||||
|
"tree-sitter-javascript": "^0.25.0"
|
||||||
|
}
|
||||||
|
}
|
||||||
52
experiments/tree-sitter-1.mjs
Normal file
52
experiments/tree-sitter-1.mjs
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
import Parser from 'tree-sitter';
|
||||||
|
import JavaScript from 'tree-sitter-javascript';
|
||||||
|
import { readFileSync } from 'node:fs';
|
||||||
|
import { inspect } from 'node:util';
|
||||||
|
|
||||||
|
// NOTE: once upon a time
|
||||||
|
// there was some sort of
|
||||||
|
//
|
||||||
|
// example comment that we wanted to investigate
|
||||||
|
|
||||||
|
const parser = new Parser();
|
||||||
|
parser.setLanguage(JavaScript);
|
||||||
|
|
||||||
|
class example {
|
||||||
|
|
||||||
|
#private = 123
|
||||||
|
|
||||||
|
/*
|
||||||
|
This other comment
|
||||||
|
is of the style of a
|
||||||
|
block comment of course
|
||||||
|
*/
|
||||||
|
|
||||||
|
stuff() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
const source = readFileSync('./tree-sitter-1.mjs', 'utf-8');
|
||||||
|
const tree = parser.parse(source);
|
||||||
|
|
||||||
|
function* iter_nodes(node) {
|
||||||
|
yield node;
|
||||||
|
for (let i = 0; i < node.childCount; i++) {
|
||||||
|
yield* iter_nodes(node.child(i));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function *iter_child_nodes(node) {
|
||||||
|
for (let i = 0; i < node.childCount; i++) {
|
||||||
|
yield node.child(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
for (const node of iter_child_nodes(tree.rootNode)) {
|
||||||
|
//console.log({type: node.type, text: node.text?.slice(0, 40)});
|
||||||
|
console.log(inspect(node));
|
||||||
|
console.log({text: node.text});
|
||||||
|
}
|
||||||
25
planning/dsl.md
Normal file
25
planning/dsl.md
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
|
||||||
|
## Example of indented block
|
||||||
|
|
||||||
|
```
|
||||||
|
§ block
|
||||||
|
this content
|
||||||
|
is in the block body
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
## Inline
|
||||||
|
|
||||||
|
`«inline expression»`
|
||||||
|
|
||||||
|
## Escaping
|
||||||
|
|
||||||
|
|
||||||
|
```
|
||||||
|
«§» block
|
||||||
|
|
||||||
|
Here is an «la»inline expression«ra»
|
||||||
|
Or possibly «outer escape: inline expression»
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
19
planning/to-document.md
Normal file
19
planning/to-document.md
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
# Readme.md
|
||||||
|
|
||||||
|
In `readme.md` we should explain that `npm install` can be used both with and without development dependencies.
|
||||||
|
|
||||||
|
We are likely to want some development dependencies for the following purposes:
|
||||||
|
|
||||||
|
- Template processing
|
||||||
|
- Ecmascript parsing for inline rich semantic documentation
|
||||||
|
|
||||||
|
|
||||||
|
## Installing tree-sitter-javascript
|
||||||
|
|
||||||
|
- requires `node-gyp`
|
||||||
|
|
||||||
|
```sh
|
||||||
|
CXXFLAGS="-std=c++20" npm i -D tree-sitter tree-sitter-javascript
|
||||||
|
```
|
||||||
|
|
||||||
|
This section should be somewhat expanded - especially regarding node-gyp
|
||||||
Reference in New Issue
Block a user