"Copyright (c) 2015, Mark Tarver All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. The name of Mark Tarver may not be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY Mark Tarver ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL Mark Tarver BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." (defun shen.yacc (V4159) (cond ((and (cons? V4159) (and (= defcc (hd V4159)) (cons? (tl V4159)))) (shen.yacc->shen (hd (tl V4159)) (tl (tl V4159)))) (true (shen.f_error shen.yacc)))) (defun shen.yacc->shen (V4162 V4163) (let CCRules (shen.split_cc_rules true V4163 ()) (let CCBody (map (lambda X (shen.cc_body X)) CCRules) (let YaccCases (shen.yacc_cases CCBody) (cons define (cons V4162 (cons Stream (cons -> (cons (shen.kill-code YaccCases) ()))))))))) (defun shen.kill-code (V4165) (cond ((> (occurrences kill V4165) 0) (cons trap-error (cons V4165 (cons (cons lambda (cons E (cons (cons shen.analyse-kill (cons E ())) ()))) ())))) (true V4165))) (defun kill () (simple-error "yacc kill")) (defun shen.analyse-kill (V4167) (let String (error-to-string V4167) (if (= String "yacc kill") (fail) V4167))) (defun shen.split_cc_rules (V4173 V4174 V4175) (cond ((and (= () V4174) (= () V4175)) ()) ((= () V4174) (cons (shen.split_cc_rule V4173 (reverse V4175) ()) ())) ((and (cons? V4174) (= ; (hd V4174))) (cons (shen.split_cc_rule V4173 (reverse V4175) ()) (shen.split_cc_rules V4173 (tl V4174) ()))) ((cons? V4174) (shen.split_cc_rules V4173 (tl V4174) (cons (hd V4174) V4175))) (true (shen.f_error shen.split_cc_rules)))) (defun shen.split_cc_rule (V4183 V4184 V4185) (cond ((and (cons? V4184) (and (= := (hd V4184)) (and (cons? (tl V4184)) (= () (tl (tl V4184)))))) (cons (reverse V4185) (tl V4184))) ((and (cons? V4184) (and (= := (hd V4184)) (and (cons? (tl V4184)) (and (cons? (tl (tl V4184))) (and (= where (hd (tl (tl V4184)))) (and (cons? (tl (tl (tl V4184)))) (= () (tl (tl (tl (tl V4184))))))))))) (cons (reverse V4185) (cons (cons where (cons (hd (tl (tl (tl V4184)))) (cons (hd (tl V4184)) ()))) ()))) ((= () V4184) (do (shen.semantic-completion-warning V4183 V4185) (shen.split_cc_rule V4183 (cons := (cons (shen.default_semantics (reverse V4185)) ())) V4185))) ((cons? V4184) (shen.split_cc_rule V4183 (tl V4184) (cons (hd V4184) V4185))) (true (shen.f_error shen.split_cc_rule)))) (defun shen.semantic-completion-warning (V4196 V4197) (cond ((= true V4196) (do (shen.prhush "warning: " (stoutput)) (do (shen.for-each (lambda X (shen.prhush (shen.app X " " shen.a) (stoutput))) (reverse V4197)) (shen.prhush "has no semantics. " (stoutput))))) (true shen.skip))) (defun shen.default_semantics (V4199) (cond ((= () V4199) ()) ((and (cons? V4199) (and (= () (tl V4199)) (shen.grammar_symbol? (hd V4199)))) (hd V4199)) ((and (cons? V4199) (shen.grammar_symbol? (hd V4199))) (cons append (cons (hd V4199) (cons (shen.default_semantics (tl V4199)) ())))) ((cons? V4199) (cons cons (cons (hd V4199) (cons (shen.default_semantics (tl V4199)) ())))) (true (shen.f_error shen.default_semantics)))) (defun shen.grammar_symbol? (V4201) (and (symbol? V4201) (let Cs (shen.strip-pathname (explode V4201)) (and (= (hd Cs) "<") (= (hd (reverse Cs)) ">"))))) (defun shen.yacc_cases (V4203) (cond ((and (cons? V4203) (= () (tl V4203))) (hd V4203)) ((cons? V4203) (let P YaccParse (cons let (cons P (cons (hd V4203) (cons (cons if (cons (cons = (cons P (cons (cons fail ()) ()))) (cons (shen.yacc_cases (tl V4203)) (cons P ())))) ())))))) (true (shen.f_error shen.yacc_cases)))) (defun shen.cc_body (V4205) (cond ((and (cons? V4205) (and (cons? (tl V4205)) (= () (tl (tl V4205))))) (shen.syntax (hd V4205) Stream (hd (tl V4205)))) (true (shen.f_error shen.cc_body)))) (defun shen.syntax (V4209 V4210 V4211) (cond ((and (= () V4209) (and (cons? V4211) (and (= where (hd V4211)) (and (cons? (tl V4211)) (and (cons? (tl (tl V4211))) (= () (tl (tl (tl V4211))))))))) (cons if (cons (shen.semantics (hd (tl V4211))) (cons (cons shen.pair (cons (cons hd (cons V4210 ())) (cons (shen.semantics (hd (tl (tl V4211)))) ()))) (cons (cons fail ()) ()))))) ((= () V4209) (cons shen.pair (cons (cons hd (cons V4210 ())) (cons (shen.semantics V4211) ())))) ((cons? V4209) (if (shen.grammar_symbol? (hd V4209)) (shen.recursive_descent V4209 V4210 V4211) (if (variable? (hd V4209)) (shen.variable-match V4209 V4210 V4211) (if (shen.jump_stream? (hd V4209)) (shen.jump_stream V4209 V4210 V4211) (if (shen.terminal? (hd V4209)) (shen.check_stream V4209 V4210 V4211) (if (cons? (hd V4209)) (shen.list-stream (shen.decons (hd V4209)) (tl V4209) V4210 V4211) (simple-error (shen.app (hd V4209) " is not legal syntax " shen.a)))))))) (true (shen.f_error shen.syntax)))) (defun shen.list-stream (V4216 V4217 V4218 V4219) (let Test (cons and (cons (cons cons? (cons (cons hd (cons V4218 ())) ())) (cons (cons cons? (cons (cons shen.hdhd (cons V4218 ())) ())) ()))) (let Placeholder (gensym shen.place) (let RunOn (shen.syntax V4217 (cons shen.pair (cons (cons shen.tlhd (cons V4218 ())) (cons (cons shen.hdtl (cons V4218 ())) ()))) V4219) (let Action (shen.insert-runon RunOn Placeholder (shen.syntax V4216 (cons shen.pair (cons (cons shen.hdhd (cons V4218 ())) (cons (cons shen.hdtl (cons V4218 ())) ()))) Placeholder)) (cons if (cons Test (cons Action (cons (cons fail ()) ()))))))))) (defun shen.decons (V4221) (cond ((and (cons? V4221) (and (= cons (hd V4221)) (and (cons? (tl V4221)) (and (cons? (tl (tl V4221))) (and (= () (hd (tl (tl V4221)))) (= () (tl (tl (tl V4221))))))))) (cons (hd (tl V4221)) ())) ((and (cons? V4221) (and (= cons (hd V4221)) (and (cons? (tl V4221)) (and (cons? (tl (tl V4221))) (= () (tl (tl (tl V4221)))))))) (cons (hd (tl V4221)) (shen.decons (hd (tl (tl V4221)))))) (true V4221))) (defun shen.insert-runon (V4236 V4237 V4238) (cond ((and (cons? V4238) (and (= shen.pair (hd V4238)) (and (cons? (tl V4238)) (and (cons? (tl (tl V4238))) (and (= () (tl (tl (tl V4238)))) (= (hd (tl (tl V4238))) V4237)))))) V4236) ((cons? V4238) (map (lambda Z (shen.insert-runon V4236 V4237 Z)) V4238)) (true V4238))) (defun shen.strip-pathname (V4244) (cond ((not (element? "." V4244)) V4244) ((cons? V4244) (shen.strip-pathname (tl V4244))) (true (shen.f_error shen.strip-pathname)))) (defun shen.recursive_descent (V4248 V4249 V4250) (cond ((cons? V4248) (let Test (cons (hd V4248) (cons V4249 ())) (let Action (shen.syntax (tl V4248) (concat Parse_ (hd V4248)) V4250) (let Else (cons fail ()) (cons let (cons (concat Parse_ (hd V4248)) (cons Test (cons (cons if (cons (cons not (cons (cons = (cons (cons fail ()) (cons (concat Parse_ (hd V4248)) ()))) ())) (cons Action (cons Else ())))) ())))))))) (true (shen.f_error shen.recursive_descent)))) (defun shen.variable-match (V4254 V4255 V4256) (cond ((cons? V4254) (let Test (cons cons? (cons (cons hd (cons V4255 ())) ())) (let Action (cons let (cons (concat Parse_ (hd V4254)) (cons (cons shen.hdhd (cons V4255 ())) (cons (shen.syntax (tl V4254) (cons shen.pair (cons (cons shen.tlhd (cons V4255 ())) (cons (cons shen.hdtl (cons V4255 ())) ()))) V4256) ())))) (let Else (cons fail ()) (cons if (cons Test (cons Action (cons Else ())))))))) (true (shen.f_error shen.variable-match)))) (defun shen.terminal? (V4266) (cond ((cons? V4266) false) ((variable? V4266) false) (true true))) (defun shen.jump_stream? (V4272) (cond ((= V4272 _) true) (true false))) (defun shen.check_stream (V4276 V4277 V4278) (cond ((cons? V4276) (let Test (cons and (cons (cons cons? (cons (cons hd (cons V4277 ())) ())) (cons (cons = (cons (hd V4276) (cons (cons shen.hdhd (cons V4277 ())) ()))) ()))) (let NewStr (gensym NewStream) (let Action (cons let (cons NewStr (cons (cons shen.pair (cons (cons shen.tlhd (cons V4277 ())) (cons (cons shen.hdtl (cons V4277 ())) ()))) (cons (shen.syntax (tl V4276) NewStr V4278) ())))) (let Else (cons fail ()) (cons if (cons Test (cons Action (cons Else ()))))))))) (true (shen.f_error shen.check_stream)))) (defun shen.jump_stream (V4282 V4283 V4284) (cond ((cons? V4282) (let Test (cons cons? (cons (cons hd (cons V4283 ())) ())) (let Action (shen.syntax (tl V4282) (cons shen.pair (cons (cons shen.tlhd (cons V4283 ())) (cons (cons shen.hdtl (cons V4283 ())) ()))) V4284) (let Else (cons fail ()) (cons if (cons Test (cons Action (cons Else ())))))))) (true (shen.f_error shen.jump_stream)))) (defun shen.semantics (V4286) (cond ((= () V4286) ()) ((shen.grammar_symbol? V4286) (cons shen.hdtl (cons (concat Parse_ V4286) ()))) ((variable? V4286) (concat Parse_ V4286)) ((cons? V4286) (map (lambda Z (shen.semantics Z)) V4286)) (true V4286))) (defun shen.pair (V4289 V4290) (cons V4289 (cons V4290 ()))) (defun shen.hdtl (V4292) (hd (tl V4292))) (defun shen.hdhd (V4294) (hd (hd V4294))) (defun shen.tlhd (V4296) (tl (hd V4296))) (defun shen.snd-or-fail (V4304) (cond ((and (cons? V4304) (and (cons? (tl V4304)) (= () (tl (tl V4304))))) (hd (tl V4304))) (true (fail)))) (defun fail () shen.fail!)(defun (V4312) (cond ((and (cons? V4312) (and (cons? (tl V4312)) (= () (tl (tl V4312))))) (cons () (cons (hd V4312) ()))) (true (fail)))) (defun (V4318) (cond ((and (cons? V4318) (and (cons? (tl V4318)) (= () (tl (tl V4318))))) (cons (hd V4318) (cons () ()))) (true (shen.f_error ))))