-
I’m developing a Scheme program where I aim to parse a custom language using the sllgen library, focusing on handling try-catch-finally blocks. However, I’m encountering an error related to list manipulation with the caddr function.
-
Here’s the section of my grammar definition related to the error:
(expression
("try" "{" expression "}"
(arbno "catch" "[" "Except" "]" ":" expression ":")
(arbno "finally:" expression ";") try-exp))
- I am attempting to implement the following grammar specifications:
Try Expression:
Expression ::= try { Expression }
{ catch [ Except ] : Expression ;}*
{ finally : Expression ; }*
try-exp (exp1 excpts excptexps finexps)
- Throw Expression:
Expression ::= throw Except
throw-exp (excpt)
- Exception Handling:
Except ::= message
Exception (msg)
message ::= general | not a number | not a boolean | environment
- This is what I did:
(expression
("try" "{" expression "}"
(arbno "catch" "[" "Except" "]" ":" expression ":")
(arbno "finally:" expression ";") try-exp))
- During the parsing and processing of these expressions, I’m facing this runtime error:
caddr: expects argument of type <caddrable value>; given '(expression ("try" "{" expression "}" (arbno "catch" "[" "Except" "]" ":" expression ":") (arbno "finally:" expression ";") try-exp))
- Can anyone help me understand what I’m doing wrong and how to correctly access the elements in this list structure to avoid the caddr error? Any guidance on proper list manipulation or insights into handling complex grammar structures in Scheme would be highly appreciated.
New contributor
Majd Abusaleh is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.