RailRoad Pascal Diagrams

Where can I find pascal style railroad diagrams to describe the C ++ syntax? (Alternatively EBNF)

+1


source to share


3 answers


There, as I know, does not exist. C ++ syntax cannot even be expressed in proper EBNF - it is a context sensitive grammar, and anything that tries to parse it should be able to handle C ++ code at least until instantiated and overload resolution (not to mention macros).



+1


source


I don't know if there are any railroad diagrams for C ++ diagrams (I don't appreciate this image very much), but it is purely mechanical work of converting EBNF to these diagrams.

About C ++ grammar: If you look at the grammar in the C ++ standard application, it is a context-free grammar . The problem with this grammar is that it is an ambiguous grammar . Another thing is that the grammar accepts strings that are not valid C ++ programs, but this is true of all typed languages ​​with variable declarations. If the gram was undecidable , that would mean that you could not specify for any line if it was generated according to the grammar or not. By the way, actually the problem is unsolvable regardless of whether the file is compiled in C ++, because the templates are Turing-complete.



The reason this ambiguous grammar was frowned upon is because it complicates, slows down, and / or requires more memory.

+1


source


There is not one - the C ++ grammar is not only not context sensitive, it is undecidable. Cm.http://yosefk.com/c++fqa/defective.html#defect-2 and related links for more in-depth discussion.

0


source







All Articles