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

📄 ycmm.y

📁 使用yacc和lex编写的cmm语言的词法分析和语法分析程序.
💻 Y
字号:
%{#include <stdio.h>%}%token IDENTIFIER CONSTANT%token GE_OP LE_OP EQ_OP NE_OP AND_OP OR_OP%token INT REAL%token WHILE WRITE READ IF ELSE%nonassoc IF%nonassoc ELSE%right '='%left OR_OP%left AND_OP%left '>' '<' EQ_OP NE_OP LE_OP GE_OP%left '+' '-'%left '*' '/' '%'%right UNARY%left '.' '(' '['%start program%%program      : decls xstmts      | xstmts      ;unop      : '-'      | '+'      | '~'      | '!'expr      : nonnull_exprlist      ;nonnull_exprlist      : expr_no_commas      | nonnull_exprlist ',' expr_no_commas      ;unary_expr      : primary       | unop cast_expr %prec UNARY       ;cast_expr      : unary_expr       ;expr_no_commas      : cast_expr      | expr_no_commas '+' expr_no_commas      | expr_no_commas '-' expr_no_commas      | expr_no_commas '*' expr_no_commas      | expr_no_commas '/' expr_no_commas      | expr_no_commas '%' expr_no_commas      | expr_no_commas '=' expr_no_commas      | expr_no_commas '<' expr_no_commas      | expr_no_commas '>' expr_no_commas      | expr_no_commas EQ_OP expr_no_commas      | expr_no_commas NE_OP expr_no_commas      | expr_no_commas LE_OP expr_no_commas      | expr_no_commas GE_OP expr_no_commas      | expr_no_commas AND_OP expr_no_commas      | expr_no_commas OR_OP expr_no_commasprimary      : IDENTIFIER       | CONSTANT        | '(' expr ')'      | primary '[' expr ']'      ;lineno_decl      :save_filename save_lineno decl      ;decls      : lineno_decl      | decls lineno_decl      ;setspecs:        ;decl      : typed_declspecs setspecs initdecls ';'      ;typed_declspecs      : typespec      ;typespec      : INT      | REAL      ;initdecls      : initdcl      | initdecls ',' initdcl      ;initdcl      : declarator '=' init      | declarator      ;init      : expr_no_commas      | '{' '}'      | '{' initlist '}'      | '{' initlist ',' '}'initlist      : init      | initlist ',' init      ;declarator      : notype_declarator      ;notype_declarator      : IDENTIFIER      | notype_declarator '[' expr ']'      | notype_declarator '[' ']'      ;stmts      : lineno_stmt_or_label      | stmts lineno_stmt_or_label      ;lineno_stmt_or_label      : save_filename save_lineno stmt_or_label      ;stmt_or_label      : stmt      | label      ;label      : IDENTIFIER ':'      ;xstmts      :       | stmts      ;compstmt      : '{' decls xstmts '}'      | '{' xstmts '}'      ;simple_if      : if_prefix lineno_labeled_stmt      ;if_prefix      : IF '(' expr ')'      ;save_filename      :      ;save_lineno      :      ;lineno_labeled_stmt      : save_filename save_lineno stmt      ;stmt      : compstmt                                      | expr ';'                                      | simple_if ELSE lineno_labeled_stmt            | simple_if %prec IF                            | WHILE '(' expr ')' lineno_labeled_stmt        | WRITE '(' expr ')' ';'                       | READ '(' identifiers ')' ';'          identifiers      : IDENTIFIER      | identifiers ',' IDENTIFIER      ;%%int main () {      yyparse();}

⌨️ 快捷键说明

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