Skip to content

Instantly share code, notes, and snippets.

@msassak
Forked from aslakhellesoy/java1.rl
Created November 24, 2009 22:08
Show Gist options
  • Save msassak/242283 to your computer and use it in GitHub Desktop.
Save msassak/242283 to your computer and use it in GitHub Desktop.
/*
* @LANG: java
*/
class java1
{
%%{
machine java1;
alphtype byte;
# hello = 'hello' @{ System.out.println("ACCEPT hello"); };
hello = 'hållo' @{ System.out.println("ACCEPT aring"); };
there = 'there' @{ System.out.println("ACCEPT there"); };
friend = 'friend' @{ System.out.println("ACCEPT friend"); };
main := (hello|there|friend);
}%%
%% write data;
static void test( byte data[] )
{
int cs, p = 0, pe = data.length;
int top;
%% write init;
%% write exec;
}
public static void main( String args[] )
{
test( "hållo\none\n".getBytes() );
test( "there\ntwo\n".getBytes() );
test( "friend\nfour\n".getBytes() );
}
}
/* _____OUTPUT_____
ACCEPT
FAIL
FAIL
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment