![avatar](http://wklejamy.pl/img/default-avatar.png)
Untitled
Guest 160 25th Feb, 2024
%{
#include <stdio.h>
void yyerror(char *s);
extern int yylex(void);
%}
%token H1_OPEN H1_CLOSE H2_OPEN H2_CLOSE
%token P_OPEN P_CLOSE B_OPEN B_CLOSE BR
%token A_OPEN A_CLOSE IMG_OPEN TAG_CLOSE SELF_CLOSE
%token HREF SRC ALT WIDTH HEIGHT QUOTE TEXT
%%
document:
| document element
;
element:
H1_OPEN content H1_CLOSE
| H2_OPEN content H2_CLOSE
| P_OPEN content P_CLOSE
| B_OPEN content B_CLOSE
| BR
| A_OPEN link_attributes TAG_CLOSE content A_CLOSE
| IMG_OPEN img_attributes SELF_CLOSE
;
content:
TEXT
| content element
;
link_attributes:
HREF TEXT QUOTE
;
img_attributes:
SRC TEXT QUOTE ALT TEXT QUOTE WIDTH TEXT QUOTE HEIGHT TEXT QUOTE
;
%%
void yyerror(char *s) {
fprintf(stderr, "Error: %s\n", s);
}
int main(void) {
if (!yyparse())
printf("Plik jest poprawny.\n");
else
printf("Plik jest niepoprawny.\n");
return 0;
}
To share this paste please copy this url and send to your friends
RAW Paste Data