Is the same as i(am, a(tree))
. Finally, you can have array-like/hash-like syntax like the example above, with link a/b[c/d][e]/f[g[h[i/j]]]
. That "nest" is always a leaf node. See the parser in the repo on how that is handled, it is just consumed as one block in the lexer. That is pretty much it. The lexer basically processes/handles the indentation and the terms, giving to the processorparser what can be treated as a tree, so the parser doesn't have to figure out the indentation logic too.
Is the same as i(am, a(tree))
. Finally, you can have array-like/hash-like syntax like the example above, with link a/b[c/d][e]/f[g[h[i/j]]]
. That "nest" is always a leaf node. See the parser in the repo on how that is handled, it is just consumed as one block in the lexer. That is pretty much it. The lexer basically processes/handles the indentation and the terms, giving to the processor what can be treated as a tree, so the parser doesn't have to figure out the indentation logic too.
Is the same as i(am, a(tree))
. Finally, you can have array-like/hash-like syntax like the example above, with link a/b[c/d][e]/f[g[h[i/j]]]
. That "nest" is always a leaf node. See the parser in the repo on how that is handled, it is just consumed as one block in the lexer. That is pretty much it. The lexer basically processes/handles the indentation and the terms, giving to the parser what can be treated as a tree, so the parser doesn't have to figure out the indentation logic too.
I don't have an actual BNF grammar yet, but here is a brief explanation. "Terms" are words separated by hyphens like foo
or foo-bar
or foo-bar-baz
, all lowercase letters or numbers (can't start with a number). Text (strings) are like <hello I'm some text>
, with optional templating like <I am a {term}>
. Terms can be used like functions too, so you can do <I am a {function-term(arg1)}>
. You can include the angle brackets in text with backslash escaping \<
or \>
. Then there are integers and floats and "codes" like #x000000
where #
is the prefix, x
means hex, and then the code. There is binary codes b
and octal o
, and unicode u
. Then the main part is the indentation. Terms are nested into a tree based on 2-space indentation. There can be multiple blank lines between nested terms. The indentation serves the same function/purpose as parentheses, they result in the same AST. So this:
I mainly want to know how to simplify handling the indentation logic. Here's a real-world example of some of the code.
I don't have an actual BNF grammar yet, but here is a brief explanation. "Terms" are words separated by hyphens like foo
or foo-bar
or foo-bar-baz
, all lowercase letters or numbers (can't start with a number). Text (strings) are like <hello I'm some text>
, with optional templating like <I am a {term}>
. Terms can be used like functions too, so you can do <I am a {function-term(arg1)}>
. Then there are integers and floats and "codes" like #x000000
where #
is the prefix, x
means hex, and then the code. There is binary codes b
and octal o
, and unicode u
. Then the main part is the indentation. Terms are nested into a tree based on 2-space indentation. There can be multiple blank lines between nested terms. The indentation serves the same function/purpose as parentheses, they result in the same AST. So this:
I don't have an actual BNF grammar yet, but here is a brief explanation. "Terms" are words separated by hyphens like foo
or foo-bar
or foo-bar-baz
, all lowercase letters or numbers (can't start with a number). Text (strings) are like <hello I'm some text>
, with optional templating like <I am a {term}>
. Terms can be used like functions too, so you can do <I am a {function-term(arg1)}>
. You can include the angle brackets in text with backslash escaping \<
or \>
. Then there are integers and floats and "codes" like #x000000
where #
is the prefix, x
means hex, and then the code. There is binary codes b
and octal o
, and unicode u
. Then the main part is the indentation. Terms are nested into a tree based on 2-space indentation. There can be multiple blank lines between nested terms. The indentation serves the same function/purpose as parentheses, they result in the same AST. So this:
I mainly want to know how to simplify handling the indentation logic. Here's a real-world example of some of the code.
- 22.4k
- 6
- 34
- 70