iotestcaselexer.flex

来自「Python Development Environment (Python I」· FLEX 代码 · 共 108 行

FLEX
108
字号
package org.python.pydev.refactoring.tests.core;

import java.io.IOException;

%%
%class IOTestCaseLexer
%standalone
%line

%init{
	sourceLines = new StringBuffer();
	resultLines = new StringBuffer();
	configLines = new StringBuffer();
%init}

%{
	StringBuffer sourceLines;
	StringBuffer resultLines;
	StringBuffer configLines;
	
	public String getSource()
	{
		return sourceLines.toString().trim();
	}
	
	public String getResult()
	{
		return resultLines.toString().trim();
	}
	
	public String getConfig()
	{
		return configLines.toString().trim();
	}
	
	public void scan() throws IOException
	{
		while ( !this.zzAtEOF ) 
			this.yylex();
	}

%}

Source = "##s" {InputCharacter}* {newline}
Config = "##c" {InputCharacter}* {newline}
Result = "##r" {InputCharacter}* {newline}
TripleQuote = '''

InputCharacter = [^\r\n]
newline = \r\n|\n|\r

line = {InputCharacter}*

%xstate RESULT
%xstate CONFIG

%%
<YYINITIAL> {

{Source} { }

{Result} {
	yybegin(RESULT);
}

{Config} {
	yybegin(CONFIG);
}

{line} { sourceLines.append(yytext()); }

{newline} { sourceLines.append("\n"); }

}

<CONFIG> {

{TripleQuote} {} 

{Source} {
	yybegin(YYINITIAL);
}

{Result} {
	yybegin(RESULT);
}

{line} { configLines.append(yytext()); }

{newline} { configLines.append("\n"); }
 
}

<RESULT> {

{Source} {
	yybegin(YYINITIAL);
}

{Config} {
	yybegin(CONFIG);
}

{line} { resultLines.append(yytext()); }

{newline} { resultLines.append("\n"); }
 
}

⌨️ 快捷键说明

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