On Mon, Jul 5, 2010 at 5:40 PM, Ludovic Courtès <l...@gnu.org> wrote: > Hi! > > Thanks for the status report! > > Michael Lucy <michaelgl...@gmail.com> writes: > >> Files I've added so far: >> guile/modules/ice-9/peg.scm (I assume this is the right place to put this?) > > No, it should rather go under ‘module/language/peg.scm’, for the sake of > consistency with other compiler front-ends. But see below.
I'm not quite sure how this qualifies as a compiler front-end. The functionality is mostly done (if unoptimized), so it shouldn't be too hard to turn it into one if that's what you want, but the original thought was just to build a compiling parser. E.g.: (use-modules (ice-9 peg)) (peg-find "'b'+" "aabbcc") --> (2 4 "bb") It does this by compiling "'b'+" into a lambda expression that then gets called on whatever the second argument is (the compilation is done at read-time). So after macro-expansion, you have something like: ((lambda (...) ...) "aabbcc" ...) I was thinking of this as a sort of alternative to regular expressions that also does parsing, and I noticed the regular expressions module was in ice-9, so I put it there. Are you saying that the functionality that compiles "'b'+" to a lambda expression should be broken out into a language module that instead compiles it to TREE-IL code? Am I fundamentally misunderstanding something? > >> PEG compiler: Works for all the grammars I've tested, no known bugs. >> Currently compiles to Scheme code rather than Tree-IL for debugging. > > It should rather compiler to tree-IL, like other front-ends, which is > very close to Scheme anyway. Alright, I'll fix that. Noob question: The only way I can figure out to compile tree-il code is the rather ugly: (compile (parse-tree-il '(code here)) #:from 'tree-il) Is there a better way? > >> 2. Tests aren't standardized (peg.test looks nothing like the other >> .test files). > > Well, you know what to do then. ;-) > >> 3. This: >> >> scheme@(guile-user)> (use-modules (ice-9 peg)) >> ;;; note: source file /home/zededarian/guile/module/ice-9/peg.scm >> ;;; newer than compiled >> /home/zededarian/guile/cache/guile/ccache/2.0-0.R-LE-4/home/zededarian/guile/module/ice-9/peg.scm.go >> ;;; note: autocompilation is enabled, set GUILE_AUTO_COMPILE=0 >> ;;; or pass the --no-autocompile argument to disable. >> ;;; compiling /home/zededarian/guile/module/ice-9/peg.scm >> ;;; WARNING: compilation of /home/zededarian/guile/module/ice-9/peg.scm >> failed: >> ;;; key wrong-type-arg, throw args ("vm-debug-engine" "Wrong type to >> apply: ~S" (#f) (#f)) >> >> Somehow it works fine despite the warnings. Can anybody shed light on >> what this means? > > Actually it doesn’t work. Try: It can definitely use the functions: " ~/guile-git/tst/guile/meta $ ./guile GNU Guile 1.9.11.154-b1066 Copyright (C) 1995-2010 Free Software Foundation, Inc. Guile comes with ABSOLUTELY NO WARRANTY; for details type `,show w'. This program is free software, and you are welcome to redistribute it under certain conditions; type `,show c' for details. Enter `,help' for help. scheme@(guile-user)> (use-modules (ice-9 peg)) ;;; note: autocompilation is enabled, set GUILE_AUTO_COMPILE=0 ;;; or pass the --no-autocompile argument to disable. ;;; compiling /home/zededarian/guile-git/tst/guile/module/ice-9/peg.scm ;;; WARNING: compilation of /home/zededarian/guile-git/tst/guile/module/ice-9/peg.scm failed: ;;; key wrong-type-arg, throw args ("vm-debug-engine" "Wrong type to apply: ~S" (#f) (#f)) scheme@(guile-user)> (peg-find "'b'+" "aabbcc") (2 4 "bb") scheme@(guile-user)> " And when I use it with --no-autocompile I don't get any errors: " ~/guile-git/tst/guile/meta $ ./guile --no-autocompile GNU Guile 1.9.11.154-b1066 Copyright (C) 1995-2010 Free Software Foundation, Inc. Guile comes with ABSOLUTELY NO WARRANTY; for details type `,show w'. This program is free software, and you are welcome to redistribute it under certain conditions; type `,show c' for details. Enter `,help' for help. scheme@(guile-user)> (use-modules (ice-9 peg)) scheme@(guile-user)> (peg-find "'b'+" "aabbcc") (2 4 "bb") scheme@(guile-user)> " What does this mean? > > $ ./meta/guile --no-autocompile > > (use-modules (ice-9 peg)) > > It should trigger the debugger from where you can get a backtrace. > > Thanks, > Ludo’. > > > Thanks.