Syntax 赋值抛出错误
这个程序的编译抛出 compilers@compilers-vm:~/cool/jim$coolc list.clSyntax 赋值抛出错误,syntax,Syntax,这个程序的编译抛出 compilers@compilers-vm:~/cool/jim$coolc list.cl “list.cl”,第7行:“;”处或附近的语法错误 由于lex和解析错误,编译已停止 类列表{ 项目:字符串; 下一步:列表; init(i:String,n:List):List { item必须有一个为init method返回值的块。 这里 项目 class List{ item : String; next : List; init(i: Str
“list.cl”,第7行:“;”处或附近的语法错误
由于lex和解析错误,编译已停止
类列表{
项目:字符串;
下一步:列表;
init(i:String,n:List):List
{
item必须有一个为init method返回值的块。
这里
项目
class List{
item : String;
next : List;
init(i: String, n: List) : List
{
item <- i;
next <- n;
self
};
flattn(): String
{
if( isvoid next )
then
item
else
item.concat( next.flattn())
fi
};
};
class Main inherits IO {
main() : Object{
let hello : String <- "Hello ",
wold : String <- "world ",
newLine : String <- "\n",
unfedined : List,
l : List <- (new List).init(hello,
(new List).init(wold,
(new List).init(newLine, unfedined ) ) )
in
out_string( l.flattn() )
};
};
item <- i;
next <- n;
self;
init(i: String, n: List) : List
{
{
item <- i;
next <- n;
self;
}
};