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

📄 input.y

📁 实时操作系统RT LINUX的源代码
💻 Y
字号:
%{/* Parser input for the graphical interface.    This file is created by the simulator and red by the    front_end grap_tool (can be a Xwindows or PostScript ).   */#include <stdio.h>#include <string.h>#include "crono.h"extern int   NPoints;extern int   TimeSim;extern int   NTasks;extern int   NResources;extern Accion        Chronog[MAX_MATRIX];extern char          Tasks[MAX_TASKS][20];extern char          Resources[MAX_TASKS][20];static void cal_tsim(int,int);extern FILE   *yyin;   /* File used by lex to read the file */int linenumber=1;%}%union {  long  ivalue;  char  *cvalue;}%token <ivalue> ACTI EXEC END ENDHEAD NUM TASK RESOURCE %token <cvalue> IDEN%start inicio%type <ivalue>  inicio header body line_body line_head %%inicio : header ENDHEAD body  {}  ; body :  body line_body {}	|  {}	;line_body :ACTI NUM NUM NUM 	   { 	        if ($2 > NTasks) {		  yyerror("Task Not declared");		}		Chronog[NPoints].accion = ACTI;                Chronog[NPoints].id = $2;		Chronog[NPoints].x1 = $3;		Chronog[NPoints].x2 = $4;		cal_tsim($4,$3);		NPoints++; 	   } 	| END NUM NUM	   { 	        if ($2 > NTasks) {		  yyerror("Task Not declared");		}		Chronog[NPoints].accion = END;		Chronog[NPoints].id = $2;		Chronog[NPoints].x1 = $3;		cal_tsim($3,0);		NPoints++;	   }	| EXEC NUM NUM NUM 	   {	        if ($2 > NTasks) { 		  yyerror("Task Not declared");		}		Chronog[NPoints].accion = EXEC;		Chronog[NPoints].id = $2;		Chronog[NPoints].x1 = $3;		Chronog[NPoints].x2 = $4;		cal_tsim($3,$4);		NPoints++;	}	;header : header line_head {}	|  {}	;line_head: TASK NUM IDEN		{		  if ($2>=MAX_TASKS){			printf ("\nToo many tasks, graphic tool overflow.\n");			printf ("Maximun number of tasks %d",MAX_TASKS);			exit(1);		  }		  if ($2>NTasks){		    NTasks = $2;		  }		  strncpy((char*)&Tasks[$2],$3,20);		}	| RESOURCE NUM IDEN 		{		   if ($2>=MAX_RESOURCES){			printf ("\nToo many resources, graphic tool overflow.\n");			printf ("Maximun number of resources %d",MAX_RESOURCES);			exit(1);		   }		   if ($2>NResources){		     NResources = $2;		   }		   strncpy((char*)&Resources[$2],$3,20);		}	| {}	;%%static void cal_tsim(a,b){  if (a<b)    a=b;    if (a>TimeSim)    TimeSim=a;}yyerror(s)   char *s;{  printf("\nERROR Line %d -->  %s\n",linenumber, s);  exit();}void   Fill_Matrix(char *name){  int  x;  if (strlen(name) != 0){    yyin = fopen (name, "r");  }      for (x=0; x<MAX_RESOURCES; x++)    Resources[x][0]=0x0;  for (x=0; x<MAX_TASKS; x++)    Tasks[x][0]=0x0;  NPoints=TimeSim=NTasks=NResources= 0;  yyparse();    if (strlen(name) != 0){    fclose(yyin);  }}

⌨️ 快捷键说明

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