Custom Language Support Plugin with Regex

Answered

Can someone please explain to me why the following code does not work? I have made various changes and can only get parts of the syntax I'm trying to create to not show an error.

{
parserClass="com.exopacket.aloft.language.AloftParser"

extends="com.intellij.extapi.psi.ASTWrapperPsiElement"

psiClassPrefix="Aloft"
psiImplClassSuffix="Impl"
psiPackage="com.exopacket.aloft.psi"
psiImplPackage="com.exopacket.aloft.psi.impl"

elementTypeHolderClass="com.exopacket.aloft.psi.AloftTypes"
elementTypeClass="com.exopacket.aloft.psi.AloftElementType"
tokenTypeClass="com.exopacket.aloft.psi.AloftTokenType"

}

root_unit ::= SourceDeclarations? CommentBlockDeclarations? ClassTypeDeclarations?
SourceDeclarations ::= SourceDeclaration
SourceDeclaration ::= 'source' SourceFile ";"?
SourceFile ::= ("regexp:(([\"'])([a-zA-Z0-9._-])+([\"']))") | ("regexp:([a-zA-Z0-9\.\-_]+)")
CommentBlockDeclarations ::= CommentBlockDeclaration*
CommentBlockDeclaration ::= "regexp:(/\*(.|\n)*\*/)"
ClassTypeDeclarations ::= ClassTypeDeclaration*
ClassTypeDeclaration ::= "class" "regexp:([a-z][a-zA-Z0-9\.\-_]+)" "{"

upload 2022_09_21_eoKWfJwuDd6qebiKN649ao

1 comment
Comment actions Permalink

Hi Ryan,

Does it work in the running IDE development instance? The preview can report false errors when you have a custom lexer implementation that is different from the one generated for preview based on the BNF file.

See: https://github.com/JetBrains/Grammar-Kit/issues/44

If this is the case, then you should test your language parsing in the running IDE (runIde Gradle task), not in the preview editor.

0

Please sign in to leave a comment.