All Downloads are FREE. Search and download functionalities are using the official Maven repository.

templates.lexer.flex.template Maven / Gradle / Ivy

The newest version!
package $packageName;

import com.intellij.lexer.FlexLexer;
import com.intellij.psi.tree.IElementType;

import static com.intellij.psi.TokenType.BAD_CHARACTER;
import static 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