Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // LEX
- %{
- #include <stdio.h>
- #include "y.tab.h"
- extern int yyline;
- %}
- %%
- [0-9][0-9]* { yylval.cbroj = atoi(yytext); return CBROJ; }
- "ZAR" { return ZAR; }
- . { return yytext[0]; }
- \n { yyline++; }
- %%
- // YACC
- %{
- #include <stdio.h>
- #include <stdlib.h>
- int yyline;
- int yylex();
- %}
- %union
- {
- int cbroj;
- }
- %start program
- %token <cbroj> CBROJ ZAR
- %%
- program : kraj
- kraj : CBROJ ' ' ZAR { printf("%d", $1);}
- %%
- int yyerror(char *s)
- {
- printf("Error %s, %d\n", s, yyline);
- }
- int main()
- {
- extern FILE *yyin;
- yyin = fopen("input.txt", "r");
- if (yyparse() == 0) { printf("Ok"); }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement