Discussion:
[ragel-users] Ragel 6.8 broken in Go
Guido Witmond
2013-10-22 14:44:26 UTC
Permalink
Hi,

Thanks for developing Ragel.

Being new, I tried the example from the user manual.

It runs in C but it breaks in Go.

I've run: ragel -Z -G2 main.rl && go run main.go

Results are:

# command-line-arguments
./main.go:66: goto tr0 jumps into block starting at ./main.go:39
./main.go:71: goto tr3 jumps into block starting at ./main.go:48
./main.go:72: goto st0 jumps into block starting at ./main.go:48
... too many errors.

It happens in a backported go-1.1.2 from Sid to Wheezy, 64bit
and in go-1.02 on ubuntu 12.04 on 32bits.

I've run the same program in C: number.rl

ragel number.rl && gcc number.c && ./a.out "123.456e+789"
DGT: 1
DGT: 2
DGT: 3
DEC: .
enz...


Is this a known problem? Do I (newbie) do something wrong?

Regards, Guido.

-------------- next part --------------
package main
import (
"fmt"
)

%%{
machine numbers;
action dgt { fmt.Printf("DGT: %c\n", fc); }
action dec { fmt.Printf("DEC: .\n"); }
action exp { fmt.Printf("EXP: %c\n", fc); }
action exp_sign { fmt.Printf("SGN: %c\n", fc); }
action number { fmt.Printf("Number parsed"); }

number = (
[0-9]+ $dgt ( '.' @dec [0-9]+ $dgt )?
( [eE] ( [+\-] $exp_sign )? [0-9]+ $exp )?
) %number;

main := ( number '\n' )*;
}%%

%% write data;

func main() {
data := "123.456e+789" // data is the input to the state machine
cs := 0 // state
p := 0 // data pointer (index into data)
pe := len(data)

%% write init;
%% write exec;

return
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: main.go
Type: text/x-go
Size: 2599 bytes
Desc: not available
URL: <http://www.complang.org/pipermail/ragel-users/attachments/20131022/ec50e4df/attachment.bin>
-------------- next part --------------
#include <string.h>
#include <stdio.h>

%%{
machine numbers;

action dgt { printf("DGT: %c\n", fc); }
action dec { printf("DEC: .\n"); }
action exp { printf("EXP: %c\n", fc); }
action exp_sign { printf("SGN: %c\n", fc); }
action number { res = 1; }

number = (
[0-9]+ $dgt ( '.' @dec [0-9]+ $dgt )?
( [eE] ( [+\-] $exp_sign )? [0-9]+ $exp )?
) $number;

main := ( number '\n' )*;
}%%

%% write data;

int main( int argc, char **argv )
{
int cs, res = 0;
if ( argc > 1 ) {
char *p = argv[1];
char *pe = p + strlen(p) + 1;

%% write init;
%% write exec;
}
printf("result = %i\n", res );
return 0;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 897 bytes
Desc: OpenPGP digital signature
URL: <http://www.complang.org/pipermail/ragel-users/attachments/20131022/ec50e4df/attachment.pgp>
Anton Ageev
2013-10-22 15:37:28 UTC
Permalink
Hello.

I can't reproduce this case:

$ ./ragel-6.8/ragel/ragel -v
Ragel State Machine Compiler version 6.8 Feb 2013
Copyright (c) 2001-2009 by Adrian Thurston
$ ./ragel-6.8/ragel/ragel -Z -G2 main.rl
$ go version
go version go1.1.2 linux/amd64
$ go run main.go
DGT: 1
DGT: 2
DGT: 3
DEC: .
DGT: 4
DGT: 5
DGT: 6
SGN: +
EXP: 7
EXP: 8
EXP: 9

It seems you use ragel 6.7 or older.
Post by Guido Witmond
Hi,
Thanks for developing Ragel.
Being new, I tried the example from the user manual.
It runs in C but it breaks in Go.
I've run: ragel -Z -G2 main.rl && go run main.go
# command-line-arguments
./main.go:66: goto tr0 jumps into block starting at ./main.go:39
./main.go:71: goto tr3 jumps into block starting at ./main.go:48
./main.go:72: goto st0 jumps into block starting at ./main.go:48
... too many errors.
It happens in a backported go-1.1.2 from Sid to Wheezy, 64bit
and in go-1.02 on ubuntu 12.04 on 32bits.
I've run the same program in C: number.rl
ragel number.rl && gcc number.c && ./a.out "123.456e+789"
DGT: 1
DGT: 2
DGT: 3
DEC: .
enz...
Is this a known problem? Do I (newbie) do something wrong?
Regards, Guido.
_______________________________________________
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/20131022/0f28acf1/attachment.html>
Guido Witmond
2013-10-22 15:44:01 UTC
Permalink
Post by Anton Ageev
Hello.
$ ./ragel-6.8/ragel/ragel -v
Ragel State Machine Compiler version 6.8 Feb 2013
Copyright (c) 2001-2009 by Adrian Thurston
$ ./ragel-6.8/ragel/ragel -Z -G2 main.rl
$ go version
go version go1.1.2 linux/amd64
$ go run main.go
DGT: 1
DGT: 2
DGT: 3
DEC: .
DGT: 4
DGT: 5
DGT: 6
SGN: +
EXP: 7
EXP: 8
EXP: 9
It seems you use ragel 6.7 or older.
$ ragel -v
Ragel State Machine Compiler version 6.7 May 2011


Oops, forgot to check that.


Thanks for pointing out that Wheezy is stable but old....


Regards, Guido.



-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 897 bytes
Desc: OpenPGP digital signature
URL: <http://www.complang.org/pipermail/ragel-users/attachments/20131022/034a86bf/attachment.pgp>
Loading...