andthen Oz keyword

754 Views Asked by At

I'm trying to write a tokenizer, but I'm getting a parse error:


%*************************** parse error ************************
%**
%** syntax error, unexpected T_DEFAULT, expecting T_then
%**
%** in file "/Users/xxx/Programmering/Oz/Oving1/Oz_oving1_task8.oz", line 15, column 36
%** ------------------ rejected (1 error)

Here's the code, I have marked line 15 and column 36 with %=ERROR=%

declare
fun {Tokenize L} 
   Keys Ops Token
in
   Keys = ["local", "in", "if", "then", "else", "end"]
   Ops = ["+", "-", "*", "/"]

   case Tokenize of Head|Tail then
      if {Member Head Keys} then
  Token = key(Head)
      elseif {Member Head Ops} then
  Token = op(Head)
      else
  case Head of Forste|_ then
     if Forste >= &a andthen Forste <= &z then % THIS IS LINE 15, COLUMN 36 = ..andthen [here]Forste..
        Token = atom(Forste)
     elseif
        Forste >= &A andthen Forste <= &Z then
        Token = id(Forste)
     end
  end
  Token | {Tokenize Tail}
      end
   else
      nil
   end
end

Any idea what I'm doing wrong?

1

There are 1 best solutions below

0
On BEST ANSWER

I found the solution already:

  • My lists should have whitespace instead of a comma (,) between each element.

  • In Oz, you write >= andthen =< not >= andthen <= as I did (> on wrong side of the =).

  • I made a case on Tokenize, the case should be on the input L.

Cheers!