Discussion:
[ragel-users] Go line directives
Folke B.
2013-04-27 21:38:55 UTC
Permalink
Hi

I was wondering if Ragel could emit line directives in a format that is
understood by the Go compiler. The format is "\n//line
path/to/file.rl:123\n". (Note that it has to start at column 1.)

Thanks,
Folke

PS: Ragel is awesome!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.complang.org/pipermail/ragel-users/attachments/20130427/2dd8195b/attachment.html>
Anton Ageev
2013-04-28 08:00:29 UTC
Permalink
It's interesting undocumented feature. I played with go examples and I got
very discouraging behaviour.

Example 1.

atoi.go:
...
//line atoi.rl:34
neg = ttrue // I change 'true' to 'ttrue' to make error message
case 1:
//line atoi.rl:35

val = val * 10 + (int(data[p]) - '0')
...

I run `go run atoi.go` and I got following message:

# command-line-arguments
atoi.rl:34[/home/antage/workspace/ragel-go/examples/go/atoi.go:163]:
undefined: ttrue

It's looking fine.

Example 2.

atoi.go:
...
//line atoi.rl:34

neg = ttrue // I change 'true' to 'ttrue' to make error message
case 1:
//line atoi.rl:35

val = val * 10 + (int(data[p]) - '0')
...

I just add empty line after '//line atoi.rl:34' directive.
I got following message:

# command-line-arguments
atoi.rl:35[/home/antage/workspace/ragel-go/examples/go/atoi.go:164]:
undefined: ttrue

It's not fine. Error isn't at atoi.rl:35, it's at atoi.rl:34.

Ragel generates a lot of empty lines when embedding an action code. So we
can't rely on '//line' directive to locate errors in .rl files.



On Sun, Apr 28, 2013 at 1:38 AM, Folke B. <messias at gmail.com> wrote:

> Hi
>
> I was wondering if Ragel could emit line directives in a format that is
> understood by the Go compiler. The format is "\n//line
> path/to/file.rl:123\n". (Note that it has to start at column 1.)
>
> Thanks,
> Folke
>
> PS: Ragel is awesome!
>
>
> _______________________________________________
> ragel-users mailing list
> ragel-users at complang.org
> http://www.complang.org/mailman/listinfo/ragel-users
>



--
WBR, Anton
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.complang.org/pipermail/ragel-users/attachments/20130428/c7e12e82/attachment.html>
Dan Kortschak
2013-04-28 21:32:16 UTC
Permalink
This would a useful addition to the process though, so it is probably worth filing an issue with the Go project.

On 28/04/2013, at 5:30 PM, "Anton Ageev" <antage at gmail.com> wrote:

> It's interesting undocumented feature. I played with go examples and I got very discouraging behaviour.
>
> Example 1.
>
> atoi.go:
> ...
> //line atoi.rl:34
> neg = ttrue // I change 'true' to 'ttrue' to make error message
> case 1:
> //line atoi.rl:35
>
> val = val * 10 + (int(data[p]) - '0')
> ...
>
> I run `go run atoi.go` and I got following message:
>
> # command-line-arguments
> atoi.rl:34[/home/antage/workspace/ragel-go/examples/go/atoi.go:163]: undefined: ttrue
>
> It's looking fine.
>
> Example 2.
>
> atoi.go:
> ...
> //line atoi.rl:34
>
> neg = ttrue // I change 'true' to 'ttrue' to make error message
> case 1:
> //line atoi.rl:35
>
> val = val * 10 + (int(data[p]) - '0')
> ...
>
> I just add empty line after '//line atoi.rl:34' directive.
> I got following message:
>
> # command-line-arguments
> atoi.rl:35[/home/antage/workspace/ragel-go/examples/go/atoi.go:164]: undefined: ttrue
>
> It's not fine. Error isn't at atoi.rl:35, it's at atoi.rl:34.
>
> Ragel generates a lot of empty lines when embedding an action code. So we can't rely on '//line' directive to locate errors in .rl files.
Anton Ageev
2013-05-07 17:46:30 UTC
Permalink
On Mon, Apr 29, 2013 at 1:32 AM, Dan Kortschak <
dan.kortschak at adelaide.edu.au> wrote:

> This would a useful addition to the process though, so it is probably
> worth filing an issue with the Go project.
>
>
I realized it isn't a bug. Go compiler takes in consideration a distance
between '//line' directive and a line with error.
I added experimental support for '//line' directive at
https://github.com/antage/ragel-go/tree/golang-6
I need a feedback about how to accurate go compiler report error line
location in *.rl file.


