• ChatGPT explains compilers

    From gah4@21:1/5 to All on Wed Feb 15 14:06:15 2023
    Someone in another group asked ChatGPT a computer hardware question.
    After a few other tries, I asked about recursive descent or flex/bison.
    Here is the answer:

    "Both recursive descent and Flex/Bison have their own strengths and weaknesses when it comes to writing compilers.

    Recursive descent is a top-down parsing technique that involves writing separate procedures for each non-terminal symbol in the grammar. This can be a good approach for smaller grammars or when you want more control over the parsing process, since you are essentially writing the parsing logic by hand. Recursive descent parsers are also generally easier to debug than parsers generated by tools like Flex/Bison.

    On the other hand, Flex/Bison are tools that generate lexer and parser code based on a grammar specification. This can be a good approach for larger and more complex grammars, as it can save a lot of time and effort in writing the parsing logic. Additionally, Flex/Bison-generated parsers are usually more efficient than recursive descent parsers, as they are often implemented using
    a bottom-up parsing technique.

    Ultimately, the choice between recursive descent and Flex/Bison (or similar tools) will depend on the specific needs of your compiler project. If you have a simple grammar and want more control over the parsing process, recursive descent might be a good choice. If you have a more complex grammar and want to save time and effort, Flex/Bison might be a better choice."

    I also asked about Fortran vs. PL/I for scientific programming.
    Among others, it claims that PL/I has a more complex syntax than
    Fortran. I suspect I would have said the other way around.

    But what is the actual scale to measure syntax complexity?
    [Gee, I wasted all that time writing a flex/bison book by hand. Re Fortran
    vs. PL/I, it depends a lot what versions you're talking about, but IBM PL/I
    has a very large grammar due to things like the COBOL picture stuff and the many flavors of I/O. -John]

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)