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

📄 table.h

📁 pascal编译器
💻 H
📖 第 1 页 / 共 2 页
字号:
		if ((isdigit(currentchar)) && (nextchar == ']'))
		{
			result = rw_digits;
			if (nodenum == 0)
				result = num;
			return (result);
		}
		if ((isdigit(currentchar)) && (isdigit(nextchar)))
		{
			result = -1;
			return (result);
		}
	}
	if (wlength == 1) 
	{
		if ((sword[0] == '<') && (sword[1] == '='))
		{
			result = op_le;
			return (result);
        }			//<=
		if ((sword[0] == '>') && (sword[1] == '='))
		{
			result = op_ge;
			return (result);
        }			//>=
		if ((sword[0] == '<') && (sword[1] == '>'))
		{
			result = op_nequ;
			return (result);
        }			//<>
		if ((sword[0] == ':') && (sword[1] == '='))
		{
			result = assignop;
			return (result);
        }			// :=
		if ((sword[0] == 'd') && (sword[1] == 'o') && !(isalnum(nextchar)))
		{
			result = rw_do;
			return (result);
        }			//do
		if ((sword[0] == 'i') && (sword[1] == 'f') && !(isalnum(nextchar)))
		{
			result = rw_if;
			return (result);
        }			//if
		if ((sword[0] == 'o') && (sword[1] == 'f') && !(isalnum(nextchar)))
		{
			result = rw_of;
			return (result);
        }			//of
		if ((sword[0] == 'o') && (sword[1] == 'r') && !(isalnum(nextchar)))
		{
			result = rw_or;
			return (result);
        }			// or
	}//end_wlength == 1
	if (wlength == 2) 
	{
		if ((sword[0] == 'a') && (sword[1] == 'n') && (sword[2] == 'd') && !(isalnum(nextchar)))
		{
			result = rw_and;
			return (result);
        }			//and
		if ((sword[0] == 'e') && (sword[1] == 'n') && (sword[2] == 'd') && !(isalnum(nextchar)))
		{
			if ((func_var == 1) && (func_id == 1))
			{
				func_match--;
			}
			if (func_match == 0)
			{
				func_var = 0;
				func_id = 0;
			}

			result = rw_end;
			return (result);
        }			//end
		if ((sword[0] == 'n') && (sword[1] == 'o') && (sword[2] == 't') && !(isalnum(nextchar)))
		{
			result = rw_not;
			return (result);
        }			//not
		if ((sword[0] == 'v') && (sword[1] == 'a') && (sword[2] == 'r') && !(isalnum(nextchar)))
		{
			result = rw_var;
			return (result);
        }			//var
		if ((sword[0] == 'd') && (sword[1] == 'i') && (sword[2] == 'v') && !(isalnum(nextchar)))
		{
			result = rw_divv;
			return (result);
        }			//var
		if ((sword[0] == 'm') && (sword[1] == 'o') && (sword[2] == 'd') && !(isalnum(nextchar)))
		{
			result = rw_mod;
			return (result);
        }			//var
	}//end_wlength == 2
	if (wlength == 3)
	{
		if ((sword[0] == 'e') && (sword[1] == 'l') && (sword[2] == 's') && 
			(sword[3] == 'e') && !(isalnum(nextchar))) 
		{
			result = rw_else;
			return (result);
        }			//else
		if ((sword[0] == 'r') && (sword[1] == 'e') && (sword[2] == 'a') && 
			(sword[3] == 'd') && !(isalnum(nextchar)))
		{
			result = rw_read;
			return (result);
        }			//read
		if ((sword[0] == 'r') && (sword[1] == 'e') && (sword[2] == 'a') && 
			(sword[3] == 'l') && !(isalnum(nextchar)))
		{
			result = rw_real;
			return (result);
        }			//real
		if ((sword[0] == 't') && (sword[1] == 'h') && (sword[2] == 'e') && 
			(sword[3] == 'n') && !(isalnum(nextchar))) 
		{
			result = rw_then;
			return (result);
        }			//then
		if ((sword[0] == 't') && (sword[1] == 'r') && (sword[2] == 'u') && 
			(sword[3] == 'e') && !(isalnum(nextchar)))
		{
			result = rw_true;
			return (result);
        }			//true
	}//end_wlength == 3
	if (wlength == 4)
	{
		if ((sword[0] == 'a') && (sword[1] == 'r') && (sword[2] == 'r') && 
			(sword[3] == 'a') && (sword[4] == 'y') &&!(isalnum(nextchar)))
		{
			result = rw_array;
			return (result);
        }			//array
		if ((sword[0] == 'b') && (sword[1] == 'e') && (sword[2] == 'g') && 
			(sword[3] == 'i') && (sword[4] == 'n') &&!(isalnum(nextchar))) 
		{
			if ((func_id == 1) && (func_var == 1))
			{
				func_match++;
			}
			result = rw_begin;
			return (result);
        }			//begin
		if ((sword[0] == 'f') && (sword[1] == 'a') && (sword[2] == 'l') && 
			(sword[3] == 's') && (sword[4] == 'e') &&!(isalnum(nextchar))) 
		{
			result = rw_false;
			return (result);
        }			//	false
		if ((sword[0] == 'w') && (sword[1] == 'h') && (sword[2] == 'i') && 
			(sword[3] == 'l') && (sword[4] == 'e') &&!(isalnum(nextchar))) 
		{
			result = rw_while;
			return (result);
        }			// while
		if ((sword[0] == 'w') && (sword[1] == 'r') && (sword[2] == 'i') && 
			(sword[3] == 't') && (sword[4] == 'e') &&!(isalnum(nextchar))) 
		{
			result = rw_write;
			return (result);
        }			//write
		if ((sword[0] == 'i') && (sword[1] == 'n') && (sword[2] == 'p') && 
			(sword[3] == 'u') && (sword[4] == 't') &&!(isalnum(nextchar))) 
		{
			result = id;
			return (result);
        }			//input
	}//end_wlenght == 4
	if (wlength == 5){
	if ((sword[0] == 'r') && (sword[1] == 'e') && (sword[2] == 'c') && 
		(sword[3] == 'o') && (sword[4] == 'r') && (sword[5] == 'd') && 
		!(isalnum(nextchar)))  
	{
		result = rw_record;
		return (result);
    }				//record
    if ((sword[0] == 'o') && (sword[1] == 'u') && (sword[2] == 't') && 
		(sword[3] == 'p') && (sword[4] == 'u') && (sword[5] == 't') && 
		!(isalnum(nextchar)))  
	{
		result = id;
		return (result);
    }				//output
	}
	if (wlength == 6)
	{
		if ((sword[0] == 'b') && (sword[1] == 'o') && (sword[2] == 'o') && 
			(sword[3] == 'l') && (sword[4] == 'e') && (sword[5] == 'a') &&
			(sword[6] == 'n') && !(isalnum(nextchar)))
		{
			result = rw_boolean;
			return (result);
        }			// boolean
		if ((sword[0] == 'i') && (sword[1] == 'n') && (sword[2] == 't') && 
			(sword[3] == 'e') && (sword[4] == 'g') && (sword[5] == 'e') &&
			(sword[6] == 'r') && !(isalnum(nextchar))) 
		{
			result = rw_integer;
			return (result);
        }			//integer
		if ((sword[0] == 'p') && (sword[1] == 'r') && (sword[2] == 'o') && 
			(sword[3] == 'g') && (sword[4] == 'r') && (sword[5] == 'a') &&
			(sword[6] == 'm') && !(isalnum(nextchar))) 
		{
			result = rw_program;
			return (result);
        }			// program
	}//end_wlength == 6
	if ((sword[0] == 'f') && (sword[1] == 'u') && (sword[2] == 'n') && 
		(sword[3] == 'c') && (sword[4] == 't') && (sword[5] == 'i') &&
		(sword[6] == 'o') && (sword[7] == 'n') && !(isalnum(nextchar))) 
	{
		func_id = 1;
		result = rw_function;
		return (result);
    }			//funtion
	if ((sword[0] == 'p') && (sword[1] == 'r') && (sword[2] == 'o') && 
		(sword[3] == 'c') && (sword[4] == 'e') && (sword[5] == 'd') &&
		(sword[6] == 'u') && (sword[7] == 'r') && (sword[8] == 'e') &&
		!(isalnum(nextchar)))
	{
		func_id = 1;
		result = rw_procedure;
		return (result);
    }			//procedure
	if ((isalpha(sword[0])) && !(isalnum(nextchar)))
	{
		result = id;
		return (result);
	}		//id
	if ((currentchar == '.') && (sword[wlength - 3] == 'e') && 
		(sword[wlength - 2] == 'n') && (sword[wlength - 1] == 'd'))
	{
		result = rw_end;
		return (result);
	}	//end

	if ((currentchar == '.') && (isdigit(nextchar)) && (isdigit(sword[wlength - 2])))
	{
		result = -1;
		return (result);
	}		//x.x
	if (isdigit(sword[0]))
	{	flag = 1;
		i = 0;
		while (sword[i] != '#')
		{
			if (!(isdigit(sword[i])) && (sword[i] != '.'))
			{
			flag = 0;
			break;
			}
			i++;
		}
		if ((flag == 1) && !(isalnum(nextchar)) && !(nextchar == '.'))
		{
			result = num;
			return (result);
		}
		if ((flag == 1) && (isdigit(nextchar) || (nextchar == '.')))
		{
			result = -1;
			return (result);
		}
			result = -2;
			return (result);
	}		//num
	if ((isalnum(nextchar)) && (isalpha(sword[0])))
	{
		result = -1;
		return (result);
	}
	if (currentchar == '.')
	{
		result = node;
		return (result);
	}
	return (result);
}

void displayl (L_ListNodePtr sPtr)    //显示标记流
{
   L_ListNodePtr previousPtr, currentPtr;
   previousPtr = NULL;
   currentPtr = sPtr;
      while ( currentPtr != NULL ) { 
		 printf("%d",currentPtr->label_type);
		 printf("%c",'>');
         previousPtr = currentPtr;          /* walk to ...   */
         currentPtr = currentPtr->next;  /* ... next node */
      }


}
void displays (S_ListNodePtr sPtr)    //显示符号表
{
   S_ListNodePtr previousPtr, currentPtr;
   previousPtr = NULL;
   currentPtr = sPtr;
      while ( currentPtr != NULL ) { 
		 printf("%d",currentPtr->Ln);
		 printf("%c",'>');
         previousPtr = currentPtr;          /* walk to ...   */
         currentPtr = currentPtr->next;  /* ... next node */
      }

}

#endif

⌨️ 快捷键说明

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