CalcBasYacc

De DCA-Wiki

%{
#include <stdio.h>

  int valor;
%}

%token VAL
%start expr
%%
expr : term '+' term
     | term '-' term
     | term '*' term
     | term '/' term
;
term : VAL
     | '(' expr ')'
;

%%

void yyerror(char *m) {
  fprintf(stderr, "Erro sintaxe: %s\n", m);
}

int main() {
  yyparse();
}
Ferramentas pessoais