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

📄 lex.c

📁 gcc-2.95.3 Linux下最常用的C编译器
💻 C
📖 第 1 页 / 共 3 页
字号:
    case '(':      JAVA_LEX_SEP (c);      BUILD_OPERATOR (OP_TK);    case ')':      JAVA_LEX_SEP (c);      return CP_TK;    case '{':      JAVA_LEX_SEP (c);      if (ctxp->ccb_indent == 1)	ctxp->first_ccb_indent1 = lineno;      ctxp->ccb_indent++;      BUILD_OPERATOR (OCB_TK);    case '}':      JAVA_LEX_SEP (c);      ctxp->ccb_indent--;      if (ctxp->ccb_indent == 1)        ctxp->last_ccb_indent1 = lineno;      BUILD_OPERATOR (CCB_TK);    case '[':      JAVA_LEX_SEP (c);      BUILD_OPERATOR (OSB_TK);    case ']':      JAVA_LEX_SEP (c);      return CSB_TK;    case ';':      JAVA_LEX_SEP (c);      return SC_TK;    case ',':      JAVA_LEX_SEP (c);      return C_TK;    case '.':      JAVA_LEX_SEP (c);      BUILD_OPERATOR (DOT_TK);      /*      return DOT_TK; */    }  /* Operators */  switch (c)    {    case '=':      if ((c = java_get_unicode ()) == '=')	{	  BUILD_OPERATOR (EQ_TK);	}      else	{	  /* Equals is used in two different locations. In the 	     variable_declarator: rule, it has to be seen as '=' as opposed	     to being seen as an ordinary assignment operator in	     assignment_operators: rule.  */	  java_unget_unicode ();	  BUILD_OPERATOR (ASSIGN_TK);	}          case '>':      switch ((c = java_get_unicode ()))	{	case '=':	  BUILD_OPERATOR (GTE_TK);	case '>':	  switch ((c = java_get_unicode ()))	    {	    case '>':	      if ((c = java_get_unicode ()) == '=')		{		  BUILD_OPERATOR2 (ZRS_ASSIGN_TK);		}	      else		{		  java_unget_unicode ();		  BUILD_OPERATOR (ZRS_TK);		}	    case '=':	      BUILD_OPERATOR2 (SRS_ASSIGN_TK);	    default:	      java_unget_unicode ();	      BUILD_OPERATOR (SRS_TK);	    }	default:	  java_unget_unicode ();	  BUILD_OPERATOR (GT_TK);	}	    case '<':      switch ((c = java_get_unicode ()))	{	case '=':	  BUILD_OPERATOR (LTE_TK);	case '<':	  if ((c = java_get_unicode ()) == '=')	    {	      BUILD_OPERATOR2 (LS_ASSIGN_TK);	    }	  else	    {	      java_unget_unicode ();	      BUILD_OPERATOR (LS_TK);	    }	default:	  java_unget_unicode ();	  BUILD_OPERATOR (LT_TK);	}    case '&':      switch ((c = java_get_unicode ()))	{	case '&':	  BUILD_OPERATOR (BOOL_AND_TK);	case '=':	  BUILD_OPERATOR2 (AND_ASSIGN_TK);	default:	  java_unget_unicode ();	  BUILD_OPERATOR (AND_TK);	}    case '|':      switch ((c = java_get_unicode ()))	{	case '|':	  BUILD_OPERATOR (BOOL_OR_TK);	case '=':	  BUILD_OPERATOR2 (OR_ASSIGN_TK);	default:	  java_unget_unicode ();	  BUILD_OPERATOR (OR_TK);	}    case '+':      switch ((c = java_get_unicode ()))	{	case '+':	  BUILD_OPERATOR (INCR_TK);	case '=':	  BUILD_OPERATOR2 (PLUS_ASSIGN_TK);	default:	  java_unget_unicode ();	  BUILD_OPERATOR (PLUS_TK);	}    case '-':      switch ((c = java_get_unicode ()))	{	case '-':	  BUILD_OPERATOR (DECR_TK);	case '=':	  BUILD_OPERATOR2 (MINUS_ASSIGN_TK);	default:	  java_unget_unicode ();	  ctxp->minus_seen = 1;	  BUILD_OPERATOR (MINUS_TK);	}    case '*':      if ((c = java_get_unicode ()) == '=')	{	  BUILD_OPERATOR2 (MULT_ASSIGN_TK);	}      else	{	  java_unget_unicode ();	  BUILD_OPERATOR (MULT_TK);	}    case '/':      if ((c = java_get_unicode ()) == '=')	{	  BUILD_OPERATOR2 (DIV_ASSIGN_TK);	}      else	{	  java_unget_unicode ();	  BUILD_OPERATOR (DIV_TK);	}    case '^':      if ((c = java_get_unicode ()) == '=')	{	  BUILD_OPERATOR2 (XOR_ASSIGN_TK);	}      else	{	  java_unget_unicode ();	  BUILD_OPERATOR (XOR_TK);	}    case '%':      if ((c = java_get_unicode ()) == '=')	{	  BUILD_OPERATOR2 (REM_ASSIGN_TK);	}      else	{	  java_unget_unicode ();	  BUILD_OPERATOR (REM_TK);	}    case '!':      if ((c = java_get_unicode()) == '=')	{	  BUILD_OPERATOR (NEQ_TK);	}      else	{	  java_unget_unicode ();	  BUILD_OPERATOR (NEG_TK);	}	      case '?':      JAVA_LEX_OP ("?");      BUILD_OPERATOR (REL_QM_TK);    case ':':      JAVA_LEX_OP (":");      BUILD_OPERATOR (REL_CL_TK);    case '~':      BUILD_OPERATOR (NOT_TK);    }    /* Keyword, boolean literal or null literal */  for (first_unicode = c, all_ascii = 1, ascii_index = 0;        JAVA_ID_CHAR_P (c); c = java_get_unicode ())    {      java_unicode_2_utf8 (c);      if (all_ascii && c >= 128)        all_ascii = 0;      ascii_index++;    }  obstack_1grow (&temporary_obstack, '\0');  string = obstack_finish (&temporary_obstack);  java_unget_unicode ();  /* If we have something all ascii, we consider a keyword, a boolean     literal, a null literal or an all ASCII identifier.  Otherwise,     this is an identifier (possibly not respecting formation rule).  */  if (all_ascii)    {      struct java_keyword *kw;      if ((kw=java_keyword (string, ascii_index)))	{	  JAVA_LEX_KW (string);	  switch (kw->token)	    {	    case PUBLIC_TK:       case PROTECTED_TK: case STATIC_TK:	    case ABSTRACT_TK:     case FINAL_TK:     case NATIVE_TK:	    case SYNCHRONIZED_TK: case TRANSIENT_TK: case VOLATILE_TK:	    case PRIVATE_TK:	      SET_MODIFIER_CTX (kw->token);	      return MODIFIER_TK;	    case FLOAT_TK:	      SET_LVAL_NODE (float_type_node);	      return FP_TK;	    case DOUBLE_TK:	      SET_LVAL_NODE (double_type_node);	      return FP_TK;	    case BOOLEAN_TK:	      SET_LVAL_NODE (boolean_type_node);	      return BOOLEAN_TK;	    case BYTE_TK:	      SET_LVAL_NODE (byte_type_node);	      return INTEGRAL_TK;	    case SHORT_TK:	      SET_LVAL_NODE (short_type_node);	      return INTEGRAL_TK;	    case INT_TK:	      SET_LVAL_NODE (int_type_node);	      return INTEGRAL_TK;	    case LONG_TK:	      SET_LVAL_NODE (long_type_node);	      return INTEGRAL_TK;	    case CHAR_TK:	      SET_LVAL_NODE (char_type_node);	      return INTEGRAL_TK;	      /* Keyword based literals */	    case TRUE_TK:	    case FALSE_TK:	      SET_LVAL_NODE ((kw->token == TRUE_TK ? 			      boolean_true_node : boolean_false_node));	      return BOOL_LIT_TK;	    case NULL_TK:	      SET_LVAL_NODE (null_pointer_node);	      return NULL_TK;	      /* Some keyword we want to retain information on the location		 they where found */	    case CASE_TK:	    case DEFAULT_TK:	    case SUPER_TK:	    case THIS_TK:	    case RETURN_TK:	    case BREAK_TK:	    case CONTINUE_TK:	    case TRY_TK:	    case CATCH_TK:	    case THROW_TK:	    case INSTANCEOF_TK:	      BUILD_OPERATOR (kw->token);	    default:	      return kw->token;	    }	}    }    /* We may have and ID here */  if (JAVA_ID_CHAR_P(first_unicode) && !JAVA_DIGIT_P (first_unicode))    {      JAVA_LEX_ID (string);      java_lval->node = BUILD_ID_WFL (GET_IDENTIFIER (string));      return ID_TK;    }  /* Everything else is an invalid character in the input */  {    char lex_error_buffer [128];    sprintf (lex_error_buffer, "Invalid character '%s' in input", 	     java_sprint_unicode (ctxp->c_line, ctxp->c_line->current));    java_lex_error (lex_error_buffer, 1);  }  return 0;}static voidjava_unicode_2_utf8 (unicode)    unicode_t unicode;{  if (RANGE (unicode, 0x01, 0x7f))    obstack_1grow (&temporary_obstack, (char)unicode);  else if (RANGE (unicode, 0x80, 0x7ff) || unicode == 0)    {      obstack_1grow (&temporary_obstack,		     (unsigned char)(0xc0 | ((0x7c0 & unicode) >> 6)));      obstack_1grow (&temporary_obstack,		     (unsigned char)(0x80 | (unicode & 0x3f)));    }  else				/* Range 0x800-0xffff */    {      obstack_1grow (&temporary_obstack,		     (unsigned char)(0xe0 | (unicode & 0xf000) >> 12));      obstack_1grow (&temporary_obstack,		     (unsigned char)(0x80 | (unicode & 0x0fc0) >> 6));      obstack_1grow (&temporary_obstack,		     (unsigned char)(0x80 | (unicode & 0x003f)));    }}#ifndef JC1_LITEstatic treebuild_wfl_node (node)     tree node;{  return build_expr_wfl (node, ctxp->filename, ctxp->elc.line, ctxp->elc.col);}#endifstatic voidjava_lex_error (msg, forward)     char *msg ATTRIBUTE_UNUSED;     int forward ATTRIBUTE_UNUSED;{#ifndef JC1_LITE  ctxp->elc.line = ctxp->c_line->lineno;  ctxp->elc.col = ctxp->c_line->char_col-1+forward;  /* Might be caught in the middle of some error report */  ctxp->java_error_flag = 0;  java_error (NULL);  java_error (msg);#endif}#ifndef JC1_LITEstatic intjava_is_eol (fp, c)  FILE *fp;  int c;{  int next;  switch (c)    {    case '\r':      next = getc (fp);      if (next != '\n' && next != EOF)	ungetc (next, fp);      return 1;    case '\n':      return 1;    default:      return 0;    }  }#endifchar *java_get_line_col (filename, line, col)     char *filename ATTRIBUTE_UNUSED;     int line ATTRIBUTE_UNUSED, col ATTRIBUTE_UNUSED;{#ifdef JC1_LITE  return 0;#else  /* Dumb implementation. Doesn't try to cache or optimize things. */  /* First line of the file is line 1, first column is 1 */  /* COL == -1 means, at the CR/LF in LINE */  /* COL == -2 means, at the first non space char in LINE */  FILE *fp;  int c, ccol, cline = 1;  int current_line_col = 0;  int first_non_space = 0;  char *base;  if (!(fp = fopen (filename, "r")))    fatal ("Can't open file - java_display_line_col");  while (cline != line)    {      c = getc (fp);      if (c < 0)	{	  static char msg[] = "<<file too short - unexpected EOF>>";	  obstack_grow (&temporary_obstack, msg, sizeof(msg)-1);	  goto have_line;	}      if (java_is_eol (fp, c))	cline++;    }  /* Gather the chars of the current line in a buffer */  for (;;)    {      c = getc (fp);      if (c < 0 || java_is_eol (fp, c))	break;      if (!first_non_space && !JAVA_WHITE_SPACE_P (c))	first_non_space = current_line_col;      obstack_1grow (&temporary_obstack, c);      current_line_col++;    } have_line:  obstack_1grow (&temporary_obstack, '\n');  if (col == -1)    {      col = current_line_col;      first_non_space = 0;    }  else if (col == -2)    col = first_non_space;  else    first_non_space = 0;  /* Place the '^' a the right position */  base = obstack_base (&temporary_obstack);  for (ccol = 1; ccol <= col; ccol++)    {      /* Compute \t when reaching first_non_space */      char c = (first_non_space ?		(base [ccol-1] == '\t' ? '\t' : ' ') : ' ');      obstack_1grow (&temporary_obstack, c);    }  obstack_grow0 (&temporary_obstack, "^", 1);  fclose (fp);  return obstack_finish (&temporary_obstack);#endif}

⌨️ 快捷键说明

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