Last active
August 22, 2016 18:53
-
-
Save Millak/56b18b29a92402fd49c54525baa2de8d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/guix/build/bournish.scm b/guix/build/bournish.scm | |
index 928bef5..60eb899 100644 | |
--- a/guix/build/bournish.scm | |
+++ b/guix/build/bournish.scm | |
@@ -162,6 +162,20 @@ characters." | |
(else | |
`((@@ (guix build bournish) wc-command-implementation) ,@args)))) | |
+(define (bash-command-implementation commands) | |
+ (define-peg-pattern command-list all (and (* cmd) (not-followed-by peg-any))) | |
+ (define-peg-pattern parser all (or aand oor break)) | |
+ (define-peg-pattern aand all "&&") | |
+ (define-peg-pattern oor all "||") | |
+ (define-peg-pattern pipe all (and "|" (not-followd-by (+ "|")))) | |
+ (define-peg-pattern break all ";") | |
+ (define-peg-pattern echo body "echo") | |
+ | |
+ (peg:tree (match-pattern command-list commands))) | |
+ | |
+(define (bash-command . args) | |
+ `((@@ (guix build bournish) bash-command-implementation) ,@args)) | |
+ | |
(define (help-command . _) | |
(display "\ | |
Hello, this is Bournish, a minimal Bourne-like shell in Guile! | |
@@ -189,7 +203,8 @@ commands such as 'ls' and 'cd'; it lacks globbing, pipes---everything.\n")) | |
("ls" ,ls-command) | |
("which" ,which-command) | |
("cat" ,cat-command) | |
- ("wc" ,wc-command))) | |
+ ("wc" ,wc-command) | |
+ ("bash" ,bash-command))) | |
(define (read-bournish port env) | |
"Read a Bournish expression from PORT, and return the corresponding Scheme |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
My GSoC project started as a Bourne-shell compiler front-end for guile. To this end | |
I spent some time learning guile and wrote an implementation of 'wc' for | |
guix/build/bournish.scm. From there one of my mentors Ludovic suggested that I take | |
a look at PEG parsing, using the development branch of guile, to turn my attention | |
from reimplementing the programs in coreutils to the actual parsing of commands, | |
which would allow us to chain together commands, much as is done from the command | |
line or while compiling programs. Unfortunately this proved to be a larger project | |
than I had time left for during GSoC, so I have not yet made a lot of progress on | |
that front. | |
To this end I do plan on continuing my work after the end of GSoC, I want to get | |
the parsing down and I want to see how far I can push this and how much it can be | |
integrated into the project. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment