📄 yylex
字号:
// LLAnalyze -- Nathaniel Nystrom, February 2000// For use in Cornell University Computer Science 412/413// Lexical specification for grammar files.package Iota.util.grammar;import java.lang.System;%%%{ public int yyline() { return yyline; }%} %line%char%state COMMENTALPHA=[A-Za-z]DIGIT=[0-9]WHITE_SPACE_CHAR=[\r\n\ \t\b\012]COMMENT_TEXT=([^*]|"*"+[^/])*%% <YYINITIAL> ":" { return (new Yytoken(Yytoken.COLON,yyline,yytext())); }<YYINITIAL> ";" { return (new Yytoken(Yytoken.SEMI,yyline,yytext())); }<YYINITIAL> "(" { return (new Yytoken(Yytoken.LPAREN,yyline,yytext())); }<YYINITIAL> ")" { return (new Yytoken(Yytoken.RPAREN,yyline,yytext())); }<YYINITIAL> "[" { return (new Yytoken(Yytoken.LBRACKET,yyline,yytext())); }<YYINITIAL> "]" { return (new Yytoken(Yytoken.RBRACKET,yyline,yytext())); }<YYINITIAL> "|" { return (new Yytoken(Yytoken.OR,yyline,yytext())); }<YYINITIAL> "*" { return (new Yytoken(Yytoken.STAR,yyline,yytext())); }<YYINITIAL> "+" { return (new Yytoken(Yytoken.PLUS,yyline,yytext())); }<YYINITIAL> "%%" { return (new Yytoken(Yytoken.SEPSEP,yyline,yytext())); }<YYINITIAL> "%token" { return (new Yytoken(Yytoken.SEPTOKEN,yyline,yytext())); }<YYINITIAL> "%start" { return (new Yytoken(Yytoken.SEPSTART,yyline,yytext())); }<YYINITIAL> {WHITE_SPACE_CHAR}+ { }<YYINITIAL> "/*" { yybegin(COMMENT); }<COMMENT> "*/" { yybegin(YYINITIAL);}<COMMENT> {COMMENT_TEXT} { }<YYINITIAL> {ALPHA}({ALPHA}|{DIGIT}|_)* { return (new Yytoken(Yytoken.ID,yyline,yytext()));} <YYINITIAL,COMMENT> . { throw new RuntimeException(yyline + ": Illegal character: <" + yytext() + ">");}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -