Add tinyC grammar desc

This commit is contained in:
Mathieu Maret 2023-11-10 22:54:35 +01:00
parent d6dc298d35
commit b0a192ce7c

View File

@ -284,6 +284,23 @@ void run()
int func_tiny()
{
printf("TinyC grammar\n");
printf("<program> ::= <statement>\n");
printf("<statement> ::= \"if\" <paren_expr> <statement> |\n");
printf(" \"if\" <paren_expr> <statement> \"else\" <statement> |\n");
printf(" \"while\" <paren_expr> <statement> |\n");
printf(" \"do\" <statement> \"while\" <paren_expr> \";\" |\n");
printf(" \"{\" { <statement> } \"}\" |\n");
printf(" <expr> \";\" |\n");
printf(" \";\"\n");
printf("<paren_expr> ::= \"(\" <expr> \")\"\n");
printf("<expr> ::= <test> | <id> \"=\" <expr>\n");
printf("<test> ::= <sum> | <sum> \"<\" <sum> | <sum> \">\" <sum>\n");
printf("<sum> ::= <term> | <sum> \"+\" <term> | <sum> \"-\" <term>\n");
printf("<term> ::= <id> | <int> | <paren_expr>\n");
printf("<id> ::= \"a\" | \"b\" | \"c\" | \"d\" | ... | \"z\"\n");
printf("<int> ::= <an_unsigned_decimal_integer>\n");
int i;
ch = ' ';
sym = 0;