parsing types

0 views
Skip to first unread message

Joseph Heydorn

unread,
Nov 22, 2010, 8:46:31 PM11/22/10
to byu-cs-330-Fall-2010
If the parser finds a line such as:

(fun (x : (t-num)) : (t-num) (+ 1 0))

How do we pull the (t-num) out? The only way I can think of is to
treat (t-num) as a list with the sybmol 't-num as it's first element,
then call a function which translates that symbol into a type (t-num),
which would be messy when the parser finds a (t-fun type type). Is
there a way to do this by simply converting the concrete
representation of (t-num) to the data type (t-num)?

Steven Nay

unread,
Nov 22, 2010, 8:52:19 PM11/22/10
to byu-cs-330...@googlegroups.com
t-num is part of the abstract syntax (types as you, the writer of the language, represent them in your model). They are not part of the concrete syntax (what the person writing in your language will type). Instead, it would look like this:

(fun (x : number) : number (+ 1 0))

You'll have to pull those out in your parser.

Steve

Jay McCarthy

unread,
Nov 22, 2010, 9:07:37 PM11/22/10
to byu-cs-330...@googlegroups.com
Correct

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

Joseph Heydorn

unread,
Nov 22, 2010, 9:37:16 PM11/22/10
to byu-cs-330-Fall-2010
Thanks.

On Nov 22, 7:07 pm, Jay McCarthy <jay.mccar...@gmail.com> wrote:
> Correct
>
> Jay
>
>
>
> On Mon, Nov 22, 2010 at 6:52 PM, Steven Nay <steven....@gmail.com> wrote:
> > t-num is part of the abstract syntax (types as you, the writer of the
> > language, represent them in your model). They are not part of the concrete
> > syntax (what the person writing in your language will type). Instead, it
> > would look like this:
> > (fun (x : number) : number (+ 1 0))
> > You'll have to pull those out in your parser.
> > Steve
>
> > On Mon, Nov 22, 2010 at 6:46 PM, Joseph Heydorn <jeheyd...@gmail.com> wrote:
>
> >> If the parser finds a line such as:
>
> >> (fun (x : (t-num)) : (t-num) (+ 1 0))
>
> >> How do we pull the (t-num) out? The only way I can think of is to
> >> treat (t-num) as a list with the sybmol 't-num as it's first element,
> >> then call a function which translates that symbol into a type (t-num),
> >> which would be messy when the parser finds a (t-fun type type). Is
> >> there a way to do this by simply converting the concrete
> >> representation of (t-num) to the data type (t-num)?
>
> --
> Jay McCarthy <j...@cs.byu.edu>
> Assistant Professor / Brigham Young Universityhttp://faculty.cs.byu.edu/~jay
Reply all
Reply to author
Forward
0 new messages