📄 yabasic.bison
字号:
| tSYSTEM2 '(' string_expression ')' {create_function(fSYSTEM2); add_command(cPOP,NULL);} | tPOKE string_expression ',' string_expression {create_poke('s');} | tPOKE string_expression ',' expression {create_poke('d');} | tPOKE hashed_number ',' string_expression {create_poke('S');} | tPOKE hashed_number ',' expression {create_poke('D');} | tEND {add_command(cEND,NULL);} | tEXIT {create_pushdbl(0);add_command(cEXIT,NULL);} | tEXIT expression {add_command(cEXIT,NULL);} | tDOCU {create_docu($1);} | tBIND string_expression {add_command(cBIND,NULL);} ;clear_fill_clause: /* empty */ {drawmode=0;} | tCLEAR {drawmode=dmCLEAR;} | tFILL {drawmode=dmFILL;} | tCLEAR tFILL {drawmode=dmFILL+dmCLEAR;} | tFILL tCLEAR {drawmode=dmFILL+dmCLEAR;} ;string_assignment: tSTRSYM tEQU string_expression {add_command(cPOPSTRSYM,dotify($1,FALSE));} | tMID '(' string_scalar_or_array ',' expression ',' expression ')' tEQU string_expression {create_changestring(fMID);} | tMID '(' string_scalar_or_array ',' expression ')' tEQU string_expression {create_changestring(fMID2);} | tLEFT '(' string_scalar_or_array ',' expression ')' tEQU string_expression {create_changestring(fLEFT);} | tRIGHT '(' string_scalar_or_array ',' expression ')' tEQU string_expression {create_changestring(fRIGHT);} | stringfunction_or_array tEQU string_expression {create_doarray(dotify($1,FALSE),ASSIGNSTRINGARRAY);} ;to: ',' | tTO ;open_clause: tOPEN hashed_number ',' string_expression ',' string_expression {create_myopen(OPEN_HAS_STREAM+OPEN_HAS_MODE);} | tOPEN hashed_number ',' string_expression {create_myopen(OPEN_HAS_STREAM);} | tOPEN hashed_number ',' tPRINTER {create_myopen(OPEN_HAS_STREAM+OPEN_PRINTER);} | tOPEN string_expression tFOR tREADING tAS hashed_number {add_command(cSWAP,NULL);create_pushstr("r");create_myopen(OPEN_HAS_STREAM+OPEN_HAS_MODE);} | tOPEN string_expression tFOR tWRITING tAS hashed_number {add_command(cSWAP,NULL);create_pushstr("w");create_myopen(OPEN_HAS_STREAM+OPEN_HAS_MODE);} ;seek_clause: tSEEK hashed_number ',' expression {add_command(cSEEK,NULL);} | tSEEK hashed_number ',' expression ',' string_expression {add_command(cSEEK2,NULL);} ;string_scalar_or_array: tSTRSYM {add_command(cPUSHSTRPTR,dotify($1,FALSE));} | tSTRSYM '(' call_list ')' {create_doarray(dotify($1,FALSE),GETSTRINGPOINTER);} ;string_expression: tSTRSYM {add_command(cPUSHSTRSYM,dotify($1,FALSE));} | string_function | stringfunction_or_array {add_command(cSTRINGFUNCTION_OR_ARRAY,$1);} | tSTRING {if ($1==NULL) {error(ERROR,"String not terminated");create_pushstr("");} else {create_pushstr($1);}} | string_expression '+' string_expression {add_command(cCONCAT,NULL);} | '(' string_expression ')' ;string_function: tLEFT '(' string_expression ',' expression ')' {create_function(fLEFT);} | tRIGHT '(' string_expression ',' expression ')' {create_function(fRIGHT);} | tMID '(' string_expression ',' expression ',' expression ')' {create_function(fMID);} | tMID '(' string_expression ',' expression ')' {create_function(fMID2);} | tSTR '(' expression ')' {create_function(fSTR);} | tSTR '(' expression ',' string_expression ')' {create_function(fSTR2);} | tSTR '(' expression ',' string_expression ',' string_expression ')' {create_function(fSTR3);} | tINKEY {create_pushdbl(-1);create_function(fINKEY);} | tINKEY '(' ')' {create_pushdbl(-1);create_function(fINKEY);} | tINKEY '(' expression ')' {create_function(fINKEY);} | tCHR '(' expression ')' {create_function(fCHR);} | tUPPER '(' string_expression ')' {create_function(fUPPER);} | tLOWER '(' string_expression ')' {create_function(fLOWER);} | tLTRIM '(' string_expression ')' {create_function(fLTRIM);} | tRTRIM '(' string_expression ')' {create_function(fRTRIM);} | tTRIM '(' string_expression ')' {create_function(fTRIM);} | tSYSTEM '(' string_expression ')' {create_function(fSYSTEM);} | tDATE {create_function(fDATE);} | tDATE '(' ')' {create_function(fDATE);} | tTIME {create_function(fTIME);} | tTIME '(' ')' {create_function(fTIME);} | tPEEK2 '(' string_expression ')' {create_function(fPEEK2);} | tPEEK2 '(' string_expression ',' string_expression ')' {create_function(fPEEK3);} | tTOKENALT '(' string_scalar_or_array ',' string_expression ')' {add_command(cTOKENALT2,NULL);} | tTOKENALT '(' string_scalar_or_array ')' {add_command(cTOKENALT,NULL);} | tSPLITALT '(' string_scalar_or_array ',' string_expression ')' {add_command(cSPLITALT2,NULL);} | tSPLITALT '(' string_scalar_or_array ')' {add_command(cSPLITALT,NULL);} | tGETBIT '(' coordinates to coordinates ')' {create_function(fGETBIT);} | tGETCHAR '(' expression ',' expression to expression ',' expression ')' {create_function(fGETCHAR);} | tHEX '(' expression ')' {create_function(fHEX);} | tBIN '(' expression ')' {create_function(fBIN);} | tEXECUTE2 '(' call_list ')' {create_execute(1);add_command(cSWAP,NULL);add_command(cPOP,NULL);} ;assignment: tSYMBOL tEQU expression {add_command(cPOPDBLSYM,dotify($1,FALSE));} | function_or_array tEQU expression {create_doarray($1,ASSIGNARRAY);} ;expression: expression tOR {add_command(cORSHORT,NULL);pushlabel();} expression {poplabel();create_boole('|');} | expression tAND {add_command(cANDSHORT,NULL);pushlabel();} expression {poplabel();create_boole('&');} | tNOT expression {create_boole('!');} | expression tEQU expression {create_dblrelop('=');} | expression tNEQ expression {create_dblrelop('!');} | expression tLTN expression {create_dblrelop('<');} | expression tLEQ expression {create_dblrelop('{');} | expression tGTN expression {create_dblrelop('>');} | expression tGEQ expression {create_dblrelop('}');} | tMYEOF '(' hashed_number ')' {add_command(cTESTEOF,NULL);} | tGLOB '(' string_expression ',' string_expression ')' {add_command(cGLOB,NULL);} | number {create_pushdbl($1);} | tARDIM '(' arrayref ')' {add_command(cARDIM,"");} | tARDIM '(' string_arrayref ')' {add_command(cARDIM,"");} | tARSIZE '(' arrayref ',' expression ')' {add_command(cARSIZE,"");} | tARSIZE '(' string_arrayref ',' expression ')' {add_command(cARSIZE,"");} | function_or_array {add_command(cFUNCTION_OR_ARRAY,$1);} | tSYMBOL {add_command(cPUSHDBLSYM,dotify($1,FALSE));} | expression '+' expression {create_dblbin('+');} | expression '-' expression {create_dblbin('-');} | expression '*' expression {create_dblbin('*');} | expression '/' expression {create_dblbin('/');} | expression tPOW expression {create_dblbin('^');} | '-' expression %prec UMINUS {add_command(cNEGATE,NULL);} | string_expression tEQU string_expression {create_strrelop('=');} | string_expression tNEQ string_expression {create_strrelop('!');} | string_expression tLTN string_expression {create_strrelop('<');} | string_expression tLEQ string_expression {create_strrelop('{');} | string_expression tGTN string_expression {create_strrelop('>');} | string_expression tGEQ string_expression {create_strrelop('}');} | function | '(' expression ')' ;arrayref: tSYMBOL '(' ')' {create_pusharrayref(dotify($1,FALSE),stNUMBERARRAYREF);} ;string_arrayref: tSTRSYM '(' ')' {create_pusharrayref(dotify($1,FALSE),stSTRINGARRAYREF);} ;coordinates: expression ',' expression ;function: tSIN '(' expression ')' {create_function(fSIN);} | tASIN '(' expression ')' {create_function(fASIN);} | tCOS '(' expression ')' {create_function(fCOS);} | tACOS '(' expression ')' {create_function(fACOS);} | tTAN '(' expression ')' {create_function(fTAN);} | tATAN '(' expression ')' {create_function(fATAN);} | tATAN '(' expression ',' expression ')' {create_function(fATAN2);} | tEXP '(' expression ')' {create_function(fEXP);} | tLOG '(' expression ')' {create_function(fLOG);} | tLOG '(' expression ',' expression ')' {create_function(fLOG2);} | tSQRT '(' expression ')' {create_function(fSQRT);} | tSQR '(' expression ')' {create_function(fSQR);} | tINT '(' expression ')' {create_function(fINT);} | tFRAC '(' expression ')' {create_function(fFRAC);} | tABS '(' expression ')' {create_function(fABS);} | tSIG '(' expression ')' {create_function(fSIG);} | tMOD '(' expression ',' expression ')' {create_function(fMOD);} | tRAN '(' expression ')' {create_function(fRAN);} | tRAN '(' ')' {create_function(fRAN2);} | tMIN '(' expression ',' expression ')' {create_function(fMIN);} | tMAX '(' expression ',' expression ')' {create_function(fMAX);} | tLEN '(' string_expression ')' {create_function(fLEN);} | tVAL '(' string_expression ')' {create_function(fVAL);} | tASC '(' string_expression ')' {create_function(fASC);} | tDEC '(' string_expression ')' {create_function(fDEC);} | tDEC '(' string_expression ',' expression ')' {create_function(fDEC2);} | tINSTR '(' string_expression ',' string_expression ')' {if (check_compat) error(WARNING,"instr() has changed in version 2.712"); create_function(fINSTR);} | tINSTR '(' string_expression ',' string_expression ',' expression ')' {create_function(fINSTR2);} | tRINSTR '(' string_expression ',' string_expression ')' {create_function(fRINSTR);} | tRINSTR '(' string_expression ',' string_expression ',' expression ')' {create_function(fRINSTR2);} | tSYSTEM2 '(' string_expression ')' {create_function(fSYSTEM2);} | tPEEK '(' hashed_number ')' {create_function(fPEEK4);} | tPEEK '(' string_expression ')' {create_function(fPEEK);} | tMOUSEX '(' string_expression ')' {create_function(fMOUSEX);} | tMOUSEX {create_pushstr("");create_function(fMOUSEX);} | tMOUSEX '(' ')' {create_pushstr("");create_function(fMOUSEX);} | tMOUSEY '(' string_expression ')' {create_function(fMOUSEY);} | tMOUSEY {create_pushstr("");create_function(fMOUSEY);} | tMOUSEY '(' ')' {create_pushstr("");create_function(fMOUSEY);} | tMOUSEB '(' string_expression ')' {create_function(fMOUSEB);} | tMOUSEB {create_pushstr("");create_function(fMOUSEB);} | tMOUSEB '(' ')' {create_pushstr("");create_function(fMOUSEB);} | tMOUSEMOD '(' string_expression ')' {create_function(fMOUSEMOD);} | tMOUSEMOD {create_pushstr("");create_function(fMOUSEMOD);} | tMOUSEMOD '(' ')' {create_pushstr("");create_function(fMOUSEMOD);} | tAND '(' expression ',' expression ')' {create_function(fAND);} | tOR '(' expression ',' expression ')' {create_function(fOR);} | tEOR '(' expression ',' expression ')' {create_function(fEOR);} | tTELL '(' hashed_number ')' {create_function(fTELL);} | tTOKEN '(' string_expression ',' string_arrayref ',' string_expression ')' {add_command(cTOKEN2,NULL);} | tTOKEN '(' string_expression ',' string_arrayref ')' {add_command(cTOKEN,NULL);} | tSPLIT '(' string_expression ',' string_arrayref ',' string_expression ')' {add_command(cSPLIT2,NULL);} | tSPLIT '(' string_expression ',' string_arrayref ')' {add_command(cSPLIT,NULL);} | tEXECUTE '(' call_list ')' {create_execute(0);add_command(cSWAP,NULL);add_command(cPOP,NULL);} | tOPEN '(' tPRINTER ')' {create_myopen(OPEN_PRINTER);} | tOPEN '(' string_expression ')' {create_myopen(0);} | tOPEN '(' string_expression ',' string_expression ')' {create_myopen(OPEN_HAS_MODE);} | tOPEN '(' hashed_number ',' tPRINTER ')' {create_myopen(OPEN_PRINTER+OPEN_HAS_STREAM);} | tOPEN '(' hashed_number ',' string_expression ')' {create_myopen(OPEN_HAS_STREAM);} | tOPEN '(' hashed_number ',' string_expression ',' string_expression ')' {create_myopen(OPEN_HAS_STREAM+OPEN_HAS_MODE);} ;const: number {$$=$1;} | '+' number {$$=$2;} | '-' number {$$=-$2;} ;number: tFNUM {$$=$1;} | tDIGITS {$$=strtod($1,NULL);} ;symbol_or_lineno: tDIGITS {$$=my_strdup(dotify($1,FALSE));} | tSYMBOL {$$=my_strdup(dotify($1,FALSE));} ;dimlist: tSYMBOL '(' call_list ')' {create_dim(dotify($1,FALSE),'D');} | dimlist ',' tSYMBOL '(' call_list ')' {create_dim(dotify($3,FALSE),'D');} | tSTRSYM '(' call_list ')' {create_dim(dotify($1,FALSE),'S');} | dimlist ',' tSTRSYM '(' call_list ')' {create_dim(dotify($3,FALSE),'S');} ;function_or_array: tSYMBOL '(' call_list ')' {$$=my_strdup(dotify($1,FALSE));} ;stringfunction_or_array: tSTRSYM '(' call_list ')' {$$=my_strdup(dotify($1,FALSE));} ;call_list: {add_command(cPUSHFREE,NULL);} calls ;calls: /* empty */ | call_item | calls ',' call_item ;call_item: string_expression | expression ; function_definition: export tSUB {missing_endsub++;missing_endsub_line=yylineno;pushlabel();report_missing(WARNING,"do not define a function in a loop or an if-statement");if (function_type!=ftNONE) {error(ERROR,"nested functions not allowed");YYABORT;}} function_name {if (exported) create_sublink($4); create_label($4,cUSER_FUNCTION); add_command(cPUSHSYMLIST,NULL);add_command(cCLEARREFS,NULL);firstref=lastref=lastcmd; create_numparam();} '(' paramlist ')' {create_require(stFREE);add_command(cPOP,NULL);} statement_list endsub {add_command(cCLEARREFS,NULL);lastcmd->nextref=firstref;add_command(cPOPSYMLIST,NULL);create_retval(ftNONE,function_type);function_type=ftNONE;add_command(cRET_FROM_FUN,NULL);lastref=NULL;create_endfunction();poplabel();} ;endsub: tEOPROG {if (missing_endsub) {sprintf(string,"%d end-sub(s) are missing (last at line %d)",missing_endsub,missing_endsub_line);error(ERROR,string);} YYABORT;} | tENDSUB {missing_endsub--;} ;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -