Som v 4.2 a

 

Som 4.2a is som 4.2 (triple 9 release) with correction to lex that enables it to run in interactive mode.  After two or three years of comtemplation, I decide to write a new parser generator.  A lot of code is borrowed from Som compiler herself.  

 

Two improvements are implemented:

1)  make print-string to be syscall (syscall {11 fp str}). print-string in som calls fprintc a lot of times. It should be better to convert som-string to c-string and call fprints once.

2)  write parser generator in som and generate a new “parse2.som”. The goal is to improve som compiler and to have a new application in som.

 

"parse2.som" (in dir pgen) becomes the new parser. It is slightly more efficient than the previous one (which has been hand-tuned).  The parser generator is about 700 lines. To compile som v4.2 it tooks som42a noi 2974486.  Use it to compile the benchmark som31 in noi 3363375.  Compare this to som 4.1 compiling som31 in 4798780, and som 4.2 with old parser in 3757236.   You can read more about this parser generator here.   The performance in terms of number of instruction executed (noi) is:

 

    v42a/v41 =  3363375 / 4798780 = 0.70, speedup 30%

    v42a/v42 =  3363375 / 3757236 = 0.89, speedup 11%

 

It is too inaccurate to measure the actual running time with this small size benchmark.   So, I think measuring noi should give some indication of the development. With lex as a built-in function (syscall {16 fp}), many “parsing” applications can be done more easily.  This is shown in the parser generator program which makes use of this function heavily.

 

You can try to run it in interactive mode:

 

C:> som42a

> print 1 + 2

>3

>to sq x = x * x

>print sq 20

>400

 

22 sept 2009