I'm not very familiarized with parsers and grammars, so I needed assistance understand correclty the subject.
Let's say I have a grammar and I want to define a parser for said grammar. Looking in other Stack Overflow questions I learned that there might be infinite parsers for a grammar. However, what conditions should I impose on the grammar or on the parser to prevent infinite loops on the parser?
After checking similar questions in Stack Overflow I learnt that my grammar must be a deterministic context-free grammar. If that is correct that means that the grammar can be generated by a determinsitic push-down automata. What sufficient conditions allows to assure that a context-free grammar is deterministic without reference to push-down automatas?
Finally, for the problem I'm actually interested the length of the words in the language is fixed, so I guess that in those cases infinite loops can be avoid. Am I correct in this guess?
I suspect this are all well-known results already researched and published, so I'm totally fine with just getting recommendation for a book or a paper on the subject.
There are many different parsing algorithms to pick from, each of which will impose their own rules and restrictions. So in that sense there isn’t a single unified answer to this problem. Some CFGs that can’t be parsed by an LL(1) parser, for example, can be parsed with an LR(0) parser and vice-versa. So a good first step would be to select which parsing algorithm you want to use. LL(1) parsers are probably the simplest to understand but require some gymnastics to handle many grammars. LR-family parsers are more powerful but require a bit of specialized knowledge about their inner workings to use.
There are some subtleties here that make this statement technically incorrect. You’re right that there’s a link between deterministic pushdown automata and deterministic grammars, but it’s a tricky one. Deterministic grammars are only of concern if you’re using LR-style parsers, and while there’s a theorem that says a language is a deterministic CFL if and only if there exists a deterministic grammar for it, that theorem doesn’t necessarily help you find a way to write a grammar for the language that works with an LR parser unless you’re super familiar with how deterministic pushdown automata work. (And even then the grammar you’d get back would be pretty tricky to work with.)
The most common way you’ll see people check if a grammar works for an LR parser is to just run the grammar through an LR parser generator and see if it produces any shift/reduce or reduce/reduce conflicts.
Yep, any “reasonable” CFG for fixed-length strings should avoid the kinds of conflicts described above - unless the structure of those strings is surprisingly complex.