📄 lex.c
字号:
default: UngetChar(t); UngetChar('\\'); GenOp("+"); goto next; } case '+': GenOp("++"); goto next; case '=': GenOp("+="); goto next; default: UngetChar(t); GenOp("+"); goto next; } case '*': star_start: switch(t = GetChar()) { case '\\': switch(t = GetChar()) { case '\n': lineno++; lineno_offset++; goto star_start; default: UngetChar(t); UngetChar('\\'); GenOp("*"); goto next; } case '=': GenOp("*="); goto next; default: UngetChar(t); GenOp("*"); goto next; } case '%': mod_start: switch(t = GetChar()) { case '\\': switch(t = GetChar()) { case '\n': lineno++; lineno_offset++; goto mod_start; default: UngetChar(t); UngetChar('\\'); GenOp("%"); goto next; } case '=': GenOp("%="); goto next; default: UngetChar(t); GenOp("%"); goto next; } case '>': gt_start: switch (t = GetChar()) { case '\\': switch(t = GetChar()) { case '\n': lineno++; lineno_offset++; goto gt_start; default: UngetChar(t); UngetChar('\\'); GenOp(">"); goto next; } case '=': GenOp(">="); goto next; case '>': sr_start: switch (t = GetChar()) { case '\\': switch(t = GetChar()) { case '\n': lineno++; lineno_offset++; goto sr_start; default: UngetChar(t); UngetChar('\\'); GenOp(">>"); goto next; } case '=': GenOp(">>="); goto next; default: UngetChar (t); GenOp(">>"); goto next; } default: UngetChar (t); GenOp(">"); goto next; } case '<': lt_start: switch (t = GetChar()) { case '\\': switch(t = GetChar()) { case '\n': lineno++; lineno_offset++; goto lt_start; default: UngetChar(t); UngetChar('\\'); GenOp("<"); goto next; } case '=': GenOp("<="); goto next; case '<': sl_start: switch (t = GetChar()) { case '\\': switch(t = GetChar()) { case '\n': lineno++; lineno_offset++; goto sl_start; default: UngetChar(t); UngetChar('\\'); GenOp("<<"); goto next; } case '=': GenOp("<<="); goto next; default: UngetChar (t); GenOp("<<"); goto next; } default: UngetChar (t); GenOp("<"); goto next; } case '=': equals_start: switch(t = GetChar()) { case '\\': switch(t = GetChar()) { case '\n': lineno++; lineno_offset++; goto equals_start; default: UngetChar(t); UngetChar('\\'); GenOp("="); goto next; } case '=': GenOp("=="); goto next; default: UngetChar(t); GenOp("="); goto next; } case '!': bang_start: switch(t = GetChar()) { case '\\': switch(t = GetChar()) { case '\n': lineno++; lineno_offset++; goto bang_start; default: UngetChar(t); UngetChar('\\'); GenOp("!"); goto next; } case '=': GenOp("!="); goto next; default: UngetChar(t); GenOp("!"); goto next; } case '^': xor_start: switch(t = GetChar()) { case '\\': switch(t = GetChar()) { case '\n': lineno++; lineno_offset++; goto xor_start; default: UngetChar(t); UngetChar('\\'); GenOp("^"); goto next; } case '=': GenOp("^="); goto next; default: UngetChar(t); GenOp("^"); goto next; } case '|': or_start: switch(t = GetChar()) { case '\\': switch(t = GetChar()) { case '\n': lineno++; lineno_offset++; goto or_start; default: UngetChar(t); UngetChar('\\'); GenOp("|"); goto next; } case '=': GenOp("|="); goto next; case '|': GenOp("||"); goto next; default: UngetChar(t); GenOp("|"); goto next; } case '&': and_start: switch(t = GetChar()) { case '\\': switch(t = GetChar()) { case '\n': lineno++; lineno_offset++; goto and_start; default: UngetChar(t); UngetChar('\\'); GenOp("&"); goto next; } case '=': GenOp("&="); goto next; case '&': GenOp("&&"); goto next; default: UngetChar(t); GenOp("&"); goto next; } case '#': if(preproc) GenOp("#"); goto next; case '@': if(preproc) GenOp("@"); else goto errBadToken; goto next; case '`': if(preproc) GenOp("`"); else goto errBadToken; goto next; case '~': GenOp("~"); goto next; case '(': GenOp("("); goto next; case ')': GenOp(")"); goto next; case '{': GenOp("{"); goto next; case '}': GenOp("}"); goto next; case '[': GenOp("["); goto next; case ']': GenOp("]"); goto next; case ',': GenOp(","); goto next; case ':': GenOp(":"); goto next; case '?': GenOp("?"); goto next; case '"': stringpart: switch(t = GetChar()) { case EOF: goto eofError; case '\\': switch(t = GetChar()) { case EOF: goto eofError; case '\n': lineno++; lineno_offset++; goto stringpart; default: AddCharToStr('\\'); AddCharToStr(t); goto stringpart; } case '"': EndStr(); goto next; default: AddCharToStr(t); goto stringpart; } case '\'': char_const: switch(t = GetChar()) { case '\\': switch(t = GetChar()) { case '\n': lineno++; lineno_offset++; goto char_const; case '\\': case '\'': if(GetChar() != '\'') { goto errBadToken; } GenChr(t); goto next; case 'x': case 'X': reading_hex_char: switch(t = GetChar()) { case '\\': switch(t = GetChar()) { case '\n': lineno_offset++; lineno++; goto reading_hex_char; default: goto errBadToken; } case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case 'a': case 'A': case 'b': case 'B': case 'c': case 'C': case 'd': case 'D': case 'e': case 'E': case 'f': case 'F': StartHexChr(t); hex: switch(t = GetChar()) { case '\\': switch(t = GetChar()) { case '\n': lineno_offset++; lineno++; goto hex; default: goto errBadToken; } case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case 'a': case 'A': case 'b': case 'B': case 'c': case 'C': case 'd': case 'D': case 'e': case 'E': case 'f': case 'F': AddHexChr(t); goto hex; default: if(t != '\'') { goto errBadToken; } EndHexChr(); goto next; } default: goto errBadToken; } case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': StartOctChr(t); start_octal_char: switch (t = GetChar()) { case '\\': switch(t = GetChar()) { case '\n': lineno++; lineno_offset++; goto start_octal_char; default: goto errBadToken; } case '\'': EndOctChr(); goto next; case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': AddOctChr(t); grab_octal_char: switch (t = GetChar()) { case '\\': switch(t = GetChar()) { case '\n': lineno++; lineno_offset++; goto grab_octal_char; default: goto errBadToken; } case '\'': EndOctChr(); goto next; case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': finish_octal: switch(GetChar()) { case '\'': AddOctChr(t); EndOctChr(); goto next; case '\\': switch(GetChar()) { case '\n': lineno++; lineno_offset++; goto finish_octal; default: goto errBadToken; } default: goto errBadToken; } } default: goto errBadToken; } case 'n': finish_newline: switch(GetChar()) { case '\\': switch(GetChar()) { case '\n': lineno++; lineno_offset++; goto finish_newline; default: goto errBadToken; } case '\'': GenChr('\n'); goto next; default: goto errBadToken; } case 't': finish_tab: switch(GetChar()) { case '\\': switch(GetChar()) { case '\n': lineno++; lineno_offset++; goto finish_tab; default: goto errBadToken; } case '\'': GenChr('\t'); goto next; default: goto errBadToken; } case 'v': finish_vtab: switch(GetChar()) { case '\\': switch(GetChar()) { case '\n': lineno++; lineno_offset++; goto finish_vtab; default: goto errBadToken; } case '\'': GenChr('\v'); goto next; default: goto errBadToken; } case 'b': finish_backspace: switch(GetChar()) { case '\\': switch(GetChar()) { case '\n': lineno++; lineno_offset++; goto finish_backspace; default: goto errBadToken; } case '\'': GenChr('\b'); goto next; default: goto errBadToken; } case 'r': finish_cr: switch(GetChar()) { case '\\': switch(GetChar()) { case '\n': lineno++; lineno_offset++; goto finish_cr; default: goto errBadToken; } case '\'': GenChr('\r'); goto next; default: goto errBadToken; } case 'f': finish_formfeed: switch(GetChar()) { case '\\': switch(GetChar()) { case '\n': lineno++; lineno_offset++; goto finish_formfeed; default: goto errBadToken; } case '\'': GenChr('\f'); goto next; default: goto errBadToken; } case 'a': finish_alarm: switch(GetChar()) { case '\\': switch(GetChar()) { case '\n': lineno++; lineno_offset++; goto finish_alarm; default: goto errBadToken; } case '\'': GenChr('\a'); goto next; default: goto errBadToken; } case '?': finish_qmark: switch(GetChar()) { case '\\': switch(GetChar()) { case '\n': lineno++; lineno_offset++; goto finish_qmark; default: goto errBadToken; } case '\'': GenChr('\?'); goto next; default: goto errBadToken; } case '"': finish_quote: switch(GetChar()) { case '\\': switch(GetChar()) { case '\n': lineno++; lineno_offset++; goto finish_quote; default: goto errBadToken; } case '\'': GenChr('\"'); goto next; default: goto errBadToken; } default: goto errBadToken; } case '\'': // TODO: Is the right? GenChr(0); goto next; default: finish_regular: switch(GetChar()) { case '\\': switch(GetChar()) { case '\n': lineno++; lineno_offset++; goto finish_regular; default: goto errBadToken; } case '\'': GenChr(t); goto next; default: goto errBadToken; } } case 'l': case 'L': start_long: switch(t2 = GetChar()) { case '\\': switch(GetChar()) { case '\n': lineno++; lineno_offset++; goto start_long; default: goto errBadToken; } case '"': goto stringpart; case '\'': goto char_const; default: UngetChar(t2); } case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v':
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -