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

📄 scan-gram.l

📁 GNU的词法/语法分析器bison源码
💻 L
📖 第 1 页 / 共 3 页
字号:
  {splice}	 STRING_GROW;  <<EOF>>	 BEGIN context_state;}  /*------------------------------------------------.  | Scanning a Bison string, including its escapes. |  | The initial quote is already eaten.             |  `------------------------------------------------*/<SC_ESCAPED_STRING>{  "\"" {    STRING_FINISH;    loc->start = token_start;    val->chars = last_string;    rule_length++;    BEGIN INITIAL;    return STRING;  }  \n		unexpected_newline (token_start, "\"");	BEGIN INITIAL;  <<EOF>>	unexpected_eof (token_start, "\"");	BEGIN INITIAL;}  /*----------------------------------------------------------.  | Scanning a Bison character literal, decoding its escapes. |  | The initial quote is already eaten.			      |  `----------------------------------------------------------*/<SC_ESCAPED_CHARACTER>{  "'" {    unsigned char last_string_1;    STRING_GROW;    STRING_FINISH;    loc->start = token_start;    val->symbol = symbol_get (quotearg_style (escape_quoting_style,					      last_string),			      *loc);    symbol_class_set (val->symbol, token_sym, *loc);    last_string_1 = last_string[1];    symbol_user_token_number_set (val->symbol, last_string_1, *loc);    STRING_FREE;    rule_length++;    BEGIN INITIAL;    return ID;  }  \n		unexpected_newline (token_start, "'");	BEGIN INITIAL;  <<EOF>>	unexpected_eof (token_start, "'");	BEGIN INITIAL;}<SC_ESCAPED_CHARACTER,SC_ESCAPED_STRING>{  \0	    complain_at (*loc, _("invalid null character"));}  /*----------------------------.  | Decode escaped characters.  |  `----------------------------*/<SC_ESCAPED_STRING,SC_ESCAPED_CHARACTER>{  \\[0-7]{1,3} {    unsigned long int c = strtoul (yytext + 1, 0, 8);    if (UCHAR_MAX < c)      complain_at (*loc, _("invalid escape sequence: %s"), quote (yytext));    else if (! c)      complain_at (*loc, _("invalid null character: %s"), quote (yytext));    else      obstack_1grow (&obstack_for_string, c);  }  \\x[0-9abcdefABCDEF]+ {    unsigned long int c;    set_errno (0);    c = strtoul (yytext + 2, 0, 16);    if (UCHAR_MAX < c || get_errno ())      complain_at (*loc, _("invalid escape sequence: %s"), quote (yytext));    else if (! c)      complain_at (*loc, _("invalid null character: %s"), quote (yytext));    else      obstack_1grow (&obstack_for_string, c);  }  \\a	obstack_1grow (&obstack_for_string, '\a');  \\b	obstack_1grow (&obstack_for_string, '\b');  \\f	obstack_1grow (&obstack_for_string, '\f');  \\n	obstack_1grow (&obstack_for_string, '\n');  \\r	obstack_1grow (&obstack_for_string, '\r');  \\t	obstack_1grow (&obstack_for_string, '\t');  \\v	obstack_1grow (&obstack_for_string, '\v');  /* \\[\"\'?\\] would be shorter, but it confuses xgettext.  */  \\("\""|"'"|"?"|"\\")  obstack_1grow (&obstack_for_string, yytext[1]);  \\(u|U[0-9abcdefABCDEF]{4})[0-9abcdefABCDEF]{4} {    int c = convert_ucn_to_byte (yytext);    if (c < 0)      complain_at (*loc, _("invalid escape sequence: %s"), quote (yytext));    else if (! c)      complain_at (*loc, _("invalid null character: %s"), quote (yytext));    else      obstack_1grow (&obstack_for_string, c);  }  \\(.|\n)	{    complain_at (*loc, _("unrecognized escape sequence: %s"), quote (yytext));    STRING_GROW;  }}  /*--------------------------------------------.  | Scanning user-code characters and strings.  |  `--------------------------------------------*/<SC_CHARACTER,SC_STRING>{  {splice}|\\{splice}[^\n$@\[\]]	STRING_GROW;}<SC_CHARACTER>{  "'"		STRING_GROW; BEGIN context_state;  \n		unexpected_newline (token_start, "'"); BEGIN context_state;  <<EOF>>	unexpected_eof (token_start, "'"); BEGIN context_state;}<SC_STRING>{  "\""		STRING_GROW; BEGIN context_state;  \n		unexpected_newline (token_start, "\""); BEGIN context_state;  <<EOF>>	unexpected_eof (token_start, "\""); BEGIN context_state;}  /*---------------------------------------------------.  | Strings, comments etc. can be found in user code.  |  `---------------------------------------------------*/<SC_BRACED_CODE,SC_PROLOGUE,SC_EPILOGUE>{  "'" {    STRING_GROW;    context_state = YY_START;    token_start = loc->start;    BEGIN SC_CHARACTER;  }  "\"" {    STRING_GROW;    context_state = YY_START;    token_start = loc->start;    BEGIN SC_STRING;  }  "/"{splice}"*" {    STRING_GROW;    context_state = YY_START;    token_start = loc->start;    BEGIN SC_COMMENT;  }  "/"{splice}"/" {    STRING_GROW;    context_state = YY_START;    BEGIN SC_LINE_COMMENT;  }}  /*---------------------------------------------------------------.  | Scanning after %union etc., possibly followed by white space.  |  | For %union only, allow arbitrary C code to appear before the   |  | following brace, as an extension to POSIX.			   |  `---------------------------------------------------------------*/<SC_PRE_CODE>{  . {    bool valid = yytext[0] == '{' || token_type == PERCENT_UNION;    scanner_cursor.column -= mbsnwidth (yytext, yyleng, 0);    yyless (0);    if (valid)      {	braces_level = -1;	code_start = loc->start;	BEGIN SC_BRACED_CODE;      }    else      {	complain_at (*loc, _("missing `{' in %s"),		     token_name (token_type));	obstack_sgrow (&obstack_for_string, "{}");	STRING_FINISH;	val->chars = last_string;	BEGIN INITIAL;	return token_type;      }  }  <<EOF>>  unexpected_eof (scanner_cursor, "{}"); BEGIN INITIAL;}  /*---------------------------------------------------------------.  | Scanning some code in braces (%union and actions). The initial |  | "{" is already eaten.                                          |  `---------------------------------------------------------------*/<SC_BRACED_CODE>{  "{"|"<"{splice}"%"  STRING_GROW; braces_level++;  "%"{splice}">"      STRING_GROW; braces_level--;  "}" {    bool outer_brace = --braces_level < 0;    /* As an undocumented Bison extension, append `;' before the last       brace in braced code, so that the user code can omit trailing       `;'.  But do not append `;' if emulating Yacc, since Yacc does       not append one.       FIXME: Bison should warn if a semicolon seems to be necessary       here, and should omit the semicolon if it seems unnecessary       (e.g., after ';', '{', or '}', each followed by comments or       white space).  Such a warning shouldn't depend on --yacc; it       should depend on a new --pedantic option, which would cause       Bison to warn if it detects an extension to POSIX.  --pedantic       should also diagnose other Bison extensions like %yacc.       Perhaps there should also be a GCC-style --pedantic-errors       option, so that such warnings are diagnosed as errors.  */    if (outer_brace && token_type == BRACED_CODE && ! yacc_flag)      obstack_1grow (&obstack_for_string, ';');    obstack_1grow (&obstack_for_string, '}');    if (outer_brace)      {	STRING_FINISH;	rule_length++;	loc->start = code_start;	val->chars = last_string;	BEGIN INITIAL;	return token_type;      }  }  /* Tokenize `<<%' correctly (as `<<' `%') rather than incorrrectly     (as `<' `<%').  */  "<"{splice}"<"  STRING_GROW;  "$"("<"{tag}">")?(-?[0-9]+|"$")  handle_dollar (token_type, yytext, *loc);  "@"(-?[0-9]+|"$")		   handle_at (token_type, yytext, *loc);  <<EOF>>  unexpected_eof (code_start, "}"); BEGIN INITIAL;}  /*--------------------------------------------------------------.  | Scanning some prologue: from "%{" (already scanned) to "%}".  |  `--------------------------------------------------------------*/<SC_PROLOGUE>{  "%}" {    STRING_FINISH;    loc->start = code_start;    val->chars = last_string;    BEGIN INITIAL;    return PROLOGUE;  }  <<EOF>>  unexpected_eof (code_start, "%}"); BEGIN INITIAL;}  /*---------------------------------------------------------------.  | Scanning the epilogue (everything after the second "%%", which |  | has already been eaten).                                       |  `---------------------------------------------------------------*/<SC_EPILOGUE>{  <<EOF>> {    STRING_FINISH;    loc->start = code_start;    val->chars = last_string;    BEGIN INITIAL;    return EPILOGUE;  }}  /*-----------------------------------------.  | Escape M4 quoting characters in C code.  |  `-----------------------------------------*/<SC_COMMENT,SC_LINE_COMMENT,SC_STRING,SC_CHARACTER,SC_BRACED_CODE,SC_PROLOGUE,SC_EPILOGUE>{  \$	obstack_sgrow (&obstack_for_string, "$][");  \@	obstack_sgrow (&obstack_for_string, "@@");  \[	obstack_sgrow (&obstack_for_string, "@{");  \]	obstack_sgrow (&obstack_for_string, "@}");}  /*-----------------------------------------------------.  | By default, grow the string obstack with the input.  |  `-----------------------------------------------------*/<SC_COMMENT,SC_LINE_COMMENT,SC_BRACED_CODE,SC_PROLOGUE,SC_EPILOGUE,SC_STRING,SC_CHARACTER,SC_ESCAPED_STRING,SC_ESCAPED_CHARACTER>.	|<SC_COMMENT,SC_LINE_COMMENT,SC_BRACED_CODE,SC_PROLOGUE,SC_EPILOGUE>\n	STRING_GROW;%%/* Keeps track of the maximum number of semantic values to the left of   a handle (those referenced by $0, $-1, etc.) are required by the   semantic actions of this grammar. */int max_left_semantic_context = 0;/* Set *LOC and adjust scanner cursor to account for token TOKEN of   size SIZE.  */static voidadjust_location (location *loc, char const *token, size_t size){  int line = scanner_cursor.line;  int column = scanner_cursor.column;  char const *p0 = token;  char const *p = token;  char const *lim = token + size;  loc->start = scanner_cursor;  for (p = token; p < lim; p++)    switch (*p)      {      case '\n':	line++;	column = 1;	p0 = p + 1;	break;      case '\t':	column += mbsnwidth (p0, p - p0, 0);	column += 8 - ((column - 1) & 7);	p0 = p + 1;	break;      }  scanner_cursor.line = line;  scanner_cursor.column = column + mbsnwidth (p0, p - p0, 0);  loc->end = scanner_cursor;}/* Read bytes from FP into buffer BUF of size SIZE.  Return the   number of bytes read.  Remove '\r' from input, treating \r\n   and isolated \r as \n.  */static size_tno_cr_read (FILE *fp, char *buf, size_t size){  size_t bytes_read = fread (buf, 1, size, fp);  if (bytes_read)

⌨️ 快捷键说明

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