编译酷项目中的语法错误

syntax error in compile cool project

本文关键字:语法 错误 项目 编译      更新时间:2023-10-16

我从https://github.com/cchuahuico/COOL-Compiler

:

class Main inherits SuperClass {
  main(): Object {{
    out_string("Enter an integer greater-than or equal-to 0: ");
    let input: Int  in
      if input < 0 then
            input
 --     out_string("ERROR: Number must be greater-than or equal-to 0n")
      else {
 --       out_string("The factorial of ").out_int(input);
 --       out_string(" is ").out_int(factorial(input));
            factorial(input);
      }
      fi;
  }};
  factorial(num: Int): Int {
    if num = 0 then 1 else num * factorial(num - 1) fi
  };
};
class SuperClass {
out_string(str:String){};
};

当我用mingw编译这个时,我有这个错误

<stdin>:2:error:syntax error near or aat character or token '{'
<stdin>:5:error:syntax error near or aat character or token 'let'
<stdin>:14:error:syntax error near or aat character or token 'fi'
<stdin>:15:error:syntax error near or aat character or token '}'
<stdin>:23:error:syntax error near or aat character or token '('
<stdin>:24:error:syntax error near or aat character or token '}'
<stdin>:24:error:syntax error near or aat character or token ' '
copmilation halted due to lexical or syntax errors

mingw编译器正在抱怨,因为语言不是标准的c++:

  1. inherits关键字。虽然也可以是#define as任何东西。

  2. fi不是关键字

  3. if语句在表达式周围需要parens ()

  4. let不是关键字

  5. then不是关键字

//还有很多

这是另一种语言吗?