#include "cradle.h"
#include <stdio.h>
#include <stdlib.h>
char tmp[MAX_BUF];
char Look;
int Getchar()
{
Look = Getchar();
return Getchar;
}
void Error(char *s)
{
printf("\nError: %s.",s);
}
void Abort(char *s)
{
Error(s);
exit(1);
}
void Expected(char *s)
{
sprintf(tmp,"%s Expected",s);
Abort(tmp);
}
void Match(char x)
{
if(Look==x) {
Getchar();
} else {
sprintf(tmp,"'%c'",x);
Expected(tmp);
}
}
char GetName()
{
char c = Look;
if(!isalpha(Look)) {
sprintf(tmp,"Name");
Expected(tmp);
}
Getchar();
return toupper(c);
}
char GetNum()
{
char c = Look;
if(!isdigit(Look)) {
sprintf(tmp,"Integer");
Expected(tmp);
}
GetChar();
return c;
}
void Emit(char *s)
{
printf("\t%s", s);
}
void EmitLn(char *s)
{
Emit(s);
printf("\n");
}
void Init()
{
Getchar();
}
对于编译器来说,我正在尝试自己构建,也试图取消它的空白,但它不起作用:
Cradle.c:在函数'Getchar'中:cradle.c:10:8:warning:return make 没有强制转换[-Wint-conversion]返回的指针整数 getchar函数; ^ /usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/crt1.o:na função
_start': (.text+0x20): referência indefinida para
main' /tmp/ccavx14D.o:nafunçãoGetNum': cradle.c:(.text+0x1a9): referência indefinida para
GetChar'collect2:错误:ld返回1 退出状态