Re: on bootstrapping: first Mes 0.3 released

2016-12-25 Thread Jan Nieuwenhuizen
Ludovic Courtès writes:

Hi!

> Impressive!

Thanks!

> Is it a goal to try interpret a language as close as possible to that of
> Guile, and have the same libraries?  I guess that could help in the
> future: we could use (system base lalr), nyacc, etc.

We definitely want Nyacc and PEG, and who can live without lambda*?
Other than that I intend to cut as many corners as I can get away with,
also wrt Guile compatibility; at least for now.

> Also, currently there’s approximately 2K lines of C.  How do you plan to
> make sure that it doesn’t grow over time, or even that it shrinks?  :-)

It was worse, about 2600LOC.  I worked very hard last week and also had
a bit of luck.  I found a performance clue-bat while reading Guile-1.8's
eval.c; now macros are expanded only once.

This helped so much that I finally started moving stuff from the C
prototype into Scheme; about 1000LOC have been removed.  The intepreter
with all dependencies, including cell creation and garbage collector is
now ~1000LOC.  That is able to execute a Scheme program that has been
loaded into memory.  Another ~500LOC is spent to load a minimal Scheme
program and to dump it, to provide a small posix interface, math
functions and do some error reporting.

Next up: 0.4 release.  Then I want to start working on the now very
simplistic compiler backend and hook it up to Nyacc's AST.  As the
current proof-of-concept C compiler runs in Guile too and Nyacc runs
in Mes this can be all done in Guile or a joint Guile/Mes project.

> This all sounds very promising, thanks a lot!

Yay, quit happy to hack on this!

Greetings,
Jan

-- 
Jan Nieuwenhuizen  | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com | Avatar®  http://AvatarAcademy.nl  



Mes 0.4 released

2016-12-25 Thread Jan Nieuwenhuizen

I am pleased to announce the release of Mes 0.4, representing 115
commits over barely two weeks.  It now runs Nyacc and PEG and has much
reduced core.

* About

Mes aims to create an entirely source-based bootstrapping path.  The
target is to [have GuixSD] boostrap from a minimal, easily inspectable
binary --that should be readable as source-- into something close to
R6RS Scheme.

As bootstrapping is presumably easiest and probably most fun with
Scheme, the next step for Mes is mescc: a C compiler/linker to
boostrap into GNU Gcc and GNU Guile, possibly via Tiny-CC.

It currently has an interpreter written in C (mes) with Garbage
Collector (Jam Scraper), a library of loadable Scheme modules--
notably Dominique Boucher's LALR[1], Pre-R6RS portable
syntax-case[2] with R7RS ellipsis, Nyacc[3] and Guile's PEG[4]
--and test suite just barely enough to support a simple REPL
(repl.mes) and a proof-of-concept C-compiler (mescc.mes) that
produces an elf from the simplest of C files.

Mes is inspired by The Maxwell Equations of Software: LISP-1.5[5]
-- John McCarthy page 13

* Download

git clone https://gitlab.com/janneke/mes

wget https://gitlab.com/janneke/mes/repository/archive.tar.gz?ref=v0.4 -O 
mes-0.4.tar.gz

Mes runs from the source tree and can also be built, packaged and
installed in Guix[SD] by the usual

guix package -f guix.scm


