Skip to content

Instantly share code, notes, and snippets.

@aslakhellesoy
Created November 24, 2009 21:27
Show Gist options
  • Save aslakhellesoy/242235 to your computer and use it in GitHub Desktop.
Save aslakhellesoy/242235 to your computer and use it in GitHub Desktop.
/*
* @LANG: java
*/
class java1
{
%%{
machine java1;
one := 'one\n';
two := 'two\n';
four := 'four\n';
main :=
( 'h' 0xC3 0xA5 'llo' | 'there' | 'friend' )
'\n' @{int s = fentry(one); fgoto *s; char c = fc;}
( 'one' | 'two' | 'four' ) '\n';
}%%
%% write data;
static void test( char data[] )
{
int cs, p = 0, pe = data.length;
int top;
%% write init;
%% write exec;
if ( cs >= java1_first_final )
System.out.println( "ACCEPT" );
else
System.out.println( "FAIL" );
}
public static void main( String args[] )
{
test( "hållo\none\n".toCharArray() );
test( "there\ntwo\n".toCharArray() );
test( "friend\nfour\n".toCharArray() );
}
}
/* _____OUTPUT_____
ACCEPT
FAIL
FAIL
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment