⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ch1-06.y

📁 YACC与LEX教程 英文原版(中文书附代码与答案)
💻 Y
字号:
%{#include <stdio.h>/* we found the following required for some yacc implementations. *//* #define YYSTYPE int */%}%token NOUN PRONOUN VERB ADVERB ADJECTIVE PREPOSITION CONJUNCTION%%sentence: simple_sentence   { printf("Parsed a simple sentence.\n"); }	| compound_sentence { printf("Parsed a compound sentence.\n"); }	; simple_sentence: subject verb object	|	subject verb object prep_phrase	;compound_sentence: simple_sentence CONJUNCTION simple_sentence	|	compound_sentence CONJUNCTION simple_sentence	;subject:	NOUN	|	PRONOUN	|	ADJECTIVE subject	;verb:		VERB	|	ADVERB VERB	|	verb VERB	;	object:		NOUN	|	ADJECTIVE object	;prep_phrase:	PREPOSITION NOUN	;%%extern FILE *yyin;main(){	while(!feof(yyin)) {		yyparse();	}}yyerror(s)char *s;{    fprintf(stderr, "%s\n", s);}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -