1999-10-20 02:27:34 +00:00
|
|
|
(progn
|
|
|
|
(defparameter *tcw*
|
|
|
|
(generate-world
|
|
|
|
"TC"
|
|
|
|
'((lexer throw-catch-lexer
|
|
|
|
:lalr-1
|
|
|
|
:main
|
|
|
|
((:digit (#\0 #\1 #\2 #\3 #\4 #\5 #\6 #\7 #\8 #\9)
|
|
|
|
((value $digit-value))))
|
|
|
|
(($digit-value integer digit-value digit-char-36)))
|
|
|
|
|
|
|
|
(%charclass :digit)
|
|
|
|
|
|
|
|
(deftype semantic-exception integer)
|
|
|
|
|
|
|
|
(rule :expr ((value (-> () integer)))
|
|
|
|
(production :expr (:digit) expr-digit
|
2001-10-17 03:55:25 +00:00
|
|
|
((value) (return (value :digit))))
|
1999-10-20 02:27:34 +00:00
|
|
|
(production :expr (#\t :expr) expr-throw
|
|
|
|
((value) (throw ((value :expr)))))
|
|
|
|
(production :expr (#\c #\{ :expr #\} :expr) expr-catch
|
2001-10-17 03:55:25 +00:00
|
|
|
((value) (catch ((return ((value :expr 1))))
|
|
|
|
(e) (return (+ (* e 10) ((value :expr 2))))))))
|
1999-10-20 02:27:34 +00:00
|
|
|
|
|
|
|
(rule :main ((value integer))
|
|
|
|
(production :main (:expr) main-expr
|
|
|
|
(value ((value :expr)))))
|
|
|
|
(%print-actions)
|
|
|
|
)))
|
|
|
|
|
|
|
|
(defparameter *tcl* (world-lexer *tcw* 'throw-catch-lexer))
|
|
|
|
(defparameter *tcg* (lexer-grammar *tcl*)))
|
|
|
|
|
|
|
|
#|
|
|
|
|
(depict-rtf-to-local-file
|
1999-11-20 02:16:56 +00:00
|
|
|
"Test/ThrowCatchSemantics.rtf"
|
2001-10-17 03:55:25 +00:00
|
|
|
"Throw-Catch Semantics"
|
1999-10-20 02:27:34 +00:00
|
|
|
#'(lambda (rtf-stream)
|
2001-10-19 23:18:03 +00:00
|
|
|
(depict-world-commands rtf-stream *tcw* :heading-offset 1)))
|
1999-10-20 02:27:34 +00:00
|
|
|
|
|
|
|
(depict-html-to-local-file
|
1999-11-20 02:16:56 +00:00
|
|
|
"Test/ThrowCatchSemantics.html"
|
2001-10-17 03:55:25 +00:00
|
|
|
"Throw-Catch Semantics"
|
1999-10-20 02:27:34 +00:00
|
|
|
t
|
|
|
|
#'(lambda (html-stream)
|
2001-10-19 23:18:03 +00:00
|
|
|
(depict-world-commands html-stream *tcw* :heading-offset 1))
|
1999-10-20 02:27:34 +00:00
|
|
|
:external-link-base "")
|
|
|
|
|
|
|
|
|
|
|
|
(lexer-pparse *tcl* "7")
|
|
|
|
(lexer-pparse *tcl* "t3")
|
|
|
|
(lexer-pparse *tcl* "c{t6}5")
|
|
|
|
|
|
|
|
|#
|
|
|
|
|
|
|
|
(length (grammar-states *tcg*))
|