[ragel-users] Ragel 6.8 broken in Go
Guido Witmond
guido at witmond.nl
Tue Oct 22 14:44:26 UTC 2013
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.colm.net/pipermail/ragel-users/attachments/20131022/ec50e4df/attachment-0001.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.colm.net/pipermail/ragel-users/attachments/20131022/ec50e4df/attachment-0001.sig>
-------------- next part --------------
_______________________________________________
ragel-users mailing list
ragel-users at complang.org
http://www.complang.org/mailman/listinfo/ragel-users
More information about the ragel-users
mailing list