Custom Language rule works fine when viewed in PsiViewer but show BAD_CHARACTER
I'm new to Plugin Development. I have a requirement to turn a json like properties file (Plist) into a custom language. I had the following written in my language definition (bnf) file.
root ::= '{' meta_property [property+] '}'
meta_property ::= 'PARENT' '=' '{' context_property '}'';'
context_property ::= 'CHILD' '=' object
object ::= '{' (property)* '}' ';'
property ::= property_name '=' value ';'
property_name ::= literal
literal ::= SINGLE_QUOTED_STRING|DOUBLE_
reference_expression ::= IDENTIFIER
value ::= object| literal | reference_expression
Tried to borrow the bnf created for json in the Intellij-ide source code (json.bnf)
Everything looks fine but when I observe the output in the PsiViewer, I see the mention of a BAD_CHARACTER for the '=' sign. I'm not sure what is marking it as BAD_CHARACTER. Could someone help me with what is going on ?
请先登录再写评论。
Please always link to full sources. This seems to be a problem with lexer.
Hi Yann,
Sorry. Here are the details.
fofik.bnf:
{
parserClass = "com.fofik.parser.FofikParser"
psiPackage = "com.fofik.psi"
psiImplPackage = "com.fofik.psi.impl"
elementTypeHolderClass = "com.fofik.psi.FofikTypes"
elementTypeClass = "com.fofik.psi.FofikElementType"
psiClassPrefix = "Fofik"
psiVisitorName = "FofikElementVisitor"
tokenTypeClass = "com.fofik.psi.FofikTokenType"
psiImplUtilClass = "com.fofik.psi.impl.FofikPsiImplUtil"
extends("literal|reference_expression")=value
tokens = [
L_CURLY='{'
R_CURLY='}'
L_PAREN = '('
R_PAREN=')'
SEMICOLON = ';'
DOT = '.'
PLUS = '+'
COMMA = ','
ASSIGN = 'regexp:[:=]'
NUMBER="regexp:((0|[1-9][0-9]*)(\.[0-9]+)?([eE][+-]?[0-9]*)?)|Infinity|-Infinity|NaN"
LINE_COMMENT='regexp://.*"/*" ([^*]|\*+[^*/])* (\*+"/")?'
BLOCK_COMMENT='regexp:/\*([^*]|\*+[^*/])*(\*+/)?'
DOUBLE_QUOTED_STRING='regexp:"([^\\"\r\n]|\\[^\r\n])*"?'
SINGLE_QUOTED_STRING="regexp:'([^\\'\r\n]|\\[^\r\n])*'?"
IDENTIFIER="regexp:[[:jletterdigit:]~!()*\-./@\^<>=]+"
CRLF = "regexp:[\r\n]"
]
}
root ::= '{' property+ '}'
object ::= '{' (property)* '}'
property ::= property_name ('=' value ';') {
methods = [ getName getValue]
mixin = "com.fofik.psi.impl.FofikNamedElementImpl"
implements = "com.fofik.psi.FofikNamedElement"
pin(".*") = 1
}
private property_name ::= literal |reference_expression
literal ::= SINGLE_QUOTED_STRING|DOUBLE_QUOTED_STRING|IDENTIFIER
reference_expression ::= IDENTIFIER
value ::= object| literal | reference_expression
fofik.lex:
Unfortunately, I cannot upload my project outside of the company network. Please do let me know if there is any further detail required.Thanks again.
Sorry but it is impossible to diagnose this without having the full project sources.
Yann, I'm working on moving the pieces specific to plugin into another project.