Sentence Generation Superfluous Whitespace #217
-
Why does my sentence generation cause tons of extra white space? Is there a way to clean it up?
https://git.sr.ht/~madcapjake/antlr-kokanu/tree/main/item/grammar/KokanuParser.g4 |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Whitespaces are usually not quantitative elements, but more of fill elements, and appear in any cluster size. The sentence generation, however, generates on a single space (not tab, no linebreak etc.) between every generated element. Because of the recursive and iterative nature of parser grammars, elements might not have been created actually, but their surrounding spaces, which creates a sequence of them. In any case, these (extra) spaces have no impact on the parsability of the generated text. It's still valid input for the given grammar. I recommend adding a post processing job to get rid of elements you don't want. |
Beta Was this translation helpful? Give feedback.
Whitespaces are usually not quantitative elements, but more of fill elements, and appear in any cluster size. The sentence generation, however, generates on a single space (not tab, no linebreak etc.) between every generated element. Because of the recursive and iterative nature of parser grammars, elements might not have been created actually, but their surrounding spaces, which creates a sequence of them.
In any case, these (extra) spaces have no impact on the parsability of the generated text. It's still valid input for the given grammar. I recommend adding a post processing job to get rid of elements you don't want.