然后是Oz关键字

时间:2010-09-07 10:02:08

标签: oz

我正在尝试编写一个tokenizer,但我得到一个解析错误:


%*************************** 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)

这是代码,我标记了第15行和第36列,其中%= 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

知道我做错了吗?

1 个答案:

答案 0 :(得分:2)

我已经找到了解决方案:

  • 我的列表在每个元素之间应该有空格而不是逗号(,)。

  • 在Oz中,您写的是>= andthen =<,而不是>= andthen <= >=的错误一侧。

  • 我在case上发了Tokenizecase应该在输入L上。

干杯!

相关问题