- #1
martix
- 163
- 1
I need to create a simple text parser that replaces {tokens} with text from a table.
The one more complicated bit is the {?text?} tag where text must be included only if the preceding AND the following tokens exist and are not empty. You could do {?text} where it looks for a non-empty neighbouring tag only on that side.
I have already bodged it based on common sense and an hour with the debugger.
What I don't know is how to approach this in a formal manner.
Like starting with a formal EBNF specification, perhaps creating the correct Abstract Syntax Tree, or however one goes about (what I assume can be classified as) creating a new language.
As you can probably guess I have no formal CS education, but I am interested in learning about this in a more structured manner (whatever 'this' is - language/compiler design?).
The one more complicated bit is the {?text?} tag where text must be included only if the preceding AND the following tokens exist and are not empty. You could do {?text} where it looks for a non-empty neighbouring tag only on that side.
I have already bodged it based on common sense and an hour with the debugger.
What I don't know is how to approach this in a formal manner.
Like starting with a formal EBNF specification, perhaps creating the correct Abstract Syntax Tree, or however one goes about (what I assume can be classified as) creating a new language.
As you can probably guess I have no formal CS education, but I am interested in learning about this in a more structured manner (whatever 'this' is - language/compiler design?).