* Changes in 0.4 since 0.3
 ** Core
 *** Improved performance.
 Macros are now memoized; after expansion and before eval'ing the
 expanded form, their input s-expression is replaced by the expansion.
 This yields a nice performance improvement which finally allowed
 moving all non-essential bits from the C-core into Scheme...including
 the reader.  The Scheme reader is much, much slower than the previous
 C version, making Mes--again-- feel slow.  Think of that as a feature.
 *** Bootstrap with minimal reader in C.
 The C-reader needs only support reading of words and lists
 (s-expressions), line-comments to read the initial Scheme reader which
 then takes over and handles reading of quoting, characters, strings,
 block-comments.
 *** Reduced size.
 Total C size: ~1500LOC.  The main Mes evaluator is now ~1000LOC
 including cell creation and garbage collector.  This code is able to
 execute a Scheme program that has been loaded into memory.  Another
 ~500LOC is spent to load a minimal Scheme program and to dump it, to
 provide a small posix interface, math functions and do some error
 reporting.
 *** Programs can be dumped and loaded using --dump and --load.
 ** Language
 *** Minimal syntactic exception support for Nyacc.
 *** Minimal syntactic fluids support for Nyacc.
 *** Keywords are now supported.
 *** Cond now supports =>.
 *** Guile's optargs: lambda* and define* are now supported.
 *** #;-comments are now supported.
 *** Non-nested #| |#-comments are now supported.
 *** Quasisyntax is now supported.
 *** R7RS syntax-rules with custom ellipsis, with-ellipsis are now supported.
 *** 9 new [partial] modules
 (mes fluids), (mes nyacc), (mes optargs), (mes pmatch), (mes peg),
 (srfi srfi-13), (srfi srfi-9-psyntax), (srfi srfi-26), (srfi srfi-43),
 (rnrs arithmetic bitwise), (sxml xpath)
 *** 36 new functions
 1+, 1-, abs, and=>, append-reverse, ash, char<=?, char=?,
 char>?, even?, filter, delete, delq, vector-copy, fold, fold-right,
 getenv, iota, keyword->symbol list-head, list-tail, negative?, odd?,
 positive?, remove!, remove, string->number, string-copy,
 string-prefix?, string=, string=?, symbol->keyword symbol-append,
 symbol-prefix?, unless, write, zero?.
 ** Noteworthy bug fixes
 *** Macros are now memoized.
 *** An error is reported when using a wrong number of arguments with a call.
 *** Cond now evaluates its test clauses only once.
 *** Append can also handle one argument.
 *** For-each now supports 2 list arguments.
 *** Map now supports 3 list arguments.
 *** Backslash in string is supported.
 *** Closure is not a pair.
 *** All standard characters are supported.
 *** Mescc now also runs in Guile.


Greetings,
Jan

[1] https://github.com/schemeway/lalr-scm
[2] https://www.cs.indiana.edu/chezscheme/syntax-case/old-psyntax.html
[3] https://www.nongnu.org/nyacc/
[4] https://www.gnu.org/software/guile/docs/master/guile.html/PEG-Parsing.html
[5] 
http://www.softwarepreservation.org/projects/LISP/book/LISP%25201.5%2520Programmers%2520Manual.pdf

-- 
Jan Nieuwenhuizen  | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com | Avatar®  http://AvatarAcademy.nl  



nyacc 0.73.0 released

2016-12-25 Thread Matt Wette
NYACC, for Not Yet Another Compiler Compiler!, is set of guile modules for
generating parsers and lexical analyzers.  It also provides sample parsers
and pretty-printers using SXML trees as an intermediate representation.

Version 0.73.0 has been released.  It provides some minor fixes.  I have not 
been working on this for a few months due to other priorities.  I am hoping to 
spend some quality time on this project now. This version fixes a few bugs in 
the C99 parser and pretty printer.

git clone git://git.savannah.nongnu.org/nyacc.git 


Or

http://download.savannah.gnu.org/releases/nyacc/ 





Re: nyacc 0.73.0 released

2016-12-25 Thread Jan Nieuwenhuizen
Matt Wette writes:

> Version 0.73.0 has been released.  It provides some minor fixes.  I
> have not been working on this for a few months due to other
> priorities.  I am hoping to spend some quality time on this project
> now. This version fixes a few bugs in the C99 parser and pretty
> printer.

Great!  Just yesterday I released the first version of Mes that can load
and run Nyacc and started work on replacing Mes' own minimal C-parsing
LALR frontend with Nyacc's C99 parser.

Nyacc is awesome!  I wrote a proof of concept ANSI C parser (as small as
it can possibly get) and delayed further work on that.  Ludovic advised
me to look into Nyacc; it took me quite a bit of work to mature Mes into
a state were it could run it...and now I have a better Scheme with a(n
almost?) full C99 parser too!

Thank you!
Greetings,
Jan.

-- 
Jan Nieuwenhuizen  | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com | Avatar®  http://AvatarAcademy.nl