tags:

views:

23

answers:

1
+1  Q: 

andthen Oz keyword

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  A: 

I found the solution already.

First of all, my lists should have whitespace instead of a "," between each element. Second in Oz you write ">= andthen =<" not ">= andthen <=" as I did (> on wrong side of the =). And last, I made a case on Tokenize, the case should be on the input L.

Cheers!

Johannes