• Paper: Developing a Modular Compiler for a Subset of a C-like Language

    From John R Levine@johnl@taugh.com to comp.compilers on Thu Jan 9 09:18:08 2025
    From Newsgroup: comp.compilers

    The authors developed a compiler for a toy language targeting Raspberry Pi using lex and yacc. Nothing very new but it shows how you build a
    compiler incremntally expanding the source language.

    https://arxiv.org/abs/2501.04503

    Regards,
    John Levine, johnl@taugh.com, Taughannock Networks, Trumansburg NY
    Please consider the environment before reading this e-mail. https://jl.ly
    --- Synchronet 3.21b-Linux NewsLink 1.2
  • From OrangeFish@OrangeFish@invalid.invalid to comp.compilers on Sat Jan 11 09:15:48 2025
    From Newsgroup: comp.compilers

    On 2025-01-09 09:18, John R Levine wrote:
    The authors developed a compiler for a toy language targeting Raspberry Pi using lex and yacc. Nothing very new but it shows how you build a
    compiler incremntally expanding the source language.

    https://arxiv.org/abs/2501.04503

    I wish that they had proofread the pdf before posting. Various pieces
    of yacc/lex code are missing.

    OF.
    [It's just a draft and the authors' actual contact addresses are on that
    web page. How about writing to them and asking them to put in the
    missing code? People update arXiv papers all the time. -John]
    --- Synchronet 3.21b-Linux NewsLink 1.2
  • From antispam@antispam@fricas.org to comp.compilers on Thu Jan 16 13:46:20 2025
    From Newsgroup: comp.compilers

    John R Levine <johnl@taugh.com> wrote:
    The authors developed a compiler for a toy language targeting Raspberry Pi using lex and yacc. Nothing very new but it shows how you build a
    compiler incremntally expanding the source language.

    https://arxiv.org/abs/2501.04503

    I am affraid that the best use of this paper is to forget it.
    On one hand presentation is very naive and their "final"
    compiler apparently does not handle things handled in ususal toy
    compilers. On the other hand their presentation has a lot of
    gaps and mistakes, so that a newbie is unlikely to be able to
    follow them.
    --
    Waldek Hebisch
    --- Synchronet 3.21b-Linux NewsLink 1.2
  • From Salvador Mirzo@smirzo@antartida.xyz to comp.compilers on Mon Jan 20 08:38:42 2025
    From Newsgroup: comp.compilers

    antispam@fricas.org writes:

    John R Levine <johnl@taugh.com> wrote:
    The authors developed a compiler for a toy language targeting Raspberry Pi >> using lex and yacc. Nothing very new but it shows how you build a
    compiler incremntally expanding the source language.

    https://arxiv.org/abs/2501.04503

    I am affraid that the best use of this paper is to forget it.
    On one hand presentation is very naive and their "final"
    compiler apparently does not handle things handled in ususal toy
    compilers. On the other hand their presentation has a lot of
    gaps and mistakes, so that a newbie is unlikely to be able to
    follow them.

    Would you recommend an equivalent paper or book that addresses these short-comings but maintains the educational spirit of the paper? (It's
    okay if the architecture is not a popular one.)
    [Good question. There's the old Let's Build a Compiler which you can find
    on my web site and some books. Alan Holub wrote a well known book but the
    code in the book is incredibly buggy so I wouldn't recommend it. -John]
    --- Synchronet 3.21b-Linux NewsLink 1.2
  • From antispam@antispam@fricas.org to comp.compilers on Tue Jan 21 12:01:02 2025
    From Newsgroup: comp.compilers

    Salvador Mirzo <smirzo@antartida.xyz> wrote:
    antispam@fricas.org writes:

    John R Levine <johnl@taugh.com> wrote:
    The authors developed a compiler for a toy language targeting Raspberry Pi >>> using lex and yacc. Nothing very new but it shows how you build a
    compiler incremntally expanding the source language.

    https://arxiv.org/abs/2501.04503

    I am affraid that the best use of this paper is to forget it.
    On one hand presentation is very naive and their "final"
    compiler apparently does not handle things handled in ususal toy
    compilers. On the other hand their presentation has a lot of
    gaps and mistakes, so that a newbie is unlikely to be able to
    follow them.

    Would you recommend an equivalent paper or book that addresses these short-comings but maintains the educational spirit of the paper? (It's
    okay if the architecture is not a popular one.)
    [Good question. There's the old Let's Build a Compiler which you can find
    on my web site and some books. Alan Holub wrote a well known book but the code in the book is incredibly buggy so I wouldn't recommend it. -John]

    I like very much old presentation of PL/0 in Wirth book "Algoritms
    + Data Structures = Programs". Unfortunately, it is available in
    old edition of the book but missing in newer ones. Presentation is
    in Pascal which seem to be unknown to current students. Wirth uses
    hand coded LL parser (unlike texts depending on parser generators).
    Code generator covers only imaginary stack machine which is
    interpreted (one cound instead generate machine code, but Wirth does
    not explain this). PL/0 compiler does not cover type-checking, but
    there is PL/S which is similar, but shows more realistic language
    including types.

    Wirth "Compiler Construction" book available on the net contains
    examples of Oberon-like compiler, about 20 pages. This is
    written in Oberon, which may be a problem.

    For compiler course that I gave in the past I developed my own
    examples. One is variation on Wirth PL/0, but using flex and
    bison for syntax and generating code for x86_64. If interested
    see:

    /zaj/public_html/kompi2015/pr

    and look for links to subdirectories of 'pl0'. Version 1
    is just lexical analyzer for 'flex', version 2 contains bison
    grammar, version 3 builds a parse tree, version 4 builds
    simplified parse tree, version 5 adds a code generator.

    There are comments inside, but course was in Polish, so comments
    and variable names are in Polish too.

    Note: this is phase-by-phase approach. Enlarging language
    may be tricky, unless one is subsetting compiler for bigger
    language. And even when subsetting, there can be unexpected
    dependence: code for expressions may need intermediate variables,
    so general expressions and variables naturally appear together
    in code generator.

    I also made somewhat simpler example 'sk' (reachable from the
    URL I gave above). This one trivializes syntax, using one letter
    variable names and precedence based parser, but contains
    "retargetable" code generator (one version generates normal C,
    one i386 code, one multiprecision C).

    In the past I fetched several compiler books from the net.
    "Compiler Construction; A Practical Approach" by F.J.F. Benders
    J.W. Haaring, T.H. Janssen, D. Meffert and A.C. van Oostenrijk
    contains simple compiler for toy language called "Inger".

    --
    Waldek Hebisch
    --- Synchronet 3.21b-Linux NewsLink 1.2
  • From antispam@antispam@fricas.org to comp.compilers on Tue Jan 21 18:45:12 2025
    From Newsgroup: comp.compilers

    antispam@fricas.org wrote:
    For compiler course that I gave in the past I developed my own
    examples. One is variation on Wirth PL/0, but using flex and
    bison for syntax and generating code for x86_64. If interested
    see:

    /zaj/public_html/kompi2015/pr

    Oops, I should give a link instead of a filname:

    http://fricas.org/~p-wyk4/kompi2015/pr

    --
    Waldek Hebisch
    --- Synchronet 3.21b-Linux NewsLink 1.2
  • From Dmitri Volkov@dmitri.s.volkov@gmail.com to comp.compilers on Thu Jan 23 15:54:35 2025
    From Newsgroup: comp.compilers

    On Mon, 20 Jan 2025 08:38:42 -0300, Salvador Mirzo
    <smirzo@antartida.xyz> wrote:
    Would you recommend an equivalent paper or book that addresses these
    short-comings but maintains the educational spirit of the paper? (It's
    okay if the architecture is not a popular one.)

    I went through Jeremy Siek's Essentials of Compilation last year, and
    found it very effective. Nanopass-based, and there's both Racket and
    Python versions of the book.

    I believe it's available on GitHub: https://github.com/IUCompilerCourse
    --- Synchronet 3.21b-Linux NewsLink 1.2
  • From Keith Thompson@Keith.S.Thompson+u@gmail.com to comp.compilers on Thu Jan 23 13:56:34 2025
    From Newsgroup: comp.compilers

    OrangeFish <OrangeFish@invalid.invalid> writes:
    On 2025-01-20 06:38, Salvador Mirzo wrote:
    Would you recommend an equivalent paper or book that addresses these
    short-comings but maintains the educational spirit of the paper? (It's
    okay if the architecture is not a popular one.)
    [Good question. There's the old Let's Build a Compiler which you can find >> on my web site and some books. Alan Holub wrote a well known book but the >> code in the book is incredibly buggy so I wouldn't recommend it. -John]

    What are expert opinions on Wirth's book Compilerbau (German notwithstanding)? There seem to love-it or hate-it opinions without
    much substance.

    The English version, "Compiler Construction", is available in free PDF
    form at <https://people.inf.ethz.ch/wirth/CompilerConstruction/>.

    Compiler Construction
    Niklaus Wirth
    This is a slightly revised version of the book published by
    Addison-Wesley in 1996
    ISBN 0-201-40353-6
    Z|+rich, May 2017

    --
    Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
    void Void(void) { Void(); } /* The recursive call of the void */
    --- Synchronet 3.21b-Linux NewsLink 1.2
  • From OrangeFish@OrangeFish@invalid.invalid to comp.compilers on Thu Jan 23 20:49:51 2025
    From Newsgroup: comp.compilers

    On 2025-01-21 19:44, George Neuner wrote:
    On Mon, 20 Jan 2025 11:17:21 -0500, OrangeFish
    <OrangeFish@invalid.invalid> wrote:

    What are expert opinions on Wirth's book Compilerbau (German
    notwithstanding)? There seem to love-it or hate-it opinions without
    much substance.

    (Another question is where to look for how to add debugging information
    to the output.)

    OF.

    The English version is fairly simplistic - an undergrad intro course
    at best. I haven't seen the German version.

    I was suggesting Wirth to answer Salvador Misro's request for "Would you recommend an equivalent paper or book that addresses these short-comings
    but maintains the educational spirit of the paper?".

    Is Wirth (in any version) suitable?

    OF.
    --- Synchronet 3.21b-Linux NewsLink 1.2