Line pragmas in ATS2 source

Is it possible to emit a line pragma in ATS2 source?

I’ve written a (soon to be released) preprocessor for ATS2, and pragmas
would be very valuable addition to help with debugging.

You said ‘a line pragma in ATS2 source’.

I may not have understood your question correctly.

I am looking forward to the preprocessor!

Yes, I am generating ATS code for printing HTML fragments, kind of like a
templating engine. I would like to retain positions from the source HTML
file in the generated ATS code, for easier debugging.

The input file is plain HTML (or a fragment, but I haven’t tested fragments
yet…) with some ATS directives embedded in it. For instance, the input is:

${1 + 2}

and the output is basically:

val () = fprint!(out, “

”)
#pragma 1 “input.html”
val () = fprint!(out, 1 + 2)
val () = fprint!(out, “

”)

I’d like to specify that the second line in the above code is generated
from the input (see the pragma, but it is rejected currently). So I need to
put a #line pragma before the expression. It would be much easier to debug
if line information was retained.

Sorry for the confusion.> On Sunday, January 10, 2016 at 1:14:35 AM UTC-5, gmhwxi wrote:

If you pass the flag ‘–gline’ to patscc or patsopt, the generated
C code should contain line pragmas.

On Sunday, January 10, 2016 at 1:06:27 AM UTC-5, Artyom Shalkhakov wrote:

Is it possible to emit a line pragma in ATS2 source?

I’ve written a (soon to be released) preprocessor for ATS2, and pragmas
would be very valuable addition to help with debugging.

Because ATS will be used more and more as a target language,
supporting various forms of #pragma is becoming a very important issue.

I will find some time to do this (hopefully before the next release). A
general
pragma should look like:

#pragma(CATEGORY, arg1, arg2, …)

So a line pragma looks like:

#pragma(line, FILENAME, LINE_NUMBER)

This issue is now mention on ats-lang-devel:

Redirecting to Google Groups Sunday, January 10, 2016 at 3:54:41 AM UTC-5, Artyom Shalkhakov wrote:

On Sunday, January 10, 2016 at 12:37:42 PM UTC+6, gmhwxi wrote:

You said ‘a line pragma in ATS2 source’.

I may not have understood your question correctly.

I am looking forward to the preprocessor!

Yes, I am generating ATS code for printing HTML fragments, kind of like a
templating engine. I would like to retain positions from the source HTML
file in the generated ATS code, for easier debugging.

The input file is plain HTML (or a fragment, but I haven’t tested
fragments yet…) with some ATS directives embedded in it. For instance,
the input is:

${1 + 2}

and the output is basically:

val () = fprint!(out, “

”)
#pragma 1 “input.html”
val () = fprint!(out, 1 + 2)
val () = fprint!(out, “

”)

I’d like to specify that the second line in the above code is generated
from the input (see the pragma, but it is rejected currently). So I need to
put a #line pragma before the expression. It would be much easier to debug
if line information was retained.

Sorry for the confusion.

On Sunday, January 10, 2016 at 1:14:35 AM UTC-5, gmhwxi wrote:

If you pass the flag ‘–gline’ to patscc or patsopt, the generated
C code should contain line pragmas.

On Sunday, January 10, 2016 at 1:06:27 AM UTC-5, Artyom Shalkhakov wrote:

Is it possible to emit a line pragma in ATS2 source?

I’ve written a (soon to be released) preprocessor for ATS2, and pragmas
would be very valuable addition to help with debugging.

There is currently no support for line pragmas in ATS source code.

For the moment, I suggest that you generate the following line for your
example:

#print “input.html: line 1\n”

Such a line is printed out to the stderr. It can help debugging as well.On Sun, Jan 10, 2016 at 3:54 AM, Artyom Shalkhakov < artyom.s...@gmail.com> wrote:

On Sunday, January 10, 2016 at 12:37:42 PM UTC+6, gmhwxi wrote:

You said ‘a line pragma in ATS2 source’.

I may not have understood your question correctly.

I am looking forward to the preprocessor!

Yes, I am generating ATS code for printing HTML fragments, kind of like a
templating engine. I would like to retain positions from the source HTML
file in the generated ATS code, for easier debugging.

The input file is plain HTML (or a fragment, but I haven’t tested
fragments yet…) with some ATS directives embedded in it. For instance,
the input is:

${1 + 2}

and the output is basically:

val () = fprint!(out, “

”)
#pragma 1 “input.html”
val () = fprint!(out, 1 + 2)
val () = fprint!(out, “

”)

I’d like to specify that the second line in the above code is generated
from the input (see the pragma, but it is rejected currently). So I need to
put a #line pragma before the expression. It would be much easier to debug
if line information was retained.

Sorry for the confusion.

On Sunday, January 10, 2016 at 1:14:35 AM UTC-5, gmhwxi wrote:

If you pass the flag ‘–gline’ to patscc or patsopt, the generated
C code should contain line pragmas.

On Sunday, January 10, 2016 at 1:06:27 AM UTC-5, Artyom Shalkhakov wrote:

Is it possible to emit a line pragma in ATS2 source?

I’ve written a (soon to be released) preprocessor for ATS2, and pragmas
would be very valuable addition to help with debugging.


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/cdcbea1e-9bdb-431a-9cea-f0fe0be7f3f0%40googlegroups.com
https://groups.google.com/d/msgid/ats-lang-users/cdcbea1e-9bdb-431a-9cea-f0fe0be7f3f0%40googlegroups.com?utm_medium=email&utm_source=footer
.

Okay.

I can introduce something like:

//
#pragma
( location
, “abcde.dats”
, “69(line=4, offs=31) – 88(line=4, offs=50)”
)
//

This should be pretty straightforward to support.

My plan is to use pragma to support meta-programming.
For instance, #codegen2 is such an example. Supporting
line pragma is really just a very simple and special case.On Sunday, January 10, 2016 at 10:22:19 PM UTC-5, Artyom Shalkhakov wrote:

On Sunday, January 10, 2016 at 11:08:19 PM UTC+6, gmhwxi wrote:

Because ATS will be used more and more as a target language,
supporting various forms of #pragma is becoming a very important issue.

I will find some time to do this (hopefully before the next release). A
general
pragma should look like:

#pragma(CATEGORY, arg1, arg2, …)

So a line pragma looks like:

#pragma(line, FILENAME, LINE_NUMBER)

This issue is now mention on ats-lang-devel:

Redirecting to Google Groups

Thanks, Hongwei!

May I also mention right away that specifying column would be useful as
well?

I couldn’t find something similar in GCC right away (seems like they don’t
support column specification), but MLton does support it, linking for
reference:

LineDirective

On Sunday, January 10, 2016 at 3:54:41 AM UTC-5, Artyom Shalkhakov wrote:

On Sunday, January 10, 2016 at 12:37:42 PM UTC+6, gmhwxi wrote:

You said ‘a line pragma in ATS2 source’.

I may not have understood your question correctly.

I am looking forward to the preprocessor!

Yes, I am generating ATS code for printing HTML fragments, kind of like
a templating engine. I would like to retain positions from the source HTML
file in the generated ATS code, for easier debugging.

The input file is plain HTML (or a fragment, but I haven’t tested
fragments yet…) with some ATS directives embedded in it. For instance,
the input is:

${1 + 2}

and the output is basically:

val () = fprint!(out, “

”)
#pragma 1 “input.html”
val () = fprint!(out, 1 + 2)
val () = fprint!(out, “

”)

I’d like to specify that the second line in the above code is generated
from the input (see the pragma, but it is rejected currently). So I need to
put a #line pragma before the expression. It would be much easier to debug
if line information was retained.

Sorry for the confusion.

On Sunday, January 10, 2016 at 1:14:35 AM UTC-5, gmhwxi wrote:

If you pass the flag ‘–gline’ to patscc or patsopt, the generated
C code should contain line pragmas.

On Sunday, January 10, 2016 at 1:06:27 AM UTC-5, Artyom Shalkhakov wrote:

Is it possible to emit a line pragma in ATS2 source?

I’ve written a (soon to be released) preprocessor for ATS2, and
pragmas would be very valuable addition to help with debugging.

This style of #pragma is now supported.
It should be going into the next release of ATS2.On Monday, January 11, 2016 at 12:20:43 AM UTC-5, gmhwxi wrote:

Okay.

I can introduce something like:

//
#pragma
( location
, “abcde.dats”
, “69(line=4, offs=31) – 88(line=4, offs=50)”
)
//

This should be pretty straightforward to support.

My plan is to use pragma to support meta-programming.
For instance, #codegen2 is such an example. Supporting
line pragma is really just a very simple and special case.

On Sunday, January 10, 2016 at 10:22:19 PM UTC-5, Artyom Shalkhakov wrote:

On Sunday, January 10, 2016 at 11:08:19 PM UTC+6, gmhwxi wrote:

Because ATS will be used more and more as a target language,
supporting various forms of #pragma is becoming a very important issue.

I will find some time to do this (hopefully before the next release). A
general
pragma should look like:

#pragma(CATEGORY, arg1, arg2, …)

So a line pragma looks like:

#pragma(line, FILENAME, LINE_NUMBER)

This issue is now mention on ats-lang-devel:

Redirecting to Google Groups

Thanks, Hongwei!

May I also mention right away that specifying column would be useful as
well?

I couldn’t find something similar in GCC right away (seems like they
don’t support column specification), but MLton does support it, linking for
reference:

LineDirective

On Sunday, January 10, 2016 at 3:54:41 AM UTC-5, Artyom Shalkhakov wrote:

On Sunday, January 10, 2016 at 12:37:42 PM UTC+6, gmhwxi wrote:

You said ‘a line pragma in ATS2 source’.

I may not have understood your question correctly.

I am looking forward to the preprocessor!

Yes, I am generating ATS code for printing HTML fragments, kind of like
a templating engine. I would like to retain positions from the source HTML
file in the generated ATS code, for easier debugging.

The input file is plain HTML (or a fragment, but I haven’t tested
fragments yet…) with some ATS directives embedded in it. For instance,
the input is:

${1 + 2}

and the output is basically:

val () = fprint!(out, “

”)
#pragma 1 “input.html”
val () = fprint!(out, 1 + 2)
val () = fprint!(out, “

”)

I’d like to specify that the second line in the above code is generated
from the input (see the pragma, but it is rejected currently). So I need to
put a #line pragma before the expression. It would be much easier to debug
if line information was retained.

Sorry for the confusion.

On Sunday, January 10, 2016 at 1:14:35 AM UTC-5, gmhwxi wrote:

If you pass the flag ‘–gline’ to patscc or patsopt, the generated
C code should contain line pragmas.

On Sunday, January 10, 2016 at 1:06:27 AM UTC-5, Artyom Shalkhakov wrote:

Is it possible to emit a line pragma in ATS2 source?

I’ve written a (soon to be released) preprocessor for ATS2, and
pragmas would be very valuable addition to help with debugging.

You said ‘a line pragma in ATS2 source’.

I may not have understood your question correctly.

I am looking forward to the preprocessor!On Sunday, January 10, 2016 at 1:14:35 AM UTC-5, gmhwxi wrote:

If you pass the flag ‘–gline’ to patscc or patsopt, the generated
C code should contain line pragmas.

On Sunday, January 10, 2016 at 1:06:27 AM UTC-5, Artyom Shalkhakov wrote:

Is it possible to emit a line pragma in ATS2 source?

I’ve written a (soon to be released) preprocessor for ATS2, and pragmas
would be very valuable addition to help with debugging.

Sorry, what I suggested does not really work.On Sunday, January 10, 2016 at 10:13:41 AM UTC-5, gmhwxi wrote:

There is currently no support for line pragmas in ATS source code.

For the moment, I suggest that you generate the following line for your
example:

#print “input.html: line 1\n”

Such a line is printed out to the stderr. It can help debugging as well.

On Sun, Jan 10, 2016 at 3:54 AM, Artyom Shalkhakov <artyom…> wrote:

On Sunday, January 10, 2016 at 12:37:42 PM UTC+6, gmhwxi wrote:

You said ‘a line pragma in ATS2 source’.

I may not have understood your question correctly.

I am looking forward to the preprocessor!

Yes, I am generating ATS code for printing HTML fragments, kind of like a
templating engine. I would like to retain positions from the source HTML
file in the generated ATS code, for easier debugging.

The input file is plain HTML (or a fragment, but I haven’t tested
fragments yet…) with some ATS directives embedded in it. For instance,
the input is:

${1 + 2}

and the output is basically:

val () = fprint!(out, “

”)
#pragma 1 “input.html”
val () = fprint!(out, 1 + 2)
val () = fprint!(out, “

”)

I’d like to specify that the second line in the above code is generated
from the input (see the pragma, but it is rejected currently). So I need to
put a #line pragma before the expression. It would be much easier to debug
if line information was retained.

Sorry for the confusion.

On Sunday, January 10, 2016 at 1:14:35 AM UTC-5, gmhwxi wrote:

If you pass the flag ‘–gline’ to patscc or patsopt, the generated
C code should contain line pragmas.

On Sunday, January 10, 2016 at 1:06:27 AM UTC-5, Artyom Shalkhakov wrote:

Is it possible to emit a line pragma in ATS2 source?

I’ve written a (soon to be released) preprocessor for ATS2, and
pragmas would be very valuable addition to help with debugging.


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/cdcbea1e-9bdb-431a-9cea-f0fe0be7f3f0%40googlegroups.com
https://groups.google.com/d/msgid/ats-lang-users/cdcbea1e-9bdb-431a-9cea-f0fe0be7f3f0%40googlegroups.com?utm_medium=email&utm_source=footer
.

If you pass the flag ‘–gline’ to patscc or patsopt, the generated
C code should contain line pragmas.On Sunday, January 10, 2016 at 1:06:27 AM UTC-5, Artyom Shalkhakov wrote:

Is it possible to emit a line pragma in ATS2 source?

I’ve written a (soon to be released) preprocessor for ATS2, and pragmas
would be very valuable addition to help with debugging.

Because ATS will be used more and more as a target language,
supporting various forms of #pragma is becoming a very important issue.

I will find some time to do this (hopefully before the next release). A
general
pragma should look like:

#pragma(CATEGORY, arg1, arg2, …)

So a line pragma looks like:

#pragma(line, FILENAME, LINE_NUMBER)

This issue is now mention on ats-lang-devel:

Redirecting to Google Groups

Thanks, Hongwei!

May I also mention right away that specifying column would be useful as
well?

I couldn’t find something similar in GCC right away (seems like they don’t
support column specification), but MLton does support it, linking for
reference:

LineDirective> On Sunday, January 10, 2016 at 3:54:41 AM UTC-5, Artyom Shalkhakov wrote:

On Sunday, January 10, 2016 at 12:37:42 PM UTC+6, gmhwxi wrote:

You said ‘a line pragma in ATS2 source’.

I may not have understood your question correctly.

I am looking forward to the preprocessor!

Yes, I am generating ATS code for printing HTML fragments, kind of like a
templating engine. I would like to retain positions from the source HTML
file in the generated ATS code, for easier debugging.

The input file is plain HTML (or a fragment, but I haven’t tested
fragments yet…) with some ATS directives embedded in it. For instance,
the input is:

${1 + 2}

and the output is basically:

val () = fprint!(out, “

”)
#pragma 1 “input.html”
val () = fprint!(out, 1 + 2)
val () = fprint!(out, “

”)

I’d like to specify that the second line in the above code is generated
from the input (see the pragma, but it is rejected currently). So I need to
put a #line pragma before the expression. It would be much easier to debug
if line information was retained.

Sorry for the confusion.

On Sunday, January 10, 2016 at 1:14:35 AM UTC-5, gmhwxi wrote:

If you pass the flag ‘–gline’ to patscc or patsopt, the generated
C code should contain line pragmas.

On Sunday, January 10, 2016 at 1:06:27 AM UTC-5, Artyom Shalkhakov wrote:

Is it possible to emit a line pragma in ATS2 source?

I’ve written a (soon to be released) preprocessor for ATS2, and
pragmas would be very valuable addition to help with debugging.