suggestions for matching (fun...)

3 views
Skip to first unread message

Ogden Mills

unread,
Nov 22, 2011, 4:07:58 PM11/22/11
to byu-cs-330-Fall-2011
in my parser I'm trying to match up the pieces of a fun.

I'm having trouble recognizing a Type.

I know that (Type? [t-bool]) returns true,
but (? Type? IAmATypeISwear) in the match statement will not match to
'[t-bool]. It seems to me that what I send in is being changed to '(t-
bool) and (Type? (t-bool)) is #f.

in the grand scheme of my parser here is what I'd like to match

(match sexpr
...
[(list 'fun (list (? validSymbol? ident) ': (? Type? argType)) ': (?
Type? returnType) expr)
...(fun ... )]
...
)

but I can't even match
[(? Type? t)]

am I trying this correctly? I've tried making my own functions that
perform like Type? but my error seems to be the transformation of '['
']' to '(' ')'.

Any suggestions? I've implemented all of my parser so far using
(match...) since I remember learning in a code review that it looked a
lot simpler than an overburdened (cond...) statement.

Ogden

Jay McCarthy

unread,
Nov 22, 2011, 6:10:52 PM11/22/11
to byu-cs-330...@googlegroups.com
The program source code does not contain Types, like (t-num), instead it contains their syntax, like 'number, and you have to parse that.

Basically, you should write a 'parse-type' function and call it in the right spots.

Jay
--
Jay McCarthy <j...@cs.byu.edu>
Assistant Professor / Brigham Young University
http://faculty.cs.byu.edu/~jay

"The glory of God is Intelligence" - D&C 93
Reply all
Reply to author
Forward
0 new messages