Custom Language Support - newbie issue...

已回答

I have a simple grammar mimicking from http://www.jetbrains.org/intellij/sdk/docs/tutorials/custom_language_support/grammar_and_parser.html 

The grammar file is

{
parserClass = "com.home.parser.RulesParser"

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

psiClassPrefix = "Rule"
psiImplClassSuffix = "Impl"
psiPackage = "com.home.plugin.psi"
psiImplPackage = "com.home.plugin.psi.impl"

elementTypeHolderClass = "com.home.plugin.psi.RulesTypes"
elementTypeClass = "com.home.plugin.RuleElementType"
tokenTypeClass = "com.home.plugin.RuleTokenType"

psiImplUtilClass = "com.home.plugin.psi.impl.RulePsiImplUtil"

tokens = [
INCLUDE_FILE = '*include-file*'
space = 'regexp:\s+'
comment = 'regexp:[#|//].*'
string = "regexp:\"[^\"]*\"|'[^']*'"

]
}

ruleFile ::= spacing sections

sections ::= [ spacing include-section spacing ]

include-section ::= (INCLUDE_FILE space+ string)*

spacing ::= (space | comment)*

when i generate parser code, the RuleTypes java generated has compile error:

Error:(19, 16) java: variable INCLUDE_SECTION is already defined in interface com.home.plugin.psi.RulesTypes

This is my first attempt to work on plugins. I tried searching for info regarding this subject and have been unsuccessful. Any help appreciated.

 

 

0

It is a bug in generator regarding dash-separated rule names (I always use underscore-separated..)

It's fixed now in the latest dev build, so you may grab it from the project github page:

https://github.com/JetBrains/Grammar-Kit  (click the "[Dev]" link or go to the TeamCity page)

.. or just change the name to include_section

0

Thanks Gregory for your help. I am inching along.

0

请先登录再写评论。