[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Tinycc-devel] Segmentation fault compiling jslong.c

From: Peter Lund
Subject: Re: [Tinycc-devel] Segmentation fault compiling jslong.c
Date: Sat, 22 Sep 2007 01:34:13 +0200

On Fri, 2007-09-21 at 18:04 -0500, Rob Landley wrote:

> Wandering back on topic, people who care about formal mathematical models use 
> lexx and yacc.

Nope!  They are often the same people who hack up LaTeX macros to
typeset weird things with greek letters.

They consider lexx uninteresting and yacc severely limited and both very

>   People who want to turn source code into object code in a 
> fast and simple way with minimal external dependencies hand code recursive 
> descent parsers in ways that make theoretical mathematicians' skin crawl.  

Again, nope.

Nice formal grammars map straightforwardly to recursive descent parsers.
It is only the non-nice ones that don't.  The formal study of grammars
gave us an understanding of what a grammar that's easy to hack up a
parser for looks like.

C has an almost but not quite nice grammar.  Pascal has a nice one.

(Actually, most comp.sci. language researchers probably prefer
combinator parsers which are even nicer and easier and more powerful
than recursive descent parsers.  Alas, they aren't well-suited to
implementations in C and other non-functional languages.)

> Which kind of project is tcc?

Hopefully one where people who do know formal semantics and type theory
-- and know how to write recursive descent parsers ;) -- find a welcome
place to hack.

> Back in college, I stopped reading about Backus-Naur form when I found out 
> it's not executable.

Err... what?

The only sense in which a set of BNF terms can be set to constitute a
"program" (so the word "executable" can apply) is in the sense that they
specify precisely the set of symbol sequences that match, i.e. the
language that matches.

In that sense, BNF most definitely IS executable.

You just gotta run it on a decent virtual machine ;)

The simple LR parser that yacc implements isn't decent, it will not work
for all grammars.  However, bison implements a GLR parser so it /will/
work for all grammars.

>   GCC had all this BNR stuff, but it never ran a 
> preprocessor on BNR source to generate actual code.  For me, it went 
> from "useful tool" to "waste of time" with that one fact.  Because something 
> like that _could_ be executable, but the kind of people who use it apparently 
> don't think that's important.  This was my first big "Shut up and show me the 
> code!" moment.  (I've had to learn it since because some stuff is _only_ 
> documented in it, but I consider that a deficiency of the documentation.)

Nope, BNF is a fantastic documentation format for grammars.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]