3 ms·
What do you lose by sticking to context-free grammars?
by thedonald123 11y ago
What do you lose by sticking to context-free grammars?
- rumcajz 11y agoAbility to prefix fields by size. Which in turn means you can't preallocate buffers because you don't know the sizes in advance.
- nly 11y agoMeh, you're probably going to want to limit your buffer size anyway in any highly concurrent system. Assuming you need to scan them anyway, delimited fields can also be faster to scan. If a field can't contain 0x00, and is 0x00 terminated (you can ensure this), then you don't need to do as many bounds-checks. If you know what you're doing, then Ragels 'noend' directive enables this, for instance.
- DasIch 11y agoAs the name suggests you lose context, you can't "remember" anything you've seen in the token stream. So you can't really parse languages that use indentation. Although you can circumvent that by processing indentation in the lexer or inbetween lexer and parser.