when i debug this code it is giving few errors whats wrong in this code can anyone please help out :S
#include "stdafx.h"
#include <iostream>
#include <conio.h>
#include <string>
#define T_SEMICOLON';'
#define T_LPAREN'('
#define T_RPAREN')'
#define T_ASSIGN'='
#define T_DIVIDE'/'
#define T_WHILE 257
#define T_IF 258
#define T_RETURN 259
#define T_IDENTIFIER 268
#define T_INTEGER 269
#define T_DOUBLE 270
#define T_STRING 271
#define T_END 349
#define T_UNKNOWN 350
using namespace System;
struct token_t {
int type;
union{
char stringValue [256];
int intValue;
double doubleValue;
} val;
};
//array<System::String ^> ^args
int main(int argc,char *argv[])
{
Console.WriteLine("enter any string:");
struct token_t token;
InitScanner();
while (ScanOneToken(stdin, &token) !=T_END);
return 0;
}
static void InitScanner()
{
create_reserved_table();
{
insert_reserved("WHILE",T_WHILE)
insert_reserved("IF",T_IF)
insert_reserved("RETURN",T_RETURN)
}
static int ScanOneToken(FILE *fp,struct token_t *token)
{
int i,ch,nextch;
ch =getc(fp);
while (isspace(ch))
ch = getc(fp);
switch(ch)
{
case'/':
nextch=getc(fp);
if(nextch=='/'|| nextch =='*');
else
ungetc(nextch,fp););
case';':case',':case'=':
token->type =ch;
return ch;
case 'A':case'B':case'C':case'D':case'E':case'F':case'G':case'H':case 'I':case'J':case'K':case'L':case'M':case'N':case'O':case'P':
case 'Q':case'R':case'S':case'T':case'U':case'V':case'W':case'X':case'Y':case'Z':
token->val.stringValue[0]=ch;
for (i=1;isupper(ch =getc(fp));i++)
token->type =lookup_reserved(token->val.stringValue);
return token->type;
case 'a':case'b':case'c':case'd':case'e':case'f':case'g':case'h':case 'i':case'j':case'k':case'l':case'm':case'n':case'o':case'p':
case 'q':case'r':case's':case't':case'u':case'v':case'w':case'x':case'y':case'z':
token->type = T_IDENTIFIER;
token->val.stringValue[0] = ch;
for (i=1; islower(ch= getc(fp));i++)
token->val.stringValue[i]=ch;
ungetc(ch,fp);
token->val.stringValue[i] ='\0';
if (lookup_symtab(token->val.stringValue)==NULL)
add_symtab(token->val.stringValue);
return T_IDENTIFIER;
case '0':case'1':case'2':case'3':case'4':case'5':case'6':case'7':case '8':case'9':
token->type=T_INTEGER;
token->val.intValue = ch -'0';
while (isdigit(ch = getc(fp)))
token->val.intValue = token->val.intValue*10+ch-'0';
ungetc(ch,fp);
return T_INTEGER;
case EOF:
return T_END;
default:
token->val.intValue = ch;
token->type = T_UNKNOWN;
return T_UNKNOWN;
}
}