
templates.fleet.lexer.flex.template Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of grammar-kit Show documentation
Show all versions of grammar-kit Show documentation
Grammar-Kit library dedicated for language plugin developers.
The newest version!
package $packageName;
import fleet.com.intellij.lexer.FlexLexer;
import fleet.com.intellij.psi.tree.IElementType;
import static fleet.com.intellij.psi.TokenType.BAD_CHARACTER;
import static fleet.com.intellij.psi.TokenType.WHITE_SPACE;
import static $typesClass.*;
%%
%{
public $lexerClass() {
this((java.io.Reader)null);
}
%}
%public
%class $lexerClass
%implements FlexLexer
%function advance
%type IElementType
%unicode
EOL=\R
WHITE_SPACE=\s+
#foreach( $token in $regexpTokens.keySet() )
$token=$regexpTokens.get($token)
#end
#macro(spaces $len) #set( $count = $maxTokenLength - $len ) $StringUtil.repeat(" ", $count) #end
%%
{
{WHITE_SPACE} #spaces(11) { return WHITE_SPACE; }
#foreach( $token in $simpleTokens.keySet() )
"$simpleTokens.get($token)" #spaces($simpleTokens.get($token).length()) { return ${tokenPrefix}$token; }
#end
#foreach( $token in $regexpTokens.keySet() )
{$token} #spaces($token.length()) { return ${tokenPrefix}$token; }
#end
}
[^] { return BAD_CHARACTER; }
© 2015 - 2025 Weber Informatics LLC | Privacy Policy