Fix a few parsing bugs at both levels, port some of the method demo over to new_kraken

This commit is contained in:
Nathan Braswell
2020-12-22 02:40:54 -05:00
parent 5152e1d109
commit 8d80f38f76
4 changed files with 46 additions and 9 deletions

View File

@@ -155,19 +155,19 @@
(insert_into_scope_let
(insert_into_scope_let scope_let_sans_import_gram (quote standard_grammar) (gen_standard_grammar))
(quote with_import) with_import)
(array (read-string (slurp (eval lib_path de))))) root_env))
(array (read-string (slurp (eval lib_path de)) (gen_standard_grammar) (quote start_symbol)))) root_env))
(eval (concat imported_scope_let (array code)) de)))
gen_standard_grammar (vau de () (array
(array (quote WS) (array "( | |
|(;[ -~]*
))+") (lambda (x) nil))
(array (quote atom) (array "-?[0-9]+") (lambda (x) (read-string x)))
(array (quote atom) (array "-?[0-9]+") (lambda (x) (do (println "read-str for number") (read-string x))))
(array (quote atom) (array "\"([#-[]| |[]-~]|(\\\\)|(\\n)|(\\t)|(\\\\*)|(\\0)|
|[ -!]|(\\\\\"))*\"") (lambda (x) (read-string x)))
|[ -!]|(\\\\\"))*\"") (lambda (x) (do (println "read-str for string") (read-string x))))
(array (quote atom) (array "-|(([a-z]|[A-Z]|_|\\*|/|\\?|\\+|!|=|&|<|>|%)([a-z]|[A-Z]|_|[0-9]|\\*|\\?|\\+|-|!|=|&|<|>|%)*)") (lambda (x) (cond (= "true" x) true
(= "false" x) false
(= "nil" x) nil
true (read-string x))))
true (do (println "read-string for atom") (read-string x)))))
(array (quote form) (array (quote atom)) (lambda (x) x))
(array (quote form) (array "\\(" (quote WS) * "\\)" ) (lambda (_ _ _) (array)))
(array (quote form) (array "\\(" (quote WS) * (quote form) (array (quote WS) + (quote form)) * (quote WS) * "\\)" ) (lambda (_ _ head tail _ _) (concat (array head) (map (lambda (x) (idx x 1)) tail))))