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

📄 yabasic.bison

📁 Linux下VB解释器
💻 BISON
📖 第 1 页 / 共 3 页
字号:
function_name: tSYMBOL {function_type=ftNUMBER;current_function=my_strdup(dotify($1,FALSE));$$=my_strdup(dotify($1,FALSE));}  | tSTRSYM {function_type=ftSTRING;current_function=my_strdup(dotify($1,FALSE));$$=my_strdup(dotify($1,FALSE));}  ;export: /* empty */ {exported=FALSE;}  | tEXPORT {exported=TRUE;}  | tRUNTIME_CREATED_SUB {exported=FALSE;}  | tRUNTIME_CREATED_SUB tEXPORT {exported=TRUE;}  ;local_list: local_item  | local_list ',' local_item  ;local_item: tSYMBOL {create_makelocal(dotify($1,FALSE),syNUMBER);}  | tSTRSYM {create_makelocal(dotify($1,FALSE),sySTRING);}  | tSYMBOL '(' call_list ')' {create_makelocal(dotify($1,FALSE),syARRAY);create_dim(dotify($1,FALSE),'d');}  | tSTRSYM '(' call_list ')' {create_makelocal(dotify($1,FALSE),syARRAY);create_dim(dotify($1,FALSE),'s');}  ;  static_list: static_item  | static_list ',' static_item  ;static_item: tSYMBOL {create_makestatic(dotify($1,TRUE),syNUMBER);}  | tSTRSYM {create_makestatic(dotify($1,TRUE),sySTRING);}  | tSYMBOL '(' call_list ')' {create_makestatic(dotify($1,TRUE),syARRAY);create_dim(dotify($1,TRUE),'D');}  | tSTRSYM '(' call_list ')' {create_makestatic(dotify($1,TRUE),syARRAY);create_dim(dotify($1,TRUE),'S');}  ;  paramlist: /* empty */  | paramitem  | paramlist ',' paramitem  ;  paramitem: tSYMBOL {create_require(stNUMBER);create_makelocal(dotify($1,FALSE),syNUMBER);add_command(cPOPDBLSYM,dotify($1,FALSE));}  | tSTRSYM {create_require(stSTRING);create_makelocal(dotify($1,FALSE),sySTRING);add_command(cPOPSTRSYM,dotify($1,FALSE));}  | tSYMBOL '(' ')' {create_require(stNUMBERARRAYREF);create_arraylink(dotify($1,FALSE),stNUMBERARRAYREF);}  | tSTRSYM '(' ')' {create_require(stSTRINGARRAYREF);create_arraylink(dotify($1,FALSE),stSTRINGARRAYREF);}  ;for_loop: tFOR {missing_next++;missing_next_line=yylineno;} tSYMBOL tEQU             {pushname(dotify($3,FALSE)); /* will be used by next_symbol to check equality */	     add_command(cRESETSKIPONCE,NULL);	     pushgoto();add_command(cCONTINUE_HERE,NULL);create_break_mark(0,1);}	  expression tTO expression 	  step_part { /* pushes another expression */	     add_command(cSKIPONCE,NULL);	     pushlabel();	     add_command(cSTARTFOR,NULL);	     add_command(cPOPDBLSYM,dotify($3,FALSE));	     poplabel();	     add_command(cPUSHDBLSYM,dotify($3,FALSE));	     add_command(cFORINCREMENT,NULL);	     add_command(cPOPDBLSYM,dotify($3,FALSE));	     add_command(cPUSHDBLSYM,dotify($3,FALSE));	     add_command(cFORCHECK,NULL);	     add_command(cDECIDE,NULL);             pushlabel();}          statement_list {             swap();popgoto();poplabel();}          next next_symbol {create_break_mark(0,-1);add_command(cBREAK_HERE,NULL);}  ;next: tEOPROG {if (missing_next) {sprintf(string,"%d next(s) are missing (last at line %d)",missing_next,missing_next_line);error(ERROR,string);} YYABORT;}  | tNEXT {missing_next--;}  ;step_part: {create_pushdbl(1);} /* can be omitted */  | tSTEP expression  ;next_symbol:  {pop(stSTRING);}/* can be omitted */  | tSYMBOL {if (strcmp(pop(stSTRING)->pointer,dotify($1,FALSE)))              {error(ERROR,"'for' and 'next' do not match"); YYABORT;}           }  ;switch_number_or_string: tSWITCH {push_switch_id();add_command(cPUSH_SWITCH_MARK,NULL);create_break_mark(0,1);	add_command(cCONTINUE_CORRECTION,NULL);}                 number_or_string sep_list case_list default tSEND {create_break_mark(-1,0);add_command(cBREAK_HERE,NULL);create_break_mark(0,-1);add_command(cBREAK_HERE,NULL);create_clean_switch_mark(0,FALSE);pop_switch_id();}  ;sep_list: tSEP {if ($1>=0) yylineno+=$1;}   | sep_list tSEP {if ($2>=0) yylineno+=$2;}   ;number_or_string: expression  | string_expression  ;case_list: /* empty */  | case_list tCASE {create_break_mark(-1,0);add_command(cBREAK_HERE,NULL);} number_or_string      {add_command(cSWITCH_COMPARE,NULL);add_command(cDECIDE,NULL);add_command(cMINOR_BREAK,NULL);create_break_mark(1,0);} statement_list {add_command(cNEXT_CASE,NULL);}  ;default: /* empty */  | tDEFAULT tSEP {if ($2>=0) yylineno+=$2; create_break_mark(-1,0);add_command(cBREAK_HERE,NULL);} statement_list  ;do_loop: tDO {add_command(cCONTINUE_HERE,NULL);create_break_mark(0,1);missing_loop++;missing_loop_line=yylineno;pushgoto();}	      statement_list            loop  ;loop: tEOPROG {if (missing_loop) {sprintf(string,"%d loop(s) are missing (last at line %d)",missing_loop,missing_loop_line);error(ERROR,string);} YYABORT;}  | tLOOP {missing_loop--;popgoto();create_break_mark(0,-1);add_command(cBREAK_HERE,NULL);}  ;while_loop: tWHILE {add_command(cCONTINUE_HERE,NULL);create_break_mark(0,1);missing_wend++;missing_wend_line=yylineno;pushgoto()} '(' expression ')'	      {add_command(cDECIDE,NULL);	      pushlabel();}	      statement_list            wend  ;	    wend: tEOPROG {if (missing_wend) {sprintf(string,"%d wend(s) are missing (last at line %d)",missing_wend,missing_wend_line);error(ERROR,string);} YYABORT;}  | tWEND {missing_wend--;swap();popgoto();poplabel();create_break_mark(0,-1);add_command(cBREAK_HERE,NULL);}  ;repeat_loop: tREPEAT {add_command(cCONTINUE_HERE,NULL);create_break_mark(0,1);missing_until++;missing_until_line=yylineno;pushgoto();} 	       statement_list	     until  ;until: tEOPROG {if (missing_until) {sprintf(string,"%d until(s) are missing (last at line %d)",missing_until,missing_until_line);error(ERROR,string);} YYABORT;}  | tUNTIL '(' expression ')'	       {missing_until--;add_command(cDECIDE,NULL);popgoto();create_break_mark(0,-1);add_command(cBREAK_HERE,NULL);}  ;if_clause: tIF expression {add_command(cDECIDE,NULL);storelabel();pushlabel();}           tTHEN {missing_endif++;missing_endif_line=yylineno;} statement_list {swap();matchgoto();swap();poplabel();}	   elsif_part           else_part {poplabel();}           endif  ;endif: tEOPROG {if (missing_endif) {sprintf(string,"%d endif(s) are missing (last at line %d)",missing_endif,missing_endif_line);error(ERROR,string);} YYABORT;}  | tENDIF {missing_endif--;}  ;short_if:  tIF expression {fi_pending++;add_command(cDECIDE,NULL);pushlabel();}	statement_list tENDIF {poplabel();}  ;else_part: /* can be omitted */  | tELSE statement_list  ;elsif_part: /* can be omitted */  | tELSIF expression maybe_then    	{add_command(cDECIDE,NULL);pushlabel();}     statement_list 	{swap();matchgoto();swap();poplabel();}     elsif_part  ;maybe_then: /* can be omitted */  | tTHEN  ;inputlist: input  | input ',' {add_command(cCHKPROMPT,NULL);} inputlist  ;input: tSYMBOL {create_myread('d',tileol);add_command(cPOPDBLSYM,dotify($1,FALSE));}  | tSYMBOL '(' call_list ')'     	{create_myread('d',tileol);create_doarray(dotify($1,FALSE),ASSIGNARRAY);}  | tSTRSYM {create_myread('s',tileol);add_command(cPOPSTRSYM,dotify($1,FALSE));}  | tSTRSYM '(' call_list ')'     	{create_myread('s',tileol);create_doarray(dotify($1,FALSE),ASSIGNSTRINGARRAY);}  ;readlist: readitem  | readlist ',' readitem  ;readitem: tSYMBOL {create_readdata('d');add_command(cPOPDBLSYM,dotify($1,FALSE));}  | tSYMBOL '(' call_list ')'     {create_readdata('d');create_doarray(dotify($1,FALSE),ASSIGNARRAY);}  | tSTRSYM {create_readdata('s');add_command(cPOPSTRSYM,dotify($1,FALSE));}  | tSTRSYM '(' call_list ')'     {create_readdata('s');create_doarray(dotify($1,FALSE),ASSIGNSTRINGARRAY);}  ;datalist: tSTRING {create_strdata($1);}  | const {create_dbldata($1);}  | datalist ','  tSTRING {create_strdata($3);}  | datalist ',' const {create_dbldata($3);}  ;printlist:  /* possible empty */  | expression using  | printlist ',' expression using  | string_expression {create_print('s');}   | printlist ',' string_expression {create_print('s');}  ;using: {create_print('d');} /* possible empty */  | tUSING string_expression {create_print('u');}  | tUSING '(' string_expression ',' string_expression ')' {create_print('U');}  ;inputbody: '#' tSYMBOL {add_command(cPUSHDBLSYM,dotify($2,FALSE));create_pps(cPUSHSTREAM,1);} inputlist {create_pps(cPOPSTREAM,0);}  | '#' tDIGITS {create_pushdbl(atoi($2));create_pps(cPUSHSTREAM,1);} inputlist {create_pps(cPOPSTREAM,0);}  | '#' '(' expression ')' {create_pps(cPUSHSTREAM,1);} inputlist {create_pps(cPOPSTREAM,0);}  | tAT '(' expression ',' expression ')' {add_command(cMOVE,NULL);create_pushdbl(STDIO_STREAM);create_pps(cPUSHSTREAM,1);} prompt inputlist {create_pps(cPOPSTREAM,0);}  | {create_pushdbl(STDIO_STREAM);create_pps(cPUSHSTREAM,1);} prompt inputlist {create_pps(cPOPSTREAM,0);}  ;prompt: /* empty */ {create_pushstr("?");create_print('s');}   | tSTRING {create_pushstr($1);create_print('s');}  ;printintro: /* may be empty */ {create_pushdbl(STDIO_STREAM);create_pps(cPUSHSTREAM,0);}  | '#' tSYMBOL {add_command(cPUSHDBLSYM,dotify($2,FALSE));create_pps(cPUSHSTREAM,0);}  | '#' tDIGITS {create_pushdbl(atoi($2));create_pps(cPUSHSTREAM,0);}  | '#' '(' expression ')' {create_pps(cPUSHSTREAM,0);}  | tREVERSE {create_colour(1);create_pushdbl(STDIO_STREAM);create_pps(cPUSHSTREAM,0);}  | tCOLOUR '(' string_expression ')' {create_colour(2);create_pushdbl(STDIO_STREAM);create_pps(cPUSHSTREAM,0);}  | tCOLOUR '(' string_expression ',' string_expression ')' {create_colour(3);create_pushdbl(STDIO_STREAM);create_pps(cPUSHSTREAM,0);}  | tAT '(' expression ',' expression ')' {add_command(cMOVE,NULL);create_pushdbl(STDIO_STREAM);create_pps(cPUSHSTREAM,0);}  | tREVERSE tAT '(' expression ',' expression ')' {add_command(cMOVE,NULL);create_colour(1);create_pushdbl(STDIO_STREAM);create_pps(cPUSHSTREAM,0);}  | tCOLOUR '(' string_expression ')' tAT '(' expression ',' expression ')' {add_command(cMOVE,NULL);create_colour(2);create_pushdbl(STDIO_STREAM);create_pps(cPUSHSTREAM,0);}  | tCOLOUR '(' string_expression ',' string_expression ')' tAT '(' expression ',' expression ')' {add_command(cMOVE,NULL);create_colour(3);create_pushdbl(STDIO_STREAM);create_pps(cPUSHSTREAM,0);}  | tAT '(' expression ',' expression ')' tREVERSE {create_colour(1);create_pushdbl(STDIO_STREAM);create_pps(cPUSHSTREAM,0);add_command(cMOVE,NULL);}  | tAT '(' expression ',' expression ')' tCOLOUR '(' string_expression ')' {create_colour(2);create_pushdbl(STDIO_STREAM);create_pps(cPUSHSTREAM,0);add_command(cMOVE,NULL);}  | tAT '(' expression ',' expression ')' tCOLOUR '(' string_expression ',' string_expression ')' {create_colour(3);create_pushdbl(STDIO_STREAM);create_pps(cPUSHSTREAM,0);add_command(cMOVE,NULL);}  ;  hashed_number: '#' expression  | expression;goto_list: symbol_or_lineno {create_goto((function_type!=ftNONE)?dotify($1,TRUE):$1);add_command(cFINDNOP,NULL);}  | goto_list ',' symbol_or_lineno {create_goto((function_type!=ftNONE)?dotify($3,TRUE):$3);add_command(cFINDNOP,NULL);}  ;gosub_list: symbol_or_lineno {create_gosub((function_type!=ftNONE)?dotify($1,TRUE):$1);add_command(cFINDNOP,NULL);}  | gosub_list ',' symbol_or_lineno {create_gosub((function_type!=ftNONE)?dotify($3,TRUE):$3);add_command(cFINDNOP,NULL);}  ;

⌨️ 快捷键说明

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