[Snowball-discuss] Possible issue with generated Java code

Stefan Petkovic petkovic8 at gmail.com
Sat Apr 25 17:51:41 BST 2020


Hello all,

I hope this is the right place to report my findings.
While I was learning Snowball language and trying out different things
you can do with it, I wrote a small Snowball script which when
translated to Java language results in an endless loop.

Script in question:

> routines (
>     Step_1
>     Step_2
> )
>
> strings ( str1 str2 )
>
> externals ( stem )
>
> stringescapes {}
>
> define Step_1 as (
>     $str1 = 'animation'
>     $str1 ( [
>              loop 2 gopast 'a'
>              ]
>              -> str2
>            )
>)
>
> define Step_2 as (
>     [ tolimit ] <- str2
> )
>
> define stem as (
>     do Step_1
>     do Step_2
> )

Whatever you pass as an input to this script should be replaced by the
'anima' string. I wrote it while I was reading the Snowball Manual and
I was curious if you can manipulate local strings or just the current
string (input). Script works if you translate it to C language, but it
does not work if you translate it to Java.
Below is the part of generated Java code that seams to be the problem.
Every time copy_from(v_2) method is called cursor is set back to zero
and current string is replaced.

> SnowballProgram v_2 = new SnowballProgram(this);
>         current = S_str1;
>         cursor = 0;
>         limit = current.length();
>         bra = cursor;
>         for (int v_3 = 2; v_3 > 0; v_3--)
>         {
>             golab0: while(true)
>             {
>                 lab1: {
>                     if (!(eq_s("a")))
>                     {
>                         copy_from(v_2);
>                         break lab1;
>                     }
>                     break golab0;
>                 }
>                 if (cursor >= limit)
>                 {
>                     copy_from(v_2);
>                     return false;
>                 }
>                 cursor++;
>             }
>        }

Not sure how common is this scenario where you want to use tests like
loop and gopast on a local strings, but it seams that it does not work
when translated to Java, or maybe I made a mistake somewhere in my
script.

Best regards,

Stefan Petkovic



More information about the Snowball-discuss mailing list