> On 28/04/2013, at 5:30 PM, "Anton Ageev" <antage at gmail.com> wrote:
>
> > It's interesting undocumented feature. I played with go examples and I
> got very discouraging behaviour.
> >
> > Example 1.
> >
> > atoi.go:
> > ...
> > //line atoi.rl:34
> > neg = ttrue // I change 'true' to 'ttrue' to make error message
> > case 1:
> > //line atoi.rl:35
> >
> > val = val * 10 + (int(data[p]) - '0')
> > ...
> >
> > I run `go run atoi.go` and I got following message:
> >
> > # command-line-arguments
> > atoi.rl:34[/home/antage/workspace/ragel-go/examples/go/atoi.go:163]:
> undefined: ttrue
> >
> > It's looking fine.
> >
> > Example 2.
> >
> > atoi.go:
> > ...
> > //line atoi.rl:34
> >
> > neg = ttrue // I change 'true' to 'ttrue' to make error message
> > case 1:
> > //line atoi.rl:35
> >
> > val = val * 10 + (int(data[p]) - '0')
> > ...
> >
> > I just add empty line after '//line atoi.rl:34' directive.
> > I got following message:
> >
> > # command-line-arguments
> > atoi.rl:35[/home/antage/workspace/ragel-go/examples/go/atoi.go:164]:
> undefined: ttrue
> >
> > It's not fine. Error isn't at atoi.rl:35, it's at atoi.rl:34.
> >
> > Ragel generates a lot of empty lines when embedding an action code. So
> we can't rely on '//line' directive to locate errors in .rl files.
>
> _______________________________________________
> ragel-users mailing list
> ragel-users at complang.org
> http://www.complang.org/mailman/listinfo/ragel-users
>



--
WBR, Anton
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.complang.org/pipermail/ragel-users/attachments/20130507/04f6c74a/attachment.html>
Adrian Thurston
2013-06-26 01:51:38 UTC
Permalink
Thanks, just merged.

On 13-05-07 01:46 PM, Anton Ageev wrote:
> On Mon, Apr 29, 2013 at 1:32 AM, Dan Kortschak
> <dan.kortschak at adelaide.edu.au <mailto:dan.kortschak at adelaide.edu.au>>
> wrote:
>
> This would a useful addition to the process though, so it is
> probably worth filing an issue with the Go project.
>
>
> I realized it isn't a bug. Go compiler takes in consideration a distance
> between '//line' directive and a line with error.
> I added experimental support for '//line' directive at
> https://github.com/antage/ragel-go/tree/golang-6
> I need a feedback about how to accurate go compiler report error line
> location in *.rl file.
>
> On 28/04/2013, at 5:30 PM, "Anton Ageev" <antage at gmail.com
> <mailto:antage at gmail.com>> wrote:
>
> > It's interesting undocumented feature. I played with go examples
> and I got very discouraging behaviour.
> >
> > Example 1.
> >
> > atoi.go:
> > ...
> > //line atoi.rl:34
> > neg = ttrue // I change 'true' to 'ttrue' to make error message
> > case 1:
> > //line atoi.rl:35
> >
> > val = val * 10 + (int(data[p]) - '0')
> > ...
> >
> > I run `go run atoi.go` and I got following message:
> >
> > # command-line-arguments
> >
> atoi.rl:34[/home/antage/workspace/ragel-go/examples/go/atoi.go:163]:
> undefined: ttrue
> >
> > It's looking fine.
> >
> > Example 2.
> >
> > atoi.go:
> > ...
> > //line atoi.rl:34
> >
> > neg = ttrue // I change 'true' to 'ttrue' to make error message
> > case 1:
> > //line atoi.rl:35
> >
> > val = val * 10 + (int(data[p]) - '0')
> > ...
> >
> > I just add empty line after '//line atoi.rl:34' directive.
> > I got following message:
> >
> > # command-line-arguments
> >
> atoi.rl:35[/home/antage/workspace/ragel-go/examples/go/atoi.go:164]:
> undefined: ttrue
> >
> > It's not fine. Error isn't at atoi.rl:35, it's at atoi.rl:34.
> >
> > Ragel generates a lot of empty lines when embedding an action
> code. So we can't rely on '//line' directive to locate errors in .rl
> files.
>
> _______________________________________________
> ragel-users mailing list
> ragel-users at complang.org <mailto:ragel-users at complang.org>
> http://www.complang.org/mailman/listinfo/ragel-users
>
>
>
>
> --
> WBR, Anton
>
>
> _______________________________________________
> ragel-users mailing list
> ragel-users at complang.org
> http://www.complang.org/mailman/listinfo/ragel-users
>
Loading...