Category : Miscellaneous Language Source Code
Archive   : SYACC31B.ZIP
Filename : YACC.259

 
Output of file : YACC.259 contained in archive : SYACC31B.ZIP

#include
#include
#include
#include

#define PA_STACK_TYPE int

#define LEXER lexer
char* lexer ();

#define MALLOC(x) ((x *) malloc (sizeof(x)))

%%
// this is the precedences and associativity declarations area
%%
//
// A simple calculator
//
line : expr '\n'
{ printf ( "\nTHE RESULT: %d\n", *$1 ); }
;
expr : expr '+' term
{ *$$ = *$1 + *$3; }
| term
;
term : term '*' factor
{ *$$ = *$1 * *$3; }
| factor
;
factor : '(' expr ')'
{ *$$ = *$2; }
| DIGIT
;
%%


char token[128];

char* lexer()
{
int c;
int value;

c = getche ();

/* using Renter key to signify the end of input */
if ( c == '\r' )
return "";
else if ( isdigit (c) )
{
token_value = MALLOC (int);
*token_value = c - '0';
return "DIGIT";
};
token[0] = c;
token[1] = '\0';

return token;
};



  3 Responses to “Category : Miscellaneous Language Source Code
Archive   : SYACC31B.ZIP
Filename : YACC.259

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/