Skip to main content
Code Review

Return to Question

Notice removed Draw attention by Community Bot
Bounty Ended with Sᴀᴍ Onᴇᴌᴀ's answer chosen by Community Bot
edited tags
Link
deleted 3 characters in body
Source Link

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.

added 73 characters in body
Source Link

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.

enter image description here

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.

enter image description here

added 1377 characters in body
Source Link
Loading
Tweeted twitter.com/StackCodeReview/status/1490430097274380296
Notice added Draw attention by Lance Pollard
Bounty Started worth 50 reputation by Lance Pollard
added 2751 characters in body
Source Link
Loading
All questions should have a language tag; adding language from opening code gate.
Link
mdfst13
  • 22.4k
  • 6
  • 34
  • 70
Loading
added 115 characters in body
Source Link
Loading
Source Link
Loading
lang-js

AltStyle によって変換されたページ (->オリジナル) /