C compilation issue with an indexed, abstract, external type (templates not being instantiated)

46 views
Skip to first unread message

Artyom Shalkhakov

unread,
Apr 27, 2016, 11:46:41 PM4/27/16
to ats-lang-users
Hello,

I'm trying out the following code (just modified the flat union example, where said unions are put into a stack):


I think it should work, but it gives me C compilation errors, such as this one (but there are others):

union_dats.c:644:119: error: expected expression before ‘)’ token
 ATSINSmove_void(tmp23__1, PMVtmpltcstmat[0](ptr0_set<S2Eexi(tag(3977); ; S2Eapp(S2Ecst(intfloat); S2Evar(tag(3977))))>)(tmp22__1, arg1)) ;

I wondering if this example can be made to work?

Hongwei Xi

unread,
Apr 28, 2016, 12:02:41 AM4/28/16
to ats-lan...@googlegroups.com

You just need to add the following line at the beginning:

staload "share/atspre_staload.hats"

--
You received this message because you are subscribed to the Google Groups "ats-lang-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ats-lang-user...@googlegroups.com.
To post to this group, send email to ats-lan...@googlegroups.com.
Visit this group at https://groups.google.com/group/ats-lang-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/ats-lang-users/baa9f016-0776-4cb4-a790-21b6859c5bc9%40googlegroups.com.

Artyom Shalkhakov

unread,
Apr 28, 2016, 12:34:53 AM4/28/16
to ats-lang-users
On Thursday, April 28, 2016 at 10:02:41 AM UTC+6, gmhwxi wrote:

You just need to add the following line at the beginning:

staload "share/atspre_staload.hats"


Thank you very much, #including "share/atspre_stalod.hats" fixed it!

Now here's a more contrived example:


I've copied compilation errors verbatim (in the comment to that gist).

Hongwei Xi

unread,
Apr 28, 2016, 12:51:21 AM4/28/16
to ats-lan...@googlegroups.com
Try to move the following code to the top:

staload "libats/SATS/stkarray.sats"
staload _(*anon*) = "libats/DATS/stkarray.dats"

extern
fun{a:t@ype}
stkarray_peek_top
  {m,n:int | n > 0}
(
  stk: !stkarray (INV(a), m, n) >> stkarray (a, m, n)
) :<!wrt> (a) // endfun                                                                                                                               

implement{a}
stkarray_peek_top {m,n} (stk) = let
  prval () = lemma_stkarray_param (stk)
  val res = stkarray_takeout<a> (stk)
  val () = stkarray_insert<a> (stk, res)
in
  res
end

######

val () = opt_some(...)

should change to

prval () = opt_some(...)

######

token_print is yet to be implemented.




Artyom Shalkhakov

unread,
Apr 28, 2016, 3:42:10 AM4/28/16
to ats-lang-users
Thank you for the suggestions, indeed this helped to fix the issue.

I'm off to debug the whole thing. Thanks!

gmhwxi

unread,
Apr 28, 2016, 9:39:11 AM4/28/16
to ats-lang-users
I read your code a bit.

I guess I used shuntingyard to parse expressions in ATS; I just
didn't know the name of the algorithm until this moment :)

I learned it from reading Frank Pfenning's code about 20 years ago.

Artyom Shalkhakov

unread,
Apr 28, 2016, 11:10:34 PM4/28/16
to ats-lang-users
On Thursday, April 28, 2016 at 7:39:11 PM UTC+6, gmhwxi wrote:
I read your code a bit.

I guess I used shuntingyard to parse expressions in ATS; I just
didn't know the name of the algorithm until this moment :)


Yes, actually, I was thinking about fixity resolution in ATS, and why it works.

The classic approach to parsing with precedence, where one has to contort the grammar, is really awful. If there are like 5 operators in the language being parsed, it's mostly okay, but it doesn't really scale when there are many operators to handle.
 
I learned it from reading Frank Pfenning's code about 20 years ago.

I don't think I understand why it works, so I decided to implement it following the Wikipedia article.

I'll make something neatly interactive with it.

gmhwxi

unread,
Apr 29, 2016, 6:57:51 AM4/29/16
to ats-lang-users


On Thursday, April 28, 2016 at 11:10:34 PM UTC-4, Artyom Shalkhakov wrote:
On Thursday, April 28, 2016 at 7:39:11 PM UTC+6, gmhwxi wrote:
I read your code a bit.

I guess I used shuntingyard to parse expressions in ATS; I just
didn't know the name of the algorithm until this moment :)


Yes, actually, I was thinking about fixity resolution in ATS, and why it works.

The classic approach to parsing with precedence, where one has to contort the grammar, is really awful. If there are like 5 operators in the language being parsed, it's mostly okay, but it doesn't really scale when there are many operators to handle.

It complicates the grammar and does not scale.

Whenever I teach this stuff, I always feel a bit guilty because I know it is not a practical approach.
 
Reply all
Reply to author
Forward
0 new messages