Hello! Efraim Flashner <efr...@flashner.co.il> skribis:
[...] >> I prefer the approach Ricardo suggested, I think it’s more concise and >> clearer: >> >> https://lists.gnu.org/archive/html/guix-devel/2016-06/msg00525.html >> >> Also, note that @@ would not be needed here; @@ serves to access private >> bindings within a specific module: >> >> >> https://www.gnu.org/software/guile/manual/html_node/Using-Guile-Modules.html >> >> Last, do not miss the bit about docstrings at: >> >> https://www.gnu.org/software/guix/manual/html_node/Formatting-Code.html >> >> :-) >> >> With these changes, we’re all set. Thanks! > > I've attached another patch Sorry for taking so long! I’ve applied the patch with minor cosmetic changes: procedure names, docstrings, and formatting (please take a look). >> From a GSoC viewpoint, I think we must move to the compilation part >> now. Specifically, I think the next step is to start parsing Bash >> code. > > This part took much longer than I thought it would. Going forward I'll > try to be more pro-active on IRC about asking for help. > >> >> For that we could use SILex + parse-lalr, but these are not the nicest >> tools for the job. Better tools would be “parsing expression grammars” >> (the (ice-9 peg) module in Guile 2.1) or parser combinators, though I >> don’t think there’s a directly usable Guile library for that. Maybe >> Eric or David can comment? >> > > I get lalr as look-ahead left->right parser and found this¹, but what's SILex? SILex is a lexer: it turns character sequences into tokens, that can then be passed to the parser. I think SILex no longer has a home on the Internet, but you can find a copy at <http://git.savannah.gnu.org/cgit/guile-rpc.git/tree/modules/silex>. Guile-RPC uses both SILex and ‘parse-lalr’, so it could serve as an example, but again, PEG is probably preferable (Dave’s guile-parser-combinator library is not ready for prime time, per a recent discussion on guile-u...@gnu.org.) >> The goal is to have a parser that returns an abstract syntax tree (AST) >> as an sexp: >> >> (parse "(cd /foo; ls $HOME) && echo *.a ; echo done") >> => >> '(sequence >> (success-sequence >> (subshell >> (sequence (command "cd" "/foo") >> (command "ls" (variable-ref "HOME")))) >> (command "echo" (glob "*.a"))) >> (command "echo" "done")) >> >> Thoughts? So let’s focus on this part now. Feel free to ping me/us while researching the best approach or tools to work on it! Thanks, Ludo’.