From 4b67c328cbc5c22658f6367bd9e1a15cf24f2941 Mon Sep 17 00:00:00 2001 From: Felix Berlakovich Date: Tue, 15 Dec 2020 09:54:57 +0100 Subject: [PATCH 01/20] Implement support for referencing labels defined in optional parameters of commands --- resources/META-INF/plugin.xml | 1 + .../hannahsten/texifyidea/index/IndexKeys.kt | 4 +++ .../LatexParameterLabeledCommandsIndex.kt | 15 +++++++++ .../index/stub/LatexCommandsStub.kt | 2 +- .../stub/LatexCommandsStubElementType.kt | 33 +++++++++++++------ .../index/stub/LatexCommandsStubImpl.kt | 2 +- .../stub/LatexEnvironmentStubElementType.kt | 2 +- .../latex/LatexLabelConventionInspection.kt | 2 +- .../latex/LatexMissingLabelInspection.kt | 2 +- .../texifyidea/psi/LatexEnvironmentUtil.kt | 2 +- src/nl/hannahsten/texifyidea/util/Labels.kt | 28 +++++++++++----- src/nl/hannahsten/texifyidea/util/Magic.kt | 12 +++---- .../reference/LatexLabelCompletionTest.kt | 22 +++++++++++++ 13 files changed, 96 insertions(+), 31 deletions(-) create mode 100644 src/nl/hannahsten/texifyidea/index/LatexParameterLabeledCommandsIndex.kt diff --git a/resources/META-INF/plugin.xml b/resources/META-INF/plugin.xml index 488da558b..d72c64069 100644 --- a/resources/META-INF/plugin.xml +++ b/resources/META-INF/plugin.xml @@ -504,6 +504,7 @@ + diff --git a/src/nl/hannahsten/texifyidea/index/IndexKeys.kt b/src/nl/hannahsten/texifyidea/index/IndexKeys.kt index 84d1e81c7..b9e73e86d 100644 --- a/src/nl/hannahsten/texifyidea/index/IndexKeys.kt +++ b/src/nl/hannahsten/texifyidea/index/IndexKeys.kt @@ -1,6 +1,7 @@ package nl.hannahsten.texifyidea.index import com.intellij.psi.stubs.StubIndexKey +import nl.hannahsten.texifyidea.lang.LatexCommand import nl.hannahsten.texifyidea.psi.LatexCommands import nl.hannahsten.texifyidea.psi.LatexEnvironment import nl.hannahsten.texifyidea.psi.LatexMagicComment @@ -21,4 +22,7 @@ object IndexKeys { StubIndexKey.createIndexKey("nl.hannahsten.texifyidea.magiccomment") val LABELED_ENVIRONMENTS_KEY = StubIndexKey.createIndexKey("nl.hannahsten.texifyidea.parameterlabeledenvironments") + val LABELED_COMMANDS_KEY = + StubIndexKey.createIndexKey("nl.hannahsten.texifyidea.parameterlabeledcommands") + } \ No newline at end of file diff --git a/src/nl/hannahsten/texifyidea/index/LatexParameterLabeledCommandsIndex.kt b/src/nl/hannahsten/texifyidea/index/LatexParameterLabeledCommandsIndex.kt new file mode 100644 index 000000000..48a86e133 --- /dev/null +++ b/src/nl/hannahsten/texifyidea/index/LatexParameterLabeledCommandsIndex.kt @@ -0,0 +1,15 @@ +package nl.hannahsten.texifyidea.index + +import com.intellij.psi.stubs.StringStubIndexExtension +import nl.hannahsten.texifyidea.psi.LatexCommands +import nl.hannahsten.texifyidea.psi.LatexEnvironment + +/** + * This index contains commands that define a label in their optional parameters. + */ +class LatexParameterLabeledCommandsIndex : StringStubIndexExtension() { + companion object : IndexUtilBase(LatexCommands::class.java, IndexKeys.LABELED_COMMANDS_KEY) + + @Suppress("RedundantCompanionReference") + override fun getKey() = Companion.key() +} \ No newline at end of file diff --git a/src/nl/hannahsten/texifyidea/index/stub/LatexCommandsStub.kt b/src/nl/hannahsten/texifyidea/index/stub/LatexCommandsStub.kt index 0952e3f37..8af0bf3e3 100644 --- a/src/nl/hannahsten/texifyidea/index/stub/LatexCommandsStub.kt +++ b/src/nl/hannahsten/texifyidea/index/stub/LatexCommandsStub.kt @@ -10,5 +10,5 @@ import nl.hannahsten.texifyidea.psi.LatexCommands interface LatexCommandsStub : StubElement, NamedStub { val commandToken: String val requiredParams: List - val optionalParams: List + val optionalParams: Map } \ No newline at end of file diff --git a/src/nl/hannahsten/texifyidea/index/stub/LatexCommandsStubElementType.kt b/src/nl/hannahsten/texifyidea/index/stub/LatexCommandsStubElementType.kt index b86b3ec7c..cbef1792f 100644 --- a/src/nl/hannahsten/texifyidea/index/stub/LatexCommandsStubElementType.kt +++ b/src/nl/hannahsten/texifyidea/index/stub/LatexCommandsStubElementType.kt @@ -2,10 +2,9 @@ package nl.hannahsten.texifyidea.index.stub import com.intellij.psi.stubs.* import nl.hannahsten.texifyidea.LatexLanguage -import nl.hannahsten.texifyidea.index.LatexCommandsIndex -import nl.hannahsten.texifyidea.index.LatexDefinitionIndex -import nl.hannahsten.texifyidea.index.LatexIncludesIndex +import nl.hannahsten.texifyidea.index.* import nl.hannahsten.texifyidea.psi.LatexCommands +import nl.hannahsten.texifyidea.psi.getOptionalParameters import nl.hannahsten.texifyidea.psi.impl.LatexCommandsImpl import nl.hannahsten.texifyidea.util.Magic import nl.hannahsten.texifyidea.util.getIncludeCommands @@ -30,8 +29,8 @@ class LatexCommandsStubElementType(debugName: String) : override fun createStub(latexCommands: LatexCommands, parent: StubElement<*>?): LatexCommandsStub { val commandToken = latexCommands.commandToken.text val requiredParameters = latexCommands.requiredParameters - val optionalParameters: List = - LinkedList(latexCommands.optionalParameters.keys) + val optionalParameters: Map = + latexCommands.optionalParameters return LatexCommandsStubImpl( parent!!, this, commandToken, @@ -58,7 +57,7 @@ class LatexCommandsStubElementType(debugName: String) : override fun deserialize(stubInputStream: StubInputStream, parent: StubElement<*>): LatexCommandsStub { val name = stubInputStream.readName().toString() val required = deserialiseList(stubInputStream.readName().toString()) - val optional = deserialiseList(stubInputStream.readName().toString()) + val optional = deserializeMap(stubInputStream.readName().toString()) return LatexCommandsStubImpl( parent, this, name, @@ -67,6 +66,14 @@ class LatexCommandsStubElementType(debugName: String) : ) } + private fun deserializeMap(fromString: String): Map { + val keyValuePairs = deserialiseList(fromString) + return keyValuePairs.filter { it.isNotEmpty() }.map { + val parts = it.split(KEY_VALUE_SEPARATOR) + parts[0] to parts[1] + }.toMap() + } + override fun indexStub(latexCommandsStub: LatexCommandsStub, indexSink: IndexSink) { indexSink.occurrence( LatexCommandsIndex.key(), @@ -79,23 +86,29 @@ class LatexCommandsStubElementType(debugName: String) : if (Magic.Command.definitions.contains(token) || Magic.Command.redefinitions.contains(token)) { indexSink.occurrence(LatexDefinitionIndex.key(), token) } + if (Magic.labelAsParameter.contains(token.substring(1)) && latexCommandsStub.optionalParams.contains("label")) { + val label = latexCommandsStub.optionalParams["label"]!! + indexSink.occurrence(LatexParameterLabeledCommandsIndex.key(), label) + } } private fun deserialiseList(string: String): List { - return SEPERATOR.splitAsStream(string) + return LIST_ELEMENT_SEPARATOR.splitAsStream(string) .collect(Collectors.toList()) } private fun serialiseRequired(stub: LatexCommandsStub): String { - return java.lang.String.join(SEPERATOR.pattern(), stub.requiredParams) + return java.lang.String.join(LIST_ELEMENT_SEPARATOR.pattern(), stub.requiredParams) } private fun serialiseOptional(stub: LatexCommandsStub): String { - return java.lang.String.join(SEPERATOR.pattern(), stub.optionalParams) + val keyValuePairs = stub.optionalParams.map { "${it.key}=${it.value}" } + return java.lang.String.join(LIST_ELEMENT_SEPARATOR.pattern(), keyValuePairs) } companion object { - private val SEPERATOR = + private val LIST_ELEMENT_SEPARATOR = Pattern.compile("\u1923\u9123\u2d20 hello\u0012") + private val KEY_VALUE_SEPARATOR = "=".toRegex() } } \ No newline at end of file diff --git a/src/nl/hannahsten/texifyidea/index/stub/LatexCommandsStubImpl.kt b/src/nl/hannahsten/texifyidea/index/stub/LatexCommandsStubImpl.kt index 8df9c9eaf..60bee023d 100644 --- a/src/nl/hannahsten/texifyidea/index/stub/LatexCommandsStubImpl.kt +++ b/src/nl/hannahsten/texifyidea/index/stub/LatexCommandsStubImpl.kt @@ -13,7 +13,7 @@ class LatexCommandsStubImpl( elementType: IStubElementType<*, *>, override val commandToken: String, override val requiredParams: List, - override val optionalParams: List + override val optionalParams: Map ) : NamedStubBase(parent, elementType, commandToken), LatexCommandsStub { override fun getName() = commandToken diff --git a/src/nl/hannahsten/texifyidea/index/stub/LatexEnvironmentStubElementType.kt b/src/nl/hannahsten/texifyidea/index/stub/LatexEnvironmentStubElementType.kt index 8ce20bb08..a668dc15d 100644 --- a/src/nl/hannahsten/texifyidea/index/stub/LatexEnvironmentStubElementType.kt +++ b/src/nl/hannahsten/texifyidea/index/stub/LatexEnvironmentStubElementType.kt @@ -37,7 +37,7 @@ open class LatexEnvironmentStubElementType(debugName: String) : IStubElementType sink.occurrence(LatexEnvironmentsIndex.key(), stub.environmentName) // only record environments with a label in the optional parameters - if (stub.label.isNotEmpty() && Magic.Environment.labelAsParameter.contains(stub.environmentName)) { + if (stub.label.isNotEmpty() && Magic.labelAsParameter.contains(stub.environmentName)) { sink.occurrence(LatexParameterLabeledEnvironmentsIndex.key(), stub.label) } } diff --git a/src/nl/hannahsten/texifyidea/inspections/latex/LatexLabelConventionInspection.kt b/src/nl/hannahsten/texifyidea/inspections/latex/LatexLabelConventionInspection.kt index ab30f4331..bdaf236cd 100644 --- a/src/nl/hannahsten/texifyidea/inspections/latex/LatexLabelConventionInspection.kt +++ b/src/nl/hannahsten/texifyidea/inspections/latex/LatexLabelConventionInspection.kt @@ -31,7 +31,7 @@ open class LatexLabelConventionInspection : TexifyInspectionBase() { is LatexCommands -> { if (label.inDirectEnvironmentMatching { Magic.Environment.labeled.containsKey(it.environmentName) && - !Magic.Environment.labelAsParameter.contains(it.environmentName) + !Magic.labelAsParameter.contains(it.environmentName) } ) { label.parentOfType(LatexEnvironment::class) diff --git a/src/nl/hannahsten/texifyidea/inspections/latex/LatexMissingLabelInspection.kt b/src/nl/hannahsten/texifyidea/inspections/latex/LatexMissingLabelInspection.kt index a4c12dbff..dde8a0811 100644 --- a/src/nl/hannahsten/texifyidea/inspections/latex/LatexMissingLabelInspection.kt +++ b/src/nl/hannahsten/texifyidea/inspections/latex/LatexMissingLabelInspection.kt @@ -178,7 +178,7 @@ open class LatexMissingLabelInspection : TexifyInspectionBase() { ) val moveCaretAfter: PsiElement - moveCaretAfter = if (Magic.Environment.labelAsParameter.contains(command.environmentName)) { + moveCaretAfter = if (Magic.labelAsParameter.contains(command.environmentName)) { val insertedElements = helper.addOptionalParameter(command.beginCommand, "label", createdLabel) insertedElements.last() } diff --git a/src/nl/hannahsten/texifyidea/psi/LatexEnvironmentUtil.kt b/src/nl/hannahsten/texifyidea/psi/LatexEnvironmentUtil.kt index f5c15b5ed..92dd9799d 100644 --- a/src/nl/hannahsten/texifyidea/psi/LatexEnvironmentUtil.kt +++ b/src/nl/hannahsten/texifyidea/psi/LatexEnvironmentUtil.kt @@ -16,7 +16,7 @@ import nl.hannahsten.texifyidea.util.Magic fun getLabel(element: LatexEnvironment): String? { val stub = element.stub if (stub != null) return stub.label - return if (Magic.Environment.labelAsParameter.contains(element.environmentName)) { + return if (Magic.labelAsParameter.contains(element.environmentName)) { // See if we can find a label option val optionalParameters = getOptionalParameters(element.beginCommand.parameterList) optionalParameters.getOrDefault("label", null) diff --git a/src/nl/hannahsten/texifyidea/util/Labels.kt b/src/nl/hannahsten/texifyidea/util/Labels.kt index 870d0c682..6e2d6fb05 100644 --- a/src/nl/hannahsten/texifyidea/util/Labels.kt +++ b/src/nl/hannahsten/texifyidea/util/Labels.kt @@ -5,6 +5,7 @@ import com.intellij.psi.PsiElement import com.intellij.psi.PsiFile import nl.hannahsten.texifyidea.index.BibtexEntryIndex import nl.hannahsten.texifyidea.index.LatexCommandsIndex +import nl.hannahsten.texifyidea.index.LatexParameterLabeledCommandsIndex import nl.hannahsten.texifyidea.index.LatexParameterLabeledEnvironmentsIndex import nl.hannahsten.texifyidea.lang.CommandManager import nl.hannahsten.texifyidea.psi.* @@ -30,7 +31,8 @@ fun PsiFile.findLatexAndBibtexLabelStringsInFileSet(): Set = (findLatexL */ fun PsiFile.findLabelsInFileSetAsCollection(): List = sequenceOf( findLabelingCommandsInFileSetAsSequence(), - LatexParameterLabeledEnvironmentsIndex.getItemsInFileSet(this).asSequence() + LatexParameterLabeledEnvironmentsIndex.getItemsInFileSet(this).asSequence(), + LatexParameterLabeledCommandsIndex.getItemsInFileSet(this).asSequence() ).flatten().toList() /* @@ -51,7 +53,8 @@ fun PsiFile.findLatexLabelStringsInFileSetAsSequence(): Sequence { */ fun PsiFile.findLatexLabelPsiElementsInFileAsSequence(): Sequence = sequenceOf( findLabelingCommandsInFileAsSequence(), - LatexParameterLabeledEnvironmentsIndex.getItems(this).asSequence() + LatexParameterLabeledEnvironmentsIndex.getItems(this).asSequence(), + LatexParameterLabeledCommandsIndex.getItemsInFileSet(this).asSequence() ).flatten() /** @@ -59,7 +62,8 @@ fun PsiFile.findLatexLabelPsiElementsInFileAsSequence(): Sequence = */ fun PsiFile.findLatexLabelPsiElementsInFileSetAsSequence(): Sequence = sequenceOf( findLabelingCommandsInFileSetAsSequence(), - LatexParameterLabeledEnvironmentsIndex.getItemsInFileSet(this).asSequence() + LatexParameterLabeledEnvironmentsIndex.getItemsInFileSet(this).asSequence(), + LatexParameterLabeledCommandsIndex.getItemsInFileSet(this).asSequence() ).flatten() /** @@ -147,9 +151,11 @@ fun Project.findAllLabelsAndBibtexIds(): Collection { val commands = LatexCommandsIndex.getItems(this).findLatexCommandsLabels(this) val bibtexIds = BibtexEntryIndex.getIndexedEntries(this) val environments = LatexParameterLabeledEnvironmentsIndex.getItems(this) + val parameterLabeledCommands = LatexParameterLabeledCommandsIndex.getItems(this) val result = ArrayList(commands) result.addAll(bibtexIds) result.addAll(environments) + result.addAll(parameterLabeledCommands) return result } @@ -164,12 +170,16 @@ fun PsiElement.extractLabelName(): String { return when (this) { is BibtexEntry -> identifier() ?: "" is LatexCommands -> { - // For now just take the first label name (may be multiple for user defined commands) - val info = CommandManager.labelAliasesInfo.getOrDefault(name, null) - val position = info?.positions?.firstOrNull() ?: 0 - val prefix = info?.prefix ?: "" - // Skip optional parameters for now (also below and in - prefix + this.requiredParameter(position) + if (Magic.labelAsParameter.contains(commandToken.text.substring(1))) { + optionalParameters["label"]!! + } else { + // For now just take the first label name (may be multiple for user defined commands) + val info = CommandManager.labelAliasesInfo.getOrDefault(name, null) + val position = info?.positions?.firstOrNull() ?: 0 + val prefix = info?.prefix ?: "" + // Skip optional parameters for now (also below and in + prefix + this.requiredParameter(position) + } } is LatexEnvironment -> this.label ?: "" else -> text diff --git a/src/nl/hannahsten/texifyidea/util/Magic.kt b/src/nl/hannahsten/texifyidea/util/Magic.kt index 23a244db7..64cc8587e 100644 --- a/src/nl/hannahsten/texifyidea/util/Magic.kt +++ b/src/nl/hannahsten/texifyidea/util/Magic.kt @@ -201,6 +201,12 @@ object Magic { ) } + /** + * Commands and environments that define their label via an optional parameter + */ + @JvmField + val labelAsParameter = hashSetOf("lstlisting", "Verbatim", "lstinputlisting") + /** * @author Hannah Schellekens */ @@ -227,12 +233,6 @@ object Magic { "Verbatim", "verb" ) - /** - * Environments that define their label via an optional parameter - */ - @JvmField - val labelAsParameter = hashSetOf("lstlisting", "Verbatim") - /** * Environments that introduce figures */ diff --git a/test/nl/hannahsten/texifyidea/reference/LatexLabelCompletionTest.kt b/test/nl/hannahsten/texifyidea/reference/LatexLabelCompletionTest.kt index 2fdc15f99..ad575d80e 100644 --- a/test/nl/hannahsten/texifyidea/reference/LatexLabelCompletionTest.kt +++ b/test/nl/hannahsten/texifyidea/reference/LatexLabelCompletionTest.kt @@ -36,4 +36,26 @@ class LatexLabelCompletionTest : BasePlatformTestCase() { assertTrue(result.any { l -> l.lookupString == "lst:listing" }) assertTrue(result.any { l -> l.lookupString == "sec:some-section" }) } + + + @Test + fun testCommandParameterLabelReferenceCompletion() { + // given + myFixture.configureByText( + LatexFileType, + """ + \begin{document} + \lstinputlisting[label={lst:inputlisting}]{some/file} + \ref{} + \end{document} + """.trimIndent() + ) + + // when + val result = myFixture.complete(CompletionType.BASIC) + + // then + assertEquals(1, result.size) + assertTrue(result.any { l -> l.lookupString == "lst:inputlisting" }) + } } \ No newline at end of file From d80d8d1a7ea50f9e9e48feabe781bb9245f3098d Mon Sep 17 00:00:00 2001 From: Felix Berlakovich Date: Tue, 15 Dec 2020 11:10:23 +0100 Subject: [PATCH 02/20] Separate command and environment magic list for parameter labeling --- .../index/stub/LatexCommandsStubElementType.kt | 2 +- .../stub/LatexEnvironmentStubElementType.kt | 2 +- .../latex/LatexLabelConventionInspection.kt | 2 +- .../latex/LatexMissingLabelInspection.kt | 2 +- .../texifyidea/psi/LatexEnvironmentUtil.kt | 2 +- src/nl/hannahsten/texifyidea/util/Labels.kt | 2 +- src/nl/hannahsten/texifyidea/util/Magic.kt | 18 ++++++++++++------ 7 files changed, 18 insertions(+), 12 deletions(-) diff --git a/src/nl/hannahsten/texifyidea/index/stub/LatexCommandsStubElementType.kt b/src/nl/hannahsten/texifyidea/index/stub/LatexCommandsStubElementType.kt index cbef1792f..5e9bf556b 100644 --- a/src/nl/hannahsten/texifyidea/index/stub/LatexCommandsStubElementType.kt +++ b/src/nl/hannahsten/texifyidea/index/stub/LatexCommandsStubElementType.kt @@ -86,7 +86,7 @@ class LatexCommandsStubElementType(debugName: String) : if (Magic.Command.definitions.contains(token) || Magic.Command.redefinitions.contains(token)) { indexSink.occurrence(LatexDefinitionIndex.key(), token) } - if (Magic.labelAsParameter.contains(token.substring(1)) && latexCommandsStub.optionalParams.contains("label")) { + if (Magic.Command.labelAsParameter.contains(token) && latexCommandsStub.optionalParams.contains("label")) { val label = latexCommandsStub.optionalParams["label"]!! indexSink.occurrence(LatexParameterLabeledCommandsIndex.key(), label) } diff --git a/src/nl/hannahsten/texifyidea/index/stub/LatexEnvironmentStubElementType.kt b/src/nl/hannahsten/texifyidea/index/stub/LatexEnvironmentStubElementType.kt index a668dc15d..8ce20bb08 100644 --- a/src/nl/hannahsten/texifyidea/index/stub/LatexEnvironmentStubElementType.kt +++ b/src/nl/hannahsten/texifyidea/index/stub/LatexEnvironmentStubElementType.kt @@ -37,7 +37,7 @@ open class LatexEnvironmentStubElementType(debugName: String) : IStubElementType sink.occurrence(LatexEnvironmentsIndex.key(), stub.environmentName) // only record environments with a label in the optional parameters - if (stub.label.isNotEmpty() && Magic.labelAsParameter.contains(stub.environmentName)) { + if (stub.label.isNotEmpty() && Magic.Environment.labelAsParameter.contains(stub.environmentName)) { sink.occurrence(LatexParameterLabeledEnvironmentsIndex.key(), stub.label) } } diff --git a/src/nl/hannahsten/texifyidea/inspections/latex/LatexLabelConventionInspection.kt b/src/nl/hannahsten/texifyidea/inspections/latex/LatexLabelConventionInspection.kt index bdaf236cd..ab30f4331 100644 --- a/src/nl/hannahsten/texifyidea/inspections/latex/LatexLabelConventionInspection.kt +++ b/src/nl/hannahsten/texifyidea/inspections/latex/LatexLabelConventionInspection.kt @@ -31,7 +31,7 @@ open class LatexLabelConventionInspection : TexifyInspectionBase() { is LatexCommands -> { if (label.inDirectEnvironmentMatching { Magic.Environment.labeled.containsKey(it.environmentName) && - !Magic.labelAsParameter.contains(it.environmentName) + !Magic.Environment.labelAsParameter.contains(it.environmentName) } ) { label.parentOfType(LatexEnvironment::class) diff --git a/src/nl/hannahsten/texifyidea/inspections/latex/LatexMissingLabelInspection.kt b/src/nl/hannahsten/texifyidea/inspections/latex/LatexMissingLabelInspection.kt index dde8a0811..a4c12dbff 100644 --- a/src/nl/hannahsten/texifyidea/inspections/latex/LatexMissingLabelInspection.kt +++ b/src/nl/hannahsten/texifyidea/inspections/latex/LatexMissingLabelInspection.kt @@ -178,7 +178,7 @@ open class LatexMissingLabelInspection : TexifyInspectionBase() { ) val moveCaretAfter: PsiElement - moveCaretAfter = if (Magic.labelAsParameter.contains(command.environmentName)) { + moveCaretAfter = if (Magic.Environment.labelAsParameter.contains(command.environmentName)) { val insertedElements = helper.addOptionalParameter(command.beginCommand, "label", createdLabel) insertedElements.last() } diff --git a/src/nl/hannahsten/texifyidea/psi/LatexEnvironmentUtil.kt b/src/nl/hannahsten/texifyidea/psi/LatexEnvironmentUtil.kt index 92dd9799d..f5c15b5ed 100644 --- a/src/nl/hannahsten/texifyidea/psi/LatexEnvironmentUtil.kt +++ b/src/nl/hannahsten/texifyidea/psi/LatexEnvironmentUtil.kt @@ -16,7 +16,7 @@ import nl.hannahsten.texifyidea.util.Magic fun getLabel(element: LatexEnvironment): String? { val stub = element.stub if (stub != null) return stub.label - return if (Magic.labelAsParameter.contains(element.environmentName)) { + return if (Magic.Environment.labelAsParameter.contains(element.environmentName)) { // See if we can find a label option val optionalParameters = getOptionalParameters(element.beginCommand.parameterList) optionalParameters.getOrDefault("label", null) diff --git a/src/nl/hannahsten/texifyidea/util/Labels.kt b/src/nl/hannahsten/texifyidea/util/Labels.kt index 6e2d6fb05..e4d431f2f 100644 --- a/src/nl/hannahsten/texifyidea/util/Labels.kt +++ b/src/nl/hannahsten/texifyidea/util/Labels.kt @@ -170,7 +170,7 @@ fun PsiElement.extractLabelName(): String { return when (this) { is BibtexEntry -> identifier() ?: "" is LatexCommands -> { - if (Magic.labelAsParameter.contains(commandToken.text.substring(1))) { + if (Magic.Command.labelAsParameter.contains(commandToken.text)) { optionalParameters["label"]!! } else { // For now just take the first label name (may be multiple for user defined commands) diff --git a/src/nl/hannahsten/texifyidea/util/Magic.kt b/src/nl/hannahsten/texifyidea/util/Magic.kt index 64cc8587e..22b77b22c 100644 --- a/src/nl/hannahsten/texifyidea/util/Magic.kt +++ b/src/nl/hannahsten/texifyidea/util/Magic.kt @@ -201,12 +201,6 @@ object Magic { ) } - /** - * Commands and environments that define their label via an optional parameter - */ - @JvmField - val labelAsParameter = hashSetOf("lstlisting", "Verbatim", "lstinputlisting") - /** * @author Hannah Schellekens */ @@ -267,6 +261,12 @@ object Magic { "aligned", "alignedat", "cases", "dcases" ) + matrixEnvironments + + /** + * Environments that define their label via an optional parameter + */ + @JvmField + val labelAsParameter = hashSetOf("lstlisting", "Verbatim") } /** @@ -321,6 +321,12 @@ object Magic { SUBPARAGRAPH to 5 ) + /** + * Commands that define a label via an optional parameter + */ + @JvmField + val labelAsParameter = hashSetOf("\\lstinputlisting") + /** * All commands that mark some kind of section. */ From a0bee4cd3f10b4292c09f4b7e14500d6216938d1 Mon Sep 17 00:00:00 2001 From: Felix Berlakovich Date: Tue, 15 Dec 2020 15:08:43 +0100 Subject: [PATCH 03/20] Implement missing label inspection and quickfix for parameter labeled commands --- .../hannahsten/texifyidea/index/IndexKeys.kt | 2 -- .../LatexParameterLabeledCommandsIndex.kt | 1 - .../stub/LatexCommandsStubElementType.kt | 1 - .../latex/LatexLabelConventionInspection.kt | 19 +++++++++--- .../latex/LatexMissingLabelInspection.kt | 2 ++ .../texifyidea/psi/LatexCommandsImplUtil.kt | 4 +++ src/nl/hannahsten/texifyidea/util/Labels.kt | 9 ++++-- src/nl/hannahsten/texifyidea/util/Magic.kt | 3 +- .../LatexLabelConventionInspectionTest.kt | 31 +++++++++++++++++++ .../latex/LatexMissingLabelInspectionTest.kt | 24 ++++++++++++++ .../reference/LatexLabelCompletionTest.kt | 1 - 11 files changed, 83 insertions(+), 14 deletions(-) diff --git a/src/nl/hannahsten/texifyidea/index/IndexKeys.kt b/src/nl/hannahsten/texifyidea/index/IndexKeys.kt index b9e73e86d..3b2f7d295 100644 --- a/src/nl/hannahsten/texifyidea/index/IndexKeys.kt +++ b/src/nl/hannahsten/texifyidea/index/IndexKeys.kt @@ -1,7 +1,6 @@ package nl.hannahsten.texifyidea.index import com.intellij.psi.stubs.StubIndexKey -import nl.hannahsten.texifyidea.lang.LatexCommand import nl.hannahsten.texifyidea.psi.LatexCommands import nl.hannahsten.texifyidea.psi.LatexEnvironment import nl.hannahsten.texifyidea.psi.LatexMagicComment @@ -24,5 +23,4 @@ object IndexKeys { StubIndexKey.createIndexKey("nl.hannahsten.texifyidea.parameterlabeledenvironments") val LABELED_COMMANDS_KEY = StubIndexKey.createIndexKey("nl.hannahsten.texifyidea.parameterlabeledcommands") - } \ No newline at end of file diff --git a/src/nl/hannahsten/texifyidea/index/LatexParameterLabeledCommandsIndex.kt b/src/nl/hannahsten/texifyidea/index/LatexParameterLabeledCommandsIndex.kt index 48a86e133..7a603cf83 100644 --- a/src/nl/hannahsten/texifyidea/index/LatexParameterLabeledCommandsIndex.kt +++ b/src/nl/hannahsten/texifyidea/index/LatexParameterLabeledCommandsIndex.kt @@ -2,7 +2,6 @@ package nl.hannahsten.texifyidea.index import com.intellij.psi.stubs.StringStubIndexExtension import nl.hannahsten.texifyidea.psi.LatexCommands -import nl.hannahsten.texifyidea.psi.LatexEnvironment /** * This index contains commands that define a label in their optional parameters. diff --git a/src/nl/hannahsten/texifyidea/index/stub/LatexCommandsStubElementType.kt b/src/nl/hannahsten/texifyidea/index/stub/LatexCommandsStubElementType.kt index 5e9bf556b..c18f0afe7 100644 --- a/src/nl/hannahsten/texifyidea/index/stub/LatexCommandsStubElementType.kt +++ b/src/nl/hannahsten/texifyidea/index/stub/LatexCommandsStubElementType.kt @@ -4,7 +4,6 @@ import com.intellij.psi.stubs.* import nl.hannahsten.texifyidea.LatexLanguage import nl.hannahsten.texifyidea.index.* import nl.hannahsten.texifyidea.psi.LatexCommands -import nl.hannahsten.texifyidea.psi.getOptionalParameters import nl.hannahsten.texifyidea.psi.impl.LatexCommandsImpl import nl.hannahsten.texifyidea.util.Magic import nl.hannahsten.texifyidea.util.getIncludeCommands diff --git a/src/nl/hannahsten/texifyidea/inspections/latex/LatexLabelConventionInspection.kt b/src/nl/hannahsten/texifyidea/inspections/latex/LatexLabelConventionInspection.kt index ab30f4331..9f56a41e5 100644 --- a/src/nl/hannahsten/texifyidea/inspections/latex/LatexLabelConventionInspection.kt +++ b/src/nl/hannahsten/texifyidea/inspections/latex/LatexLabelConventionInspection.kt @@ -29,6 +29,10 @@ open class LatexLabelConventionInspection : TexifyInspectionBase() { private fun getLabeledCommand(label: PsiElement): PsiElement? { return when (label) { is LatexCommands -> { + if (Magic.Command.labelAsParameter.contains(label.commandToken.text)) { + return label + } + if (label.inDirectEnvironmentMatching { Magic.Environment.labeled.containsKey(it.environmentName) && !Magic.Environment.labelAsParameter.contains(it.environmentName) @@ -129,12 +133,17 @@ open class LatexLabelConventionInspection : TexifyInspectionBase() { // Replace in command label definition if (command is LatexCommands) { - val labelInfo = CommandManager.labelAliasesInfo.getOrDefault(command.name, null) ?: return - if (!labelInfo.labelsPreviousCommand) return - val position = labelInfo.positions.firstOrNull() ?: return + if (Magic.Command.labelAsParameter.contains(command.commandToken.text)) { + latexPsiHelper.replaceOptionalParameter(command.parameterList, "label", createdLabel) + } + else { + val labelInfo = CommandManager.labelAliasesInfo.getOrDefault(command.name, null) ?: return + if (!labelInfo.labelsPreviousCommand) return + val position = labelInfo.positions.firstOrNull() ?: return - val labelParameter = command.requiredParameters().getOrNull(position) ?: return - labelParameter.replace(latexPsiHelper.createRequiredParameter(createdLabel)) + val labelParameter = command.requiredParameters().getOrNull(position) ?: return + labelParameter.replace(latexPsiHelper.createRequiredParameter(createdLabel)) + } } // Replace in environment diff --git a/src/nl/hannahsten/texifyidea/inspections/latex/LatexMissingLabelInspection.kt b/src/nl/hannahsten/texifyidea/inspections/latex/LatexMissingLabelInspection.kt index a4c12dbff..ba62912f9 100644 --- a/src/nl/hannahsten/texifyidea/inspections/latex/LatexMissingLabelInspection.kt +++ b/src/nl/hannahsten/texifyidea/inspections/latex/LatexMissingLabelInspection.kt @@ -47,6 +47,8 @@ open class LatexMissingLabelInspection : TexifyInspectionBase() { Magic.Command.labeledLevels[command]?.let { it <= minimumLevel } == true // -1 is a higher level than 0 }.map { "\\" + it.command }.toMutableList() + labeledCommands.addAll(Magic.Command.labelAsParameter) + // Document classes like book and report provide \part as sectioning, but with exam class it's a part in a question if (file.findRootFile().documentClass() == LatexDocumentClass.EXAM.name) { labeledCommands.remove("\\part") diff --git a/src/nl/hannahsten/texifyidea/psi/LatexCommandsImplUtil.kt b/src/nl/hannahsten/texifyidea/psi/LatexCommandsImplUtil.kt index d6d387d7d..0aebd4fdd 100644 --- a/src/nl/hannahsten/texifyidea/psi/LatexCommandsImplUtil.kt +++ b/src/nl/hannahsten/texifyidea/psi/LatexCommandsImplUtil.kt @@ -201,6 +201,10 @@ fun LatexCommands.extractUrlReferences(firstParam: LatexRequiredParam): Array = (findLatexLabelStringsInFileSetAsSequence() + findBibtexLabelsInFileSetAsSequence()).toSet() +fun PsiFile.findLatexAndBibtexLabelStringsInFileSet(): Set = + (findLatexLabelStringsInFileSetAsSequence() + findBibtexLabelsInFileSetAsSequence()).toSet() /** * Finds all defined labels within a given file. @@ -172,7 +173,8 @@ fun PsiElement.extractLabelName(): String { is LatexCommands -> { if (Magic.Command.labelAsParameter.contains(commandToken.text)) { optionalParameters["label"]!! - } else { + } + else { // For now just take the first label name (may be multiple for user defined commands) val info = CommandManager.labelAliasesInfo.getOrDefault(name, null) val position = info?.positions?.firstOrNull() ?: 0 @@ -197,7 +199,8 @@ fun PsiElement.extractLabelElement(): PsiElement? { val info = CommandManager.labelAliasesInfo.getOrDefault(name, null) val position = info?.positions?.firstOrNull() ?: 0 // Skip optional parameters for now - this.parameterList.mapNotNull { it.requiredParam }.getOrNull(position)?.firstChildOfType(LatexParameterText::class) + this.parameterList.mapNotNull { it.requiredParam }.getOrNull(position) + ?.firstChildOfType(LatexParameterText::class) } else -> null } diff --git a/src/nl/hannahsten/texifyidea/util/Magic.kt b/src/nl/hannahsten/texifyidea/util/Magic.kt index 22b77b22c..d877726b7 100644 --- a/src/nl/hannahsten/texifyidea/util/Magic.kt +++ b/src/nl/hannahsten/texifyidea/util/Magic.kt @@ -304,7 +304,8 @@ object Magic { "\\" + SECTION.command to "sec", "\\" + SUBSECTION.command to "subsec", "\\" + SUBSUBSECTION.command to "subsubsec", - "\\" + ITEM.command to "itm" + "\\" + ITEM.command to "itm", + "\\lstinputlisting" to "lst" ) /** diff --git a/test/nl/hannahsten/texifyidea/inspections/latex/LatexLabelConventionInspectionTest.kt b/test/nl/hannahsten/texifyidea/inspections/latex/LatexLabelConventionInspectionTest.kt index da26481b1..943a09342 100644 --- a/test/nl/hannahsten/texifyidea/inspections/latex/LatexLabelConventionInspectionTest.kt +++ b/test/nl/hannahsten/texifyidea/inspections/latex/LatexLabelConventionInspectionTest.kt @@ -61,6 +61,18 @@ class LatexLabelConventionInspectionTest : TexifyInspectionTestBase(LatexLabelCo myFixture.checkHighlighting(false, false, true, false) } + fun testInputListingLabelConventionWarning() { + myFixture.configureByText( + LatexFileType, + """ + \begin{document} + \lstinputlisting[label={input listing}]{some/file} + \end{document} + """.trimIndent() + ) + myFixture.checkHighlighting(false, false, true, false) + } + fun testListingLabelConventionQuickFix() { testQuickFix( """ @@ -146,4 +158,23 @@ class LatexLabelConventionInspectionTest : TexifyInspectionTestBase(LatexLabelCo """.trimIndent() ) } + + fun testInputListingLabelConventionQuickFix() { + testQuickFix( + """ + \begin{document} + \lstinputlisting[label={input listing}]{some/file} + \ref{input listing} + \cref{input listing} + \end{document} + """.trimIndent(), + """ + \begin{document} + \lstinputlisting[label={lst:input-listing}]{some/file} + \ref{lst:input-listing} + \cref{lst:input-listing} + \end{document} + """.trimIndent() + ) + } } \ No newline at end of file diff --git a/test/nl/hannahsten/texifyidea/inspections/latex/LatexMissingLabelInspectionTest.kt b/test/nl/hannahsten/texifyidea/inspections/latex/LatexMissingLabelInspectionTest.kt index e0bf4eca1..079740484 100644 --- a/test/nl/hannahsten/texifyidea/inspections/latex/LatexMissingLabelInspectionTest.kt +++ b/test/nl/hannahsten/texifyidea/inspections/latex/LatexMissingLabelInspectionTest.kt @@ -188,4 +188,28 @@ class LatexMissingLabelInspectionTest : TexifyInspectionTestBase(LatexMissingLab quickFixName = "Add label for this command", numberOfFixes = 4 ) + + fun `test missing lstinputlistings label warnings`() = testHighlighting( + """ + \usepackage{listings} + \begin{document} + \lstinputlisting{some/file} + + \lstinputlisting[label={lst:inputlisting}]{some/file} + + \lstinputlisting[label={lst:inputlisting with spaces}]{some/file} + \end{document} + """.trimIndent() + ) + + fun `test lstinputlistings label no warnings`() = testHighlighting( + """ + \usepackage{listings} + \begin{document} + \lstinputlisting[label={lst:inputlisting}]{some/file} + + \lstinputlisting[label={lst:inputlisting with spaces}]{some/file} + \end{document} + """.trimIndent() + ) } \ No newline at end of file diff --git a/test/nl/hannahsten/texifyidea/reference/LatexLabelCompletionTest.kt b/test/nl/hannahsten/texifyidea/reference/LatexLabelCompletionTest.kt index ad575d80e..9d4cdc8da 100644 --- a/test/nl/hannahsten/texifyidea/reference/LatexLabelCompletionTest.kt +++ b/test/nl/hannahsten/texifyidea/reference/LatexLabelCompletionTest.kt @@ -37,7 +37,6 @@ class LatexLabelCompletionTest : BasePlatformTestCase() { assertTrue(result.any { l -> l.lookupString == "sec:some-section" }) } - @Test fun testCommandParameterLabelReferenceCompletion() { // given From c2d9ac0052928f46e13282f1eb337b6d68c7eb2d Mon Sep 17 00:00:00 2001 From: Felix Berlakovich Date: Tue, 15 Dec 2020 18:04:05 +0100 Subject: [PATCH 04/20] Implement missing label quickfix for commands with parameter labels --- .../texifyidea/psi/LatexBeginCommand.java | 2 +- .../texifyidea/psi/LatexCommands.java | 9 +++--- .../texifyidea/psi/LatexVisitor.java | 7 +++- .../psi/impl/LatexCommandsImpl.java | 17 +++++----- .../texifyidea/psi/LatexCommandWithParams.kt | 9 ++++++ .../hannahsten/texifyidea/grammar/Latex.bnf | 4 ++- .../latex/LatexMissingLabelInspection.kt | 10 ++++-- .../intentions/LatexAddLabelIntention.kt | 32 ++++++++++++++----- .../texifyidea/psi/LatexPsiHelper.kt | 2 +- .../latex/LatexMissingLabelInspectionTest.kt | 13 ++++++++ 10 files changed, 77 insertions(+), 28 deletions(-) create mode 100644 src/main/kotlin/nl/hannahsten/texifyidea/psi/LatexCommandWithParams.kt diff --git a/gen/nl/hannahsten/texifyidea/psi/LatexBeginCommand.java b/gen/nl/hannahsten/texifyidea/psi/LatexBeginCommand.java index 3a0cf6468..a57b21edf 100644 --- a/gen/nl/hannahsten/texifyidea/psi/LatexBeginCommand.java +++ b/gen/nl/hannahsten/texifyidea/psi/LatexBeginCommand.java @@ -6,7 +6,7 @@ import com.intellij.psi.PsiElement; import java.util.LinkedHashMap; -public interface LatexBeginCommand extends PsiElement { +public interface LatexBeginCommand extends LatexCommandWithParams { @NotNull List getParameterList(); diff --git a/gen/nl/hannahsten/texifyidea/psi/LatexCommands.java b/gen/nl/hannahsten/texifyidea/psi/LatexCommands.java index 3c5f30b70..974784233 100644 --- a/gen/nl/hannahsten/texifyidea/psi/LatexCommands.java +++ b/gen/nl/hannahsten/texifyidea/psi/LatexCommands.java @@ -1,17 +1,16 @@ // This is a generated file. Not intended for manual editing. package nl.hannahsten.texifyidea.psi; +import java.util.List; +import org.jetbrains.annotations.*; import com.intellij.psi.PsiElement; import com.intellij.psi.PsiNameIdentifierOwner; -import com.intellij.psi.PsiReference; import com.intellij.psi.StubBasedPsiElement; import nl.hannahsten.texifyidea.index.stub.LatexCommandsStub; -import org.jetbrains.annotations.NotNull; - +import com.intellij.psi.PsiReference; import java.util.LinkedHashMap; -import java.util.List; -public interface LatexCommands extends PsiNameIdentifierOwner, StubBasedPsiElement { +public interface LatexCommands extends PsiNameIdentifierOwner, LatexCommandWithParams, StubBasedPsiElement { @NotNull List getParameterList(); diff --git a/gen/nl/hannahsten/texifyidea/psi/LatexVisitor.java b/gen/nl/hannahsten/texifyidea/psi/LatexVisitor.java index 104e9a9b1..de75d1368 100644 --- a/gen/nl/hannahsten/texifyidea/psi/LatexVisitor.java +++ b/gen/nl/hannahsten/texifyidea/psi/LatexVisitor.java @@ -10,11 +10,12 @@ public class LatexVisitor extends PsiElementVisitor { public void visitBeginCommand(@NotNull LatexBeginCommand o) { - visitPsiElement(o); + visitCommandWithParams(o); } public void visitCommands(@NotNull LatexCommands o) { visitPsiNameIdentifierOwner(o); + // visitCommandWithParams(o); } public void visitComment(@NotNull LatexComment o) { @@ -113,6 +114,10 @@ public void visitPsiNameIdentifierOwner(@NotNull PsiNameIdentifierOwner o) { visitElement(o); } + public void visitCommandWithParams(@NotNull LatexCommandWithParams o) { + visitPsiElement(o); + } + public void visitPsiElement(@NotNull PsiElement o) { visitElement(o); } diff --git a/gen/nl/hannahsten/texifyidea/psi/impl/LatexCommandsImpl.java b/gen/nl/hannahsten/texifyidea/psi/impl/LatexCommandsImpl.java index ef0dd0652..6e5806084 100644 --- a/gen/nl/hannahsten/texifyidea/psi/impl/LatexCommandsImpl.java +++ b/gen/nl/hannahsten/texifyidea/psi/impl/LatexCommandsImpl.java @@ -1,21 +1,20 @@ // This is a generated file. Not intended for manual editing. package nl.hannahsten.texifyidea.psi.impl; +import java.util.List; +import org.jetbrains.annotations.*; import com.intellij.lang.ASTNode; import com.intellij.psi.PsiElement; import com.intellij.psi.PsiElementVisitor; -import com.intellij.psi.PsiReference; -import com.intellij.psi.stubs.IStubElementType; -import com.intellij.psi.tree.IElementType; import com.intellij.psi.util.PsiTreeUtil; -import nl.hannahsten.texifyidea.index.stub.LatexCommandsStub; +import static nl.hannahsten.texifyidea.psi.LatexTypes.*; +import nl.hannahsten.texifyidea.psi.LatexCommandsImplMixin; import nl.hannahsten.texifyidea.psi.*; -import org.jetbrains.annotations.NotNull; - +import com.intellij.psi.PsiReference; import java.util.LinkedHashMap; -import java.util.List; - -import static nl.hannahsten.texifyidea.psi.LatexTypes.COMMAND_TOKEN; +import nl.hannahsten.texifyidea.index.stub.LatexCommandsStub; +import com.intellij.psi.stubs.IStubElementType; +import com.intellij.psi.tree.IElementType; public class LatexCommandsImpl extends LatexCommandsImplMixin implements LatexCommands { diff --git a/src/main/kotlin/nl/hannahsten/texifyidea/psi/LatexCommandWithParams.kt b/src/main/kotlin/nl/hannahsten/texifyidea/psi/LatexCommandWithParams.kt new file mode 100644 index 000000000..5289ddee3 --- /dev/null +++ b/src/main/kotlin/nl/hannahsten/texifyidea/psi/LatexCommandWithParams.kt @@ -0,0 +1,9 @@ +package nl.hannahsten.texifyidea.psi + +import com.intellij.psi.PsiElement + +interface LatexCommandWithParams : PsiElement { + val parameterList: List + val requiredParameters: List + val optionalParameters: Map +} \ No newline at end of file diff --git a/src/nl/hannahsten/texifyidea/grammar/Latex.bnf b/src/nl/hannahsten/texifyidea/grammar/Latex.bnf index a8bcf9373..d8501604d 100644 --- a/src/nl/hannahsten/texifyidea/grammar/Latex.bnf +++ b/src/nl/hannahsten/texifyidea/grammar/Latex.bnf @@ -15,11 +15,13 @@ tokenTypeClass="nl.hannahsten.texifyidea.psi.LatexTokenType" extends("commands")="com.intellij.extapi.psi.StubBasedPsiElementBase" - implements("commands")="com.intellij.psi.PsiNameIdentifierOwner" + implements("commands")= ["com.intellij.psi.PsiNameIdentifierOwner" "nl.hannahsten.texifyidea.psi.LatexCommandWithParams"] extends("environment")="com.intellij.extapi.psi.StubBasedPsiElementBase" implements("environment")="com.intellij.psi.PsiLanguageInjectionHost" + implements("begin_command") = "nl.hannahsten.texifyidea.psi.LatexCommandWithParams" + extends("magic_comment")="com.intellij.extapi.psi.StubBasedPsiElementBase" // Make text have an identifier, to be able to Ctrl+B for \label parameters implements("parameter_text")="com.intellij.psi.PsiNameIdentifierOwner" diff --git a/src/nl/hannahsten/texifyidea/inspections/latex/LatexMissingLabelInspection.kt b/src/nl/hannahsten/texifyidea/inspections/latex/LatexMissingLabelInspection.kt index ba62912f9..0174ea3d3 100644 --- a/src/nl/hannahsten/texifyidea/inspections/latex/LatexMissingLabelInspection.kt +++ b/src/nl/hannahsten/texifyidea/inspections/latex/LatexMissingLabelInspection.kt @@ -77,12 +77,18 @@ open class LatexMissingLabelInspection : TexifyInspectionBase() { return false } + val fixes = mutableListOf() + fixes.add(InsertLabelForCommandFix()) + if (!Magic.Command.labelAsParameter.contains(command.commandToken.text)) { + fixes.add(ChangeMinimumLabelLevelFix()) + } + // For adding the label, see LatexAddLabelIntention descriptors.add( manager.createProblemDescriptor( command, "Missing label", - arrayOf(InsertLabelAfterCommandFix(), ChangeMinimumLabelLevelFix()), + fixes.toTypedArray(), ProblemHighlightType.WEAK_WARNING, isOntheFly, false @@ -156,7 +162,7 @@ open class LatexMissingLabelInspection : TexifyInspectionBase() { * This is also an intention, but in order to keep the same alt+enter+enter functionality (because we have an other * quickfix as well) we keep it as a quickfix also. */ - private class InsertLabelAfterCommandFix : LabelQuickFix() { + private class InsertLabelForCommandFix : LabelQuickFix() { // It has to appear in alphabetical order before the other quickfix override fun getFamilyName() = "Add label for this command" diff --git a/src/nl/hannahsten/texifyidea/intentions/LatexAddLabelIntention.kt b/src/nl/hannahsten/texifyidea/intentions/LatexAddLabelIntention.kt index 66f903d21..72a04a36d 100644 --- a/src/nl/hannahsten/texifyidea/intentions/LatexAddLabelIntention.kt +++ b/src/nl/hannahsten/texifyidea/intentions/LatexAddLabelIntention.kt @@ -45,23 +45,39 @@ open class LatexAddLabelIntention(val command: SmartPsiElementPointer NoMathContent -> Content -> Container containing the command - val commandContent = command.parent.parent - val labelCommand = commandContent.parent.addAfter(factory.createLabelCommand(createdLabel), commandContent) + val labelCommand = if (Magic.Command.labelAsParameter.contains(command.commandToken.text)) { + val insertedElements = factory.addOptionalParameter(command, "label", createdLabel) + insertedElements.last() + } + else { + // Insert label + // command -> NoMathContent -> Content -> Container containing the command + val commandContent = command.parent.parent + commandContent.parent.addAfter(factory.createLabelCommand(createdLabel), commandContent) + } // Adjust caret offset. val caret = editor.caretModel caret.moveToOffset(labelCommand.endOffset()) diff --git a/src/nl/hannahsten/texifyidea/psi/LatexPsiHelper.kt b/src/nl/hannahsten/texifyidea/psi/LatexPsiHelper.kt index d68b1949f..a22e5c6fb 100644 --- a/src/nl/hannahsten/texifyidea/psi/LatexPsiHelper.kt +++ b/src/nl/hannahsten/texifyidea/psi/LatexPsiHelper.kt @@ -113,7 +113,7 @@ class LatexPsiHelper(private val project: Project) { * * @return A list containing the newly inserted elements from left to right */ - fun addOptionalParameter(command: LatexBeginCommand, name: String, value: String?): List { + fun addOptionalParameter(command: LatexCommandWithParams, name: String, value: String?): List { val existingParameters = command.optionalParameters if (existingParameters.isEmpty()) { command.addAfter(createLatexOptionalParam(), command.parameterList[0]) diff --git a/test/nl/hannahsten/texifyidea/inspections/latex/LatexMissingLabelInspectionTest.kt b/test/nl/hannahsten/texifyidea/inspections/latex/LatexMissingLabelInspectionTest.kt index 079740484..d7725a33c 100644 --- a/test/nl/hannahsten/texifyidea/inspections/latex/LatexMissingLabelInspectionTest.kt +++ b/test/nl/hannahsten/texifyidea/inspections/latex/LatexMissingLabelInspectionTest.kt @@ -212,4 +212,17 @@ class LatexMissingLabelInspectionTest : TexifyInspectionTestBase(LatexMissingLab \end{document} """.trimIndent() ) + + fun `test quick fix in lstinputlistings with other parameters`() = testQuickFix( + before = """ + \begin{document} + \lstinputlisting[someoption,otheroption={with value}]{some/file} + \end{document} + """.trimIndent(), + after = """ + \begin{document} + \lstinputlisting[someoption,otheroption={with value},label={lst:lstinputlisting}]{some/file} + \end{document} + """.trimIndent() + ) } \ No newline at end of file From 4862e6a86363b9354120d27d5b87faa8b6a8534e Mon Sep 17 00:00:00 2001 From: Felix Berlakovich Date: Wed, 16 Dec 2020 21:04:06 +0100 Subject: [PATCH 05/20] Use command.name instead of command.commandToken.text --- .../inspections/latex/LatexLabelConventionInspection.kt | 4 ++-- .../inspections/latex/LatexMissingLabelInspection.kt | 2 +- .../texifyidea/intentions/LatexAddLabelIntention.kt | 6 +++--- src/nl/hannahsten/texifyidea/psi/LatexCommandsImplUtil.kt | 2 +- src/nl/hannahsten/texifyidea/util/Labels.kt | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/nl/hannahsten/texifyidea/inspections/latex/LatexLabelConventionInspection.kt b/src/nl/hannahsten/texifyidea/inspections/latex/LatexLabelConventionInspection.kt index 9f56a41e5..2c356a432 100644 --- a/src/nl/hannahsten/texifyidea/inspections/latex/LatexLabelConventionInspection.kt +++ b/src/nl/hannahsten/texifyidea/inspections/latex/LatexLabelConventionInspection.kt @@ -29,7 +29,7 @@ open class LatexLabelConventionInspection : TexifyInspectionBase() { private fun getLabeledCommand(label: PsiElement): PsiElement? { return when (label) { is LatexCommands -> { - if (Magic.Command.labelAsParameter.contains(label.commandToken.text)) { + if (Magic.Command.labelAsParameter.contains(label.name)) { return label } @@ -133,7 +133,7 @@ open class LatexLabelConventionInspection : TexifyInspectionBase() { // Replace in command label definition if (command is LatexCommands) { - if (Magic.Command.labelAsParameter.contains(command.commandToken.text)) { + if (Magic.Command.labelAsParameter.contains(command.name)) { latexPsiHelper.replaceOptionalParameter(command.parameterList, "label", createdLabel) } else { diff --git a/src/nl/hannahsten/texifyidea/inspections/latex/LatexMissingLabelInspection.kt b/src/nl/hannahsten/texifyidea/inspections/latex/LatexMissingLabelInspection.kt index 0174ea3d3..58b70524b 100644 --- a/src/nl/hannahsten/texifyidea/inspections/latex/LatexMissingLabelInspection.kt +++ b/src/nl/hannahsten/texifyidea/inspections/latex/LatexMissingLabelInspection.kt @@ -79,7 +79,7 @@ open class LatexMissingLabelInspection : TexifyInspectionBase() { val fixes = mutableListOf() fixes.add(InsertLabelForCommandFix()) - if (!Magic.Command.labelAsParameter.contains(command.commandToken.text)) { + if (!Magic.Command.labelAsParameter.contains(command.name)) { fixes.add(ChangeMinimumLabelLevelFix()) } diff --git a/src/nl/hannahsten/texifyidea/intentions/LatexAddLabelIntention.kt b/src/nl/hannahsten/texifyidea/intentions/LatexAddLabelIntention.kt index 72a04a36d..763e1dedd 100644 --- a/src/nl/hannahsten/texifyidea/intentions/LatexAddLabelIntention.kt +++ b/src/nl/hannahsten/texifyidea/intentions/LatexAddLabelIntention.kt @@ -45,9 +45,9 @@ open class LatexAddLabelIntention(val command: SmartPsiElementPointer identifier() ?: "" is LatexCommands -> { - if (Magic.Command.labelAsParameter.contains(commandToken.text)) { + if (Magic.Command.labelAsParameter.contains(name)) { optionalParameters["label"]!! } else { From e0fccb5aa15802c1a8af0a5841e8f5a3008dfc91 Mon Sep 17 00:00:00 2001 From: Felix Berlakovich Date: Wed, 16 Dec 2020 21:28:27 +0100 Subject: [PATCH 06/20] Added lstinputlisting as a command to LatexRegularCommand --- src/nl/hannahsten/texifyidea/lang/LatexRegularCommand.kt | 8 +++++++- src/nl/hannahsten/texifyidea/lang/RequiredFileArgument.kt | 2 ++ src/nl/hannahsten/texifyidea/util/Magic.kt | 2 +- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/nl/hannahsten/texifyidea/lang/LatexRegularCommand.kt b/src/nl/hannahsten/texifyidea/lang/LatexRegularCommand.kt index 6cb944a8f..fc83a7436 100644 --- a/src/nl/hannahsten/texifyidea/lang/LatexRegularCommand.kt +++ b/src/nl/hannahsten/texifyidea/lang/LatexRegularCommand.kt @@ -10,6 +10,7 @@ import nl.hannahsten.texifyidea.lang.LatexPackage.Companion.DEFAULT import nl.hannahsten.texifyidea.lang.LatexPackage.Companion.FONTENC import nl.hannahsten.texifyidea.lang.LatexPackage.Companion.GLOSSARIES import nl.hannahsten.texifyidea.lang.LatexPackage.Companion.GRAPHICX +import nl.hannahsten.texifyidea.lang.LatexPackage.Companion.LISTINGS import nl.hannahsten.texifyidea.lang.LatexPackage.Companion.MATHTOOLS import nl.hannahsten.texifyidea.lang.LatexPackage.Companion.NATBIB import nl.hannahsten.texifyidea.lang.LatexPackage.Companion.SIUNITX @@ -550,7 +551,12 @@ enum class LatexRegularCommand( IFFALSE("iffalse"), FI("fi"), ELSE("else"), - OR("or"); + OR("or"), + + /** + * Listings + */ + LSTINPUTLISTING("lstinputlisting", "options".asOptional(), RequiredFileArgument("filename", false, false), dependency = LISTINGS); companion object { diff --git a/src/nl/hannahsten/texifyidea/lang/RequiredFileArgument.kt b/src/nl/hannahsten/texifyidea/lang/RequiredFileArgument.kt index c120ae4a7..d3ccfa87c 100644 --- a/src/nl/hannahsten/texifyidea/lang/RequiredFileArgument.kt +++ b/src/nl/hannahsten/texifyidea/lang/RequiredFileArgument.kt @@ -40,6 +40,8 @@ open class RequiredFileArgument(name: String?, open val isAbsolutePathSupported: val regex = StringBuilder(".*") if (extensions.isEmpty()) { setRegex(regex.toString()) + this.supportedExtensions = supportedExtensions + this.defaultExtension = "" return } else { diff --git a/src/nl/hannahsten/texifyidea/util/Magic.kt b/src/nl/hannahsten/texifyidea/util/Magic.kt index d877726b7..885c52c9b 100644 --- a/src/nl/hannahsten/texifyidea/util/Magic.kt +++ b/src/nl/hannahsten/texifyidea/util/Magic.kt @@ -305,7 +305,7 @@ object Magic { "\\" + SUBSECTION.command to "subsec", "\\" + SUBSUBSECTION.command to "subsubsec", "\\" + ITEM.command to "itm", - "\\lstinputlisting" to "lst" + "\\" + LSTINPUTLISTING.command to "lst" ) /** From 6ad856dd3c6801a92854f783df7fa2354e4308e2 Mon Sep 17 00:00:00 2001 From: Thomas Date: Thu, 17 Dec 2020 08:17:42 +0100 Subject: [PATCH 07/20] Increase stub version and remove some unnecessary non-null calls --- src/nl/hannahsten/texifyidea/LatexParserDefinition.kt | 2 +- .../texifyidea/editor/LatexMoveElementLeftRightHandler.kt | 2 +- .../texifyidea/inspections/latex/LatexNoExtensionInspection.kt | 2 +- .../inspections/latex/LatexRequiredExtensionInspection.kt | 2 +- src/nl/hannahsten/texifyidea/settings/sdk/NativeTexliveSdk.kt | 3 +-- 5 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/nl/hannahsten/texifyidea/LatexParserDefinition.kt b/src/nl/hannahsten/texifyidea/LatexParserDefinition.kt index 7de162bcb..d77a0dc0b 100644 --- a/src/nl/hannahsten/texifyidea/LatexParserDefinition.kt +++ b/src/nl/hannahsten/texifyidea/LatexParserDefinition.kt @@ -50,7 +50,7 @@ class LatexParserDefinition : ParserDefinition { val FILE: IStubFileElementType<*> = object : IStubFileElementType( Language.findInstance(LatexLanguage::class.java) ) { - override fun getStubVersion(): Int = 13 + override fun getStubVersion(): Int = 14 } } diff --git a/src/nl/hannahsten/texifyidea/editor/LatexMoveElementLeftRightHandler.kt b/src/nl/hannahsten/texifyidea/editor/LatexMoveElementLeftRightHandler.kt index 27cd269a4..fa7283a70 100644 --- a/src/nl/hannahsten/texifyidea/editor/LatexMoveElementLeftRightHandler.kt +++ b/src/nl/hannahsten/texifyidea/editor/LatexMoveElementLeftRightHandler.kt @@ -8,6 +8,6 @@ import nl.hannahsten.texifyidea.psi.LatexCommands class LatexMoveElementLeftRightHandler : MoveElementLeftRightHandler() { override fun getMovableSubElements(element: PsiElement): Array { - return (element as? LatexCommands)?.parameterList?.map { it as PsiElement }?.toArray(emptyArray()) ?: emptyArray() + return (element as? LatexCommands)?.parameterList?.toArray(emptyArray()) ?: emptyArray() } } \ No newline at end of file diff --git a/src/nl/hannahsten/texifyidea/inspections/latex/LatexNoExtensionInspection.kt b/src/nl/hannahsten/texifyidea/inspections/latex/LatexNoExtensionInspection.kt index 53804fe75..24555376d 100644 --- a/src/nl/hannahsten/texifyidea/inspections/latex/LatexNoExtensionInspection.kt +++ b/src/nl/hannahsten/texifyidea/inspections/latex/LatexNoExtensionInspection.kt @@ -38,7 +38,7 @@ open class LatexNoExtensionInspection : TexifyInspectionBase() { .filter { command -> Magic.Command.illegalExtensions[command.name]!!.any { extension -> - command.requiredParameters.any { it?.split(",")?.any { parameter -> parameter.endsWith(extension) } == true } + command.requiredParameters.any { it.split(",").any { parameter -> parameter.endsWith(extension) } } } } .forEach { command -> diff --git a/src/nl/hannahsten/texifyidea/inspections/latex/LatexRequiredExtensionInspection.kt b/src/nl/hannahsten/texifyidea/inspections/latex/LatexRequiredExtensionInspection.kt index 841aa9abc..c36c634ef 100644 --- a/src/nl/hannahsten/texifyidea/inspections/latex/LatexRequiredExtensionInspection.kt +++ b/src/nl/hannahsten/texifyidea/inspections/latex/LatexRequiredExtensionInspection.kt @@ -39,7 +39,7 @@ open class LatexRequiredExtensionInspection : TexifyInspectionBase() { .filter { command -> Magic.Command.requiredExtensions[command.name]!!.any { extension -> - command.requiredParameters.any { it?.split(",")?.any { parameter -> parameter.endsWith(extension) } == false } + command.requiredParameters.any { !it.split(",").any { parameter -> parameter.endsWith(extension) } } } } .forEach { command -> diff --git a/src/nl/hannahsten/texifyidea/settings/sdk/NativeTexliveSdk.kt b/src/nl/hannahsten/texifyidea/settings/sdk/NativeTexliveSdk.kt index a894593c6..6932481ba 100644 --- a/src/nl/hannahsten/texifyidea/settings/sdk/NativeTexliveSdk.kt +++ b/src/nl/hannahsten/texifyidea/settings/sdk/NativeTexliveSdk.kt @@ -63,8 +63,7 @@ class NativeTexliveSdk : TexliveSdk("Native TeX Live SDK") { */ override fun getExecutableName(executable: String, project: Project): String { // Even though pdflatex is in path, it may be not the pdflatex we want, so we prefix the path to be sure. - // Get base path of LaTeX distribution - val home = LatexSdkUtil.getLatexProjectSdk(project)?.homePath ?: return executable + // Ideally we would get the home path of any SDK of this type. val basePath = "/usr/bin" return "$basePath/$executable" } From 6a119dfebb0ed9dbf47d17eb36404e2de5f95bea Mon Sep 17 00:00:00 2001 From: Felix Berlakovich Date: Thu, 17 Dec 2020 10:08:47 +0100 Subject: [PATCH 08/20] Fix incorrect usage of index method --- src/nl/hannahsten/texifyidea/util/Labels.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/nl/hannahsten/texifyidea/util/Labels.kt b/src/nl/hannahsten/texifyidea/util/Labels.kt index af18909f0..8361a5456 100644 --- a/src/nl/hannahsten/texifyidea/util/Labels.kt +++ b/src/nl/hannahsten/texifyidea/util/Labels.kt @@ -55,7 +55,7 @@ fun PsiFile.findLatexLabelStringsInFileSetAsSequence(): Sequence { fun PsiFile.findLatexLabelPsiElementsInFileAsSequence(): Sequence = sequenceOf( findLabelingCommandsInFileAsSequence(), LatexParameterLabeledEnvironmentsIndex.getItems(this).asSequence(), - LatexParameterLabeledCommandsIndex.getItemsInFileSet(this).asSequence() + LatexParameterLabeledCommandsIndex.getItems(this).asSequence() ).flatten() /** From 10c244fc9521aa48d47b8500f5ed2f258255b401 Mon Sep 17 00:00:00 2001 From: Felix Berlakovich Date: Tue, 22 Dec 2020 19:34:22 +0100 Subject: [PATCH 09/20] Parse optional parameters as key-val pairs --- .../texifyidea/grammar/LatexLexer.java | 12 +- .../texifyidea/parser/LatexParser.java | 154 ++++++++++++++++-- .../texifyidea/psi/LatexGreedyContent.java | 13 ++ .../hannahsten/texifyidea/psi/LatexGroup.java | 2 +- .../texifyidea/psi/LatexKeyvalContent.java | 16 ++ .../texifyidea/psi/LatexKeyvalKey.java | 13 ++ .../texifyidea/psi/LatexKeyvalPair.java | 16 ++ .../texifyidea/psi/LatexKeyvalPairs.java | 13 ++ .../texifyidea/psi/LatexKeyvalText.java | 13 ++ .../texifyidea/psi/LatexKeyvalValue.java | 13 ++ .../texifyidea/psi/LatexOptionalParam.java | 3 + .../psi/LatexOptionalParamContent.java | 3 + .../psi/LatexRequiredParamContent.java | 3 + .../hannahsten/texifyidea/psi/LatexTypes.java | 20 +++ .../texifyidea/psi/LatexVisitor.java | 20 +++ .../psi/impl/LatexGreedyContentImpl.java | 36 ++++ .../texifyidea/psi/impl/LatexGroupImpl.java | 4 +- .../psi/impl/LatexKeyvalContentImpl.java | 42 +++++ .../psi/impl/LatexKeyvalKeyImpl.java | 36 ++++ .../psi/impl/LatexKeyvalPairImpl.java | 42 +++++ .../psi/impl/LatexKeyvalValueImpl.java | 36 ++++ .../impl/LatexOptionalParamContentImpl.java | 6 + .../psi/impl/LatexOptionalParamImpl.java | 6 + .../impl/LatexRequiredParamContentImpl.java | 6 + .../texifyidea/formatting/LatexBlock.kt | 1 + .../hannahsten/texifyidea/grammar/Latex.bnf | 19 ++- .../texifyidea/grammar/LatexLexer.flex | 5 +- .../latex/LatexLabelConventionInspection.kt | 4 +- .../latex/LatexMissingLabelInspection.kt | 3 +- .../intentions/LatexAddLabelIntention.kt | 3 +- .../texifyidea/lang/CommandManager.kt | 2 +- .../texifyidea/psi/LatexCommandsImplUtil.kt | 37 ++--- .../texifyidea/psi/LatexPsiHelper.kt | 68 ++++++-- .../psi/LatexCommandsImplUtilTest.kt | 140 ++++++++++++++++ 34 files changed, 735 insertions(+), 75 deletions(-) create mode 100644 gen/nl/hannahsten/texifyidea/psi/LatexGreedyContent.java create mode 100644 gen/nl/hannahsten/texifyidea/psi/LatexKeyvalContent.java create mode 100644 gen/nl/hannahsten/texifyidea/psi/LatexKeyvalKey.java create mode 100644 gen/nl/hannahsten/texifyidea/psi/LatexKeyvalPair.java create mode 100644 gen/nl/hannahsten/texifyidea/psi/LatexKeyvalPairs.java create mode 100644 gen/nl/hannahsten/texifyidea/psi/LatexKeyvalText.java create mode 100644 gen/nl/hannahsten/texifyidea/psi/LatexKeyvalValue.java create mode 100644 gen/nl/hannahsten/texifyidea/psi/impl/LatexGreedyContentImpl.java create mode 100644 gen/nl/hannahsten/texifyidea/psi/impl/LatexKeyvalContentImpl.java create mode 100644 gen/nl/hannahsten/texifyidea/psi/impl/LatexKeyvalKeyImpl.java create mode 100644 gen/nl/hannahsten/texifyidea/psi/impl/LatexKeyvalPairImpl.java create mode 100644 gen/nl/hannahsten/texifyidea/psi/impl/LatexKeyvalValueImpl.java create mode 100644 test/nl/hannahsten/texifyidea/psi/LatexCommandsImplUtilTest.kt diff --git a/gen/nl/hannahsten/texifyidea/grammar/LatexLexer.java b/gen/nl/hannahsten/texifyidea/grammar/LatexLexer.java index 879be0fcb..c84edff12 100644 --- a/gen/nl/hannahsten/texifyidea/grammar/LatexLexer.java +++ b/gen/nl/hannahsten/texifyidea/grammar/LatexLexer.java @@ -82,12 +82,12 @@ public static int ZZ_CMAP(int ch) { /* The ZZ_CMAP_A table has 640 entries */ static final char ZZ_CMAP_A[] = zzUnpackCMap( "\11\0\1\10\1\20\2\22\1\21\22\0\1\35\1\34\1\47\1\0\1\66\1\41\1\70\1\0\1\2\1"+ - "\3\1\63\17\0\1\17\1\0\1\67\1\44\1\67\1\0\1\24\1\51\3\17\1\37\1\50\2\17\1\53"+ - "\2\17\1\56\3\17\1\60\1\17\1\55\1\17\1\36\1\61\1\17\1\54\1\40\2\17\1\4\1\1"+ - "\1\5\1\0\1\17\1\0\1\32\1\11\1\30\1\16\1\12\1\25\1\13\1\31\1\14\2\17\1\52\1"+ - "\65\1\15\1\45\1\42\1\17\1\33\1\43\1\27\1\57\1\62\1\64\1\26\2\17\1\6\1\47\1"+ - "\7\7\0\1\23\32\0\1\46\337\0\1\46\177\0\13\46\35\0\2\23\5\0\1\46\57\0\1\46"+ - "\40\0"); + "\3\1\63\1\0\1\47\15\0\1\17\1\0\1\67\1\44\1\67\1\0\1\24\1\51\3\17\1\37\1\50"+ + "\2\17\1\53\2\17\1\56\3\17\1\60\1\17\1\55\1\17\1\36\1\61\1\17\1\54\1\40\2\17"+ + "\1\4\1\1\1\5\1\0\1\17\1\0\1\32\1\11\1\30\1\16\1\12\1\25\1\13\1\31\1\14\2\17"+ + "\1\52\1\65\1\15\1\45\1\42\1\17\1\33\1\43\1\27\1\57\1\62\1\64\1\26\2\17\1\6"+ + "\1\47\1\7\7\0\1\23\32\0\1\46\337\0\1\46\177\0\13\46\35\0\2\23\5\0\1\46\57"+ + "\0\1\46\40\0"); /** * Translates DFA states to action switch labels. diff --git a/gen/nl/hannahsten/texifyidea/parser/LatexParser.java b/gen/nl/hannahsten/texifyidea/parser/LatexParser.java index 07ad8cc1a..4f5ba661d 100644 --- a/gen/nl/hannahsten/texifyidea/parser/LatexParser.java +++ b/gen/nl/hannahsten/texifyidea/parser/LatexParser.java @@ -10,6 +10,7 @@ import com.intellij.psi.tree.TokenSet; import com.intellij.lang.PsiParser; import com.intellij.lang.LightPsiParser; +import static com.intellij.lang.WhitespacesBinders.*; @SuppressWarnings({"SimplifiableIfStatement", "UnusedAssignment"}) public class LatexParser implements PsiParser, LightPsiParser { @@ -229,7 +230,19 @@ private static boolean environment_content_1(PsiBuilder b, int l) { } /* ********************************************************** */ - // OPEN_BRACE content* CLOSE_BRACE + // no_math_content + public static boolean greedy_content(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "greedy_content")) return false; + boolean r; + Marker m = enter_section_(b, l, _NONE_, GREEDY_CONTENT, ""); + r = no_math_content(b, l + 1); + register_hook_(b, WS_BINDERS, GREEDY_LEFT_BINDER, GREEDY_RIGHT_BINDER); + exit_section_(b, l, m, r, false, null); + return r; + } + + /* ********************************************************** */ + // OPEN_BRACE greedy_content* CLOSE_BRACE public static boolean group(PsiBuilder b, int l) { if (!recursion_guard_(b, l, "group")) return false; if (!nextTokenIs(b, OPEN_BRACE)) return false; @@ -243,12 +256,12 @@ public static boolean group(PsiBuilder b, int l) { return r || p; } - // content* + // greedy_content* private static boolean group_1(PsiBuilder b, int l) { if (!recursion_guard_(b, l, "group_1")) return false; while (true) { int c = current_position_(b); - if (!content(b, l + 1)) break; + if (!greedy_content(b, l + 1)) break; if (!empty_element_parsed_guard_(b, "group_1", c)) break; } return true; @@ -276,6 +289,80 @@ private static boolean inline_math_1(PsiBuilder b, int l) { return true; } + /* ********************************************************** */ + // parameter_text | group + public static boolean keyval_content(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "keyval_content")) return false; + boolean r; + Marker m = enter_section_(b, l, _NONE_, KEYVAL_CONTENT, ""); + r = parameter_text(b, l + 1); + if (!r) r = group(b, l + 1); + exit_section_(b, l, m, r, false, null); + return r; + } + + /* ********************************************************** */ + // keyval_content+ + public static boolean keyval_key(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "keyval_key")) return false; + boolean r; + Marker m = enter_section_(b, l, _NONE_, KEYVAL_KEY, ""); + r = keyval_content(b, l + 1); + while (r) { + int c = current_position_(b); + if (!keyval_content(b, l + 1)) break; + if (!empty_element_parsed_guard_(b, "keyval_key", c)) break; + } + exit_section_(b, l, m, r, false, null); + return r; + } + + /* ********************************************************** */ + // keyval_key ("=" keyval_value)? + public static boolean keyval_pair(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "keyval_pair")) return false; + boolean r; + Marker m = enter_section_(b, l, _NONE_, KEYVAL_PAIR, ""); + r = keyval_key(b, l + 1); + r = r && keyval_pair_1(b, l + 1); + exit_section_(b, l, m, r, false, null); + return r; + } + + // ("=" keyval_value)? + private static boolean keyval_pair_1(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "keyval_pair_1")) return false; + keyval_pair_1_0(b, l + 1); + return true; + } + + // "=" keyval_value + private static boolean keyval_pair_1_0(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "keyval_pair_1_0")) return false; + boolean r; + Marker m = enter_section_(b); + r = consumeToken(b, "="); + r = r && keyval_value(b, l + 1); + exit_section_(b, m, null, r); + return r; + } + + /* ********************************************************** */ + // keyval_content+ + public static boolean keyval_value(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "keyval_value")) return false; + boolean r; + Marker m = enter_section_(b, l, _NONE_, KEYVAL_VALUE, ""); + r = keyval_content(b, l + 1); + while (r) { + int c = current_position_(b); + if (!keyval_content(b, l + 1)) break; + if (!empty_element_parsed_guard_(b, "keyval_value", c)) break; + } + exit_section_(b, l, m, r, false, null); + return r; + } + /* ********************************************************** */ // content* static boolean latexFile(PsiBuilder b, int l) { @@ -382,7 +469,7 @@ private static boolean normal_text_0(PsiBuilder b, int l) { } /* ********************************************************** */ - // OPEN_BRACKET optional_param_content* CLOSE_BRACKET + // OPEN_BRACKET ( (keyval_pair ("," keyval_pair)*) | optional_param_content*) CLOSE_BRACKET public static boolean optional_param(PsiBuilder b, int l) { if (!recursion_guard_(b, l, "optional_param")) return false; if (!nextTokenIs(b, OPEN_BRACKET)) return false; @@ -395,19 +482,63 @@ public static boolean optional_param(PsiBuilder b, int l) { return r; } - // optional_param_content* + // (keyval_pair ("," keyval_pair)*) | optional_param_content* private static boolean optional_param_1(PsiBuilder b, int l) { if (!recursion_guard_(b, l, "optional_param_1")) return false; + boolean r; + Marker m = enter_section_(b); + r = optional_param_1_0(b, l + 1); + if (!r) r = optional_param_1_1(b, l + 1); + exit_section_(b, m, null, r); + return r; + } + + // keyval_pair ("," keyval_pair)* + private static boolean optional_param_1_0(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "optional_param_1_0")) return false; + boolean r; + Marker m = enter_section_(b); + r = keyval_pair(b, l + 1); + r = r && optional_param_1_0_1(b, l + 1); + exit_section_(b, m, null, r); + return r; + } + + // ("," keyval_pair)* + private static boolean optional_param_1_0_1(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "optional_param_1_0_1")) return false; + while (true) { + int c = current_position_(b); + if (!optional_param_1_0_1_0(b, l + 1)) break; + if (!empty_element_parsed_guard_(b, "optional_param_1_0_1", c)) break; + } + return true; + } + + // "," keyval_pair + private static boolean optional_param_1_0_1_0(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "optional_param_1_0_1_0")) return false; + boolean r; + Marker m = enter_section_(b); + r = consumeToken(b, ","); + r = r && keyval_pair(b, l + 1); + exit_section_(b, m, null, r); + return r; + } + + // optional_param_content* + private static boolean optional_param_1_1(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "optional_param_1_1")) return false; while (true) { int c = current_position_(b); if (!optional_param_content(b, l + 1)) break; - if (!empty_element_parsed_guard_(b, "optional_param_1", c)) break; + if (!empty_element_parsed_guard_(b, "optional_param_1_1", c)) break; } return true; } /* ********************************************************** */ - // raw_text | magic_comment | comment | environment | pseudocode_block | math_environment | COMMAND_IFNEXTCHAR | commands | group | OPEN_PAREN | CLOSE_PAREN | parameter_text + // raw_text | magic_comment | comment | environment | pseudocode_block | math_environment | COMMAND_IFNEXTCHAR | commands | group | OPEN_PAREN | CLOSE_PAREN | parameter_text | NORMAL_TEXT_CHAR public static boolean optional_param_content(PsiBuilder b, int l) { if (!recursion_guard_(b, l, "optional_param_content")) return false; boolean r; @@ -424,6 +555,7 @@ public static boolean optional_param_content(PsiBuilder b, int l) { if (!r) r = consumeToken(b, OPEN_PAREN); if (!r) r = consumeToken(b, CLOSE_PAREN); if (!r) r = parameter_text(b, l + 1); + if (!r) r = consumeToken(b, NORMAL_TEXT_CHAR); exit_section_(b, l, m, r, false, null); return r; } @@ -442,7 +574,7 @@ public static boolean parameter(PsiBuilder b, int l) { } /* ********************************************************** */ - // (commands | NORMAL_TEXT_WORD | STAR | AMPERSAND | NORMAL_TEXT_CHAR)+ + // (commands | NORMAL_TEXT_WORD | STAR | AMPERSAND)+ public static boolean parameter_text(PsiBuilder b, int l) { if (!recursion_guard_(b, l, "parameter_text")) return false; boolean r; @@ -457,7 +589,7 @@ public static boolean parameter_text(PsiBuilder b, int l) { return r; } - // commands | NORMAL_TEXT_WORD | STAR | AMPERSAND | NORMAL_TEXT_CHAR + // commands | NORMAL_TEXT_WORD | STAR | AMPERSAND private static boolean parameter_text_0(PsiBuilder b, int l) { if (!recursion_guard_(b, l, "parameter_text_0")) return false; boolean r; @@ -465,7 +597,6 @@ private static boolean parameter_text_0(PsiBuilder b, int l) { if (!r) r = consumeToken(b, NORMAL_TEXT_WORD); if (!r) r = consumeToken(b, STAR); if (!r) r = consumeToken(b, AMPERSAND); - if (!r) r = consumeToken(b, NORMAL_TEXT_CHAR); return r; } @@ -612,7 +743,7 @@ private static boolean required_param_1(PsiBuilder b, int l) { } /* ********************************************************** */ - // raw_text | magic_comment | comment | environment | pseudocode_block | math_environment | COMMAND_IFNEXTCHAR | group | OPEN_PAREN | CLOSE_PAREN | parameter_text | OPEN_BRACKET | CLOSE_BRACKET + // raw_text | magic_comment | comment | environment | pseudocode_block | math_environment | COMMAND_IFNEXTCHAR | group | OPEN_PAREN | CLOSE_PAREN | parameter_text | OPEN_BRACKET | CLOSE_BRACKET | NORMAL_TEXT_CHAR public static boolean required_param_content(PsiBuilder b, int l) { if (!recursion_guard_(b, l, "required_param_content")) return false; boolean r; @@ -630,6 +761,7 @@ public static boolean required_param_content(PsiBuilder b, int l) { if (!r) r = parameter_text(b, l + 1); if (!r) r = consumeToken(b, OPEN_BRACKET); if (!r) r = consumeToken(b, CLOSE_BRACKET); + if (!r) r = consumeToken(b, NORMAL_TEXT_CHAR); exit_section_(b, l, m, r, false, null); return r; } diff --git a/gen/nl/hannahsten/texifyidea/psi/LatexGreedyContent.java b/gen/nl/hannahsten/texifyidea/psi/LatexGreedyContent.java new file mode 100644 index 000000000..cbb2036d0 --- /dev/null +++ b/gen/nl/hannahsten/texifyidea/psi/LatexGreedyContent.java @@ -0,0 +1,13 @@ +// This is a generated file. Not intended for manual editing. +package nl.hannahsten.texifyidea.psi; + +import java.util.List; +import org.jetbrains.annotations.*; +import com.intellij.psi.PsiElement; + +public interface LatexGreedyContent extends PsiElement { + + @NotNull + LatexNoMathContent getNoMathContent(); + +} diff --git a/gen/nl/hannahsten/texifyidea/psi/LatexGroup.java b/gen/nl/hannahsten/texifyidea/psi/LatexGroup.java index e86ad9672..b5857b775 100644 --- a/gen/nl/hannahsten/texifyidea/psi/LatexGroup.java +++ b/gen/nl/hannahsten/texifyidea/psi/LatexGroup.java @@ -8,6 +8,6 @@ public interface LatexGroup extends PsiElement { @NotNull - List getContentList(); + List getContentList(); } diff --git a/gen/nl/hannahsten/texifyidea/psi/LatexKeyvalContent.java b/gen/nl/hannahsten/texifyidea/psi/LatexKeyvalContent.java new file mode 100644 index 000000000..781eaf64c --- /dev/null +++ b/gen/nl/hannahsten/texifyidea/psi/LatexKeyvalContent.java @@ -0,0 +1,16 @@ +// This is a generated file. Not intended for manual editing. +package nl.hannahsten.texifyidea.psi; + +import java.util.List; +import org.jetbrains.annotations.*; +import com.intellij.psi.PsiElement; + +public interface LatexKeyvalContent extends PsiElement { + + @Nullable + LatexGroup getGroup(); + + @Nullable + LatexParameterText getParameterText(); + +} diff --git a/gen/nl/hannahsten/texifyidea/psi/LatexKeyvalKey.java b/gen/nl/hannahsten/texifyidea/psi/LatexKeyvalKey.java new file mode 100644 index 000000000..3c04240fa --- /dev/null +++ b/gen/nl/hannahsten/texifyidea/psi/LatexKeyvalKey.java @@ -0,0 +1,13 @@ +// This is a generated file. Not intended for manual editing. +package nl.hannahsten.texifyidea.psi; + +import java.util.List; +import org.jetbrains.annotations.*; +import com.intellij.psi.PsiElement; + +public interface LatexKeyvalKey extends PsiElement { + + @NotNull + List getKeyvalContentList(); + +} diff --git a/gen/nl/hannahsten/texifyidea/psi/LatexKeyvalPair.java b/gen/nl/hannahsten/texifyidea/psi/LatexKeyvalPair.java new file mode 100644 index 000000000..3b742b43d --- /dev/null +++ b/gen/nl/hannahsten/texifyidea/psi/LatexKeyvalPair.java @@ -0,0 +1,16 @@ +// This is a generated file. Not intended for manual editing. +package nl.hannahsten.texifyidea.psi; + +import java.util.List; +import org.jetbrains.annotations.*; +import com.intellij.psi.PsiElement; + +public interface LatexKeyvalPair extends PsiElement { + + @NotNull + LatexKeyvalKey getKeyvalKey(); + + @Nullable + LatexKeyvalValue getKeyvalValue(); + +} diff --git a/gen/nl/hannahsten/texifyidea/psi/LatexKeyvalPairs.java b/gen/nl/hannahsten/texifyidea/psi/LatexKeyvalPairs.java new file mode 100644 index 000000000..41e52044a --- /dev/null +++ b/gen/nl/hannahsten/texifyidea/psi/LatexKeyvalPairs.java @@ -0,0 +1,13 @@ +// This is a generated file. Not intended for manual editing. +package nl.hannahsten.texifyidea.psi; + +import java.util.List; +import org.jetbrains.annotations.*; +import com.intellij.psi.PsiElement; + +public interface LatexKeyvalPairs extends PsiElement { + + @NotNull + List getKeyvalPairList(); + +} diff --git a/gen/nl/hannahsten/texifyidea/psi/LatexKeyvalText.java b/gen/nl/hannahsten/texifyidea/psi/LatexKeyvalText.java new file mode 100644 index 000000000..c19723f24 --- /dev/null +++ b/gen/nl/hannahsten/texifyidea/psi/LatexKeyvalText.java @@ -0,0 +1,13 @@ +// This is a generated file. Not intended for manual editing. +package nl.hannahsten.texifyidea.psi; + +import java.util.List; +import org.jetbrains.annotations.*; +import com.intellij.psi.PsiElement; + +public interface LatexKeyvalText extends PsiElement { + + @NotNull + PsiElement getNormalTextWord(); + +} diff --git a/gen/nl/hannahsten/texifyidea/psi/LatexKeyvalValue.java b/gen/nl/hannahsten/texifyidea/psi/LatexKeyvalValue.java new file mode 100644 index 000000000..577363dd2 --- /dev/null +++ b/gen/nl/hannahsten/texifyidea/psi/LatexKeyvalValue.java @@ -0,0 +1,13 @@ +// This is a generated file. Not intended for manual editing. +package nl.hannahsten.texifyidea.psi; + +import java.util.List; +import org.jetbrains.annotations.*; +import com.intellij.psi.PsiElement; + +public interface LatexKeyvalValue extends PsiElement { + + @NotNull + List getKeyvalContentList(); + +} diff --git a/gen/nl/hannahsten/texifyidea/psi/LatexOptionalParam.java b/gen/nl/hannahsten/texifyidea/psi/LatexOptionalParam.java index 80693c527..e78382926 100644 --- a/gen/nl/hannahsten/texifyidea/psi/LatexOptionalParam.java +++ b/gen/nl/hannahsten/texifyidea/psi/LatexOptionalParam.java @@ -7,6 +7,9 @@ public interface LatexOptionalParam extends PsiElement { + @NotNull + List getKeyvalPairList(); + @NotNull List getOptionalParamContentList(); diff --git a/gen/nl/hannahsten/texifyidea/psi/LatexOptionalParamContent.java b/gen/nl/hannahsten/texifyidea/psi/LatexOptionalParamContent.java index 1a0b4d5af..d5386c795 100644 --- a/gen/nl/hannahsten/texifyidea/psi/LatexOptionalParamContent.java +++ b/gen/nl/hannahsten/texifyidea/psi/LatexOptionalParamContent.java @@ -37,4 +37,7 @@ public interface LatexOptionalParamContent extends PsiElement { @Nullable PsiElement getCommandIfnextchar(); + @Nullable + PsiElement getNormalTextChar(); + } diff --git a/gen/nl/hannahsten/texifyidea/psi/LatexRequiredParamContent.java b/gen/nl/hannahsten/texifyidea/psi/LatexRequiredParamContent.java index 59d1072d6..506428d94 100644 --- a/gen/nl/hannahsten/texifyidea/psi/LatexRequiredParamContent.java +++ b/gen/nl/hannahsten/texifyidea/psi/LatexRequiredParamContent.java @@ -34,4 +34,7 @@ public interface LatexRequiredParamContent extends PsiElement { @Nullable PsiElement getCommandIfnextchar(); + @Nullable + PsiElement getNormalTextChar(); + } diff --git a/gen/nl/hannahsten/texifyidea/psi/LatexTypes.java b/gen/nl/hannahsten/texifyidea/psi/LatexTypes.java index 724ac4a27..234f3c578 100644 --- a/gen/nl/hannahsten/texifyidea/psi/LatexTypes.java +++ b/gen/nl/hannahsten/texifyidea/psi/LatexTypes.java @@ -19,8 +19,13 @@ public interface LatexTypes { IElementType END_COMMAND = new LatexElementType("END_COMMAND"); IElementType ENVIRONMENT = new LatexEnvironmentStubElementType("ENVIRONMENT"); IElementType ENVIRONMENT_CONTENT = new LatexElementType("ENVIRONMENT_CONTENT"); + IElementType GREEDY_CONTENT = new LatexElementType("GREEDY_CONTENT"); IElementType GROUP = new LatexElementType("GROUP"); IElementType INLINE_MATH = new LatexElementType("INLINE_MATH"); + IElementType KEYVAL_CONTENT = new LatexElementType("KEYVAL_CONTENT"); + IElementType KEYVAL_KEY = new LatexElementType("KEYVAL_KEY"); + IElementType KEYVAL_PAIR = new LatexElementType("KEYVAL_PAIR"); + IElementType KEYVAL_VALUE = new LatexElementType("KEYVAL_VALUE"); IElementType MAGIC_COMMENT = new LatexMagicCommentStubElementType("MAGIC_COMMENT"); IElementType MATH_CONTENT = new LatexElementType("MATH_CONTENT"); IElementType MATH_ENVIRONMENT = new LatexElementType("MATH_ENVIRONMENT"); @@ -88,12 +93,27 @@ else if (type == ENVIRONMENT) { else if (type == ENVIRONMENT_CONTENT) { return new LatexEnvironmentContentImpl(node); } + else if (type == GREEDY_CONTENT) { + return new LatexGreedyContentImpl(node); + } else if (type == GROUP) { return new LatexGroupImpl(node); } else if (type == INLINE_MATH) { return new LatexInlineMathImpl(node); } + else if (type == KEYVAL_CONTENT) { + return new LatexKeyvalContentImpl(node); + } + else if (type == KEYVAL_KEY) { + return new LatexKeyvalKeyImpl(node); + } + else if (type == KEYVAL_PAIR) { + return new LatexKeyvalPairImpl(node); + } + else if (type == KEYVAL_VALUE) { + return new LatexKeyvalValueImpl(node); + } else if (type == MAGIC_COMMENT) { return new LatexMagicCommentImpl(node); } diff --git a/gen/nl/hannahsten/texifyidea/psi/LatexVisitor.java b/gen/nl/hannahsten/texifyidea/psi/LatexVisitor.java index de75d1368..054a25dbe 100644 --- a/gen/nl/hannahsten/texifyidea/psi/LatexVisitor.java +++ b/gen/nl/hannahsten/texifyidea/psi/LatexVisitor.java @@ -42,6 +42,10 @@ public void visitEnvironmentContent(@NotNull LatexEnvironmentContent o) { visitPsiElement(o); } + public void visitGreedyContent(@NotNull LatexGreedyContent o) { + visitPsiElement(o); + } + public void visitGroup(@NotNull LatexGroup o) { visitPsiElement(o); } @@ -50,6 +54,22 @@ public void visitInlineMath(@NotNull LatexInlineMath o) { visitPsiElement(o); } + public void visitKeyvalContent(@NotNull LatexKeyvalContent o) { + visitPsiElement(o); + } + + public void visitKeyvalKey(@NotNull LatexKeyvalKey o) { + visitPsiElement(o); + } + + public void visitKeyvalPair(@NotNull LatexKeyvalPair o) { + visitPsiElement(o); + } + + public void visitKeyvalValue(@NotNull LatexKeyvalValue o) { + visitPsiElement(o); + } + public void visitMagicComment(@NotNull LatexMagicComment o) { visitPsiElement(o); } diff --git a/gen/nl/hannahsten/texifyidea/psi/impl/LatexGreedyContentImpl.java b/gen/nl/hannahsten/texifyidea/psi/impl/LatexGreedyContentImpl.java new file mode 100644 index 000000000..ec8cfcecf --- /dev/null +++ b/gen/nl/hannahsten/texifyidea/psi/impl/LatexGreedyContentImpl.java @@ -0,0 +1,36 @@ +// This is a generated file. Not intended for manual editing. +package nl.hannahsten.texifyidea.psi.impl; + +import java.util.List; +import org.jetbrains.annotations.*; +import com.intellij.lang.ASTNode; +import com.intellij.psi.PsiElement; +import com.intellij.psi.PsiElementVisitor; +import com.intellij.psi.util.PsiTreeUtil; +import static nl.hannahsten.texifyidea.psi.LatexTypes.*; +import com.intellij.extapi.psi.ASTWrapperPsiElement; +import nl.hannahsten.texifyidea.psi.*; + +public class LatexGreedyContentImpl extends ASTWrapperPsiElement implements LatexGreedyContent { + + public LatexGreedyContentImpl(@NotNull ASTNode node) { + super(node); + } + + public void accept(@NotNull LatexVisitor visitor) { + visitor.visitGreedyContent(this); + } + + @Override + public void accept(@NotNull PsiElementVisitor visitor) { + if (visitor instanceof LatexVisitor) accept((LatexVisitor)visitor); + else super.accept(visitor); + } + + @Override + @NotNull + public LatexNoMathContent getNoMathContent() { + return notNullChild(PsiTreeUtil.getChildOfType(this, LatexNoMathContent.class)); + } + +} diff --git a/gen/nl/hannahsten/texifyidea/psi/impl/LatexGroupImpl.java b/gen/nl/hannahsten/texifyidea/psi/impl/LatexGroupImpl.java index cb962e0d2..2be12d760 100644 --- a/gen/nl/hannahsten/texifyidea/psi/impl/LatexGroupImpl.java +++ b/gen/nl/hannahsten/texifyidea/psi/impl/LatexGroupImpl.java @@ -29,8 +29,8 @@ public void accept(@NotNull PsiElementVisitor visitor) { @Override @NotNull - public List getContentList() { - return PsiTreeUtil.getChildrenOfTypeAsList(this, LatexContent.class); + public List getContentList() { + return PsiTreeUtil.getChildrenOfTypeAsList(this, LatexGreedyContent.class); } } diff --git a/gen/nl/hannahsten/texifyidea/psi/impl/LatexKeyvalContentImpl.java b/gen/nl/hannahsten/texifyidea/psi/impl/LatexKeyvalContentImpl.java new file mode 100644 index 000000000..f529c3dc6 --- /dev/null +++ b/gen/nl/hannahsten/texifyidea/psi/impl/LatexKeyvalContentImpl.java @@ -0,0 +1,42 @@ +// This is a generated file. Not intended for manual editing. +package nl.hannahsten.texifyidea.psi.impl; + +import java.util.List; +import org.jetbrains.annotations.*; +import com.intellij.lang.ASTNode; +import com.intellij.psi.PsiElement; +import com.intellij.psi.PsiElementVisitor; +import com.intellij.psi.util.PsiTreeUtil; +import static nl.hannahsten.texifyidea.psi.LatexTypes.*; +import com.intellij.extapi.psi.ASTWrapperPsiElement; +import nl.hannahsten.texifyidea.psi.*; + +public class LatexKeyvalContentImpl extends ASTWrapperPsiElement implements LatexKeyvalContent { + + public LatexKeyvalContentImpl(@NotNull ASTNode node) { + super(node); + } + + public void accept(@NotNull LatexVisitor visitor) { + visitor.visitKeyvalContent(this); + } + + @Override + public void accept(@NotNull PsiElementVisitor visitor) { + if (visitor instanceof LatexVisitor) accept((LatexVisitor)visitor); + else super.accept(visitor); + } + + @Override + @Nullable + public LatexGroup getGroup() { + return PsiTreeUtil.getChildOfType(this, LatexGroup.class); + } + + @Override + @Nullable + public LatexParameterText getParameterText() { + return PsiTreeUtil.getChildOfType(this, LatexParameterText.class); + } + +} diff --git a/gen/nl/hannahsten/texifyidea/psi/impl/LatexKeyvalKeyImpl.java b/gen/nl/hannahsten/texifyidea/psi/impl/LatexKeyvalKeyImpl.java new file mode 100644 index 000000000..2265c2153 --- /dev/null +++ b/gen/nl/hannahsten/texifyidea/psi/impl/LatexKeyvalKeyImpl.java @@ -0,0 +1,36 @@ +// This is a generated file. Not intended for manual editing. +package nl.hannahsten.texifyidea.psi.impl; + +import java.util.List; +import org.jetbrains.annotations.*; +import com.intellij.lang.ASTNode; +import com.intellij.psi.PsiElement; +import com.intellij.psi.PsiElementVisitor; +import com.intellij.psi.util.PsiTreeUtil; +import static nl.hannahsten.texifyidea.psi.LatexTypes.*; +import com.intellij.extapi.psi.ASTWrapperPsiElement; +import nl.hannahsten.texifyidea.psi.*; + +public class LatexKeyvalKeyImpl extends ASTWrapperPsiElement implements LatexKeyvalKey { + + public LatexKeyvalKeyImpl(@NotNull ASTNode node) { + super(node); + } + + public void accept(@NotNull LatexVisitor visitor) { + visitor.visitKeyvalKey(this); + } + + @Override + public void accept(@NotNull PsiElementVisitor visitor) { + if (visitor instanceof LatexVisitor) accept((LatexVisitor)visitor); + else super.accept(visitor); + } + + @Override + @NotNull + public List getKeyvalContentList() { + return PsiTreeUtil.getChildrenOfTypeAsList(this, LatexKeyvalContent.class); + } + +} diff --git a/gen/nl/hannahsten/texifyidea/psi/impl/LatexKeyvalPairImpl.java b/gen/nl/hannahsten/texifyidea/psi/impl/LatexKeyvalPairImpl.java new file mode 100644 index 000000000..2113217e0 --- /dev/null +++ b/gen/nl/hannahsten/texifyidea/psi/impl/LatexKeyvalPairImpl.java @@ -0,0 +1,42 @@ +// This is a generated file. Not intended for manual editing. +package nl.hannahsten.texifyidea.psi.impl; + +import java.util.List; +import org.jetbrains.annotations.*; +import com.intellij.lang.ASTNode; +import com.intellij.psi.PsiElement; +import com.intellij.psi.PsiElementVisitor; +import com.intellij.psi.util.PsiTreeUtil; +import static nl.hannahsten.texifyidea.psi.LatexTypes.*; +import com.intellij.extapi.psi.ASTWrapperPsiElement; +import nl.hannahsten.texifyidea.psi.*; + +public class LatexKeyvalPairImpl extends ASTWrapperPsiElement implements LatexKeyvalPair { + + public LatexKeyvalPairImpl(@NotNull ASTNode node) { + super(node); + } + + public void accept(@NotNull LatexVisitor visitor) { + visitor.visitKeyvalPair(this); + } + + @Override + public void accept(@NotNull PsiElementVisitor visitor) { + if (visitor instanceof LatexVisitor) accept((LatexVisitor)visitor); + else super.accept(visitor); + } + + @Override + @NotNull + public LatexKeyvalKey getKeyvalKey() { + return notNullChild(PsiTreeUtil.getChildOfType(this, LatexKeyvalKey.class)); + } + + @Override + @Nullable + public LatexKeyvalValue getKeyvalValue() { + return PsiTreeUtil.getChildOfType(this, LatexKeyvalValue.class); + } + +} diff --git a/gen/nl/hannahsten/texifyidea/psi/impl/LatexKeyvalValueImpl.java b/gen/nl/hannahsten/texifyidea/psi/impl/LatexKeyvalValueImpl.java new file mode 100644 index 000000000..87309f46d --- /dev/null +++ b/gen/nl/hannahsten/texifyidea/psi/impl/LatexKeyvalValueImpl.java @@ -0,0 +1,36 @@ +// This is a generated file. Not intended for manual editing. +package nl.hannahsten.texifyidea.psi.impl; + +import java.util.List; +import org.jetbrains.annotations.*; +import com.intellij.lang.ASTNode; +import com.intellij.psi.PsiElement; +import com.intellij.psi.PsiElementVisitor; +import com.intellij.psi.util.PsiTreeUtil; +import static nl.hannahsten.texifyidea.psi.LatexTypes.*; +import com.intellij.extapi.psi.ASTWrapperPsiElement; +import nl.hannahsten.texifyidea.psi.*; + +public class LatexKeyvalValueImpl extends ASTWrapperPsiElement implements LatexKeyvalValue { + + public LatexKeyvalValueImpl(@NotNull ASTNode node) { + super(node); + } + + public void accept(@NotNull LatexVisitor visitor) { + visitor.visitKeyvalValue(this); + } + + @Override + public void accept(@NotNull PsiElementVisitor visitor) { + if (visitor instanceof LatexVisitor) accept((LatexVisitor)visitor); + else super.accept(visitor); + } + + @Override + @NotNull + public List getKeyvalContentList() { + return PsiTreeUtil.getChildrenOfTypeAsList(this, LatexKeyvalContent.class); + } + +} diff --git a/gen/nl/hannahsten/texifyidea/psi/impl/LatexOptionalParamContentImpl.java b/gen/nl/hannahsten/texifyidea/psi/impl/LatexOptionalParamContentImpl.java index 6eb557234..1e93e5221 100644 --- a/gen/nl/hannahsten/texifyidea/psi/impl/LatexOptionalParamContentImpl.java +++ b/gen/nl/hannahsten/texifyidea/psi/impl/LatexOptionalParamContentImpl.java @@ -87,4 +87,10 @@ public PsiElement getCommandIfnextchar() { return findChildByType(COMMAND_IFNEXTCHAR); } + @Override + @Nullable + public PsiElement getNormalTextChar() { + return findChildByType(NORMAL_TEXT_CHAR); + } + } diff --git a/gen/nl/hannahsten/texifyidea/psi/impl/LatexOptionalParamImpl.java b/gen/nl/hannahsten/texifyidea/psi/impl/LatexOptionalParamImpl.java index 0711c962e..2ee785fd8 100644 --- a/gen/nl/hannahsten/texifyidea/psi/impl/LatexOptionalParamImpl.java +++ b/gen/nl/hannahsten/texifyidea/psi/impl/LatexOptionalParamImpl.java @@ -27,6 +27,12 @@ public void accept(@NotNull PsiElementVisitor visitor) { else super.accept(visitor); } + @Override + @NotNull + public List getKeyvalPairList() { + return PsiTreeUtil.getChildrenOfTypeAsList(this, LatexKeyvalPair.class); + } + @Override @NotNull public List getOptionalParamContentList() { diff --git a/gen/nl/hannahsten/texifyidea/psi/impl/LatexRequiredParamContentImpl.java b/gen/nl/hannahsten/texifyidea/psi/impl/LatexRequiredParamContentImpl.java index b80ac31bc..4fdfaa8ff 100644 --- a/gen/nl/hannahsten/texifyidea/psi/impl/LatexRequiredParamContentImpl.java +++ b/gen/nl/hannahsten/texifyidea/psi/impl/LatexRequiredParamContentImpl.java @@ -81,4 +81,10 @@ public PsiElement getCommandIfnextchar() { return findChildByType(COMMAND_IFNEXTCHAR); } + @Override + @Nullable + public PsiElement getNormalTextChar() { + return findChildByType(NORMAL_TEXT_CHAR); + } + } diff --git a/src/nl/hannahsten/texifyidea/formatting/LatexBlock.kt b/src/nl/hannahsten/texifyidea/formatting/LatexBlock.kt index d568cf725..df61a6c16 100644 --- a/src/nl/hannahsten/texifyidea/formatting/LatexBlock.kt +++ b/src/nl/hannahsten/texifyidea/formatting/LatexBlock.kt @@ -53,6 +53,7 @@ class LatexBlock( // Indentation in groups and parameters. if (myNode.elementType === LatexTypes.REQUIRED_PARAM_CONTENT || myNode.elementType === LatexTypes.OPTIONAL_PARAM_CONTENT || + myNode.elementType === LatexTypes.KEYVAL_PAIR || (myNode.elementType !== LatexTypes.CLOSE_BRACE && myNode.treeParent?.elementType === LatexTypes.GROUP) ) { diff --git a/src/nl/hannahsten/texifyidea/grammar/Latex.bnf b/src/nl/hannahsten/texifyidea/grammar/Latex.bnf index d8501604d..1de8eafc4 100644 --- a/src/nl/hannahsten/texifyidea/grammar/Latex.bnf +++ b/src/nl/hannahsten/texifyidea/grammar/Latex.bnf @@ -1,7 +1,7 @@ { parserClass="nl.hannahsten.texifyidea.parser.LatexParser" parserUtilClass="nl.hannahsten.texifyidea.parser.LatexParserUtil" - + parserImports=["static com.intellij.lang.WhitespacesBinders.*"] extends="com.intellij.extapi.psi.ASTWrapperPsiElement" psiClassPrefix="Latex" @@ -52,10 +52,10 @@ } - latexFile ::= content* content ::= no_math_content +greedy_content ::= no_math_content { hooks = [wsBinders="GREEDY_LEFT_BINDER, GREEDY_RIGHT_BINDER"] } no_math_content ::= raw_text | magic_comment | comment | environment | pseudocode_block | math_environment | COMMAND_IFNEXTCHAR | commands | group | OPEN_PAREN | CLOSE_PAREN | OPEN_BRACKET | CLOSE_BRACKET | normal_text @@ -98,26 +98,31 @@ parameter ::= optional_param | required_param // will be seen as simply an open bracket, but '[x]' at the same location will // be parsed as optional parameter. // https://stackoverflow.com/a/48709143/6629569 -optional_param ::= OPEN_BRACKET optional_param_content* CLOSE_BRACKET { pin=3 } +optional_param ::= OPEN_BRACKET ( (keyval_pair ("," keyval_pair)*) | optional_param_content*) CLOSE_BRACKET { pin=3 } required_param ::= OPEN_BRACE required_param_content* CLOSE_BRACE { pin=1 } // These are like content, but no brackets and with parameter_text instead of normal_text // We have to separate optional and required parameter content, because required parameter content // can contain mismatched brackets, but optional parameters not (then we wouldn't know what to match) -optional_param_content ::= raw_text | magic_comment | comment | environment | pseudocode_block | math_environment | COMMAND_IFNEXTCHAR | commands | group | OPEN_PAREN | CLOSE_PAREN | parameter_text -required_param_content ::= raw_text | magic_comment | comment | environment | pseudocode_block | math_environment | COMMAND_IFNEXTCHAR | group | OPEN_PAREN | CLOSE_PAREN | parameter_text | OPEN_BRACKET | CLOSE_BRACKET +optional_param_content ::= raw_text | magic_comment | comment | environment | pseudocode_block | math_environment | COMMAND_IFNEXTCHAR | commands | group | OPEN_PAREN | CLOSE_PAREN | parameter_text | NORMAL_TEXT_CHAR +required_param_content ::= raw_text | magic_comment | comment | environment | pseudocode_block | math_environment | COMMAND_IFNEXTCHAR | group | OPEN_PAREN | CLOSE_PAREN | parameter_text | OPEN_BRACKET | CLOSE_BRACKET | NORMAL_TEXT_CHAR + +keyval_pair ::= keyval_key ("=" keyval_value)? +keyval_key ::= keyval_content+ +keyval_value ::= keyval_content+ +keyval_content ::= parameter_text | group // The lowest level of a parameter must have the getReferences etc. implemented // We don't do this on normal_text because then every normal_text in the document would be a reference // So, the following is like normal_text // This assumes that parameter text which is a reference, appears directly under param_content // Commands is here instead of in required_param_content because it can be part of reference text for example to a file -parameter_text ::= (commands | NORMAL_TEXT_WORD | STAR | AMPERSAND | NORMAL_TEXT_CHAR)+ { +parameter_text ::= (commands | NORMAL_TEXT_WORD | STAR | AMPERSAND)+ { methods=[getReferences getReference getNameIdentifier getName setName] } -group ::= OPEN_BRACE content* CLOSE_BRACE { pin=1 } +group ::= OPEN_BRACE greedy_content* CLOSE_BRACE { pin=1 methods=[contentList="greedy_content"] } comment ::= COMMENT_TOKEN diff --git a/src/nl/hannahsten/texifyidea/grammar/LatexLexer.flex b/src/nl/hannahsten/texifyidea/grammar/LatexLexer.flex index ff5a78658..26d6cce09 100644 --- a/src/nl/hannahsten/texifyidea/grammar/LatexLexer.flex +++ b/src/nl/hannahsten/texifyidea/grammar/LatexLexer.flex @@ -78,9 +78,9 @@ MAGIC_COMMENT_LEXER_SWITCH="%"{MAGIC_COMMENT_PREFIX} {WHITE_SPACE}? "parser" {WH LEXER_OFF_TOKEN={MAGIC_COMMENT_LEXER_SWITCH} "off" [^\r\n]* LEXER_ON_TOKEN={MAGIC_COMMENT_LEXER_SWITCH} "on" [^\r\n]* -NORMAL_TEXT_WORD=[^\s\\{}%\[\]$\(\)|!\"=&<>]+ +NORMAL_TEXT_WORD=[^\s\\\{\}%\[\]$\(\)|!\"=&<>,]+ // Separate from normal text, e.g. because they can be \verb delimiters or should not appear in normal text words for other reasons -NORMAL_TEXT_CHAR=[|!\"=&<>] +NORMAL_TEXT_CHAR=[|!\"=&<>,] ANY_CHAR=[^] // Algorithmicx @@ -363,5 +363,4 @@ END_PSEUDOCODE_BLOCK="\\EndFor" | "\\EndIf" | "\\EndWhile" | "\\Until" | "\\EndL {COMMENT_TOKEN} { return COMMENT_TOKEN; } {NORMAL_TEXT_WORD} { return NORMAL_TEXT_WORD; } {NORMAL_TEXT_CHAR} { return NORMAL_TEXT_CHAR; } - [^] { return com.intellij.psi.TokenType.BAD_CHARACTER; } diff --git a/src/nl/hannahsten/texifyidea/inspections/latex/LatexLabelConventionInspection.kt b/src/nl/hannahsten/texifyidea/inspections/latex/LatexLabelConventionInspection.kt index 2c356a432..9868095c0 100644 --- a/src/nl/hannahsten/texifyidea/inspections/latex/LatexLabelConventionInspection.kt +++ b/src/nl/hannahsten/texifyidea/inspections/latex/LatexLabelConventionInspection.kt @@ -134,7 +134,7 @@ open class LatexLabelConventionInspection : TexifyInspectionBase() { // Replace in command label definition if (command is LatexCommands) { if (Magic.Command.labelAsParameter.contains(command.name)) { - latexPsiHelper.replaceOptionalParameter(command.parameterList, "label", createdLabel) + latexPsiHelper.setOptionalParameter(command, "label", "{$createdLabel}") } else { val labelInfo = CommandManager.labelAliasesInfo.getOrDefault(command.name, null) ?: return @@ -148,7 +148,7 @@ open class LatexLabelConventionInspection : TexifyInspectionBase() { // Replace in environment if (command is LatexEnvironment) { - latexPsiHelper.replaceOptionalParameter(command.beginCommand.parameterList, "label", createdLabel) + latexPsiHelper.setOptionalParameter(command.beginCommand, "label", "{$createdLabel}") } // Replace in document. diff --git a/src/nl/hannahsten/texifyidea/inspections/latex/LatexMissingLabelInspection.kt b/src/nl/hannahsten/texifyidea/inspections/latex/LatexMissingLabelInspection.kt index 58b70524b..fc7bb5623 100644 --- a/src/nl/hannahsten/texifyidea/inspections/latex/LatexMissingLabelInspection.kt +++ b/src/nl/hannahsten/texifyidea/inspections/latex/LatexMissingLabelInspection.kt @@ -187,8 +187,7 @@ open class LatexMissingLabelInspection : TexifyInspectionBase() { val moveCaretAfter: PsiElement moveCaretAfter = if (Magic.Environment.labelAsParameter.contains(command.environmentName)) { - val insertedElements = helper.addOptionalParameter(command.beginCommand, "label", createdLabel) - insertedElements.last() + helper.setOptionalParameter(command.beginCommand, "label", "{$createdLabel}") } else { // in a float environment the label must be inserted after a caption diff --git a/src/nl/hannahsten/texifyidea/intentions/LatexAddLabelIntention.kt b/src/nl/hannahsten/texifyidea/intentions/LatexAddLabelIntention.kt index 763e1dedd..64e286973 100644 --- a/src/nl/hannahsten/texifyidea/intentions/LatexAddLabelIntention.kt +++ b/src/nl/hannahsten/texifyidea/intentions/LatexAddLabelIntention.kt @@ -68,8 +68,7 @@ open class LatexAddLabelIntention(val command: SmartPsiElementPointer, Serializable { val definedCommand = commandDefinition.requiredParameter(0) ?: return@forEach if (definedCommand.isBlank()) return@forEach - val isFirstParameterOptional = commandDefinition.optionalParameters.size > 1 + val isFirstParameterOptional = commandDefinition.parameterList.filter { it.optionalParam != null }.size > 1 val parameterCommands = commandDefinition.requiredParameters().getOrNull(1) ?.requiredParamContentList diff --git a/src/nl/hannahsten/texifyidea/psi/LatexCommandsImplUtil.kt b/src/nl/hannahsten/texifyidea/psi/LatexCommandsImplUtil.kt index fcc274327..709ee98a7 100644 --- a/src/nl/hannahsten/texifyidea/psi/LatexCommandsImplUtil.kt +++ b/src/nl/hannahsten/texifyidea/psi/LatexCommandsImplUtil.kt @@ -153,36 +153,27 @@ fun stripGroup(text: String): String { */ // Explicitly use a LinkedHashMap to preserve iteration order fun getOptionalParameters(parameters: List): LinkedHashMap { - val parameterMap = LinkedHashMap() // Parameters can be defined using multiple optional parameters, like \command[opt1][opt2]{req1} // But within a parameter, there can be different content like [name={value in group}] - val parameterString = parameters.mapNotNull { it.optionalParam } + val keyValueMap = parameters.mapNotNull { it.optionalParam } // extract the content of each parameter element - .map { param -> - param.optionalParamContentList - } - .map { contentList -> - contentList.mapNotNull { content: LatexOptionalParamContent -> - // the content is either simple text - val text = content.parameterText - if (text != null) return@mapNotNull text.text - // or a group like in param={some value} - if (content.group == null) return@mapNotNull null - content.group!!.contentList.joinToString { it.text } - } - // Join different content types (like name= and {value}) together without separator - .joinToString("") + .flatMap { param -> + param.keyvalPairList + }.map { pair -> + pair.keyvalKey to pair.keyvalValue } - // Join different parameters (like [param1][param2]) together with separator - .joinToString(",") - if (parameterString.trim { it <= ' ' }.isNotEmpty()) { - for (parameter in parameterString.split(",")) { - val parts = parameter.split("=".toRegex()).toTypedArray() - parameterMap[parts[0].trim()] = if (parts.size > 1) parts[1].trim() else "" - } + val parameterMap = LinkedHashMap() + keyValueMap.forEach{ pair -> + // the content is either simple text + val keyText: String = pair.first.keyvalContentList.map { it -> it.parameterText?.text ?: it.group!!.contentList.joinToString(separator = "") {it.text} }.joinToString(separator = "") + val valueText: String = pair.second?.keyvalContentList?.map { it -> it.parameterText?.text ?: it.group!!.contentList.joinToString(separator = "") {it.text} }?.joinToString(separator = "") ?: "" +// val valueText: String = pair.second?.normalTextWord?.text ?: (pair.second?.group?.contentList?.joinToString { it.text } ?: "") + parameterMap[keyText] = valueText } + return parameterMap + } fun getRequiredParameters(parameters: List): List? { diff --git a/src/nl/hannahsten/texifyidea/psi/LatexPsiHelper.kt b/src/nl/hannahsten/texifyidea/psi/LatexPsiHelper.kt index a22e5c6fb..c3553eb7e 100644 --- a/src/nl/hannahsten/texifyidea/psi/LatexPsiHelper.kt +++ b/src/nl/hannahsten/texifyidea/psi/LatexPsiHelper.kt @@ -3,7 +3,11 @@ package nl.hannahsten.texifyidea.psi import com.intellij.openapi.project.Project import com.intellij.psi.PsiElement import com.intellij.psi.PsiFileFactory +import com.intellij.psi.impl.source.tree.LeafPsiElement import nl.hannahsten.texifyidea.LatexLanguage +import nl.hannahsten.texifyidea.psi.LatexTypes.CLOSE_BRACKET +import nl.hannahsten.texifyidea.psi.LatexTypes.NORMAL_TEXT_CHAR +import nl.hannahsten.texifyidea.util.childrenOfType import nl.hannahsten.texifyidea.util.findFirstChild import nl.hannahsten.texifyidea.util.firstChildOfType @@ -33,11 +37,11 @@ class LatexPsiHelper(private val project: Project) { return fileFromText.firstChild } - private fun createOptionalParameterContent(parameter: String): List { + private fun createKeyValuePairs(parameter: String): LatexKeyvalPair { val commandText = "\\begin{lstlisting}[$parameter]" val environment = createFromText(commandText).firstChildOfType(LatexEnvironment::class)!! val optionalParam = environment.beginCommand.firstChildOfType(LatexOptionalParam::class)!! - return optionalParam.optionalParamContentList + return optionalParam.keyvalPairList[0] } fun createFromText(text: String): PsiElement = @@ -102,18 +106,55 @@ class LatexPsiHelper(private val project: Project) { } } - val newContents = createOptionalParameterContent(parameterText) - newContents.forEach { optionalParam.addBefore(it, elementsToReplace.first()) } + val newContents = createKeyValuePairs(parameterText) +// newContents.forEach { optionalParam.addBefore(it, elementsToReplace.first()) } elementsToReplace.forEach { it.delete() } } + fun setOptionalParameter(command: LatexCommandWithParams, name: String, value: String?): PsiElement { + val existingParameters = command.optionalParameters + if (existingParameters.isEmpty()) { + command.addAfter(createLatexOptionalParam(), command.parameterList[0]) + } + + val optionalParam = command.parameterList + .first { p -> p.optionalParam != null }.optionalParam!! + + val parameterText = if (value != null) { + "$name=$value" + } + else { + name + } + + val pair = createKeyValuePairs(parameterText) + val closeBracket = optionalParam.childrenOfType().first { it.elementType == CLOSE_BRACKET } + return if (optionalParam.keyvalPairList.isNotEmpty()) { + val existing = optionalParam.keyvalPairList.find { kv -> kv.keyvalKey.text == name } + if (existing != null && value != null) { + existing.keyvalValue?.delete() + existing.addAfter(pair.keyvalValue!!, existing.childrenOfType().first { it.text == "=" }) + existing + } + else { + optionalParam.addBefore(createFromText(","), closeBracket) + optionalParam.addBefore(pair, closeBracket) + closeBracket.prevSibling + } + } + else { + optionalParam.addBefore(pair, closeBracket) + closeBracket.prevSibling + } + } + /** * Add an optional parameter of the form "param" or "param={value}" to the list of optional parameters. * If there already are optional parameters, the new parameter will be appended with a "," as the separator. * * @return A list containing the newly inserted elements from left to right */ - fun addOptionalParameter(command: LatexCommandWithParams, name: String, value: String?): List { + fun addOptionalParameter(command: LatexCommandWithParams, name: String, value: String?): PsiElement { val existingParameters = command.optionalParameters if (existingParameters.isEmpty()) { command.addAfter(createLatexOptionalParam(), command.parameterList[0]) @@ -122,22 +163,19 @@ class LatexPsiHelper(private val project: Project) { val optionalParam = command.parameterList .first { p -> p.optionalParam != null }.optionalParam!! - var parameterText = if (value != null) { + val parameterText = if (value != null) { "$name={$value}" } else { name } - if (existingParameters.isNotEmpty()) { - parameterText = ",$parameterText" - } - val newElements = mutableListOf() - val contents = createOptionalParameterContent(parameterText) - contents.forEach { - val inserted = optionalParam.addBefore(it, optionalParam.lastChild) - newElements.add(inserted) + val pair = createKeyValuePairs(parameterText) + val closeBracket = optionalParam.childrenOfType().first { it.elementType == CLOSE_BRACKET } + if (optionalParam.keyvalPairList.isNotEmpty()){ + optionalParam.addBefore(LeafPsiElement(NORMAL_TEXT_CHAR, ","), closeBracket) } - return newElements + optionalParam.addBefore(pair, closeBracket) + return pair } } \ No newline at end of file diff --git a/test/nl/hannahsten/texifyidea/psi/LatexCommandsImplUtilTest.kt b/test/nl/hannahsten/texifyidea/psi/LatexCommandsImplUtilTest.kt new file mode 100644 index 000000000..3328df7c2 --- /dev/null +++ b/test/nl/hannahsten/texifyidea/psi/LatexCommandsImplUtilTest.kt @@ -0,0 +1,140 @@ +package nl.hannahsten.texifyidea.psi + +import com.intellij.psi.PsiDocumentManager +import com.intellij.testFramework.fixtures.BasePlatformTestCase +import nl.hannahsten.texifyidea.file.LatexFileType +import nl.hannahsten.texifyidea.util.firstChildOfType +import org.junit.Test + +class LatexCommandsImplUtilTest : BasePlatformTestCase(){ + @Test + fun `test simple optional parameters map`() { + // given + myFixture.configureByText(LatexFileType, + """ + \begin{document} + \lstinputlisting[param1=value1,param2=value2,param3]{some/file} + \end{document} + """.trimIndent() + ) + + // when + val parameters = PsiDocumentManager.getInstance(myFixture.project) + .getPsiFile(myFixture.editor.document)!! + .children + .first() + .firstChildOfType(LatexCommands::class)!! + .parameterList + + val map = getOptionalParameters(parameters) + assertSize(3, map.keys) + assertEquals("value1", map["param1"]) + assertEquals("value2", map["param2"]) + assertEquals("", map["param3"]) + } + + @Test + fun `test simple optional parameters map with whitespaces`() { + // given + myFixture.configureByText(LatexFileType, + """ + \begin{document} + \lstinputlisting[param1 = value1 , param2=value2]{some/file} + \end{document} + """.trimIndent() + ) + + // when + val parameters = PsiDocumentManager.getInstance(myFixture.project) + .getPsiFile(myFixture.editor.document)!! + .children + .first() + .firstChildOfType(LatexCommands::class)!! + .parameterList + + val map = getOptionalParameters(parameters) + assertSize(2, map.keys) + assertEquals("value1", map["param1"]) + assertEquals("value2", map["param2"]) + } + + @Test + fun `test multiple optional parameters map`() { + // given + myFixture.configureByText(LatexFileType, + """ + \begin{document} + \lstinputlisting[param1=value1][param2=value2,param3]{some/file} + \end{document} + """.trimIndent() + ) + + // when + val parameters = PsiDocumentManager.getInstance(myFixture.project) + .getPsiFile(myFixture.editor.document)!! + .children + .first() + .firstChildOfType(LatexCommands::class)!! + .parameterList + + val map = getOptionalParameters(parameters) + assertSize(3, map.keys) + assertEquals("value1", map["param1"]) + assertEquals("value2", map["param2"]) + assertEquals("", map["param3"]) + } + + @Test + fun `test grouped optional parameters map`() { + // given + myFixture.configureByText(LatexFileType, + """ + \begin{document} + \lstinputlisting[param1={value11,value12},param2=value2,{param3,param4}=value3,onlykey,param5={x=y},param6={ with space }{parts}]{some/file} + \end{document} + """.trimIndent() + ) + + // when + val parameters = PsiDocumentManager.getInstance(myFixture.project) + .getPsiFile(myFixture.editor.document)!! + .children + .first() + .firstChildOfType(LatexCommands::class)!! + .parameterList + + val map = getOptionalParameters(parameters) + assertSize(6, map.keys) + assertEquals("value11,value12", map["param1"]) + assertEquals("value2", map["param2"]) + assertEquals("value3", map["param3,param4"]) + assertEquals("", map["onlykey"]) + assertEquals("x=y", map["param5"]) + assertEquals(" with space parts", map["param6"]) + } + + @Test + fun `test grouped key optional parameters map`() { + // given + myFixture.configureByText(LatexFileType, + """ + \begin{document} + \lstinputlisting[{param1}=value1,param2=value2]{some/file} + \end{document} + """.trimIndent() + ) + + // when + val parameters = PsiDocumentManager.getInstance(myFixture.project) + .getPsiFile(myFixture.editor.document)!! + .children + .first() + .firstChildOfType(LatexCommands::class)!! + .parameterList + + val map = getOptionalParameters(parameters) + assertSize(2, map.keys) + assertEquals("value1", map["param1"]) + assertEquals("value2", map["param2"]) + } +} \ No newline at end of file From d4eaca24acb7402d50d357066199ad771c062536 Mon Sep 17 00:00:00 2001 From: Felix Berlakovich Date: Wed, 23 Dec 2020 19:05:58 +0100 Subject: [PATCH 10/20] Implement reference resolving for parametertext labels (groups and rename not working yet) --- .../texifyidea/psi/LatexBeginCommand.java | 2 +- .../texifyidea/psi/LatexCommands.java | 2 +- .../psi/impl/LatexBeginCommandImpl.java | 4 +- .../psi/impl/LatexCommandsImpl.java | 4 +- .../psi/impl/LatexKeyvalKeyImpl.java | 5 ++ .../psi/impl/LatexKeyvalValueImpl.java | 5 ++ .../texifyidea/psi/LatexCommandWithParams.kt | 2 +- .../completion/LatexCommandProvider.kt | 5 +- .../hannahsten/texifyidea/grammar/Latex.bnf | 12 ++-- .../stub/LatexCommandsStubElementType.kt | 3 +- .../texifyidea/psi/LatexCommandsImplUtil.kt | 37 +++++----- .../texifyidea/psi/LatexEnvironmentUtil.kt | 2 +- .../texifyidea/psi/LatexLanguageInjector.kt | 2 +- .../texifyidea/psi/LatexPsiHelper.kt | 69 +------------------ .../texifyidea/psi/LatexPsiImplUtil.java | 23 ++++--- .../texifyidea/run/latex/MakeindexUtil.kt | 5 +- .../latex/LatexNewCommandPresentation.kt | 3 +- src/nl/hannahsten/texifyidea/util/Labels.kt | 32 +++++++-- src/nl/hannahsten/texifyidea/util/Packages.kt | 5 +- .../psi/LatexCommandsImplUtilTest.kt | 10 +-- .../texifyidea/psi/LatexPsiImplUtilTest.kt | 12 ++-- .../reference/LabelDefinitionReferenceTest.kt | 63 +++++++++++++++++ 22 files changed, 173 insertions(+), 134 deletions(-) create mode 100644 test/nl/hannahsten/texifyidea/reference/LabelDefinitionReferenceTest.kt diff --git a/gen/nl/hannahsten/texifyidea/psi/LatexBeginCommand.java b/gen/nl/hannahsten/texifyidea/psi/LatexBeginCommand.java index a57b21edf..da8a8ba12 100644 --- a/gen/nl/hannahsten/texifyidea/psi/LatexBeginCommand.java +++ b/gen/nl/hannahsten/texifyidea/psi/LatexBeginCommand.java @@ -11,7 +11,7 @@ public interface LatexBeginCommand extends LatexCommandWithParams { @NotNull List getParameterList(); - LinkedHashMap getOptionalParameters(); + LinkedHashMap getOptionalParameterMap(); List getRequiredParameters(); diff --git a/gen/nl/hannahsten/texifyidea/psi/LatexCommands.java b/gen/nl/hannahsten/texifyidea/psi/LatexCommands.java index 974784233..e7783b2ca 100644 --- a/gen/nl/hannahsten/texifyidea/psi/LatexCommands.java +++ b/gen/nl/hannahsten/texifyidea/psi/LatexCommands.java @@ -22,7 +22,7 @@ public interface LatexCommands extends PsiNameIdentifierOwner, LatexCommandWithP PsiReference getReference(); - LinkedHashMap getOptionalParameters(); + LinkedHashMap getOptionalParameterMap(); List getRequiredParameters(); diff --git a/gen/nl/hannahsten/texifyidea/psi/impl/LatexBeginCommandImpl.java b/gen/nl/hannahsten/texifyidea/psi/impl/LatexBeginCommandImpl.java index 335d8e898..0e24b9741 100644 --- a/gen/nl/hannahsten/texifyidea/psi/impl/LatexBeginCommandImpl.java +++ b/gen/nl/hannahsten/texifyidea/psi/impl/LatexBeginCommandImpl.java @@ -35,8 +35,8 @@ public List getParameterList() { } @Override - public LinkedHashMap getOptionalParameters() { - return LatexPsiImplUtil.getOptionalParameters(this); + public LinkedHashMap getOptionalParameterMap() { + return LatexPsiImplUtil.getOptionalParameterMap(this); } @Override diff --git a/gen/nl/hannahsten/texifyidea/psi/impl/LatexCommandsImpl.java b/gen/nl/hannahsten/texifyidea/psi/impl/LatexCommandsImpl.java index 6e5806084..a4ca5a8bd 100644 --- a/gen/nl/hannahsten/texifyidea/psi/impl/LatexCommandsImpl.java +++ b/gen/nl/hannahsten/texifyidea/psi/impl/LatexCommandsImpl.java @@ -63,8 +63,8 @@ public PsiReference getReference() { } @Override - public LinkedHashMap getOptionalParameters() { - return LatexPsiImplUtil.getOptionalParameters(this); + public LinkedHashMap getOptionalParameterMap() { + return LatexPsiImplUtil.getOptionalParameterMap(this); } @Override diff --git a/gen/nl/hannahsten/texifyidea/psi/impl/LatexKeyvalKeyImpl.java b/gen/nl/hannahsten/texifyidea/psi/impl/LatexKeyvalKeyImpl.java index 2265c2153..2df966268 100644 --- a/gen/nl/hannahsten/texifyidea/psi/impl/LatexKeyvalKeyImpl.java +++ b/gen/nl/hannahsten/texifyidea/psi/impl/LatexKeyvalKeyImpl.java @@ -33,4 +33,9 @@ public List getKeyvalContentList() { return PsiTreeUtil.getChildrenOfTypeAsList(this, LatexKeyvalContent.class); } + @Override + public String toString() { + return LatexPsiImplUtil.toString(this); + } + } diff --git a/gen/nl/hannahsten/texifyidea/psi/impl/LatexKeyvalValueImpl.java b/gen/nl/hannahsten/texifyidea/psi/impl/LatexKeyvalValueImpl.java index 87309f46d..a9f9256ca 100644 --- a/gen/nl/hannahsten/texifyidea/psi/impl/LatexKeyvalValueImpl.java +++ b/gen/nl/hannahsten/texifyidea/psi/impl/LatexKeyvalValueImpl.java @@ -33,4 +33,9 @@ public List getKeyvalContentList() { return PsiTreeUtil.getChildrenOfTypeAsList(this, LatexKeyvalContent.class); } + @Override + public String toString() { + return LatexPsiImplUtil.toString(this); + } + } diff --git a/src/main/kotlin/nl/hannahsten/texifyidea/psi/LatexCommandWithParams.kt b/src/main/kotlin/nl/hannahsten/texifyidea/psi/LatexCommandWithParams.kt index 5289ddee3..5ff63a1f7 100644 --- a/src/main/kotlin/nl/hannahsten/texifyidea/psi/LatexCommandWithParams.kt +++ b/src/main/kotlin/nl/hannahsten/texifyidea/psi/LatexCommandWithParams.kt @@ -5,5 +5,5 @@ import com.intellij.psi.PsiElement interface LatexCommandWithParams : PsiElement { val parameterList: List val requiredParameters: List - val optionalParameters: Map + val optionalParameterMap: Map } \ No newline at end of file diff --git a/src/nl/hannahsten/texifyidea/completion/LatexCommandProvider.kt b/src/nl/hannahsten/texifyidea/completion/LatexCommandProvider.kt index c6de6089c..e48985e29 100644 --- a/src/nl/hannahsten/texifyidea/completion/LatexCommandProvider.kt +++ b/src/nl/hannahsten/texifyidea/completion/LatexCommandProvider.kt @@ -18,6 +18,7 @@ import nl.hannahsten.texifyidea.index.LatexCommandsIndex import nl.hannahsten.texifyidea.index.LatexDefinitionIndex import nl.hannahsten.texifyidea.lang.* import nl.hannahsten.texifyidea.psi.LatexCommands +import nl.hannahsten.texifyidea.psi.toStringMap import nl.hannahsten.texifyidea.util.* import nl.hannahsten.texifyidea.util.Kindness.getKindWords import nl.hannahsten.texifyidea.util.files.* @@ -196,7 +197,7 @@ class LatexCommandProvider internal constructor(private val mode: LatexMode) : private fun getTailText(commands: LatexCommands): String { return when (commands.commandToken.text) { "\\newcommand" -> { - val optional: List = LinkedList(commands.optionalParameters.keys) + val optional: List = LinkedList(commands.optionalParameterMap.toStringMap().keys) var requiredParameterCount = 0 if (optional.isNotEmpty()) { try { @@ -213,7 +214,7 @@ class LatexCommandProvider internal constructor(private val mode: LatexMode) : "\\DeclarePairedDelimiter" -> "{param}" "\\DeclarePairedDelimiterX", "\\DeclarePairedDelimiterXPP" -> { - val optional = commands.optionalParameters.keys.firstOrNull() + val optional = commands.optionalParameterMap.toStringMap().keys.firstOrNull() val nrParams = try { optional?.toInt() ?: 0 } diff --git a/src/nl/hannahsten/texifyidea/grammar/Latex.bnf b/src/nl/hannahsten/texifyidea/grammar/Latex.bnf index 1de8eafc4..d999e2630 100644 --- a/src/nl/hannahsten/texifyidea/grammar/Latex.bnf +++ b/src/nl/hannahsten/texifyidea/grammar/Latex.bnf @@ -80,13 +80,13 @@ commands ::= COMMAND_TOKEN STAR? parameter* { elementTypeClass="nl.hannahsten.texifyidea.index.stub.LatexCommandsStubElementType" stubClass="nl.hannahsten.texifyidea.index.stub.LatexCommandsStub" mixin="nl.hannahsten.texifyidea.psi.LatexCommandsImplMixin" - methods=[getReferences getReference getOptionalParameters getRequiredParameters hasLabel getTextOffset getName setName] + methods=[getReferences getReference getOptionalParameterMap getRequiredParameters hasLabel getTextOffset getName setName] } begin_command ::= BEGIN_TOKEN STAR? parameter* { pin=1 - methods=[getOptionalParameters getRequiredParameters] + methods=[getOptionalParameterMap getRequiredParameters] } end_command ::= END_TOKEN STAR? parameter* { pin=1 } @@ -109,8 +109,12 @@ optional_param_content ::= raw_text | magic_comment | comment | environment | ps required_param_content ::= raw_text | magic_comment | comment | environment | pseudocode_block | math_environment | COMMAND_IFNEXTCHAR | group | OPEN_PAREN | CLOSE_PAREN | parameter_text | OPEN_BRACKET | CLOSE_BRACKET | NORMAL_TEXT_CHAR keyval_pair ::= keyval_key ("=" keyval_value)? -keyval_key ::= keyval_content+ -keyval_value ::= keyval_content+ +keyval_key ::= keyval_content+ { + methods=[toString] +} +keyval_value ::= keyval_content+ { + methods=[toString] +} keyval_content ::= parameter_text | group // The lowest level of a parameter must have the getReferences etc. implemented diff --git a/src/nl/hannahsten/texifyidea/index/stub/LatexCommandsStubElementType.kt b/src/nl/hannahsten/texifyidea/index/stub/LatexCommandsStubElementType.kt index c18f0afe7..ea6da867a 100644 --- a/src/nl/hannahsten/texifyidea/index/stub/LatexCommandsStubElementType.kt +++ b/src/nl/hannahsten/texifyidea/index/stub/LatexCommandsStubElementType.kt @@ -5,6 +5,7 @@ import nl.hannahsten.texifyidea.LatexLanguage import nl.hannahsten.texifyidea.index.* import nl.hannahsten.texifyidea.psi.LatexCommands import nl.hannahsten.texifyidea.psi.impl.LatexCommandsImpl +import nl.hannahsten.texifyidea.psi.toStringMap import nl.hannahsten.texifyidea.util.Magic import nl.hannahsten.texifyidea.util.getIncludeCommands import java.io.IOException @@ -29,7 +30,7 @@ class LatexCommandsStubElementType(debugName: String) : val commandToken = latexCommands.commandToken.text val requiredParameters = latexCommands.requiredParameters val optionalParameters: Map = - latexCommands.optionalParameters + latexCommands.optionalParameterMap.toStringMap() return LatexCommandsStubImpl( parent!!, this, commandToken, diff --git a/src/nl/hannahsten/texifyidea/psi/LatexCommandsImplUtil.kt b/src/nl/hannahsten/texifyidea/psi/LatexCommandsImplUtil.kt index 709ee98a7..01404aba1 100644 --- a/src/nl/hannahsten/texifyidea/psi/LatexCommandsImplUtil.kt +++ b/src/nl/hannahsten/texifyidea/psi/LatexCommandsImplUtil.kt @@ -152,28 +152,25 @@ fun stripGroup(text: String): String { * If a value does not have a name, the value will be the key in the hashmap mapping to the empty string. */ // Explicitly use a LinkedHashMap to preserve iteration order -fun getOptionalParameters(parameters: List): LinkedHashMap { +fun Map.toStringMap(): LinkedHashMap { + val parameterMap = LinkedHashMap() + this.forEach { (k, v) -> parameterMap[k.toString()] = v?.toString() ?: "" } + return parameterMap +} + +fun getOptionalParameterMap(parameters: List): LinkedHashMap { + + val parameterMap = LinkedHashMap() // Parameters can be defined using multiple optional parameters, like \command[opt1][opt2]{req1} // But within a parameter, there can be different content like [name={value in group}] - val keyValueMap = parameters.mapNotNull { it.optionalParam } + parameters.mapNotNull { it.optionalParam } // extract the content of each parameter element .flatMap { param -> param.keyvalPairList - }.map { pair -> - pair.keyvalKey to pair.keyvalValue + }.forEach { pair -> + parameterMap[pair.keyvalKey] = pair.keyvalValue } - - val parameterMap = LinkedHashMap() - keyValueMap.forEach{ pair -> - // the content is either simple text - val keyText: String = pair.first.keyvalContentList.map { it -> it.parameterText?.text ?: it.group!!.contentList.joinToString(separator = "") {it.text} }.joinToString(separator = "") - val valueText: String = pair.second?.keyvalContentList?.map { it -> it.parameterText?.text ?: it.group!!.contentList.joinToString(separator = "") {it.text} }?.joinToString(separator = "") ?: "" -// val valueText: String = pair.second?.normalTextWord?.text ?: (pair.second?.group?.contentList?.joinToString { it.text } ?: "") - parameterMap[keyText] = valueText - } - return parameterMap - } fun getRequiredParameters(parameters: List): List? { @@ -193,7 +190,7 @@ fun LatexCommands.extractUrlReferences(firstParam: LatexRequiredParam): Array it.parameterText?.text ?: it.group!!.contentList.joinToString(separator = "") {it.text} }.joinToString(separator = "") + +fun toString(element: LatexKeyvalValue): String = + element.keyvalContentList.map { it -> it.parameterText?.text ?: it.group!!.contentList.joinToString(separator = "") {it.text} }.joinToString(separator = "") diff --git a/src/nl/hannahsten/texifyidea/psi/LatexEnvironmentUtil.kt b/src/nl/hannahsten/texifyidea/psi/LatexEnvironmentUtil.kt index f5c15b5ed..fe4934852 100644 --- a/src/nl/hannahsten/texifyidea/psi/LatexEnvironmentUtil.kt +++ b/src/nl/hannahsten/texifyidea/psi/LatexEnvironmentUtil.kt @@ -18,7 +18,7 @@ fun getLabel(element: LatexEnvironment): String? { if (stub != null) return stub.label return if (Magic.Environment.labelAsParameter.contains(element.environmentName)) { // See if we can find a label option - val optionalParameters = getOptionalParameters(element.beginCommand.parameterList) + val optionalParameters = getOptionalParameterMap(element.beginCommand.parameterList).toStringMap() optionalParameters.getOrDefault("label", null) } else { diff --git a/src/nl/hannahsten/texifyidea/psi/LatexLanguageInjector.kt b/src/nl/hannahsten/texifyidea/psi/LatexLanguageInjector.kt index b8401b928..eefe55361 100644 --- a/src/nl/hannahsten/texifyidea/psi/LatexLanguageInjector.kt +++ b/src/nl/hannahsten/texifyidea/psi/LatexLanguageInjector.kt @@ -22,7 +22,7 @@ class LatexLanguageInjector : LanguageInjector { // Allow lstlisting language to be overridden with magic comment val languageId = if (!hasMagicCommentKey && host.environmentName == "lstlisting") { - host.beginCommand.optionalParameters.getOrDefault("language", null) + host.beginCommand.optionalParameterMap.toStringMap().getOrDefault("language", null) } else if (hasMagicCommentKey) { magicComment.value(DefaultMagicKeys.INJECT_LANGUAGE) diff --git a/src/nl/hannahsten/texifyidea/psi/LatexPsiHelper.kt b/src/nl/hannahsten/texifyidea/psi/LatexPsiHelper.kt index c3553eb7e..ea96b72f4 100644 --- a/src/nl/hannahsten/texifyidea/psi/LatexPsiHelper.kt +++ b/src/nl/hannahsten/texifyidea/psi/LatexPsiHelper.kt @@ -74,45 +74,8 @@ class LatexPsiHelper(private val project: Project) { return createFromText(commandText).firstChildOfType(LatexRequiredParam::class)!! } - /** - * Replaces the optional parameter with the supplied name. If a value is supplied, the new parameter will - * have a value appended with an equal sign (e.g., param={value}). The new parameter has the same position - * as the old one. If no parameter with the supplied name is found, no action will be performed. - */ - fun replaceOptionalParameter(parameters: List, name: String, newValue: String?) { - val optionalParam = parameters.first { p -> p.optionalParam != null }.optionalParam!! - - val parameterText = if (newValue != null) { - "$name={$newValue}" - } - else { - name - } - - val labelRegex = "label\\s*=\\s*[^,]*".toRegex() - val elementsToReplace = mutableListOf() - val elementIterator = optionalParam.optionalParamContentList.iterator() - while (elementIterator.hasNext()) { - val latexContent = elementIterator.next() - val elementIsLabel = latexContent.parameterText?.text?.contains(labelRegex) ?: false - if (elementIsLabel) { - elementsToReplace.add(latexContent) - - // check if the label name is part of the text or in a separate group - if (latexContent.parameterText!!.text.split("=")[1].trim().isEmpty()) { - val group = elementIterator.next() - elementsToReplace.add(group) - } - } - } - - val newContents = createKeyValuePairs(parameterText) -// newContents.forEach { optionalParam.addBefore(it, elementsToReplace.first()) } - elementsToReplace.forEach { it.delete() } - } - fun setOptionalParameter(command: LatexCommandWithParams, name: String, value: String?): PsiElement { - val existingParameters = command.optionalParameters + val existingParameters = command.optionalParameterMap if (existingParameters.isEmpty()) { command.addAfter(createLatexOptionalParam(), command.parameterList[0]) } @@ -148,34 +111,4 @@ class LatexPsiHelper(private val project: Project) { } } - /** - * Add an optional parameter of the form "param" or "param={value}" to the list of optional parameters. - * If there already are optional parameters, the new parameter will be appended with a "," as the separator. - * - * @return A list containing the newly inserted elements from left to right - */ - fun addOptionalParameter(command: LatexCommandWithParams, name: String, value: String?): PsiElement { - val existingParameters = command.optionalParameters - if (existingParameters.isEmpty()) { - command.addAfter(createLatexOptionalParam(), command.parameterList[0]) - } - - val optionalParam = command.parameterList - .first { p -> p.optionalParam != null }.optionalParam!! - - val parameterText = if (value != null) { - "$name={$value}" - } - else { - name - } - - val pair = createKeyValuePairs(parameterText) - val closeBracket = optionalParam.childrenOfType().first { it.elementType == CLOSE_BRACKET } - if (optionalParam.keyvalPairList.isNotEmpty()){ - optionalParam.addBefore(LeafPsiElement(NORMAL_TEXT_CHAR, ","), closeBracket) - } - optionalParam.addBefore(pair, closeBracket) - return pair - } } \ No newline at end of file diff --git a/src/nl/hannahsten/texifyidea/psi/LatexPsiImplUtil.java b/src/nl/hannahsten/texifyidea/psi/LatexPsiImplUtil.java index 561fe8e65..6d9348885 100644 --- a/src/nl/hannahsten/texifyidea/psi/LatexPsiImplUtil.java +++ b/src/nl/hannahsten/texifyidea/psi/LatexPsiImplUtil.java @@ -39,20 +39,23 @@ public static PsiReference getReference(@NotNull LatexCommands element) { } } - /** - * Generates a list of all optional parameter names and values. - */ - public static LinkedHashMap getOptionalParameters(@NotNull LatexCommands element) { - return LatexCommandsImplUtilKt.getOptionalParameters(element.getParameterList()); + public static String toString(@NotNull LatexKeyvalKey element) { + return LatexCommandsImplUtilKt.toString(element); } - /** - * Generates a list of all optional parameter names and values. - */ - public static LinkedHashMap getOptionalParameters(@NotNull LatexBeginCommand element) { - return LatexCommandsImplUtilKt.getOptionalParameters(element.getParameterList()); + public static String toString(@NotNull LatexKeyvalValue element) { + return LatexCommandsImplUtilKt.toString(element); } + public static LinkedHashMap getOptionalParameterMap(@NotNull LatexCommands element) { + return LatexCommandsImplUtilKt.getOptionalParameterMap(element.getParameterList()); + } + + public static LinkedHashMap getOptionalParameterMap(@NotNull LatexBeginCommand element) { + return LatexCommandsImplUtilKt.getOptionalParameterMap(element.getParameterList()); + } + + /** * Generates a list of all names of all required parameters in the command. */ diff --git a/src/nl/hannahsten/texifyidea/run/latex/MakeindexUtil.kt b/src/nl/hannahsten/texifyidea/run/latex/MakeindexUtil.kt index c076b3a37..7fcdb41d1 100644 --- a/src/nl/hannahsten/texifyidea/run/latex/MakeindexUtil.kt +++ b/src/nl/hannahsten/texifyidea/run/latex/MakeindexUtil.kt @@ -6,6 +6,7 @@ import com.intellij.openapi.project.Project import com.intellij.openapi.vfs.VirtualFile import nl.hannahsten.texifyidea.index.LatexCommandsIndex import nl.hannahsten.texifyidea.lang.LatexPackage +import nl.hannahsten.texifyidea.psi.toStringMap import nl.hannahsten.texifyidea.run.compiler.MakeindexProgram import nl.hannahsten.texifyidea.util.Magic import nl.hannahsten.texifyidea.util.PackageUtils @@ -70,7 +71,7 @@ private fun getIndexPackageOptions(mainFile: VirtualFile?, project: Project): Li LatexCommandsIndex.getItemsInFileSet(mainPsiFile) .filter { it.commandToken.text in PackageUtils.PACKAGE_COMMANDS } .filter { command -> command.requiredParameters.any { it in Magic.Package.index || it in Magic.Package.glossary } } - .flatMap { it.optionalParameters.keys } + .flatMap { it.optionalParameterMap.toStringMap().keys } } } @@ -84,7 +85,7 @@ fun getMakeindexOptions(mainFile: VirtualFile?, project: @NotNull Project): Hash LatexCommandsIndex.getItemsInFileSet(mainPsiFile) .filter { it.commandToken.text == "\\makeindex" } .forEach { - makeindexOptions.putAll(it.optionalParameters) + makeindexOptions.putAll(it.optionalParameterMap.toStringMap()) } makeindexOptions } diff --git a/src/nl/hannahsten/texifyidea/structure/latex/LatexNewCommandPresentation.kt b/src/nl/hannahsten/texifyidea/structure/latex/LatexNewCommandPresentation.kt index 5f8474ceb..a51ed8082 100644 --- a/src/nl/hannahsten/texifyidea/structure/latex/LatexNewCommandPresentation.kt +++ b/src/nl/hannahsten/texifyidea/structure/latex/LatexNewCommandPresentation.kt @@ -3,6 +3,7 @@ package nl.hannahsten.texifyidea.structure.latex import com.intellij.navigation.ItemPresentation import nl.hannahsten.texifyidea.TexifyIcons import nl.hannahsten.texifyidea.psi.LatexCommands +import nl.hannahsten.texifyidea.psi.toStringMap import nl.hannahsten.texifyidea.util.nextCommand /** @@ -15,7 +16,7 @@ class LatexNewCommandPresentation(newCommand: LatexCommands) : ItemPresentation init { // Fetch parameter amount. - val optional = newCommand.optionalParameters.keys.toList() + val optional = newCommand.optionalParameterMap.toStringMap().keys.toList() var params = -1 if (optional.isNotEmpty()) { try { diff --git a/src/nl/hannahsten/texifyidea/util/Labels.kt b/src/nl/hannahsten/texifyidea/util/Labels.kt index 8361a5456..3036213f8 100644 --- a/src/nl/hannahsten/texifyidea/util/Labels.kt +++ b/src/nl/hannahsten/texifyidea/util/Labels.kt @@ -3,6 +3,7 @@ package nl.hannahsten.texifyidea.util import com.intellij.openapi.project.Project import com.intellij.psi.PsiElement import com.intellij.psi.PsiFile +import com.jetbrains.rd.util.first import nl.hannahsten.texifyidea.index.BibtexEntryIndex import nl.hannahsten.texifyidea.index.LatexCommandsIndex import nl.hannahsten.texifyidea.index.LatexParameterLabeledCommandsIndex @@ -172,7 +173,7 @@ fun PsiElement.extractLabelName(): String { is BibtexEntry -> identifier() ?: "" is LatexCommands -> { if (Magic.Command.labelAsParameter.contains(name)) { - optionalParameters["label"]!! + optionalParameterMap.toStringMap()["label"]!! } else { // For now just take the first label name (may be multiple for user defined commands) @@ -195,12 +196,29 @@ fun PsiElement.extractLabelElement(): PsiElement? { return when (this) { is BibtexEntry -> firstChildOfType(BibtexId::class) is LatexCommands -> { - // For now just take the first label name (may be multiple for user defined commands) - val info = CommandManager.labelAliasesInfo.getOrDefault(name, null) - val position = info?.positions?.firstOrNull() ?: 0 - // Skip optional parameters for now - this.parameterList.mapNotNull { it.requiredParam }.getOrNull(position) - ?.firstChildOfType(LatexParameterText::class) + if (Magic.Command.labelAsParameter.contains(name)) { + val labelEntry = optionalParameterMap.filter { pair -> pair.key.toString() == "label" }.first() + return labelEntry.value?.keyvalContentList?.first()?.parameterText + // TODO: groups are not working yet + } else { + + // For now just take the first label name (may be multiple for user defined commands) + val info = CommandManager.labelAliasesInfo.getOrDefault(name, null) + val position = info?.positions?.firstOrNull() ?: 0 + + // Skip optional parameters for now + this.parameterList.mapNotNull { it.requiredParam }.getOrNull(position) + ?.firstChildOfType(LatexParameterText::class) + } + } + is LatexEnvironment -> { + if (Magic.Environment.labelAsParameter.contains(environmentName)) { + val labelEntry = beginCommand.optionalParameterMap.filter { pair -> pair.key.toString() == "label" }.first() + return labelEntry.value?.keyvalContentList?.first()?.parameterText + // TODO: groups are not working yet + } else { + null + } } else -> null } diff --git a/src/nl/hannahsten/texifyidea/util/Packages.kt b/src/nl/hannahsten/texifyidea/util/Packages.kt index b0a0e0847..b79e1c693 100644 --- a/src/nl/hannahsten/texifyidea/util/Packages.kt +++ b/src/nl/hannahsten/texifyidea/util/Packages.kt @@ -10,6 +10,7 @@ import nl.hannahsten.texifyidea.lang.LatexPackage import nl.hannahsten.texifyidea.lang.LatexRegularCommand import nl.hannahsten.texifyidea.psi.LatexCommands import nl.hannahsten.texifyidea.psi.LatexPsiHelper +import nl.hannahsten.texifyidea.psi.toStringMap import nl.hannahsten.texifyidea.settings.sdk.LatexSdkUtil import nl.hannahsten.texifyidea.settings.TexifySettings import nl.hannahsten.texifyidea.util.files.* @@ -266,12 +267,12 @@ object PackageUtils { .text == "\\documentclass" || cmd.commandToken .text == "\\LoadClass" ) { - setOf(cmd.optionalParameters.keys.toList()) + setOf(cmd.optionalParameterMap.toStringMap().keys.toList()) } else { setOf( cmd.requiredParameters, - cmd.optionalParameters.keys + cmd.optionalParameterMap.toStringMap().keys .toList() ) } diff --git a/test/nl/hannahsten/texifyidea/psi/LatexCommandsImplUtilTest.kt b/test/nl/hannahsten/texifyidea/psi/LatexCommandsImplUtilTest.kt index 3328df7c2..be0b57f51 100644 --- a/test/nl/hannahsten/texifyidea/psi/LatexCommandsImplUtilTest.kt +++ b/test/nl/hannahsten/texifyidea/psi/LatexCommandsImplUtilTest.kt @@ -26,7 +26,7 @@ class LatexCommandsImplUtilTest : BasePlatformTestCase(){ .firstChildOfType(LatexCommands::class)!! .parameterList - val map = getOptionalParameters(parameters) + val map = getOptionalParameterMap(parameters).toStringMap() assertSize(3, map.keys) assertEquals("value1", map["param1"]) assertEquals("value2", map["param2"]) @@ -52,7 +52,7 @@ class LatexCommandsImplUtilTest : BasePlatformTestCase(){ .firstChildOfType(LatexCommands::class)!! .parameterList - val map = getOptionalParameters(parameters) + val map = getOptionalParameterMap(parameters).toStringMap() assertSize(2, map.keys) assertEquals("value1", map["param1"]) assertEquals("value2", map["param2"]) @@ -77,7 +77,7 @@ class LatexCommandsImplUtilTest : BasePlatformTestCase(){ .firstChildOfType(LatexCommands::class)!! .parameterList - val map = getOptionalParameters(parameters) + val map = getOptionalParameterMap(parameters).toStringMap() assertSize(3, map.keys) assertEquals("value1", map["param1"]) assertEquals("value2", map["param2"]) @@ -103,7 +103,7 @@ class LatexCommandsImplUtilTest : BasePlatformTestCase(){ .firstChildOfType(LatexCommands::class)!! .parameterList - val map = getOptionalParameters(parameters) + val map = getOptionalParameterMap(parameters).toStringMap() assertSize(6, map.keys) assertEquals("value11,value12", map["param1"]) assertEquals("value2", map["param2"]) @@ -132,7 +132,7 @@ class LatexCommandsImplUtilTest : BasePlatformTestCase(){ .firstChildOfType(LatexCommands::class)!! .parameterList - val map = getOptionalParameters(parameters) + val map = getOptionalParameterMap(parameters).toStringMap() assertSize(2, map.keys) assertEquals("value1", map["param1"]) assertEquals("value2", map["param2"]) diff --git a/test/nl/hannahsten/texifyidea/psi/LatexPsiImplUtilTest.kt b/test/nl/hannahsten/texifyidea/psi/LatexPsiImplUtilTest.kt index 59cb5e2cc..9989be4d7 100644 --- a/test/nl/hannahsten/texifyidea/psi/LatexPsiImplUtilTest.kt +++ b/test/nl/hannahsten/texifyidea/psi/LatexPsiImplUtilTest.kt @@ -48,7 +48,7 @@ class LatexPsiImplUtilTest : BasePlatformTestCase() { // when val psiFile = PsiDocumentManager.getInstance(myFixture.project).getPsiFile(myFixture.editor.document)!! val element = psiFile.children.first().firstChildOfType(LatexCommands::class)!! - val optionalParameters = element.optionalParameters + val optionalParameters = element.optionalParameterMap.toStringMap() // then assertEquals("biber", optionalParameters["backend"]) @@ -64,7 +64,7 @@ class LatexPsiImplUtilTest : BasePlatformTestCase() { // when val psiFile = PsiDocumentManager.getInstance(myFixture.project).getPsiFile(myFixture.editor.document)!! val element = psiFile.children.first().firstChildOfType(LatexCommands::class)!! - val optionalParameters = element.optionalParameters.keys.toList() + val optionalParameters = element.optionalParameterMap.toStringMap().keys.toList() // then assertEquals("backend", optionalParameters[0]) @@ -80,7 +80,7 @@ class LatexPsiImplUtilTest : BasePlatformTestCase() { // when val psiFile = PsiDocumentManager.getInstance(myFixture.project).getPsiFile(myFixture.editor.document)!! val element = psiFile.children.first().firstChildOfType(LatexCommands::class)!! - val optionalParameters = element.optionalParameters + val optionalParameters = element.optionalParameterMap.toStringMap() // then assertEmpty(optionalParameters.toList()) @@ -113,7 +113,7 @@ class LatexPsiImplUtilTest : BasePlatformTestCase() { val psiFile = PsiDocumentManager.getInstance(myFixture.project).getPsiFile(myFixture.editor.document)!! val element = psiFile.children.first().firstChildOfType(LatexBeginCommand::class)!! - val optionalParameters = element.optionalParameters + val optionalParameters = element.optionalParameterMap.toStringMap() assertEquals("Python", optionalParameters["language"]) assertEquals("lst:listing", optionalParameters["label"]) @@ -152,7 +152,7 @@ class LatexPsiImplUtilTest : BasePlatformTestCase() { val psiFile = PsiDocumentManager.getInstance(myFixture.project).getPsiFile(myFixture.editor.document)!! val element = psiFile.firstChildOfType(LatexCommands::class)!! - assertTrue("2" in element.optionalParameters) - assertTrue("n" in element.optionalParameters) + assertTrue("2" in element.optionalParameterMap.toStringMap()) + assertTrue("n" in element.optionalParameterMap.toStringMap()) } } \ No newline at end of file diff --git a/test/nl/hannahsten/texifyidea/reference/LabelDefinitionReferenceTest.kt b/test/nl/hannahsten/texifyidea/reference/LabelDefinitionReferenceTest.kt new file mode 100644 index 000000000..2717083f8 --- /dev/null +++ b/test/nl/hannahsten/texifyidea/reference/LabelDefinitionReferenceTest.kt @@ -0,0 +1,63 @@ +package nl.hannahsten.texifyidea.reference + +import com.intellij.testFramework.fixtures.BasePlatformTestCase +import nl.hannahsten.texifyidea.file.LatexFileType + +class LabelDefinitionReferenceTest : BasePlatformTestCase() { + + fun `test rename of label command`() { + myFixture.configureByText(LatexFileType, """\label{test} \ref{test}""") + myFixture.renameElementAtCaret("renamed") + myFixture.checkResult("""\label{renamed} \ref{renamed}""") + } + + fun `test rename of label in environment`() { + myFixture.configureByText(LatexFileType, + """ + \begin{listing}[label=test] + \end{listing} + \ref{test} + """ + .trimMargin()) + myFixture.renameElementAtCaret("renamed") + myFixture.checkResult( + """ + \begin{listing}[label=renamed] + \end{listing} + \ref{renamed} + """ + ) + } + + fun `test rename of label in command`() { + myFixture.configureByText(LatexFileType, + """ + \lstinputlisting[label=test]{inputfile} + \ref{test} + """ + .trimMargin()) + myFixture.renameElementAtCaret("renamed") + myFixture.checkResult( + """ + \lstinputlisting[label=renamed]{inputfile} + \ref{renamed} + """ + ) + } + + fun `test rename of label in group`() { + myFixture.configureByText(LatexFileType, + """ + \lstinputlisting[label={test}]{inputfile} + \ref{test} + """ + .trimMargin()) + myFixture.renameElementAtCaret("renamed") + myFixture.checkResult( + """ + \lstinputlisting[label={renamed}]{inputfile} + \ref{renamed} + """ + ) + } +} \ No newline at end of file From f7b3be5ce97bc90b31d8d47b2c35b77af91b91af Mon Sep 17 00:00:00 2001 From: Felix Berlakovich Date: Mon, 28 Dec 2020 22:13:15 +0100 Subject: [PATCH 11/20] Implement support for renaming and labels in groups --- .../texifyidea/parser/LatexParser.java | 67 ++++++++++++------- .../hannahsten/texifyidea/psi/LatexGroup.java | 7 +- .../texifyidea/psi/LatexKeyvalContent.java | 5 +- .../texifyidea/psi/LatexParameterGroup.java | 12 ++++ .../psi/LatexParameterGroupText.java | 21 ++++++ .../hannahsten/texifyidea/psi/LatexTypes.java | 32 ++++----- .../texifyidea/psi/LatexVisitor.java | 18 +++-- .../psi/impl/LatexGreedyContentImpl.java | 36 ---------- .../texifyidea/psi/impl/LatexGroupImpl.java | 17 ++--- .../psi/impl/LatexKeyvalContentImpl.java | 17 ++--- .../psi/impl/LatexParameterGroupImpl.java | 36 ++++++++++ .../psi/impl/LatexParameterGroupTextImpl.java | 54 +++++++++++++++ .../hannahsten/texifyidea/grammar/Latex.bnf | 17 ++++- .../texifyidea/psi/LatexCommandsImplUtil.kt | 6 +- .../psi/LatexParameterGroupTextUtil.kt | 38 +++++++++++ .../texifyidea/psi/LatexParameterTextUtil.kt | 8 +++ .../texifyidea/psi/LatexPsiImplUtil.java | 12 ++++ src/nl/hannahsten/texifyidea/util/Labels.kt | 6 +- .../reference/LabelDefinitionReferenceTest.kt | 25 +++---- 19 files changed, 307 insertions(+), 127 deletions(-) create mode 100644 gen/nl/hannahsten/texifyidea/psi/LatexParameterGroup.java create mode 100644 gen/nl/hannahsten/texifyidea/psi/LatexParameterGroupText.java delete mode 100644 gen/nl/hannahsten/texifyidea/psi/impl/LatexGreedyContentImpl.java create mode 100644 gen/nl/hannahsten/texifyidea/psi/impl/LatexParameterGroupImpl.java create mode 100644 gen/nl/hannahsten/texifyidea/psi/impl/LatexParameterGroupTextImpl.java create mode 100644 src/nl/hannahsten/texifyidea/psi/LatexParameterGroupTextUtil.kt diff --git a/gen/nl/hannahsten/texifyidea/parser/LatexParser.java b/gen/nl/hannahsten/texifyidea/parser/LatexParser.java index 4f5ba661d..2f8d50881 100644 --- a/gen/nl/hannahsten/texifyidea/parser/LatexParser.java +++ b/gen/nl/hannahsten/texifyidea/parser/LatexParser.java @@ -1,16 +1,17 @@ // This is a generated file. Not intended for manual editing. package nl.hannahsten.texifyidea.parser; +import com.intellij.lang.ASTNode; +import com.intellij.lang.LightPsiParser; import com.intellij.lang.PsiBuilder; import com.intellij.lang.PsiBuilder.Marker; -import static nl.hannahsten.texifyidea.psi.LatexTypes.*; -import static nl.hannahsten.texifyidea.parser.LatexParserUtil.*; -import com.intellij.psi.tree.IElementType; -import com.intellij.lang.ASTNode; -import com.intellij.psi.tree.TokenSet; import com.intellij.lang.PsiParser; -import com.intellij.lang.LightPsiParser; -import static com.intellij.lang.WhitespacesBinders.*; +import com.intellij.psi.tree.IElementType; + +import static com.intellij.lang.WhitespacesBinders.GREEDY_LEFT_BINDER; +import static com.intellij.lang.WhitespacesBinders.GREEDY_RIGHT_BINDER; +import static nl.hannahsten.texifyidea.parser.LatexParserUtil.*; +import static nl.hannahsten.texifyidea.psi.LatexTypes.*; @SuppressWarnings({"SimplifiableIfStatement", "UnusedAssignment"}) public class LatexParser implements PsiParser, LightPsiParser { @@ -230,19 +231,7 @@ private static boolean environment_content_1(PsiBuilder b, int l) { } /* ********************************************************** */ - // no_math_content - public static boolean greedy_content(PsiBuilder b, int l) { - if (!recursion_guard_(b, l, "greedy_content")) return false; - boolean r; - Marker m = enter_section_(b, l, _NONE_, GREEDY_CONTENT, ""); - r = no_math_content(b, l + 1); - register_hook_(b, WS_BINDERS, GREEDY_LEFT_BINDER, GREEDY_RIGHT_BINDER); - exit_section_(b, l, m, r, false, null); - return r; - } - - /* ********************************************************** */ - // OPEN_BRACE greedy_content* CLOSE_BRACE + // OPEN_BRACE content* CLOSE_BRACE public static boolean group(PsiBuilder b, int l) { if (!recursion_guard_(b, l, "group")) return false; if (!nextTokenIs(b, OPEN_BRACE)) return false; @@ -256,12 +245,12 @@ public static boolean group(PsiBuilder b, int l) { return r || p; } - // greedy_content* + // content* private static boolean group_1(PsiBuilder b, int l) { if (!recursion_guard_(b, l, "group_1")) return false; while (true) { int c = current_position_(b); - if (!greedy_content(b, l + 1)) break; + if (!content(b, l + 1)) break; if (!empty_element_parsed_guard_(b, "group_1", c)) break; } return true; @@ -290,13 +279,13 @@ private static boolean inline_math_1(PsiBuilder b, int l) { } /* ********************************************************** */ - // parameter_text | group + // parameter_text | parameter_group public static boolean keyval_content(PsiBuilder b, int l) { if (!recursion_guard_(b, l, "keyval_content")) return false; boolean r; Marker m = enter_section_(b, l, _NONE_, KEYVAL_CONTENT, ""); r = parameter_text(b, l + 1); - if (!r) r = group(b, l + 1); + if (!r) r = parameter_group(b, l + 1); exit_section_(b, l, m, r, false, null); return r; } @@ -573,6 +562,36 @@ public static boolean parameter(PsiBuilder b, int l) { return r; } + /* ********************************************************** */ + // OPEN_BRACE parameter_group_text CLOSE_BRACE + public static boolean parameter_group(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "parameter_group")) return false; + if (!nextTokenIs(b, OPEN_BRACE)) return false; + boolean r, p; + Marker m = enter_section_(b, l, _NONE_, PARAMETER_GROUP, null); + r = consumeToken(b, OPEN_BRACE); + p = r; // pin = 1 + r = r && report_error_(b, parameter_group_text(b, l + 1)); + r = p && consumeToken(b, CLOSE_BRACE) && r; + exit_section_(b, l, m, r, p, null); + return r || p; + } + + /* ********************************************************** */ + // content* + public static boolean parameter_group_text(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "parameter_group_text")) return false; + Marker m = enter_section_(b, l, _NONE_, PARAMETER_GROUP_TEXT, ""); + while (true) { + int c = current_position_(b); + if (!content(b, l + 1)) break; + if (!empty_element_parsed_guard_(b, "parameter_group_text", c)) break; + } + register_hook_(b, WS_BINDERS, GREEDY_LEFT_BINDER, GREEDY_RIGHT_BINDER); + exit_section_(b, l, m, true, false, null); + return true; + } + /* ********************************************************** */ // (commands | NORMAL_TEXT_WORD | STAR | AMPERSAND)+ public static boolean parameter_text(PsiBuilder b, int l) { diff --git a/gen/nl/hannahsten/texifyidea/psi/LatexGroup.java b/gen/nl/hannahsten/texifyidea/psi/LatexGroup.java index b5857b775..a2b61750e 100644 --- a/gen/nl/hannahsten/texifyidea/psi/LatexGroup.java +++ b/gen/nl/hannahsten/texifyidea/psi/LatexGroup.java @@ -1,13 +1,14 @@ // This is a generated file. Not intended for manual editing. package nl.hannahsten.texifyidea.psi; -import java.util.List; -import org.jetbrains.annotations.*; import com.intellij.psi.PsiElement; +import org.jetbrains.annotations.NotNull; + +import java.util.List; public interface LatexGroup extends PsiElement { @NotNull - List getContentList(); + List getContentList(); } diff --git a/gen/nl/hannahsten/texifyidea/psi/LatexKeyvalContent.java b/gen/nl/hannahsten/texifyidea/psi/LatexKeyvalContent.java index 781eaf64c..6134dd3bc 100644 --- a/gen/nl/hannahsten/texifyidea/psi/LatexKeyvalContent.java +++ b/gen/nl/hannahsten/texifyidea/psi/LatexKeyvalContent.java @@ -1,14 +1,13 @@ // This is a generated file. Not intended for manual editing. package nl.hannahsten.texifyidea.psi; -import java.util.List; -import org.jetbrains.annotations.*; import com.intellij.psi.PsiElement; +import org.jetbrains.annotations.Nullable; public interface LatexKeyvalContent extends PsiElement { @Nullable - LatexGroup getGroup(); + LatexParameterGroup getParameterGroup(); @Nullable LatexParameterText getParameterText(); diff --git a/gen/nl/hannahsten/texifyidea/psi/LatexParameterGroup.java b/gen/nl/hannahsten/texifyidea/psi/LatexParameterGroup.java new file mode 100644 index 000000000..ba4daa997 --- /dev/null +++ b/gen/nl/hannahsten/texifyidea/psi/LatexParameterGroup.java @@ -0,0 +1,12 @@ +// This is a generated file. Not intended for manual editing. +package nl.hannahsten.texifyidea.psi; + +import com.intellij.psi.PsiElement; +import org.jetbrains.annotations.Nullable; + +public interface LatexParameterGroup extends PsiElement { + + @Nullable + LatexParameterGroupText getParameterGroupText(); + +} diff --git a/gen/nl/hannahsten/texifyidea/psi/LatexParameterGroupText.java b/gen/nl/hannahsten/texifyidea/psi/LatexParameterGroupText.java new file mode 100644 index 000000000..c1151c526 --- /dev/null +++ b/gen/nl/hannahsten/texifyidea/psi/LatexParameterGroupText.java @@ -0,0 +1,21 @@ +// This is a generated file. Not intended for manual editing. +package nl.hannahsten.texifyidea.psi; + +import com.intellij.psi.PsiElement; +import com.intellij.psi.PsiNameIdentifierOwner; +import org.jetbrains.annotations.NotNull; + +import java.util.List; + +public interface LatexParameterGroupText extends PsiNameIdentifierOwner { + + @NotNull + List getContentList(); + + PsiElement getNameIdentifier(); + + String getName(); + + PsiElement setName(String name); + +} diff --git a/gen/nl/hannahsten/texifyidea/psi/LatexTypes.java b/gen/nl/hannahsten/texifyidea/psi/LatexTypes.java index 234f3c578..12e4ee04d 100644 --- a/gen/nl/hannahsten/texifyidea/psi/LatexTypes.java +++ b/gen/nl/hannahsten/texifyidea/psi/LatexTypes.java @@ -1,9 +1,9 @@ // This is a generated file. Not intended for manual editing. package nl.hannahsten.texifyidea.psi; -import com.intellij.psi.tree.IElementType; -import com.intellij.psi.PsiElement; import com.intellij.lang.ASTNode; +import com.intellij.psi.PsiElement; +import com.intellij.psi.tree.IElementType; import nl.hannahsten.texifyidea.index.stub.LatexCommandsStubElementType; import nl.hannahsten.texifyidea.index.stub.LatexEnvironmentStubElementType; import nl.hannahsten.texifyidea.index.stub.LatexMagicCommentStubElementType; @@ -19,7 +19,6 @@ public interface LatexTypes { IElementType END_COMMAND = new LatexElementType("END_COMMAND"); IElementType ENVIRONMENT = new LatexEnvironmentStubElementType("ENVIRONMENT"); IElementType ENVIRONMENT_CONTENT = new LatexElementType("ENVIRONMENT_CONTENT"); - IElementType GREEDY_CONTENT = new LatexElementType("GREEDY_CONTENT"); IElementType GROUP = new LatexElementType("GROUP"); IElementType INLINE_MATH = new LatexElementType("INLINE_MATH"); IElementType KEYVAL_CONTENT = new LatexElementType("KEYVAL_CONTENT"); @@ -34,6 +33,8 @@ public interface LatexTypes { IElementType OPTIONAL_PARAM = new LatexElementType("OPTIONAL_PARAM"); IElementType OPTIONAL_PARAM_CONTENT = new LatexElementType("OPTIONAL_PARAM_CONTENT"); IElementType PARAMETER = new LatexElementType("PARAMETER"); + IElementType PARAMETER_GROUP = new LatexElementType("PARAMETER_GROUP"); + IElementType PARAMETER_GROUP_TEXT = new LatexElementType("PARAMETER_GROUP_TEXT"); IElementType PARAMETER_TEXT = new LatexElementType("PARAMETER_TEXT"); IElementType PSEUDOCODE_BLOCK = new LatexElementType("PSEUDOCODE_BLOCK"); IElementType PSEUDOCODE_BLOCK_CONTENT = new LatexElementType("PSEUDOCODE_BLOCK_CONTENT"); @@ -93,9 +94,6 @@ else if (type == ENVIRONMENT) { else if (type == ENVIRONMENT_CONTENT) { return new LatexEnvironmentContentImpl(node); } - else if (type == GREEDY_CONTENT) { - return new LatexGreedyContentImpl(node); - } else if (type == GROUP) { return new LatexGroupImpl(node); } @@ -137,23 +135,21 @@ else if (type == OPTIONAL_PARAM_CONTENT) { } else if (type == PARAMETER) { return new LatexParameterImpl(node); - } - else if (type == PARAMETER_TEXT) { + } else if (type == PARAMETER_GROUP) { + return new LatexParameterGroupImpl(node); + } else if (type == PARAMETER_GROUP_TEXT) { + return new LatexParameterGroupTextImpl(node); + } else if (type == PARAMETER_TEXT) { return new LatexParameterTextImpl(node); - } - else if (type == PSEUDOCODE_BLOCK) { + } else if (type == PSEUDOCODE_BLOCK) { return new LatexPseudocodeBlockImpl(node); - } - else if (type == PSEUDOCODE_BLOCK_CONTENT) { + } else if (type == PSEUDOCODE_BLOCK_CONTENT) { return new LatexPseudocodeBlockContentImpl(node); - } - else if (type == RAW_TEXT) { + } else if (type == RAW_TEXT) { return new LatexRawTextImpl(node); - } - else if (type == REQUIRED_PARAM) { + } else if (type == REQUIRED_PARAM) { return new LatexRequiredParamImpl(node); - } - else if (type == REQUIRED_PARAM_CONTENT) { + } else if (type == REQUIRED_PARAM_CONTENT) { return new LatexRequiredParamContentImpl(node); } throw new AssertionError("Unknown element type: " + type); diff --git a/gen/nl/hannahsten/texifyidea/psi/LatexVisitor.java b/gen/nl/hannahsten/texifyidea/psi/LatexVisitor.java index 054a25dbe..46cb45d79 100644 --- a/gen/nl/hannahsten/texifyidea/psi/LatexVisitor.java +++ b/gen/nl/hannahsten/texifyidea/psi/LatexVisitor.java @@ -1,11 +1,11 @@ // This is a generated file. Not intended for manual editing. package nl.hannahsten.texifyidea.psi; -import org.jetbrains.annotations.*; -import com.intellij.psi.PsiElementVisitor; import com.intellij.psi.PsiElement; -import com.intellij.psi.PsiNameIdentifierOwner; +import com.intellij.psi.PsiElementVisitor; import com.intellij.psi.PsiLanguageInjectionHost; +import com.intellij.psi.PsiNameIdentifierOwner; +import org.jetbrains.annotations.NotNull; public class LatexVisitor extends PsiElementVisitor { @@ -42,10 +42,6 @@ public void visitEnvironmentContent(@NotNull LatexEnvironmentContent o) { visitPsiElement(o); } - public void visitGreedyContent(@NotNull LatexGreedyContent o) { - visitPsiElement(o); - } - public void visitGroup(@NotNull LatexGroup o) { visitPsiElement(o); } @@ -102,6 +98,14 @@ public void visitParameter(@NotNull LatexParameter o) { visitPsiElement(o); } + public void visitParameterGroup(@NotNull LatexParameterGroup o) { + visitPsiElement(o); + } + + public void visitParameterGroupText(@NotNull LatexParameterGroupText o) { + visitPsiNameIdentifierOwner(o); + } + public void visitParameterText(@NotNull LatexParameterText o) { visitPsiNameIdentifierOwner(o); } diff --git a/gen/nl/hannahsten/texifyidea/psi/impl/LatexGreedyContentImpl.java b/gen/nl/hannahsten/texifyidea/psi/impl/LatexGreedyContentImpl.java deleted file mode 100644 index ec8cfcecf..000000000 --- a/gen/nl/hannahsten/texifyidea/psi/impl/LatexGreedyContentImpl.java +++ /dev/null @@ -1,36 +0,0 @@ -// This is a generated file. Not intended for manual editing. -package nl.hannahsten.texifyidea.psi.impl; - -import java.util.List; -import org.jetbrains.annotations.*; -import com.intellij.lang.ASTNode; -import com.intellij.psi.PsiElement; -import com.intellij.psi.PsiElementVisitor; -import com.intellij.psi.util.PsiTreeUtil; -import static nl.hannahsten.texifyidea.psi.LatexTypes.*; -import com.intellij.extapi.psi.ASTWrapperPsiElement; -import nl.hannahsten.texifyidea.psi.*; - -public class LatexGreedyContentImpl extends ASTWrapperPsiElement implements LatexGreedyContent { - - public LatexGreedyContentImpl(@NotNull ASTNode node) { - super(node); - } - - public void accept(@NotNull LatexVisitor visitor) { - visitor.visitGreedyContent(this); - } - - @Override - public void accept(@NotNull PsiElementVisitor visitor) { - if (visitor instanceof LatexVisitor) accept((LatexVisitor)visitor); - else super.accept(visitor); - } - - @Override - @NotNull - public LatexNoMathContent getNoMathContent() { - return notNullChild(PsiTreeUtil.getChildOfType(this, LatexNoMathContent.class)); - } - -} diff --git a/gen/nl/hannahsten/texifyidea/psi/impl/LatexGroupImpl.java b/gen/nl/hannahsten/texifyidea/psi/impl/LatexGroupImpl.java index 2be12d760..c9898885f 100644 --- a/gen/nl/hannahsten/texifyidea/psi/impl/LatexGroupImpl.java +++ b/gen/nl/hannahsten/texifyidea/psi/impl/LatexGroupImpl.java @@ -1,15 +1,16 @@ // This is a generated file. Not intended for manual editing. package nl.hannahsten.texifyidea.psi.impl; -import java.util.List; -import org.jetbrains.annotations.*; +import com.intellij.extapi.psi.ASTWrapperPsiElement; import com.intellij.lang.ASTNode; -import com.intellij.psi.PsiElement; import com.intellij.psi.PsiElementVisitor; import com.intellij.psi.util.PsiTreeUtil; -import static nl.hannahsten.texifyidea.psi.LatexTypes.*; -import com.intellij.extapi.psi.ASTWrapperPsiElement; -import nl.hannahsten.texifyidea.psi.*; +import nl.hannahsten.texifyidea.psi.LatexContent; +import nl.hannahsten.texifyidea.psi.LatexGroup; +import nl.hannahsten.texifyidea.psi.LatexVisitor; +import org.jetbrains.annotations.NotNull; + +import java.util.List; public class LatexGroupImpl extends ASTWrapperPsiElement implements LatexGroup { @@ -29,8 +30,8 @@ public void accept(@NotNull PsiElementVisitor visitor) { @Override @NotNull - public List getContentList() { - return PsiTreeUtil.getChildrenOfTypeAsList(this, LatexGreedyContent.class); + public List getContentList() { + return PsiTreeUtil.getChildrenOfTypeAsList(this, LatexContent.class); } } diff --git a/gen/nl/hannahsten/texifyidea/psi/impl/LatexKeyvalContentImpl.java b/gen/nl/hannahsten/texifyidea/psi/impl/LatexKeyvalContentImpl.java index f529c3dc6..f9d38cf85 100644 --- a/gen/nl/hannahsten/texifyidea/psi/impl/LatexKeyvalContentImpl.java +++ b/gen/nl/hannahsten/texifyidea/psi/impl/LatexKeyvalContentImpl.java @@ -1,15 +1,16 @@ // This is a generated file. Not intended for manual editing. package nl.hannahsten.texifyidea.psi.impl; -import java.util.List; -import org.jetbrains.annotations.*; +import com.intellij.extapi.psi.ASTWrapperPsiElement; import com.intellij.lang.ASTNode; -import com.intellij.psi.PsiElement; import com.intellij.psi.PsiElementVisitor; import com.intellij.psi.util.PsiTreeUtil; -import static nl.hannahsten.texifyidea.psi.LatexTypes.*; -import com.intellij.extapi.psi.ASTWrapperPsiElement; -import nl.hannahsten.texifyidea.psi.*; +import nl.hannahsten.texifyidea.psi.LatexKeyvalContent; +import nl.hannahsten.texifyidea.psi.LatexParameterGroup; +import nl.hannahsten.texifyidea.psi.LatexParameterText; +import nl.hannahsten.texifyidea.psi.LatexVisitor; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; public class LatexKeyvalContentImpl extends ASTWrapperPsiElement implements LatexKeyvalContent { @@ -29,8 +30,8 @@ public void accept(@NotNull PsiElementVisitor visitor) { @Override @Nullable - public LatexGroup getGroup() { - return PsiTreeUtil.getChildOfType(this, LatexGroup.class); + public LatexParameterGroup getParameterGroup() { + return PsiTreeUtil.getChildOfType(this, LatexParameterGroup.class); } @Override diff --git a/gen/nl/hannahsten/texifyidea/psi/impl/LatexParameterGroupImpl.java b/gen/nl/hannahsten/texifyidea/psi/impl/LatexParameterGroupImpl.java new file mode 100644 index 000000000..0a224a139 --- /dev/null +++ b/gen/nl/hannahsten/texifyidea/psi/impl/LatexParameterGroupImpl.java @@ -0,0 +1,36 @@ +// This is a generated file. Not intended for manual editing. +package nl.hannahsten.texifyidea.psi.impl; + +import com.intellij.extapi.psi.ASTWrapperPsiElement; +import com.intellij.lang.ASTNode; +import com.intellij.psi.PsiElementVisitor; +import com.intellij.psi.util.PsiTreeUtil; +import nl.hannahsten.texifyidea.psi.LatexParameterGroup; +import nl.hannahsten.texifyidea.psi.LatexParameterGroupText; +import nl.hannahsten.texifyidea.psi.LatexVisitor; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +public class LatexParameterGroupImpl extends ASTWrapperPsiElement implements LatexParameterGroup { + + public LatexParameterGroupImpl(@NotNull ASTNode node) { + super(node); + } + + public void accept(@NotNull LatexVisitor visitor) { + visitor.visitParameterGroup(this); + } + + @Override + public void accept(@NotNull PsiElementVisitor visitor) { + if (visitor instanceof LatexVisitor) accept((LatexVisitor)visitor); + else super.accept(visitor); + } + + @Override + @Nullable + public LatexParameterGroupText getParameterGroupText() { + return PsiTreeUtil.getChildOfType(this, LatexParameterGroupText.class); + } + +} diff --git a/gen/nl/hannahsten/texifyidea/psi/impl/LatexParameterGroupTextImpl.java b/gen/nl/hannahsten/texifyidea/psi/impl/LatexParameterGroupTextImpl.java new file mode 100644 index 000000000..3e6d658fa --- /dev/null +++ b/gen/nl/hannahsten/texifyidea/psi/impl/LatexParameterGroupTextImpl.java @@ -0,0 +1,54 @@ +// This is a generated file. Not intended for manual editing. +package nl.hannahsten.texifyidea.psi.impl; + +import com.intellij.extapi.psi.ASTWrapperPsiElement; +import com.intellij.lang.ASTNode; +import com.intellij.psi.PsiElement; +import com.intellij.psi.PsiElementVisitor; +import com.intellij.psi.util.PsiTreeUtil; +import nl.hannahsten.texifyidea.psi.LatexContent; +import nl.hannahsten.texifyidea.psi.LatexParameterGroupText; +import nl.hannahsten.texifyidea.psi.LatexPsiImplUtil; +import nl.hannahsten.texifyidea.psi.LatexVisitor; +import org.jetbrains.annotations.NotNull; + +import java.util.List; + +public class LatexParameterGroupTextImpl extends ASTWrapperPsiElement implements LatexParameterGroupText { + + public LatexParameterGroupTextImpl(@NotNull ASTNode node) { + super(node); + } + + public void accept(@NotNull LatexVisitor visitor) { + visitor.visitParameterGroupText(this); + } + + @Override + public void accept(@NotNull PsiElementVisitor visitor) { + if (visitor instanceof LatexVisitor) accept((LatexVisitor) visitor); + else super.accept(visitor); + } + + @Override + @NotNull + public List getContentList() { + return PsiTreeUtil.getChildrenOfTypeAsList(this, LatexContent.class); + } + + @Override + public PsiElement getNameIdentifier() { + return LatexPsiImplUtil.getNameIdentifier(this); + } + + @Override + public String getName() { + return LatexPsiImplUtil.getName(this); + } + + @Override + public PsiElement setName(String name) { + return LatexPsiImplUtil.setName(this, name); + } + +} diff --git a/src/nl/hannahsten/texifyidea/grammar/Latex.bnf b/src/nl/hannahsten/texifyidea/grammar/Latex.bnf index d999e2630..2c09a1da2 100644 --- a/src/nl/hannahsten/texifyidea/grammar/Latex.bnf +++ b/src/nl/hannahsten/texifyidea/grammar/Latex.bnf @@ -26,6 +26,10 @@ // Make text have an identifier, to be able to Ctrl+B for \label parameters implements("parameter_text")="com.intellij.psi.PsiNameIdentifierOwner" + // Make text in parameter group have an identifier, to be able to Ctrl+B for \label parameters + implements("parameter_group_text")="com.intellij.psi.PsiNameIdentifierOwner" + + // See the lexer tokens=[ WHITE_SPACE='regexp:\s+' @@ -55,7 +59,6 @@ latexFile ::= content* content ::= no_math_content -greedy_content ::= no_math_content { hooks = [wsBinders="GREEDY_LEFT_BINDER, GREEDY_RIGHT_BINDER"] } no_math_content ::= raw_text | magic_comment | comment | environment | pseudocode_block | math_environment | COMMAND_IFNEXTCHAR | commands | group | OPEN_PAREN | CLOSE_PAREN | OPEN_BRACKET | CLOSE_BRACKET | normal_text @@ -108,6 +111,8 @@ required_param ::= OPEN_BRACE required_param_content* CLOSE_BRACE { pin=1 } optional_param_content ::= raw_text | magic_comment | comment | environment | pseudocode_block | math_environment | COMMAND_IFNEXTCHAR | commands | group | OPEN_PAREN | CLOSE_PAREN | parameter_text | NORMAL_TEXT_CHAR required_param_content ::= raw_text | magic_comment | comment | environment | pseudocode_block | math_environment | COMMAND_IFNEXTCHAR | group | OPEN_PAREN | CLOSE_PAREN | parameter_text | OPEN_BRACKET | CLOSE_BRACKET | NORMAL_TEXT_CHAR +// These non-terminals are used to match the key value pairs of optional parameters. We cannot (currently) define +// "=" and "," as tokens because the lexer would create them as tokens everywhere, including in normal text. keyval_pair ::= keyval_key ("=" keyval_value)? keyval_key ::= keyval_content+ { methods=[toString] @@ -115,7 +120,7 @@ keyval_key ::= keyval_content+ { keyval_value ::= keyval_content+ { methods=[toString] } -keyval_content ::= parameter_text | group +keyval_content ::= parameter_text | parameter_group // The lowest level of a parameter must have the getReferences etc. implemented // We don't do this on normal_text because then every normal_text in the document would be a reference @@ -126,7 +131,13 @@ parameter_text ::= (commands | NORMAL_TEXT_WORD | STAR | AMPERSAND)+ { methods=[getReferences getReference getNameIdentifier getName setName] } -group ::= OPEN_BRACE greedy_content* CLOSE_BRACE { pin=1 methods=[contentList="greedy_content"] } +group ::= OPEN_BRACE content* CLOSE_BRACE { pin=1 } + +parameter_group ::= OPEN_BRACE parameter_group_text CLOSE_BRACE { pin=1 } + +// Be sure to capture the whitespace before and after the actual content as groups are meant to capture +// *everything* inside them. +parameter_group_text ::= content* { hooks = [wsBinders="GREEDY_LEFT_BINDER, GREEDY_RIGHT_BINDER"] methods=[getNameIdentifier getName setName] } comment ::= COMMENT_TOKEN diff --git a/src/nl/hannahsten/texifyidea/psi/LatexCommandsImplUtil.kt b/src/nl/hannahsten/texifyidea/psi/LatexCommandsImplUtil.kt index 01404aba1..ddb082625 100644 --- a/src/nl/hannahsten/texifyidea/psi/LatexCommandsImplUtil.kt +++ b/src/nl/hannahsten/texifyidea/psi/LatexCommandsImplUtil.kt @@ -213,7 +213,9 @@ fun setName(element: LatexCommands, newName: String): PsiElement { } fun toString(element: LatexKeyvalKey): String = - element.keyvalContentList.map { it -> it.parameterText?.text ?: it.group!!.contentList.joinToString(separator = "") {it.text} }.joinToString(separator = "") + element.keyvalContentList.map { it -> it.parameterText?.text ?: it.parameterGroup!!.parameterGroupText!!.text } + .joinToString(separator = "") fun toString(element: LatexKeyvalValue): String = - element.keyvalContentList.map { it -> it.parameterText?.text ?: it.group!!.contentList.joinToString(separator = "") {it.text} }.joinToString(separator = "") + element.keyvalContentList.map { it -> it.parameterText?.text ?: it.parameterGroup!!.parameterGroupText!!.text } + .joinToString(separator = "") diff --git a/src/nl/hannahsten/texifyidea/psi/LatexParameterGroupTextUtil.kt b/src/nl/hannahsten/texifyidea/psi/LatexParameterGroupTextUtil.kt new file mode 100644 index 000000000..05ce4f191 --- /dev/null +++ b/src/nl/hannahsten/texifyidea/psi/LatexParameterGroupTextUtil.kt @@ -0,0 +1,38 @@ +package nl.hannahsten.texifyidea.psi + +import com.intellij.psi.PsiElement +import nl.hannahsten.texifyidea.util.Magic +import nl.hannahsten.texifyidea.util.firstParentOfType + +fun getNameIdentifier(element: LatexParameterGroupText): PsiElement? { + // Because we do not want to trigger the NonAsciiCharactersInspection when the LatexParameterText is not an identifier + // (think non-ASCII characters in a \section command), we return null here when the element is not an identifier + // It is important not to return null for any identifier, otherwise exceptions like "Throwable: null byMemberInplaceRenamer" may occur + val command = element.firstParentOfType(LatexCommands::class) + val environment = element.firstParentOfType(LatexEnvironment::class) + if (Magic.Command.labelAsParameter.contains(command?.name) || + Magic.Environment.labelAsParameter.contains(environment?.environmentName) + ) { + return element + } + return null +} + +fun setName(element: LatexParameterGroupText, name: String): PsiElement { + val command = element.firstParentOfType(LatexCommands::class) + val environment = element.firstParentOfType(LatexEnvironment::class) + if (Magic.Command.labelAsParameter.contains(command?.name) || Magic.Environment.labelAsParameter.contains( + environment?.environmentName + ) + ) { + val helper = LatexPsiHelper(element.project) + helper.setOptionalParameter(command ?: environment!!.beginCommand, "label", "{$name}") + } + + // Else, element is not renamable + return element +} + +fun getName(element: LatexParameterGroupText): String { + return element.text ?: "" +} \ No newline at end of file diff --git a/src/nl/hannahsten/texifyidea/psi/LatexParameterTextUtil.kt b/src/nl/hannahsten/texifyidea/psi/LatexParameterTextUtil.kt index 73631fa63..b198c9fdb 100644 --- a/src/nl/hannahsten/texifyidea/psi/LatexParameterTextUtil.kt +++ b/src/nl/hannahsten/texifyidea/psi/LatexParameterTextUtil.kt @@ -65,6 +65,7 @@ fun getNameIdentifier(element: LatexParameterText): PsiElement? { fun setName(element: LatexParameterText, name: String): PsiElement { val command = element.firstParentOfType(LatexCommands::class) + val environment = element.firstParentOfType(LatexEnvironment::class) // If we want to rename a label if (Magic.Command.reference.contains(command?.name) || Magic.Command.getLabelDefinitionCommands(element.project).contains(command?.name)) { // Get a new psi element for the complete label command (\label included), @@ -83,6 +84,13 @@ fun setName(element: LatexParameterText, name: String): PsiElement { command.parent.node.replaceChild(oldNode, newNode) } } + else if (Magic.Command.labelAsParameter.contains(command?.name) || Magic.Environment.labelAsParameter.contains( + environment?.environmentName + ) + ) { + val helper = LatexPsiHelper(element.project) + helper.setOptionalParameter(command ?: environment!!.beginCommand, "label", name) + } else if (element.firstParentOfType(LatexEndCommand::class) != null || element.firstParentOfType(LatexBeginCommand::class) != null) { // We are renaming an environment, text in \begin or \end val newElement = LatexPsiHelper(element.project).createFromText(name).firstChild diff --git a/src/nl/hannahsten/texifyidea/psi/LatexPsiImplUtil.java b/src/nl/hannahsten/texifyidea/psi/LatexPsiImplUtil.java index 6d9348885..b274452bc 100644 --- a/src/nl/hannahsten/texifyidea/psi/LatexPsiImplUtil.java +++ b/src/nl/hannahsten/texifyidea/psi/LatexPsiImplUtil.java @@ -123,6 +123,18 @@ public static String getName(@NotNull LatexParameterText element) { return LatexParameterTextUtilKt.getName(element); } + public static PsiElement getNameIdentifier(@NotNull LatexParameterGroupText element) { + return LatexParameterGroupTextUtilKt.getNameIdentifier(element); + } + + public static PsiElement setName(@NotNull LatexParameterGroupText element, String name) { + return LatexParameterGroupTextUtilKt.setName(element, name); + } + + public static String getName(@NotNull LatexParameterGroupText element) { + return LatexParameterGroupTextUtilKt.getName(element); + } + /* * LatexEnvironment */ diff --git a/src/nl/hannahsten/texifyidea/util/Labels.kt b/src/nl/hannahsten/texifyidea/util/Labels.kt index 3036213f8..47e5b6ea9 100644 --- a/src/nl/hannahsten/texifyidea/util/Labels.kt +++ b/src/nl/hannahsten/texifyidea/util/Labels.kt @@ -198,8 +198,8 @@ fun PsiElement.extractLabelElement(): PsiElement? { is LatexCommands -> { if (Magic.Command.labelAsParameter.contains(name)) { val labelEntry = optionalParameterMap.filter { pair -> pair.key.toString() == "label" }.first() - return labelEntry.value?.keyvalContentList?.first()?.parameterText - // TODO: groups are not working yet + val keyValContent = labelEntry.value?.keyvalContentList?.first() + return keyValContent?.parameterText ?: keyValContent?.parameterGroup?.parameterGroupText } else { // For now just take the first label name (may be multiple for user defined commands) @@ -215,7 +215,7 @@ fun PsiElement.extractLabelElement(): PsiElement? { if (Magic.Environment.labelAsParameter.contains(environmentName)) { val labelEntry = beginCommand.optionalParameterMap.filter { pair -> pair.key.toString() == "label" }.first() return labelEntry.value?.keyvalContentList?.first()?.parameterText - // TODO: groups are not working yet + ?: labelEntry.value.keyvalContentList.first().parameterGroup?.parameterGroupText } else { null } diff --git a/test/nl/hannahsten/texifyidea/reference/LabelDefinitionReferenceTest.kt b/test/nl/hannahsten/texifyidea/reference/LabelDefinitionReferenceTest.kt index 2717083f8..d3bdeb5fe 100644 --- a/test/nl/hannahsten/texifyidea/reference/LabelDefinitionReferenceTest.kt +++ b/test/nl/hannahsten/texifyidea/reference/LabelDefinitionReferenceTest.kt @@ -12,20 +12,21 @@ class LabelDefinitionReferenceTest : BasePlatformTestCase() { } fun `test rename of label in environment`() { - myFixture.configureByText(LatexFileType, + myFixture.configureByText( + LatexFileType, """ - \begin{listing}[label=test] - \end{listing} + \begin{lstlisting}[label=test] + \end{lstlisting} \ref{test} - """ - .trimMargin()) + """.trimMargin() + ) myFixture.renameElementAtCaret("renamed") myFixture.checkResult( """ - \begin{listing}[label=renamed] - \end{listing} + \begin{lstlisting}[label=renamed] + \end{lstlisting} \ref{renamed} - """ + """.trimMargin() ) } @@ -39,9 +40,9 @@ class LabelDefinitionReferenceTest : BasePlatformTestCase() { myFixture.renameElementAtCaret("renamed") myFixture.checkResult( """ - \lstinputlisting[label=renamed]{inputfile} + \lstinputlisting[label=renamed]{inputfile} \ref{renamed} - """ + """.trimMargin() ) } @@ -55,9 +56,9 @@ class LabelDefinitionReferenceTest : BasePlatformTestCase() { myFixture.renameElementAtCaret("renamed") myFixture.checkResult( """ - \lstinputlisting[label={renamed}]{inputfile} + \lstinputlisting[label={renamed}]{inputfile} \ref{renamed} - """ + """.trimMargin() ) } } \ No newline at end of file From 2b10ff05b05aee4b3d109cd15730c8ed8256d3da Mon Sep 17 00:00:00 2001 From: Felix Berlakovich Date: Mon, 28 Dec 2020 22:14:56 +0100 Subject: [PATCH 12/20] Linter fixes --- src/nl/hannahsten/texifyidea/psi/LatexPsiHelper.kt | 2 -- src/nl/hannahsten/texifyidea/util/Labels.kt | 10 ++++++---- .../texifyidea/psi/LatexCommandsImplUtilTest.kt | 5 +++-- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/nl/hannahsten/texifyidea/psi/LatexPsiHelper.kt b/src/nl/hannahsten/texifyidea/psi/LatexPsiHelper.kt index ea96b72f4..7a2b7233f 100644 --- a/src/nl/hannahsten/texifyidea/psi/LatexPsiHelper.kt +++ b/src/nl/hannahsten/texifyidea/psi/LatexPsiHelper.kt @@ -6,7 +6,6 @@ import com.intellij.psi.PsiFileFactory import com.intellij.psi.impl.source.tree.LeafPsiElement import nl.hannahsten.texifyidea.LatexLanguage import nl.hannahsten.texifyidea.psi.LatexTypes.CLOSE_BRACKET -import nl.hannahsten.texifyidea.psi.LatexTypes.NORMAL_TEXT_CHAR import nl.hannahsten.texifyidea.util.childrenOfType import nl.hannahsten.texifyidea.util.findFirstChild import nl.hannahsten.texifyidea.util.firstChildOfType @@ -110,5 +109,4 @@ class LatexPsiHelper(private val project: Project) { closeBracket.prevSibling } } - } \ No newline at end of file diff --git a/src/nl/hannahsten/texifyidea/util/Labels.kt b/src/nl/hannahsten/texifyidea/util/Labels.kt index 47e5b6ea9..18cbeb835 100644 --- a/src/nl/hannahsten/texifyidea/util/Labels.kt +++ b/src/nl/hannahsten/texifyidea/util/Labels.kt @@ -200,8 +200,8 @@ fun PsiElement.extractLabelElement(): PsiElement? { val labelEntry = optionalParameterMap.filter { pair -> pair.key.toString() == "label" }.first() val keyValContent = labelEntry.value?.keyvalContentList?.first() return keyValContent?.parameterText ?: keyValContent?.parameterGroup?.parameterGroupText - } else { - + } + else { // For now just take the first label name (may be multiple for user defined commands) val info = CommandManager.labelAliasesInfo.getOrDefault(name, null) val position = info?.positions?.firstOrNull() ?: 0 @@ -213,10 +213,12 @@ fun PsiElement.extractLabelElement(): PsiElement? { } is LatexEnvironment -> { if (Magic.Environment.labelAsParameter.contains(environmentName)) { - val labelEntry = beginCommand.optionalParameterMap.filter { pair -> pair.key.toString() == "label" }.first() + val labelEntry = + beginCommand.optionalParameterMap.filter { pair -> pair.key.toString() == "label" }.first() return labelEntry.value?.keyvalContentList?.first()?.parameterText ?: labelEntry.value.keyvalContentList.first().parameterGroup?.parameterGroupText - } else { + } + else { null } } diff --git a/test/nl/hannahsten/texifyidea/psi/LatexCommandsImplUtilTest.kt b/test/nl/hannahsten/texifyidea/psi/LatexCommandsImplUtilTest.kt index be0b57f51..ab0a17975 100644 --- a/test/nl/hannahsten/texifyidea/psi/LatexCommandsImplUtilTest.kt +++ b/test/nl/hannahsten/texifyidea/psi/LatexCommandsImplUtilTest.kt @@ -6,11 +6,12 @@ import nl.hannahsten.texifyidea.file.LatexFileType import nl.hannahsten.texifyidea.util.firstChildOfType import org.junit.Test -class LatexCommandsImplUtilTest : BasePlatformTestCase(){ +class LatexCommandsImplUtilTest : BasePlatformTestCase() { @Test fun `test simple optional parameters map`() { // given - myFixture.configureByText(LatexFileType, + myFixture.configureByText( + LatexFileType, """ \begin{document} \lstinputlisting[param1=value1,param2=value2,param3]{some/file} From eefda5c4b3a99e51f95c124c0831a15bdb343edb Mon Sep 17 00:00:00 2001 From: Felix Berlakovich Date: Tue, 29 Dec 2020 12:33:32 +0100 Subject: [PATCH 13/20] Fix group rename and special characters in keyval pairs --- .../texifyidea/parser/LatexParser.java | 37 ++++++++++++- .../texifyidea/psi/LatexKeyvalContent.java | 4 +- .../texifyidea/psi/LatexKeyvalText.java | 5 -- .../texifyidea/psi/LatexKeyvalValue.java | 14 +++-- .../psi/LatexParameterGroupText.java | 9 +--- .../hannahsten/texifyidea/psi/LatexTypes.java | 30 +++++------ .../texifyidea/psi/LatexVisitor.java | 8 ++- .../psi/impl/LatexKeyvalContentImpl.java | 10 ++-- .../psi/impl/LatexKeyvalTextImpl.java | 27 ++++++++++ .../psi/impl/LatexKeyvalValueImpl.java | 28 ++++++++-- .../psi/impl/LatexParameterGroupTextImpl.java | 17 ------ .../hannahsten/texifyidea/grammar/Latex.bnf | 13 +++-- .../texifyidea/psi/LatexCommandsImplUtil.kt | 4 +- .../psi/LatexParameterGroupTextUtil.kt | 11 ++-- .../texifyidea/psi/LatexPsiImplUtil.java | 6 +-- .../LatexRefactoringSupportProvider.kt | 7 ++- src/nl/hannahsten/texifyidea/util/Labels.kt | 6 +-- .../reference/LabelDefinitionReferenceTest.kt | 53 ++++++++++++++++--- 18 files changed, 197 insertions(+), 92 deletions(-) create mode 100644 gen/nl/hannahsten/texifyidea/psi/impl/LatexKeyvalTextImpl.java diff --git a/gen/nl/hannahsten/texifyidea/parser/LatexParser.java b/gen/nl/hannahsten/texifyidea/parser/LatexParser.java index 2f8d50881..e51c6ad27 100644 --- a/gen/nl/hannahsten/texifyidea/parser/LatexParser.java +++ b/gen/nl/hannahsten/texifyidea/parser/LatexParser.java @@ -279,12 +279,12 @@ private static boolean inline_math_1(PsiBuilder b, int l) { } /* ********************************************************** */ - // parameter_text | parameter_group + // keyval_text | parameter_group public static boolean keyval_content(PsiBuilder b, int l) { if (!recursion_guard_(b, l, "keyval_content")) return false; boolean r; Marker m = enter_section_(b, l, _NONE_, KEYVAL_CONTENT, ""); - r = parameter_text(b, l + 1); + r = keyval_text(b, l + 1); if (!r) r = parameter_group(b, l + 1); exit_section_(b, l, m, r, false, null); return r; @@ -336,6 +336,39 @@ private static boolean keyval_pair_1_0(PsiBuilder b, int l) { return r; } + /* ********************************************************** */ + // (NORMAL_TEXT_WORD | STAR | AMPERSAND | "|" | "!" | "\\" | "\"" | "&" | "<" | ">")+ + public static boolean keyval_text(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "keyval_text")) return false; + boolean r; + Marker m = enter_section_(b, l, _NONE_, KEYVAL_TEXT, ""); + r = keyval_text_0(b, l + 1); + while (r) { + int c = current_position_(b); + if (!keyval_text_0(b, l + 1)) break; + if (!empty_element_parsed_guard_(b, "keyval_text", c)) break; + } + exit_section_(b, l, m, r, false, null); + return r; + } + + // NORMAL_TEXT_WORD | STAR | AMPERSAND | "|" | "!" | "\\" | "\"" | "&" | "<" | ">" + private static boolean keyval_text_0(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "keyval_text_0")) return false; + boolean r; + r = consumeToken(b, NORMAL_TEXT_WORD); + if (!r) r = consumeToken(b, STAR); + if (!r) r = consumeToken(b, AMPERSAND); + if (!r) r = consumeToken(b, "|"); + if (!r) r = consumeToken(b, "!"); + if (!r) r = consumeToken(b, "\\"); + if (!r) r = consumeToken(b, "\""); + if (!r) r = consumeToken(b, AMPERSAND); + if (!r) r = consumeToken(b, "<"); + if (!r) r = consumeToken(b, ">"); + return r; + } + /* ********************************************************** */ // keyval_content+ public static boolean keyval_value(PsiBuilder b, int l) { diff --git a/gen/nl/hannahsten/texifyidea/psi/LatexKeyvalContent.java b/gen/nl/hannahsten/texifyidea/psi/LatexKeyvalContent.java index 6134dd3bc..8019d79a7 100644 --- a/gen/nl/hannahsten/texifyidea/psi/LatexKeyvalContent.java +++ b/gen/nl/hannahsten/texifyidea/psi/LatexKeyvalContent.java @@ -7,9 +7,9 @@ public interface LatexKeyvalContent extends PsiElement { @Nullable - LatexParameterGroup getParameterGroup(); + LatexKeyvalText getKeyvalText(); @Nullable - LatexParameterText getParameterText(); + LatexParameterGroup getParameterGroup(); } diff --git a/gen/nl/hannahsten/texifyidea/psi/LatexKeyvalText.java b/gen/nl/hannahsten/texifyidea/psi/LatexKeyvalText.java index c19723f24..a78acfc3a 100644 --- a/gen/nl/hannahsten/texifyidea/psi/LatexKeyvalText.java +++ b/gen/nl/hannahsten/texifyidea/psi/LatexKeyvalText.java @@ -1,13 +1,8 @@ // This is a generated file. Not intended for manual editing. package nl.hannahsten.texifyidea.psi; -import java.util.List; -import org.jetbrains.annotations.*; import com.intellij.psi.PsiElement; public interface LatexKeyvalText extends PsiElement { - @NotNull - PsiElement getNormalTextWord(); - } diff --git a/gen/nl/hannahsten/texifyidea/psi/LatexKeyvalValue.java b/gen/nl/hannahsten/texifyidea/psi/LatexKeyvalValue.java index 577363dd2..f6a917c23 100644 --- a/gen/nl/hannahsten/texifyidea/psi/LatexKeyvalValue.java +++ b/gen/nl/hannahsten/texifyidea/psi/LatexKeyvalValue.java @@ -1,13 +1,21 @@ // This is a generated file. Not intended for manual editing. package nl.hannahsten.texifyidea.psi; -import java.util.List; -import org.jetbrains.annotations.*; import com.intellij.psi.PsiElement; +import com.intellij.psi.PsiNameIdentifierOwner; +import org.jetbrains.annotations.NotNull; + +import java.util.List; -public interface LatexKeyvalValue extends PsiElement { +public interface LatexKeyvalValue extends PsiNameIdentifierOwner { @NotNull List getKeyvalContentList(); + PsiElement getNameIdentifier(); + + String getName(); + + PsiElement setName(String name); + } diff --git a/gen/nl/hannahsten/texifyidea/psi/LatexParameterGroupText.java b/gen/nl/hannahsten/texifyidea/psi/LatexParameterGroupText.java index c1151c526..198e9e0bf 100644 --- a/gen/nl/hannahsten/texifyidea/psi/LatexParameterGroupText.java +++ b/gen/nl/hannahsten/texifyidea/psi/LatexParameterGroupText.java @@ -2,20 +2,13 @@ package nl.hannahsten.texifyidea.psi; import com.intellij.psi.PsiElement; -import com.intellij.psi.PsiNameIdentifierOwner; import org.jetbrains.annotations.NotNull; import java.util.List; -public interface LatexParameterGroupText extends PsiNameIdentifierOwner { +public interface LatexParameterGroupText extends PsiElement { @NotNull List getContentList(); - PsiElement getNameIdentifier(); - - String getName(); - - PsiElement setName(String name); - } diff --git a/gen/nl/hannahsten/texifyidea/psi/LatexTypes.java b/gen/nl/hannahsten/texifyidea/psi/LatexTypes.java index 12e4ee04d..f43edb608 100644 --- a/gen/nl/hannahsten/texifyidea/psi/LatexTypes.java +++ b/gen/nl/hannahsten/texifyidea/psi/LatexTypes.java @@ -24,6 +24,7 @@ public interface LatexTypes { IElementType KEYVAL_CONTENT = new LatexElementType("KEYVAL_CONTENT"); IElementType KEYVAL_KEY = new LatexElementType("KEYVAL_KEY"); IElementType KEYVAL_PAIR = new LatexElementType("KEYVAL_PAIR"); + IElementType KEYVAL_TEXT = new LatexElementType("KEYVAL_TEXT"); IElementType KEYVAL_VALUE = new LatexElementType("KEYVAL_VALUE"); IElementType MAGIC_COMMENT = new LatexMagicCommentStubElementType("MAGIC_COMMENT"); IElementType MATH_CONTENT = new LatexElementType("MATH_CONTENT"); @@ -108,32 +109,25 @@ else if (type == KEYVAL_KEY) { } else if (type == KEYVAL_PAIR) { return new LatexKeyvalPairImpl(node); - } - else if (type == KEYVAL_VALUE) { + } else if (type == KEYVAL_TEXT) { + return new LatexKeyvalTextImpl(node); + } else if (type == KEYVAL_VALUE) { return new LatexKeyvalValueImpl(node); - } - else if (type == MAGIC_COMMENT) { + } else if (type == MAGIC_COMMENT) { return new LatexMagicCommentImpl(node); - } - else if (type == MATH_CONTENT) { + } else if (type == MATH_CONTENT) { return new LatexMathContentImpl(node); - } - else if (type == MATH_ENVIRONMENT) { + } else if (type == MATH_ENVIRONMENT) { return new LatexMathEnvironmentImpl(node); - } - else if (type == NORMAL_TEXT) { + } else if (type == NORMAL_TEXT) { return new LatexNormalTextImpl(node); - } - else if (type == NO_MATH_CONTENT) { + } else if (type == NO_MATH_CONTENT) { return new LatexNoMathContentImpl(node); - } - else if (type == OPTIONAL_PARAM) { + } else if (type == OPTIONAL_PARAM) { return new LatexOptionalParamImpl(node); - } - else if (type == OPTIONAL_PARAM_CONTENT) { + } else if (type == OPTIONAL_PARAM_CONTENT) { return new LatexOptionalParamContentImpl(node); - } - else if (type == PARAMETER) { + } else if (type == PARAMETER) { return new LatexParameterImpl(node); } else if (type == PARAMETER_GROUP) { return new LatexParameterGroupImpl(node); diff --git a/gen/nl/hannahsten/texifyidea/psi/LatexVisitor.java b/gen/nl/hannahsten/texifyidea/psi/LatexVisitor.java index 46cb45d79..870c56e51 100644 --- a/gen/nl/hannahsten/texifyidea/psi/LatexVisitor.java +++ b/gen/nl/hannahsten/texifyidea/psi/LatexVisitor.java @@ -62,10 +62,14 @@ public void visitKeyvalPair(@NotNull LatexKeyvalPair o) { visitPsiElement(o); } - public void visitKeyvalValue(@NotNull LatexKeyvalValue o) { + public void visitKeyvalText(@NotNull LatexKeyvalText o) { visitPsiElement(o); } + public void visitKeyvalValue(@NotNull LatexKeyvalValue o) { + visitPsiNameIdentifierOwner(o); + } + public void visitMagicComment(@NotNull LatexMagicComment o) { visitPsiElement(o); } @@ -103,7 +107,7 @@ public void visitParameterGroup(@NotNull LatexParameterGroup o) { } public void visitParameterGroupText(@NotNull LatexParameterGroupText o) { - visitPsiNameIdentifierOwner(o); + visitPsiElement(o); } public void visitParameterText(@NotNull LatexParameterText o) { diff --git a/gen/nl/hannahsten/texifyidea/psi/impl/LatexKeyvalContentImpl.java b/gen/nl/hannahsten/texifyidea/psi/impl/LatexKeyvalContentImpl.java index f9d38cf85..f14033796 100644 --- a/gen/nl/hannahsten/texifyidea/psi/impl/LatexKeyvalContentImpl.java +++ b/gen/nl/hannahsten/texifyidea/psi/impl/LatexKeyvalContentImpl.java @@ -6,8 +6,8 @@ import com.intellij.psi.PsiElementVisitor; import com.intellij.psi.util.PsiTreeUtil; import nl.hannahsten.texifyidea.psi.LatexKeyvalContent; +import nl.hannahsten.texifyidea.psi.LatexKeyvalText; import nl.hannahsten.texifyidea.psi.LatexParameterGroup; -import nl.hannahsten.texifyidea.psi.LatexParameterText; import nl.hannahsten.texifyidea.psi.LatexVisitor; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -30,14 +30,14 @@ public void accept(@NotNull PsiElementVisitor visitor) { @Override @Nullable - public LatexParameterGroup getParameterGroup() { - return PsiTreeUtil.getChildOfType(this, LatexParameterGroup.class); + public LatexKeyvalText getKeyvalText() { + return PsiTreeUtil.getChildOfType(this, LatexKeyvalText.class); } @Override @Nullable - public LatexParameterText getParameterText() { - return PsiTreeUtil.getChildOfType(this, LatexParameterText.class); + public LatexParameterGroup getParameterGroup() { + return PsiTreeUtil.getChildOfType(this, LatexParameterGroup.class); } } diff --git a/gen/nl/hannahsten/texifyidea/psi/impl/LatexKeyvalTextImpl.java b/gen/nl/hannahsten/texifyidea/psi/impl/LatexKeyvalTextImpl.java new file mode 100644 index 000000000..19cf75b96 --- /dev/null +++ b/gen/nl/hannahsten/texifyidea/psi/impl/LatexKeyvalTextImpl.java @@ -0,0 +1,27 @@ +// This is a generated file. Not intended for manual editing. +package nl.hannahsten.texifyidea.psi.impl; + +import com.intellij.extapi.psi.ASTWrapperPsiElement; +import com.intellij.lang.ASTNode; +import com.intellij.psi.PsiElementVisitor; +import nl.hannahsten.texifyidea.psi.LatexKeyvalText; +import nl.hannahsten.texifyidea.psi.LatexVisitor; +import org.jetbrains.annotations.NotNull; + +public class LatexKeyvalTextImpl extends ASTWrapperPsiElement implements LatexKeyvalText { + + public LatexKeyvalTextImpl(@NotNull ASTNode node) { + super(node); + } + + public void accept(@NotNull LatexVisitor visitor) { + visitor.visitKeyvalText(this); + } + + @Override + public void accept(@NotNull PsiElementVisitor visitor) { + if (visitor instanceof LatexVisitor) accept((LatexVisitor) visitor); + else super.accept(visitor); + } + +} diff --git a/gen/nl/hannahsten/texifyidea/psi/impl/LatexKeyvalValueImpl.java b/gen/nl/hannahsten/texifyidea/psi/impl/LatexKeyvalValueImpl.java index a9f9256ca..dabdf2c82 100644 --- a/gen/nl/hannahsten/texifyidea/psi/impl/LatexKeyvalValueImpl.java +++ b/gen/nl/hannahsten/texifyidea/psi/impl/LatexKeyvalValueImpl.java @@ -1,15 +1,18 @@ // This is a generated file. Not intended for manual editing. package nl.hannahsten.texifyidea.psi.impl; -import java.util.List; -import org.jetbrains.annotations.*; +import com.intellij.extapi.psi.ASTWrapperPsiElement; import com.intellij.lang.ASTNode; import com.intellij.psi.PsiElement; import com.intellij.psi.PsiElementVisitor; import com.intellij.psi.util.PsiTreeUtil; -import static nl.hannahsten.texifyidea.psi.LatexTypes.*; -import com.intellij.extapi.psi.ASTWrapperPsiElement; -import nl.hannahsten.texifyidea.psi.*; +import nl.hannahsten.texifyidea.psi.LatexKeyvalContent; +import nl.hannahsten.texifyidea.psi.LatexKeyvalValue; +import nl.hannahsten.texifyidea.psi.LatexPsiImplUtil; +import nl.hannahsten.texifyidea.psi.LatexVisitor; +import org.jetbrains.annotations.NotNull; + +import java.util.List; public class LatexKeyvalValueImpl extends ASTWrapperPsiElement implements LatexKeyvalValue { @@ -38,4 +41,19 @@ public String toString() { return LatexPsiImplUtil.toString(this); } + @Override + public PsiElement getNameIdentifier() { + return LatexPsiImplUtil.getNameIdentifier(this); + } + + @Override + public String getName() { + return LatexPsiImplUtil.getName(this); + } + + @Override + public PsiElement setName(String name) { + return LatexPsiImplUtil.setName(this, name); + } + } diff --git a/gen/nl/hannahsten/texifyidea/psi/impl/LatexParameterGroupTextImpl.java b/gen/nl/hannahsten/texifyidea/psi/impl/LatexParameterGroupTextImpl.java index 3e6d658fa..d031d0b72 100644 --- a/gen/nl/hannahsten/texifyidea/psi/impl/LatexParameterGroupTextImpl.java +++ b/gen/nl/hannahsten/texifyidea/psi/impl/LatexParameterGroupTextImpl.java @@ -3,12 +3,10 @@ import com.intellij.extapi.psi.ASTWrapperPsiElement; import com.intellij.lang.ASTNode; -import com.intellij.psi.PsiElement; import com.intellij.psi.PsiElementVisitor; import com.intellij.psi.util.PsiTreeUtil; import nl.hannahsten.texifyidea.psi.LatexContent; import nl.hannahsten.texifyidea.psi.LatexParameterGroupText; -import nl.hannahsten.texifyidea.psi.LatexPsiImplUtil; import nl.hannahsten.texifyidea.psi.LatexVisitor; import org.jetbrains.annotations.NotNull; @@ -36,19 +34,4 @@ public List getContentList() { return PsiTreeUtil.getChildrenOfTypeAsList(this, LatexContent.class); } - @Override - public PsiElement getNameIdentifier() { - return LatexPsiImplUtil.getNameIdentifier(this); - } - - @Override - public String getName() { - return LatexPsiImplUtil.getName(this); - } - - @Override - public PsiElement setName(String name) { - return LatexPsiImplUtil.setName(this, name); - } - } diff --git a/src/nl/hannahsten/texifyidea/grammar/Latex.bnf b/src/nl/hannahsten/texifyidea/grammar/Latex.bnf index 2c09a1da2..e8dbf7637 100644 --- a/src/nl/hannahsten/texifyidea/grammar/Latex.bnf +++ b/src/nl/hannahsten/texifyidea/grammar/Latex.bnf @@ -27,7 +27,7 @@ implements("parameter_text")="com.intellij.psi.PsiNameIdentifierOwner" // Make text in parameter group have an identifier, to be able to Ctrl+B for \label parameters - implements("parameter_group_text")="com.intellij.psi.PsiNameIdentifierOwner" + implements("keyval_value")="com.intellij.psi.PsiNameIdentifierOwner" // See the lexer @@ -118,9 +118,14 @@ keyval_key ::= keyval_content+ { methods=[toString] } keyval_value ::= keyval_content+ { - methods=[toString] + methods=[toString getNameIdentifier getName setName] } -keyval_content ::= parameter_text | parameter_group +keyval_content ::= keyval_text | parameter_group + +// We need to include the special characters here because changing NORMAL_TEXT_CHAR would alter the lexer's behaviour +// and break several other things. +keyval_text ::= (NORMAL_TEXT_WORD | STAR | AMPERSAND | "|" | "!" | "\\" | "\"" | "&" | "<" | ">")+ + // The lowest level of a parameter must have the getReferences etc. implemented // We don't do this on normal_text because then every normal_text in the document would be a reference @@ -137,7 +142,7 @@ parameter_group ::= OPEN_BRACE parameter_group_text CLOSE_BRACE { pin=1 } // Be sure to capture the whitespace before and after the actual content as groups are meant to capture // *everything* inside them. -parameter_group_text ::= content* { hooks = [wsBinders="GREEDY_LEFT_BINDER, GREEDY_RIGHT_BINDER"] methods=[getNameIdentifier getName setName] } +parameter_group_text ::= content* { hooks = [wsBinders="GREEDY_LEFT_BINDER, GREEDY_RIGHT_BINDER"] } comment ::= COMMENT_TOKEN diff --git a/src/nl/hannahsten/texifyidea/psi/LatexCommandsImplUtil.kt b/src/nl/hannahsten/texifyidea/psi/LatexCommandsImplUtil.kt index ddb082625..b15058533 100644 --- a/src/nl/hannahsten/texifyidea/psi/LatexCommandsImplUtil.kt +++ b/src/nl/hannahsten/texifyidea/psi/LatexCommandsImplUtil.kt @@ -213,9 +213,9 @@ fun setName(element: LatexCommands, newName: String): PsiElement { } fun toString(element: LatexKeyvalKey): String = - element.keyvalContentList.map { it -> it.parameterText?.text ?: it.parameterGroup!!.parameterGroupText!!.text } + element.keyvalContentList.map { it -> it.keyvalText?.text ?: it.parameterGroup!!.parameterGroupText!!.text } .joinToString(separator = "") fun toString(element: LatexKeyvalValue): String = - element.keyvalContentList.map { it -> it.parameterText?.text ?: it.parameterGroup!!.parameterGroupText!!.text } + element.keyvalContentList.map { it -> it.keyvalText?.text ?: it.parameterGroup!!.parameterGroupText!!.text } .joinToString(separator = "") diff --git a/src/nl/hannahsten/texifyidea/psi/LatexParameterGroupTextUtil.kt b/src/nl/hannahsten/texifyidea/psi/LatexParameterGroupTextUtil.kt index 05ce4f191..d9998c100 100644 --- a/src/nl/hannahsten/texifyidea/psi/LatexParameterGroupTextUtil.kt +++ b/src/nl/hannahsten/texifyidea/psi/LatexParameterGroupTextUtil.kt @@ -4,7 +4,7 @@ import com.intellij.psi.PsiElement import nl.hannahsten.texifyidea.util.Magic import nl.hannahsten.texifyidea.util.firstParentOfType -fun getNameIdentifier(element: LatexParameterGroupText): PsiElement? { +fun getNameIdentifier(element: LatexKeyvalValue): PsiElement? { // Because we do not want to trigger the NonAsciiCharactersInspection when the LatexParameterText is not an identifier // (think non-ASCII characters in a \section command), we return null here when the element is not an identifier // It is important not to return null for any identifier, otherwise exceptions like "Throwable: null byMemberInplaceRenamer" may occur @@ -18,7 +18,7 @@ fun getNameIdentifier(element: LatexParameterGroupText): PsiElement? { return null } -fun setName(element: LatexParameterGroupText, name: String): PsiElement { +fun setName(element: LatexKeyvalValue, name: String): PsiElement { val command = element.firstParentOfType(LatexCommands::class) val environment = element.firstParentOfType(LatexEnvironment::class) if (Magic.Command.labelAsParameter.contains(command?.name) || Magic.Environment.labelAsParameter.contains( @@ -26,13 +26,14 @@ fun setName(element: LatexParameterGroupText, name: String): PsiElement { ) ) { val helper = LatexPsiHelper(element.project) - helper.setOptionalParameter(command ?: environment!!.beginCommand, "label", "{$name}") + val commandWithParams = command ?: environment!!.beginCommand + helper.setOptionalParameter(commandWithParams, "label", "{$name}") } // Else, element is not renamable return element } -fun getName(element: LatexParameterGroupText): String { - return element.text ?: "" +fun getName(element: LatexKeyvalValue): String { + return element.toString() } \ No newline at end of file diff --git a/src/nl/hannahsten/texifyidea/psi/LatexPsiImplUtil.java b/src/nl/hannahsten/texifyidea/psi/LatexPsiImplUtil.java index b274452bc..28deedc1a 100644 --- a/src/nl/hannahsten/texifyidea/psi/LatexPsiImplUtil.java +++ b/src/nl/hannahsten/texifyidea/psi/LatexPsiImplUtil.java @@ -123,15 +123,15 @@ public static String getName(@NotNull LatexParameterText element) { return LatexParameterTextUtilKt.getName(element); } - public static PsiElement getNameIdentifier(@NotNull LatexParameterGroupText element) { + public static PsiElement getNameIdentifier(@NotNull LatexKeyvalValue element) { return LatexParameterGroupTextUtilKt.getNameIdentifier(element); } - public static PsiElement setName(@NotNull LatexParameterGroupText element, String name) { + public static PsiElement setName(@NotNull LatexKeyvalValue element, String name) { return LatexParameterGroupTextUtilKt.setName(element, name); } - public static String getName(@NotNull LatexParameterGroupText element) { + public static String getName(@NotNull LatexKeyvalValue element) { return LatexParameterGroupTextUtilKt.getName(element); } diff --git a/src/nl/hannahsten/texifyidea/refactoring/LatexRefactoringSupportProvider.kt b/src/nl/hannahsten/texifyidea/refactoring/LatexRefactoringSupportProvider.kt index 475e2e3dd..583f10fc9 100644 --- a/src/nl/hannahsten/texifyidea/refactoring/LatexRefactoringSupportProvider.kt +++ b/src/nl/hannahsten/texifyidea/refactoring/LatexRefactoringSupportProvider.kt @@ -2,6 +2,7 @@ package nl.hannahsten.texifyidea.refactoring import com.intellij.lang.refactoring.RefactoringSupportProvider import com.intellij.psi.PsiElement +import nl.hannahsten.texifyidea.psi.LatexKeyvalValue import nl.hannahsten.texifyidea.psi.LatexParameterText /** @@ -10,6 +11,10 @@ import nl.hannahsten.texifyidea.psi.LatexParameterText class LatexRefactoringSupportProvider : RefactoringSupportProvider() { override fun isMemberInplaceRenameAvailable(element: PsiElement, context: PsiElement?): Boolean { // Label parameters are LatexParameterText - return element is LatexParameterText + return when (element) { + is LatexParameterText -> true + is LatexKeyvalValue -> true + else -> false + } } } \ No newline at end of file diff --git a/src/nl/hannahsten/texifyidea/util/Labels.kt b/src/nl/hannahsten/texifyidea/util/Labels.kt index 18cbeb835..e5738fb39 100644 --- a/src/nl/hannahsten/texifyidea/util/Labels.kt +++ b/src/nl/hannahsten/texifyidea/util/Labels.kt @@ -198,8 +198,7 @@ fun PsiElement.extractLabelElement(): PsiElement? { is LatexCommands -> { if (Magic.Command.labelAsParameter.contains(name)) { val labelEntry = optionalParameterMap.filter { pair -> pair.key.toString() == "label" }.first() - val keyValContent = labelEntry.value?.keyvalContentList?.first() - return keyValContent?.parameterText ?: keyValContent?.parameterGroup?.parameterGroupText + return labelEntry.value } else { // For now just take the first label name (may be multiple for user defined commands) @@ -215,8 +214,7 @@ fun PsiElement.extractLabelElement(): PsiElement? { if (Magic.Environment.labelAsParameter.contains(environmentName)) { val labelEntry = beginCommand.optionalParameterMap.filter { pair -> pair.key.toString() == "label" }.first() - return labelEntry.value?.keyvalContentList?.first()?.parameterText - ?: labelEntry.value.keyvalContentList.first().parameterGroup?.parameterGroupText + return labelEntry.value } else { null diff --git a/test/nl/hannahsten/texifyidea/reference/LabelDefinitionReferenceTest.kt b/test/nl/hannahsten/texifyidea/reference/LabelDefinitionReferenceTest.kt index d3bdeb5fe..71bcd770e 100644 --- a/test/nl/hannahsten/texifyidea/reference/LabelDefinitionReferenceTest.kt +++ b/test/nl/hannahsten/texifyidea/reference/LabelDefinitionReferenceTest.kt @@ -23,7 +23,26 @@ class LabelDefinitionReferenceTest : BasePlatformTestCase() { myFixture.renameElementAtCaret("renamed") myFixture.checkResult( """ - \begin{lstlisting}[label=renamed] + \begin{lstlisting}[label={renamed}] + \end{lstlisting} + \ref{renamed} + """.trimMargin() + ) + } + + fun `test rename of label in environment with special character`() { + myFixture.configureByText( + LatexFileType, + """ + \begin{lstlisting}[label=test,escapechar=|] + \end{lstlisting} + \ref{test} + """.trimMargin() + ) + myFixture.renameElementAtCaret("renamed") + myFixture.checkResult( + """ + \begin{lstlisting}[label={renamed},escapechar=|] \end{lstlisting} \ref{renamed} """.trimMargin() @@ -31,28 +50,50 @@ class LabelDefinitionReferenceTest : BasePlatformTestCase() { } fun `test rename of label in command`() { - myFixture.configureByText(LatexFileType, + myFixture.configureByText( + LatexFileType, """ \lstinputlisting[label=test]{inputfile} \ref{test} """ - .trimMargin()) + .trimMargin() + ) myFixture.renameElementAtCaret("renamed") myFixture.checkResult( """ - \lstinputlisting[label=renamed]{inputfile} + \lstinputlisting[label={renamed}]{inputfile} \ref{renamed} """.trimMargin() ) } fun `test rename of label in group`() { - myFixture.configureByText(LatexFileType, + myFixture.configureByText( + LatexFileType, """ \lstinputlisting[label={test}]{inputfile} \ref{test} """ - .trimMargin()) + .trimMargin() + ) + myFixture.renameElementAtCaret("renamed") + myFixture.checkResult( + """ + \lstinputlisting[label={renamed}]{inputfile} + \ref{renamed} + """.trimMargin() + ) + } + + fun `test rename of label in multiple groups`() { + myFixture.configureByText( + LatexFileType, + """ + \lstinputlisting[label={test}{test2}]{inputfile} + \ref{testtest2} + """ + .trimMargin() + ) myFixture.renameElementAtCaret("renamed") myFixture.checkResult( """ From 84cbd95f430fd1bcbdd0e3939c67403acb76fe75 Mon Sep 17 00:00:00 2001 From: Felix Berlakovich Date: Tue, 29 Dec 2020 15:32:24 +0100 Subject: [PATCH 14/20] Create dedicated tokens for "=" and "," and fix the allowed special characters in keyval content --- .../texifyidea/grammar/LatexLexer.java | 1609 +++++++++-------- .../texifyidea/parser/LatexParser.java | 40 +- .../texifyidea/psi/LatexKeyvalContent.java | 11 +- .../hannahsten/texifyidea/psi/LatexTypes.java | 2 + .../psi/impl/LatexKeyvalContentImpl.java | 13 +- .../hannahsten/texifyidea/grammar/Latex.bnf | 16 +- .../texifyidea/grammar/LatexLexer.flex | 7 +- .../texifyidea/psi/LatexCommandsImplUtil.kt | 22 +- .../texifyidea/psi/LatexPsiHelper.kt | 5 +- .../texifyidea/psi/LatexPsiImplUtil.java | 4 +- .../psi/LatexCommandsImplUtilTest.kt | 25 + .../reference/LabelDefinitionReferenceTest.kt | 4 +- 12 files changed, 964 insertions(+), 794 deletions(-) diff --git a/gen/nl/hannahsten/texifyidea/grammar/LatexLexer.java b/gen/nl/hannahsten/texifyidea/grammar/LatexLexer.java index c84edff12..23d3579d1 100644 --- a/gen/nl/hannahsten/texifyidea/grammar/LatexLexer.java +++ b/gen/nl/hannahsten/texifyidea/grammar/LatexLexer.java @@ -2,13 +2,13 @@ package nl.hannahsten.texifyidea.grammar; -import java.util.*; - import com.intellij.lexer.FlexLexer; -import com.intellij.psi.TokenType; import com.intellij.psi.tree.IElementType; import nl.hannahsten.texifyidea.util.Magic; +import java.util.ArrayDeque; +import java.util.Deque; + import static nl.hannahsten.texifyidea.psi.LatexTypes.*; @@ -81,13 +81,13 @@ public static int ZZ_CMAP(int ch) { /* The ZZ_CMAP_A table has 640 entries */ static final char ZZ_CMAP_A[] = zzUnpackCMap( - "\11\0\1\10\1\20\2\22\1\21\22\0\1\35\1\34\1\47\1\0\1\66\1\41\1\70\1\0\1\2\1"+ - "\3\1\63\1\0\1\47\15\0\1\17\1\0\1\67\1\44\1\67\1\0\1\24\1\51\3\17\1\37\1\50"+ - "\2\17\1\53\2\17\1\56\3\17\1\60\1\17\1\55\1\17\1\36\1\61\1\17\1\54\1\40\2\17"+ - "\1\4\1\1\1\5\1\0\1\17\1\0\1\32\1\11\1\30\1\16\1\12\1\25\1\13\1\31\1\14\2\17"+ - "\1\52\1\65\1\15\1\45\1\42\1\17\1\33\1\43\1\27\1\57\1\62\1\64\1\26\2\17\1\6"+ - "\1\47\1\7\7\0\1\23\32\0\1\46\337\0\1\46\177\0\13\46\35\0\2\23\5\0\1\46\57"+ - "\0\1\46\40\0"); + "\11\0\1\10\1\20\2\22\1\21\22\0\1\35\1\34\1\47\1\0\1\66\1\41\1\70\1\0\1\2\1" + + "\3\1\63\1\0\1\71\15\0\1\17\1\0\1\67\1\44\1\67\1\0\1\24\1\51\3\17\1\37\1\50" + + "\2\17\1\53\2\17\1\56\3\17\1\60\1\17\1\55\1\17\1\36\1\61\1\17\1\54\1\40\2\17" + + "\1\4\1\1\1\5\1\0\1\17\1\0\1\32\1\11\1\30\1\16\1\12\1\25\1\13\1\31\1\14\2\17" + + "\1\52\1\65\1\15\1\45\1\42\1\17\1\33\1\43\1\27\1\57\1\62\1\64\1\26\2\17\1\6" + + "\1\47\1\7\7\0\1\23\32\0\1\46\337\0\1\46\177\0\13\46\35\0\2\23\5\0\1\46\57" + + "\0\1\46\40\0"); /** * Translates DFA states to action switch labels. @@ -95,27 +95,27 @@ public static int ZZ_CMAP(int ch) { private static final int [] ZZ_ACTION = zzUnpackAction(); private static final String ZZ_ACTION_PACKED_0 = - "\27\0\1\1\1\2\1\3\1\4\1\5\1\6\1\7"+ - "\1\10\1\11\1\12\1\2\1\13\1\14\1\15\1\2"+ - "\1\16\1\2\1\17\3\2\1\20\1\21\1\1\1\22"+ - "\1\2\1\23\1\24\1\25\1\26\1\27\1\30\1\31"+ - "\1\32\1\33\1\34\1\35\2\36\1\37\1\40\1\41"+ - "\1\42\1\43\1\2\1\44\1\36\1\45\1\46\1\47"+ - "\10\45\1\13\1\50\1\13\1\51\1\45\1\52\1\53"+ - "\1\54\2\0\11\45\2\0\7\45\1\50\1\0\1\50"+ - "\1\13\1\45\2\0\5\45\1\55\5\45\2\0\1\45"+ - "\1\56\4\45\1\0\1\50\1\13\1\45\1\0\1\57"+ - "\1\60\2\45\1\55\6\45\2\0\4\45\1\61\1\0"+ - "\1\50\1\13\1\62\1\0\5\45\1\63\7\45\2\0"+ - "\1\64\3\45\1\61\1\0\1\50\1\65\2\45\1\66"+ - "\7\45\1\0\3\45\1\0\1\50\6\45\1\0\3\45"+ - "\1\0\1\50\5\45\1\0\3\45\1\0\1\50\2\45"+ - "\1\0\2\45\1\61\1\0\1\50\2\45\1\0\2\45"+ - "\1\0\1\50\2\45\1\67\2\45\1\0\1\70\1\45"+ - "\1\71\1\45\1\72"; + "\27\0\1\1\1\2\1\3\1\4\1\5\1\6\1\7" + + "\1\10\1\11\1\12\1\2\1\13\1\14\1\15\1\16" + + "\1\2\1\17\1\20\1\2\1\21\3\2\1\22\1\23" + + "\1\1\1\24\1\2\1\25\1\26\1\27\1\30\1\31" + + "\1\32\1\33\1\34\1\35\1\36\1\37\2\40\1\41" + + "\1\42\1\43\1\44\1\45\1\2\1\46\1\40\1\47" + + "\1\50\1\51\10\47\1\13\1\52\1\13\1\53\1\47" + + "\1\54\1\55\1\56\2\0\11\47\2\0\7\47\1\52" + + "\1\0\1\52\1\13\1\47\2\0\5\47\1\57\5\47" + + "\2\0\1\47\1\60\4\47\1\0\1\52\1\13\1\47" + + "\1\0\1\61\1\62\2\47\1\57\6\47\2\0\4\47" + + "\1\63\1\0\1\52\1\13\1\64\1\0\5\47\1\65" + + "\7\47\2\0\1\66\3\47\1\63\1\0\1\52\1\67" + + "\2\47\1\70\7\47\1\0\3\47\1\0\1\52\6\47" + + "\1\0\3\47\1\0\1\52\5\47\1\0\3\47\1\0" + + "\1\52\2\47\1\0\2\47\1\63\1\0\1\52\2\47" + + "\1\0\2\47\1\0\1\52\2\47\1\71\2\47\1\0" + + "\1\72\1\47\1\73\1\47\1\74"; private static int [] zzUnpackAction() { - int [] result = new int[251]; + int[] result = new int[253]; int offset = 0; offset = zzUnpackAction(ZZ_ACTION_PACKED_0, offset, result); return result; @@ -140,41 +140,41 @@ private static int zzUnpackAction(String packed, int offset, int [] result) { private static final int [] ZZ_ROWMAP = zzUnpackRowMap(); private static final String ZZ_ROWMAP_PACKED_0 = - "\0\0\0\71\0\162\0\253\0\344\0\u011d\0\u0156\0\u018f"+ - "\0\u01c8\0\u0201\0\u023a\0\u0273\0\u02ac\0\u02e5\0\u031e\0\u0357"+ - "\0\u0390\0\u03c9\0\u0402\0\u043b\0\u0474\0\u04ad\0\u04e6\0\u051f"+ - "\0\u0558\0\u0591\0\u0591\0\u0591\0\u0591\0\u0591\0\u0591\0\u05ca"+ - "\0\u0591\0\u0591\0\u0603\0\u051f\0\u0591\0\u063c\0\u0591\0\u0675"+ - "\0\u0591\0\u06ae\0\u06e7\0\u0720\0\u0591\0\u0591\0\u0591\0\u0591"+ - "\0\u0759\0\u0591\0\u0591\0\u0591\0\u0591\0\u0591\0\u0591\0\u0591"+ - "\0\u0792\0\u0591\0\u0591\0\u0591\0\u0591\0\u07cb\0\u0591\0\u0591"+ - "\0\u0804\0\u083d\0\u0591\0\u0876\0\u08af\0\u08e8\0\u0591\0\u0591"+ - "\0\u0591\0\u0921\0\u095a\0\u0993\0\u09cc\0\u0a05\0\u0a3e\0\u0a77"+ - "\0\u0ab0\0\u0ae9\0\u0b22\0\u0b5b\0\u0591\0\u0b94\0\u0591\0\u0591"+ - "\0\u0591\0\u0bcd\0\u0c06\0\u0c3f\0\u0c78\0\u0cb1\0\u0cea\0\u0d23"+ - "\0\u0d5c\0\u0d95\0\u0dce\0\u0e07\0\u0e40\0\u0e79\0\u0eb2\0\u0eeb"+ - "\0\u0f24\0\u0f5d\0\u0f96\0\u0fcf\0\u1008\0\u1041\0\u107a\0\u10b3"+ - "\0\u10ec\0\u1125\0\u115e\0\u1197\0\u11d0\0\u1209\0\u1242\0\u127b"+ - "\0\u12b4\0\u0993\0\u12ed\0\u1326\0\u135f\0\u1398\0\u13d1\0\u140a"+ - "\0\u1443\0\u147c\0\u0993\0\u14b5\0\u14ee\0\u1527\0\u1560\0\u1599"+ - "\0\u15d2\0\u160b\0\u1644\0\u167d\0\u0591\0\u0993\0\u16b6\0\u16ef"+ - "\0\u1728\0\u1761\0\u179a\0\u17d3\0\u180c\0\u1845\0\u187e\0\u18b7"+ - "\0\u18f0\0\u1929\0\u1962\0\u199b\0\u19d4\0\u1a0d\0\u1a46\0\u1a7f"+ - "\0\u1ab8\0\u0993\0\u1af1\0\u1b2a\0\u1b63\0\u1b9c\0\u1bd5\0\u1c0e"+ - "\0\u0993\0\u1c47\0\u1c80\0\u1cb9\0\u1cf2\0\u1d2b\0\u1d64\0\u1d9d"+ - "\0\u1dd6\0\u1e0f\0\u0993\0\u1e48\0\u1e81\0\u1eba\0\u0591\0\u1ef3"+ - "\0\u1f2c\0\u0591\0\u1f65\0\u1f9e\0\u0993\0\u1fd7\0\u2010\0\u2049"+ - "\0\u2082\0\u20bb\0\u20f4\0\u212d\0\u2166\0\u219f\0\u21d8\0\u2211"+ - "\0\u224a\0\u2283\0\u22bc\0\u22f5\0\u232e\0\u2367\0\u23a0\0\u23d9"+ - "\0\u2412\0\u244b\0\u2484\0\u24bd\0\u24f6\0\u252f\0\u2568\0\u25a1"+ - "\0\u25da\0\u2613\0\u264c\0\u2685\0\u26be\0\u26f7\0\u2730\0\u2769"+ - "\0\u27a2\0\u27db\0\u2814\0\u284d\0\u2886\0\u28bf\0\u0993\0\u28f8"+ - "\0\u2931\0\u296a\0\u29a3\0\u29dc\0\u2a15\0\u2a4e\0\u2a87\0\u2ac0"+ - "\0\u2af9\0\u2b32\0\u2b6b\0\u2ba4\0\u2bdd\0\u2c16\0\u2c4f\0\u2c88"+ - "\0\u0591\0\u2cc1\0\u0993"; + "\0\0\0\72\0\164\0\256\0\350\0\u0122\0\u015c\0\u0196" + + "\0\u01d0\0\u020a\0\u0244\0\u027e\0\u02b8\0\u02f2\0\u032c\0\u0366" + + "\0\u03a0\0\u03da\0\u0414\0\u044e\0\u0488\0\u04c2\0\u04fc\0\u0536" + + "\0\u0570\0\u05aa\0\u05aa\0\u05aa\0\u05aa\0\u05aa\0\u05aa\0\u05e4" + + "\0\u05aa\0\u05aa\0\u061e\0\u05aa\0\u0536\0\u05aa\0\u0658\0\u05aa" + + "\0\u05aa\0\u0692\0\u05aa\0\u06cc\0\u0706\0\u0740\0\u05aa\0\u05aa" + + "\0\u05aa\0\u05aa\0\u077a\0\u05aa\0\u05aa\0\u05aa\0\u05aa\0\u05aa" + + "\0\u05aa\0\u05aa\0\u07b4\0\u05aa\0\u05aa\0\u05aa\0\u05aa\0\u07ee" + + "\0\u05aa\0\u05aa\0\u0828\0\u0862\0\u05aa\0\u089c\0\u08d6\0\u0910" + + "\0\u05aa\0\u05aa\0\u05aa\0\u094a\0\u0984\0\u09be\0\u09f8\0\u0a32" + + "\0\u0a6c\0\u0aa6\0\u0ae0\0\u0b1a\0\u0b54\0\u0b8e\0\u05aa\0\u0bc8" + + "\0\u05aa\0\u05aa\0\u05aa\0\u0c02\0\u0c3c\0\u0c76\0\u0cb0\0\u0cea" + + "\0\u0d24\0\u0d5e\0\u0d98\0\u0dd2\0\u0e0c\0\u0e46\0\u0e80\0\u0eba" + + "\0\u0ef4\0\u0f2e\0\u0f68\0\u0fa2\0\u0fdc\0\u1016\0\u1050\0\u108a" + + "\0\u10c4\0\u10fe\0\u1138\0\u1172\0\u11ac\0\u11e6\0\u1220\0\u125a" + + "\0\u1294\0\u12ce\0\u1308\0\u09be\0\u1342\0\u137c\0\u13b6\0\u13f0" + + "\0\u142a\0\u1464\0\u149e\0\u14d8\0\u09be\0\u1512\0\u154c\0\u1586" + + "\0\u15c0\0\u15fa\0\u1634\0\u166e\0\u16a8\0\u16e2\0\u05aa\0\u09be" + + "\0\u171c\0\u1756\0\u1790\0\u17ca\0\u1804\0\u183e\0\u1878\0\u18b2" + + "\0\u18ec\0\u1926\0\u1960\0\u199a\0\u19d4\0\u1a0e\0\u1a48\0\u1a82" + + "\0\u1abc\0\u1af6\0\u1b30\0\u09be\0\u1b6a\0\u1ba4\0\u1bde\0\u1c18" + + "\0\u1c52\0\u1c8c\0\u09be\0\u1cc6\0\u1d00\0\u1d3a\0\u1d74\0\u1dae" + + "\0\u1de8\0\u1e22\0\u1e5c\0\u1e96\0\u09be\0\u1ed0\0\u1f0a\0\u1f44" + + "\0\u05aa\0\u1f7e\0\u1fb8\0\u05aa\0\u1ff2\0\u202c\0\u09be\0\u2066" + + "\0\u20a0\0\u20da\0\u2114\0\u214e\0\u2188\0\u21c2\0\u21fc\0\u2236" + + "\0\u2270\0\u22aa\0\u22e4\0\u231e\0\u2358\0\u2392\0\u23cc\0\u2406" + + "\0\u2440\0\u247a\0\u24b4\0\u24ee\0\u2528\0\u2562\0\u259c\0\u25d6" + + "\0\u2610\0\u264a\0\u2684\0\u26be\0\u26f8\0\u2732\0\u276c\0\u27a6" + + "\0\u27e0\0\u281a\0\u2854\0\u288e\0\u28c8\0\u2902\0\u293c\0\u2976" + + "\0\u09be\0\u29b0\0\u29ea\0\u2a24\0\u2a5e\0\u2a98\0\u2ad2\0\u2b0c" + + "\0\u2b46\0\u2b80\0\u2bba\0\u2bf4\0\u2c2e\0\u2c68\0\u2ca2\0\u2cdc" + + "\0\u2d16\0\u2d50\0\u05aa\0\u2d8a\0\u09be"; private static int [] zzUnpackRowMap() { - int [] result = new int[251]; + int[] result = new int[253]; int offset = 0; offset = zzUnpackRowMap(ZZ_ROWMAP_PACKED_0, offset, result); return result; @@ -197,362 +197,364 @@ private static int zzUnpackRowMap(String packed, int offset, int [] result) { private static final int [] ZZ_TRANS = zzUnpackTrans(); private static final String ZZ_TRANS_PACKED_0 = - "\1\30\1\31\1\32\1\33\1\34\1\35\1\36\1\37"+ - "\1\40\7\30\3\40\1\41\10\30\1\42\1\40\3\30"+ - "\1\43\2\30\1\42\1\30\1\41\1\42\13\30\1\44"+ - "\2\30\1\45\1\46\1\47\1\30\1\50\1\32\1\33"+ - "\1\34\1\35\1\36\1\37\1\40\7\30\3\40\1\41"+ - "\10\30\1\42\1\40\3\30\1\43\2\30\1\42\1\30"+ - "\1\41\1\42\13\30\1\44\2\30\1\51\1\46\1\47"+ - "\1\30\1\52\1\32\1\33\1\34\1\35\1\36\1\37"+ - "\1\40\7\30\3\40\1\41\10\30\1\42\1\40\3\30"+ - "\1\43\2\30\1\42\1\30\1\41\1\42\13\30\1\44"+ - "\2\30\1\41\1\46\1\47\1\30\1\53\1\32\1\33"+ - "\1\34\1\35\1\36\1\37\1\40\7\30\3\40\1\41"+ - "\10\30\1\42\1\40\3\30\1\43\2\30\1\42\1\30"+ - "\1\41\1\42\13\30\1\44\2\30\1\45\1\46\1\47"+ - "\1\30\1\54\1\32\1\33\1\34\1\35\1\36\1\55"+ - "\1\40\7\30\3\40\1\41\10\30\1\42\1\40\3\30"+ - "\1\43\2\30\1\42\1\30\1\41\1\42\13\30\1\44"+ - "\2\30\1\56\1\46\1\47\1\30\1\54\1\32\1\33"+ - "\1\34\1\35\1\36\1\37\1\40\7\30\3\40\1\41"+ - "\10\30\1\42\1\40\3\30\1\43\2\30\1\42\1\30"+ - "\1\41\1\42\13\30\1\44\2\30\1\51\1\46\1\47"+ - "\1\30\1\54\1\32\1\33\1\34\1\35\1\36\1\55"+ - "\1\40\7\30\3\40\1\41\10\30\1\42\1\40\3\30"+ - "\1\43\2\30\1\42\1\30\1\41\1\42\13\30\1\44"+ - "\2\30\1\57\1\46\1\47\1\30\1\54\1\32\1\33"+ - "\1\34\1\35\1\36\1\60\1\40\7\30\3\40\1\41"+ - "\10\30\1\42\1\40\3\30\1\43\2\30\1\42\1\30"+ - "\1\41\1\42\13\30\1\44\2\30\1\41\1\46\1\47"+ - "\1\30\1\61\1\32\1\33\1\34\1\35\1\62\1\63"+ - "\1\40\7\30\3\40\1\41\10\30\1\42\1\40\3\30"+ - "\1\43\2\30\1\42\1\30\1\41\1\42\13\30\1\44"+ - "\2\30\1\57\1\46\1\47\1\30\1\54\1\32\1\33"+ - "\1\34\1\35\1\64\1\37\1\40\7\30\3\40\1\41"+ - "\10\30\1\42\1\40\3\30\1\43\2\30\1\42\1\30"+ - "\1\41\1\42\13\30\1\44\2\30\1\41\1\46\1\47"+ - "\1\30\1\61\1\32\1\33\1\34\1\35\1\62\1\65"+ - "\1\40\7\30\3\40\1\41\10\30\1\42\1\40\3\30"+ - "\1\43\2\30\1\42\1\30\1\41\1\42\13\30\1\44"+ - "\2\30\1\57\1\46\1\47\6\66\1\67\62\66\71\70"+ - "\1\71\1\54\1\32\1\33\1\34\1\35\1\36\1\55"+ - "\1\40\7\71\3\40\1\41\10\71\1\42\1\40\3\71"+ - "\1\43\2\71\1\42\1\71\1\41\1\42\16\71\1\41"+ - "\1\46\1\47\1\30\1\54\1\32\1\33\1\72\1\73"+ - "\1\36\1\37\1\40\7\30\3\40\1\41\10\30\1\42"+ - "\1\40\3\30\1\43\2\30\1\42\1\30\1\41\1\42"+ - "\13\30\1\44\2\30\1\41\1\46\1\47\1\30\1\54"+ - "\1\32\1\33\1\34\1\35\1\36\1\74\1\40\7\30"+ - "\3\40\1\41\10\30\1\42\1\40\3\30\1\43\2\30"+ - "\1\42\1\30\1\41\1\42\13\30\1\44\2\30\1\41"+ - "\1\46\1\47\1\30\1\54\1\32\1\33\1\34\1\35"+ - "\1\36\1\37\1\40\7\30\3\40\1\41\10\30\1\42"+ - "\1\40\3\30\1\43\2\30\1\42\1\30\1\41\1\42"+ - "\13\30\1\44\2\30\1\41\1\46\1\47\1\75\1\76"+ - "\6\75\1\40\7\75\3\40\12\75\1\40\33\75\4\77"+ - "\1\100\3\77\1\101\7\77\3\101\12\77\1\101\33\77"+ - "\1\102\5\103\1\36\2\103\7\102\4\103\10\102\2\103"+ - "\3\102\1\103\2\102\1\103\1\102\2\103\16\102\3\103"+ - "\1\30\1\104\1\32\1\33\1\34\1\35\1\36\1\37"+ - "\1\40\7\30\3\40\1\41\10\30\1\42\1\40\3\30"+ - "\1\43\2\30\1\42\1\30\1\41\1\42\13\30\1\44"+ - "\2\30\1\45\1\46\1\47\1\105\1\54\1\32\1\33"+ - "\1\34\1\35\1\36\1\37\1\40\7\105\3\40\1\41"+ - "\10\105\1\42\1\40\3\105\1\43\2\105\1\42\1\105"+ - "\1\41\1\42\16\105\1\41\1\46\1\47\41\75\1\106"+ - "\27\75\1\30\10\0\7\30\4\0\10\30\2\0\3\30"+ - "\1\0\2\30\1\0\1\30\2\0\16\30\3\0\2\107"+ - "\1\110\1\107\1\111\4\107\1\112\1\113\2\114\1\115"+ - "\2\114\1\0\1\107\2\0\1\116\6\114\1\117\2\107"+ - "\3\114\1\107\2\114\1\107\1\114\2\107\2\114\1\120"+ - "\7\114\1\121\1\107\2\114\3\107\101\0\1\40\7\0"+ - "\3\40\12\0\1\40\33\0\20\122\2\0\12\122\1\123"+ - "\1\124\33\122\6\0\1\125\62\0\4\107\1\111\4\107"+ - "\1\112\1\113\2\114\1\115\2\114\1\0\1\107\2\0"+ - "\1\116\2\114\1\126\3\114\1\117\2\107\3\114\1\107"+ - "\2\114\1\107\1\114\2\107\2\114\1\120\7\114\1\121"+ - "\1\107\2\114\6\107\1\51\1\111\4\107\1\112\1\113"+ - "\2\114\1\115\2\114\1\0\1\107\2\0\1\116\6\114"+ - "\1\117\2\107\3\114\1\107\2\114\1\107\1\114\2\107"+ - "\2\114\1\120\7\114\1\121\1\107\2\114\5\107\1\110"+ - "\1\107\1\111\1\127\3\107\1\112\1\113\2\114\1\115"+ - "\2\114\1\0\1\107\2\0\1\116\6\114\1\117\2\107"+ - "\3\114\1\107\2\114\1\107\1\114\2\107\2\114\1\120"+ - "\7\114\1\121\1\107\2\114\7\107\1\111\4\107\1\112"+ - "\1\113\2\114\1\115\2\114\1\0\1\107\2\0\1\116"+ - "\6\114\1\117\2\107\3\114\1\107\2\114\1\107\1\114"+ - "\2\107\2\114\1\120\7\114\1\121\1\107\2\114\7\107"+ - "\1\130\1\131\3\107\1\112\1\113\2\114\1\115\2\114"+ - "\1\0\1\107\2\0\1\116\6\114\1\117\2\107\3\114"+ - "\1\107\2\114\1\107\1\114\2\107\2\114\1\120\7\114"+ - "\1\121\1\107\2\114\3\107\1\71\10\0\7\71\4\0"+ - "\10\71\2\0\3\71\1\0\2\71\1\0\1\71\2\0"+ - "\16\71\14\0\1\132\1\133\66\0\1\101\7\0\3\101"+ - "\12\0\1\101\33\0\1\102\10\0\7\102\4\0\10\102"+ - "\2\0\3\102\1\0\2\102\1\0\1\102\2\0\16\102"+ - "\3\0\2\107\1\110\1\107\1\111\4\107\1\112\1\134"+ - "\2\114\1\115\2\114\1\0\1\107\2\0\1\116\6\114"+ - "\1\117\2\107\1\114\1\135\1\114\1\107\2\114\1\107"+ - "\1\114\2\107\1\136\1\114\1\120\1\137\1\140\1\141"+ - "\1\142\1\114\1\143\1\144\1\121\1\107\2\114\3\107"+ - "\1\105\10\0\7\105\4\0\10\105\2\0\3\105\1\0"+ - "\2\105\1\0\1\105\2\0\16\105\37\0\1\145\1\146"+ - "\44\0\1\114\1\147\5\114\4\0\10\114\2\0\3\114"+ - "\1\0\2\114\1\0\1\114\2\0\13\114\1\0\2\114"+ - "\14\0\4\114\1\150\2\114\4\0\10\114\2\0\3\114"+ - "\1\0\2\114\1\0\1\114\2\0\13\114\1\0\2\114"+ - "\14\0\7\114\4\0\10\114\2\0\3\114\1\0\2\114"+ - "\1\0\1\114\2\0\13\114\1\0\2\114\14\0\1\114"+ - "\1\151\5\114\4\0\10\114\2\0\3\114\1\0\2\114"+ - "\1\0\1\114\2\0\13\114\1\0\2\114\14\0\3\114"+ - "\1\152\3\114\4\0\10\114\2\0\3\114\1\0\2\114"+ - "\1\0\1\114\2\0\13\114\1\0\2\114\14\0\1\114"+ - "\1\153\5\114\4\0\10\114\2\0\3\114\1\0\2\114"+ - "\1\0\1\114\2\0\13\114\1\0\2\114\14\0\7\114"+ - "\4\0\10\114\2\0\3\114\1\0\1\114\1\154\1\0"+ - "\1\114\2\0\13\114\1\0\2\114\14\0\1\114\1\155"+ - "\5\114\4\0\10\114\2\0\3\114\1\0\2\114\1\0"+ - "\1\114\2\0\13\114\1\0\2\114\3\0\20\122\2\0"+ - "\47\122\10\156\1\123\7\156\2\157\1\123\12\156\1\123"+ - "\4\156\1\160\26\156\20\122\2\0\12\122\1\161\34\122"+ - "\11\0\1\114\1\162\5\114\4\0\10\114\2\0\3\114"+ - "\1\0\2\114\1\0\1\114\2\0\13\114\1\0\2\114"+ - "\15\0\1\163\73\0\1\164\64\0\4\114\1\165\2\114"+ - "\4\0\10\114\2\0\3\114\1\0\2\114\1\0\1\114"+ - "\2\0\13\114\1\0\2\114\14\0\4\114\1\166\2\114"+ - "\4\0\10\114\2\0\3\114\1\0\2\114\1\0\1\114"+ - "\2\0\2\114\1\167\10\114\1\0\2\114\14\0\7\114"+ - "\4\0\10\114\2\0\3\114\1\0\2\114\1\0\1\170"+ - "\2\0\7\114\1\171\3\114\1\0\2\114\14\0\7\114"+ - "\4\0\1\114\1\172\6\114\2\0\3\114\1\0\2\114"+ - "\1\0\1\114\2\0\13\114\1\0\2\114\14\0\7\114"+ - "\4\0\5\114\1\173\2\114\2\0\3\114\1\0\2\114"+ - "\1\0\1\114\2\0\13\114\1\0\2\114\14\0\1\114"+ - "\1\174\5\114\4\0\10\114\2\0\3\114\1\0\2\114"+ - "\1\0\1\114\2\0\13\114\1\0\2\114\14\0\7\114"+ - "\4\0\10\114\2\0\3\114\1\0\2\114\1\0\1\175"+ - "\2\0\13\114\1\0\2\114\14\0\7\114\4\0\7\114"+ - "\1\176\2\0\3\114\1\0\2\114\1\0\1\114\2\0"+ - "\13\114\1\0\2\114\14\0\4\114\1\177\2\114\4\0"+ - "\10\114\2\0\3\114\1\0\2\114\1\0\1\114\2\0"+ - "\13\114\1\0\2\114\13\0\1\145\7\0\3\145\12\0"+ - "\1\145\4\0\1\200\62\0\1\201\45\0\2\114\1\202"+ - "\4\114\4\0\10\114\2\0\3\114\1\0\2\114\1\0"+ - "\1\114\2\0\13\114\1\0\2\114\14\0\5\114\1\203"+ - "\1\114\4\0\10\114\2\0\3\114\1\0\2\114\1\0"+ - "\1\114\2\0\13\114\1\0\2\114\14\0\7\114\4\0"+ - "\10\114\2\0\3\114\1\0\2\114\1\0\1\114\2\0"+ - "\13\114\1\0\1\204\1\114\14\0\7\114\4\0\1\114"+ - "\1\205\6\114\2\0\3\114\1\0\2\114\1\0\1\114"+ - "\2\0\13\114\1\0\2\114\14\0\4\114\1\115\2\114"+ - "\4\0\10\114\2\0\3\114\1\0\2\114\1\0\1\114"+ - "\2\0\13\114\1\0\2\114\14\0\7\114\4\0\3\114"+ - "\1\206\4\114\2\0\3\114\1\0\2\114\1\0\1\114"+ - "\2\0\13\114\1\0\2\114\14\0\7\114\4\0\7\114"+ - "\1\207\2\0\3\114\1\0\2\114\1\0\1\114\2\0"+ - "\13\114\1\0\2\114\3\0\20\156\2\0\47\156\10\0"+ - "\1\157\7\0\3\157\12\0\1\157\4\0\1\210\26\0"+ - "\20\156\2\0\10\156\1\211\36\156\20\122\2\0\5\122"+ - "\1\212\6\122\1\212\32\122\11\0\7\114\4\0\2\114"+ - "\1\213\5\114\2\0\3\114\1\0\2\114\1\0\1\114"+ - "\2\0\13\114\1\0\2\114\16\0\1\214\73\0\1\215"+ - "\63\0\5\114\1\216\1\114\4\0\10\114\2\0\3\114"+ - "\1\0\2\114\1\0\1\114\2\0\13\114\1\0\2\114"+ - "\14\0\5\114\1\217\1\114\4\0\10\114\2\0\3\114"+ - "\1\0\2\114\1\0\1\114\2\0\13\114\1\0\2\114"+ - "\14\0\7\114\4\0\10\114\2\0\3\114\1\0\1\114"+ - "\1\220\1\0\1\114\2\0\13\114\1\0\2\114\14\0"+ - "\7\114\4\0\7\114\1\221\2\0\3\114\1\0\2\114"+ - "\1\0\1\114\2\0\13\114\1\0\2\114\14\0\4\114"+ - "\1\222\2\114\4\0\10\114\2\0\3\114\1\0\2\114"+ - "\1\0\1\114\2\0\13\114\1\0\2\114\14\0\3\114"+ - "\1\223\3\114\4\0\10\114\2\0\3\114\1\0\2\114"+ - "\1\0\1\114\2\0\13\114\1\0\2\114\14\0\7\114"+ - "\4\0\10\114\2\0\3\114\1\0\1\224\1\114\1\0"+ - "\1\114\2\0\13\114\1\0\2\114\14\0\7\114\4\0"+ - "\10\114\2\0\3\114\1\0\2\114\1\0\1\225\2\0"+ - "\13\114\1\0\2\114\14\0\7\114\4\0\10\114\2\0"+ - "\3\114\1\0\2\114\1\0\1\226\2\0\13\114\1\0"+ - "\2\114\14\0\7\114\4\0\3\114\1\227\4\114\2\0"+ - "\3\114\1\0\2\114\1\0\1\114\2\0\13\114\1\0"+ - "\2\114\35\0\1\230\65\0\1\231\6\0\1\231\43\0"+ - "\3\114\1\232\3\114\4\0\10\114\2\0\3\114\1\0"+ - "\2\114\1\0\1\114\2\0\13\114\1\0\2\114\14\0"+ - "\1\114\1\233\5\114\4\0\10\114\2\0\3\114\1\0"+ - "\2\114\1\0\1\114\2\0\13\114\1\0\2\114\14\0"+ - "\4\114\1\234\2\114\4\0\10\114\2\0\3\114\1\0"+ - "\2\114\1\0\1\114\2\0\13\114\1\0\2\114\14\0"+ - "\3\114\1\235\3\114\4\0\10\114\2\0\3\114\1\0"+ - "\2\114\1\0\1\114\2\0\13\114\1\0\2\114\14\0"+ - "\1\236\6\114\4\0\10\114\2\0\3\114\1\0\2\114"+ - "\1\0\1\114\2\0\13\114\1\0\2\114\35\0\1\237"+ - "\36\0\20\156\2\0\11\156\1\240\35\156\12\122\1\241"+ - "\5\122\2\0\15\122\1\241\31\122\11\0\7\114\4\0"+ - "\3\114\1\242\4\114\2\0\3\114\1\0\2\114\1\0"+ - "\1\114\2\0\13\114\1\0\2\114\17\0\1\243\65\0"+ - "\7\114\4\0\10\114\2\0\3\114\1\0\2\114\1\0"+ - "\1\114\2\0\1\244\2\114\1\245\1\246\1\114\1\247"+ - "\1\114\1\250\2\114\1\0\2\114\14\0\1\114\1\251"+ - "\5\114\4\0\10\114\2\0\3\114\1\0\2\114\1\0"+ - "\1\114\2\0\3\114\1\252\7\114\1\0\2\114\14\0"+ - "\7\114\4\0\10\114\2\0\3\114\1\0\2\114\1\0"+ - "\1\114\2\0\1\114\1\253\11\114\1\0\2\114\14\0"+ - "\7\114\4\0\4\114\1\254\3\114\2\0\3\114\1\0"+ - "\2\114\1\0\1\114\2\0\13\114\1\0\2\114\14\0"+ - "\7\114\4\0\10\114\2\0\3\114\1\0\2\114\1\0"+ - "\1\114\2\0\2\114\1\255\10\114\1\0\2\114\14\0"+ - "\1\114\1\256\5\114\4\0\10\114\2\0\3\114\1\0"+ - "\2\114\1\0\1\114\2\0\13\114\1\0\2\114\14\0"+ - "\7\114\4\0\10\114\2\0\3\114\1\0\1\172\1\114"+ - "\1\0\1\114\2\0\13\114\1\0\2\114\14\0\7\114"+ - "\4\0\4\114\1\257\3\114\2\0\3\114\1\0\2\114"+ - "\1\0\1\114\2\0\13\114\1\0\2\114\14\0\3\114"+ - "\1\260\3\114\4\0\10\114\2\0\3\114\1\0\2\114"+ - "\1\0\1\114\2\0\13\114\1\0\2\114\36\0\1\261"+ - "\47\0\1\262\24\0\1\262\42\0\4\114\1\263\2\114"+ - "\4\0\10\114\2\0\3\114\1\0\2\114\1\0\1\114"+ - "\2\0\13\114\1\0\2\114\14\0\4\114\1\264\2\114"+ - "\4\0\10\114\2\0\3\114\1\0\2\114\1\0\1\114"+ - "\2\0\13\114\1\0\2\114\14\0\1\114\1\265\5\114"+ - "\4\0\10\114\2\0\3\114\1\0\2\114\1\0\1\114"+ - "\2\0\13\114\1\0\2\114\14\0\4\114\1\266\2\114"+ - "\4\0\10\114\2\0\3\114\1\0\2\114\1\0\1\114"+ - "\2\0\13\114\1\0\2\114\14\0\7\114\4\0\10\114"+ - "\2\0\3\114\1\0\2\114\1\0\1\114\2\0\13\114"+ - "\1\267\2\114\36\0\1\270\35\0\20\156\2\0\21\156"+ - "\1\271\25\156\20\122\2\0\4\122\1\123\11\122\1\123"+ - "\30\122\15\0\1\272\64\0\7\114\4\0\10\114\2\0"+ - "\3\114\1\0\2\114\1\0\1\273\2\0\7\114\1\274"+ - "\3\114\1\0\2\114\14\0\7\114\4\0\1\114\1\275"+ - "\6\114\2\0\3\114\1\0\2\114\1\0\1\114\2\0"+ - "\13\114\1\0\2\114\14\0\7\114\4\0\5\114\1\276"+ - "\2\114\2\0\3\114\1\0\2\114\1\0\1\114\2\0"+ - "\13\114\1\0\2\114\14\0\7\114\4\0\10\114\2\0"+ - "\3\114\1\0\2\114\1\0\1\277\2\0\13\114\1\0"+ - "\2\114\14\0\7\114\4\0\7\114\1\300\2\0\3\114"+ - "\1\0\2\114\1\0\1\114\2\0\13\114\1\0\2\114"+ - "\14\0\7\114\4\0\1\114\1\251\6\114\2\0\3\114"+ - "\1\0\2\114\1\0\1\114\2\0\13\114\1\0\2\114"+ - "\14\0\7\114\4\0\10\114\2\0\3\114\1\0\2\114"+ - "\1\0\1\114\2\0\2\114\1\301\10\114\1\0\2\114"+ - "\14\0\7\114\4\0\3\114\1\302\4\114\2\0\3\114"+ - "\1\0\2\114\1\0\1\114\2\0\13\114\1\0\2\114"+ - "\14\0\1\114\1\172\5\114\4\0\10\114\2\0\3\114"+ - "\1\0\2\114\1\0\1\114\2\0\13\114\1\0\2\114"+ - "\14\0\7\114\4\0\6\114\1\303\1\114\2\0\3\114"+ - "\1\0\2\114\1\0\1\114\2\0\13\114\1\0\2\114"+ - "\14\0\1\114\1\304\5\114\4\0\10\114\2\0\3\114"+ - "\1\0\2\114\1\0\1\114\2\0\13\114\1\0\2\114"+ - "\14\0\7\114\4\0\10\114\2\0\3\114\1\0\2\114"+ - "\1\0\1\114\2\0\2\114\1\275\10\114\1\0\2\114"+ - "\46\0\1\305\53\0\1\145\11\0\1\145\41\0\7\114"+ - "\4\0\10\114\2\0\3\114\1\0\2\114\1\0\1\114"+ - "\2\0\12\114\1\306\1\0\2\114\14\0\7\114\4\0"+ - "\2\114\1\307\5\114\2\0\3\114\1\0\2\114\1\0"+ - "\1\114\2\0\13\114\1\0\2\114\14\0\7\114\4\0"+ - "\10\114\2\0\3\114\1\0\2\114\1\0\1\114\2\0"+ - "\2\114\1\310\10\114\1\0\2\114\46\0\1\311\25\0"+ - "\12\156\1\312\5\156\2\0\47\156\11\0\7\114\4\0"+ - "\7\114\1\275\2\0\3\114\1\0\2\114\1\0\1\114"+ - "\2\0\13\114\1\0\2\114\14\0\4\114\1\313\2\114"+ - "\4\0\10\114\2\0\3\114\1\0\2\114\1\0\1\114"+ - "\2\0\13\114\1\0\2\114\14\0\3\114\1\314\3\114"+ - "\4\0\10\114\2\0\3\114\1\0\2\114\1\0\1\114"+ - "\2\0\13\114\1\0\2\114\14\0\7\114\4\0\10\114"+ - "\2\0\3\114\1\0\2\114\1\0\1\315\2\0\13\114"+ - "\1\0\2\114\14\0\7\114\4\0\10\114\2\0\3\114"+ - "\1\0\2\114\1\0\1\316\2\0\13\114\1\0\2\114"+ - "\14\0\7\114\4\0\10\114\2\0\3\114\1\0\2\114"+ - "\1\0\1\114\2\0\2\114\1\172\10\114\1\0\2\114"+ - "\14\0\3\114\1\317\3\114\4\0\10\114\2\0\3\114"+ - "\1\0\2\114\1\0\1\114\2\0\13\114\1\0\2\114"+ - "\14\0\7\114\4\0\3\114\1\172\4\114\2\0\3\114"+ - "\1\0\2\114\1\0\1\114\2\0\13\114\1\0\2\114"+ - "\14\0\5\114\1\320\1\114\4\0\10\114\2\0\3\114"+ - "\1\0\2\114\1\0\1\114\2\0\13\114\1\0\2\114"+ - "\15\0\1\321\67\0\3\114\1\322\3\114\4\0\10\114"+ - "\2\0\3\114\1\0\2\114\1\0\1\114\2\0\13\114"+ - "\1\0\2\114\14\0\7\114\4\0\3\114\1\323\4\114"+ - "\2\0\3\114\1\0\2\114\1\0\1\114\2\0\13\114"+ - "\1\0\2\114\14\0\3\114\1\324\3\114\4\0\10\114"+ - "\2\0\3\114\1\0\2\114\1\0\1\114\2\0\13\114"+ - "\1\0\2\114\15\0\1\325\56\0\20\156\2\0\11\156"+ - "\1\326\35\156\11\0\7\114\4\0\4\114\1\327\3\114"+ - "\2\0\3\114\1\0\2\114\1\0\1\114\2\0\13\114"+ - "\1\0\2\114\14\0\7\114\4\0\10\114\2\0\3\114"+ - "\1\0\2\114\1\0\1\114\2\0\2\114\1\330\10\114"+ - "\1\0\2\114\14\0\7\114\4\0\10\114\2\0\3\114"+ - "\1\0\1\275\1\114\1\0\1\114\2\0\13\114\1\0"+ - "\2\114\14\0\7\114\4\0\4\114\1\331\3\114\2\0"+ - "\3\114\1\0\2\114\1\0\1\114\2\0\13\114\1\0"+ - "\2\114\14\0\7\114\4\0\10\114\2\0\3\114\1\0"+ - "\2\114\1\0\1\332\2\0\13\114\1\0\2\114\14\0"+ - "\7\114\4\0\10\114\2\0\3\114\1\0\2\114\1\0"+ - "\1\114\2\0\7\114\1\333\3\114\1\0\2\114\36\0"+ - "\1\334\46\0\7\114\4\0\7\114\1\335\2\0\3\114"+ - "\1\0\2\114\1\0\1\114\2\0\13\114\1\0\2\114"+ - "\14\0\7\114\4\0\4\114\1\336\3\114\2\0\3\114"+ - "\1\0\2\114\1\0\1\114\2\0\13\114\1\0\2\114"+ - "\14\0\4\114\1\337\2\114\4\0\10\114\2\0\3\114"+ - "\1\0\2\114\1\0\1\114\2\0\13\114\1\0\2\114"+ - "\36\0\1\340\35\0\10\156\1\326\7\156\2\340\1\326"+ - "\12\156\1\326\6\156\1\341\24\156\11\0\7\114\4\0"+ - "\3\114\1\342\4\114\2\0\3\114\1\0\2\114\1\0"+ - "\1\114\2\0\13\114\1\0\2\114\14\0\1\114\1\275"+ - "\5\114\4\0\10\114\2\0\3\114\1\0\2\114\1\0"+ - "\1\114\2\0\13\114\1\0\2\114\14\0\1\114\1\343"+ - "\5\114\4\0\10\114\2\0\3\114\1\0\2\114\1\0"+ - "\1\114\2\0\13\114\1\0\2\114\14\0\4\114\1\172"+ - "\2\114\4\0\10\114\2\0\3\114\1\0\2\114\1\0"+ - "\1\114\2\0\13\114\1\0\2\114\14\0\7\114\4\0"+ - "\7\114\1\255\2\0\3\114\1\0\2\114\1\0\1\114"+ - "\2\0\13\114\1\0\2\114\13\0\1\334\7\0\3\334"+ - "\12\0\1\334\6\0\1\344\35\0\7\114\4\0\10\114"+ - "\2\0\3\114\1\0\2\114\1\0\1\345\2\0\13\114"+ - "\1\0\2\114\14\0\7\114\4\0\5\114\1\346\2\114"+ - "\2\0\3\114\1\0\2\114\1\0\1\114\2\0\13\114"+ - "\1\0\2\114\14\0\1\114\1\347\5\114\4\0\10\114"+ - "\2\0\3\114\1\0\2\114\1\0\1\114\2\0\13\114"+ - "\1\0\2\114\13\0\1\340\7\0\3\340\12\0\1\340"+ - "\6\0\1\350\24\0\10\156\1\341\7\156\2\350\1\341"+ - "\12\156\1\341\7\156\1\351\23\156\11\0\3\114\1\352"+ - "\3\114\4\0\10\114\2\0\3\114\1\0\2\114\1\0"+ - "\1\114\2\0\13\114\1\0\2\114\14\0\5\114\1\353"+ - "\1\114\4\0\10\114\2\0\3\114\1\0\2\114\1\0"+ - "\1\114\2\0\13\114\1\0\2\114\13\0\1\344\7\0"+ - "\3\344\12\0\1\344\7\0\1\354\34\0\4\114\1\355"+ - "\2\114\4\0\10\114\2\0\3\114\1\0\2\114\1\0"+ - "\1\114\2\0\13\114\1\0\2\114\14\0\7\114\4\0"+ - "\6\114\1\356\1\114\2\0\3\114\1\0\2\114\1\0"+ - "\1\114\2\0\13\114\1\0\2\114\13\0\1\350\7\0"+ - "\3\350\12\0\1\350\7\0\1\357\23\0\20\156\2\0"+ - "\3\156\1\360\43\156\11\0\7\114\4\0\10\114\2\0"+ - "\3\114\1\0\2\114\1\0\1\361\2\0\13\114\1\0"+ - "\2\114\14\0\7\114\4\0\10\114\2\0\3\114\1\0"+ - "\2\114\1\0\1\114\2\0\7\114\1\362\3\114\1\0"+ - "\2\114\20\0\1\363\64\0\7\114\4\0\10\114\2\0"+ - "\3\114\1\0\2\114\1\0\1\114\2\0\13\114\1\0"+ - "\1\114\1\364\14\0\7\114\4\0\7\114\1\365\2\0"+ - "\3\114\1\0\2\114\1\0\1\114\2\0\13\114\1\0"+ - "\2\114\30\0\1\366\43\0\20\156\2\0\3\156\1\367"+ - "\43\156\11\0\4\114\1\275\2\114\4\0\10\114\2\0"+ - "\3\114\1\0\2\114\1\0\1\114\2\0\13\114\1\0"+ - "\2\114\14\0\7\114\4\0\7\114\1\330\2\0\3\114"+ - "\1\0\2\114\1\0\1\114\2\0\13\114\1\0\2\114"+ - "\3\0\20\363\2\0\47\363\11\0\1\114\1\370\5\114"+ - "\4\0\10\114\2\0\3\114\1\0\2\114\1\0\1\114"+ - "\2\0\13\114\1\0\2\114\3\0\11\371\7\114\4\0"+ - "\10\114\2\371\3\114\1\371\2\114\1\371\1\114\2\371"+ - "\13\114\1\371\2\114\3\371\25\0\1\367\43\0\20\367"+ - "\2\0\47\367\11\0\4\114\1\372\2\114\4\0\10\114"+ - "\2\0\3\114\1\0\2\114\1\0\1\114\2\0\13\114"+ - "\1\0\2\114\14\0\7\114\4\0\3\114\1\373\4\114"+ - "\2\0\3\114\1\0\2\114\1\0\1\114\2\0\13\114"+ - "\1\0\2\114\3\0"; + "\1\30\1\31\1\32\1\33\1\34\1\35\1\36\1\37" + + "\1\40\7\30\3\40\1\41\10\30\1\42\1\40\3\30" + + "\1\43\2\30\1\44\1\30\1\41\1\42\13\30\1\45" + + "\2\30\1\46\1\47\1\50\1\51\1\30\1\52\1\32" + + "\1\33\1\34\1\35\1\36\1\37\1\40\7\30\3\40" + + "\1\41\10\30\1\42\1\40\3\30\1\43\2\30\1\44" + + "\1\30\1\41\1\42\13\30\1\45\2\30\1\53\1\47" + + "\1\50\1\51\1\30\1\54\1\32\1\33\1\34\1\35" + + "\1\36\1\37\1\40\7\30\3\40\1\41\10\30\1\42" + + "\1\40\3\30\1\43\2\30\1\44\1\30\1\41\1\42" + + "\13\30\1\45\2\30\1\41\1\47\1\50\1\51\1\30" + + "\1\55\1\32\1\33\1\34\1\35\1\36\1\37\1\40" + + "\7\30\3\40\1\41\10\30\1\42\1\40\3\30\1\43" + + "\2\30\1\44\1\30\1\41\1\42\13\30\1\45\2\30" + + "\1\46\1\47\1\50\1\51\1\30\1\56\1\32\1\33" + + "\1\34\1\35\1\36\1\57\1\40\7\30\3\40\1\41" + + "\10\30\1\42\1\40\3\30\1\43\2\30\1\44\1\30" + + "\1\41\1\42\13\30\1\45\2\30\1\60\1\47\1\50" + + "\1\51\1\30\1\56\1\32\1\33\1\34\1\35\1\36" + + "\1\37\1\40\7\30\3\40\1\41\10\30\1\42\1\40" + + "\3\30\1\43\2\30\1\44\1\30\1\41\1\42\13\30" + + "\1\45\2\30\1\53\1\47\1\50\1\51\1\30\1\56" + + "\1\32\1\33\1\34\1\35\1\36\1\57\1\40\7\30" + + "\3\40\1\41\10\30\1\42\1\40\3\30\1\43\2\30" + + "\1\44\1\30\1\41\1\42\13\30\1\45\2\30\1\61" + + "\1\47\1\50\1\51\1\30\1\56\1\32\1\33\1\34" + + "\1\35\1\36\1\62\1\40\7\30\3\40\1\41\10\30" + + "\1\42\1\40\3\30\1\43\2\30\1\44\1\30\1\41" + + "\1\42\13\30\1\45\2\30\1\41\1\47\1\50\1\51" + + "\1\30\1\63\1\32\1\33\1\34\1\35\1\64\1\65" + + "\1\40\7\30\3\40\1\41\10\30\1\42\1\40\3\30" + + "\1\43\2\30\1\44\1\30\1\41\1\42\13\30\1\45" + + "\2\30\1\61\1\47\1\50\1\51\1\30\1\56\1\32" + + "\1\33\1\34\1\35\1\66\1\37\1\40\7\30\3\40" + + "\1\41\10\30\1\42\1\40\3\30\1\43\2\30\1\44" + + "\1\30\1\41\1\42\13\30\1\45\2\30\1\41\1\47" + + "\1\50\1\51\1\30\1\63\1\32\1\33\1\34\1\35" + + "\1\64\1\67\1\40\7\30\3\40\1\41\10\30\1\42" + + "\1\40\3\30\1\43\2\30\1\44\1\30\1\41\1\42" + + "\13\30\1\45\2\30\1\61\1\47\1\50\1\51\6\70" + + "\1\71\63\70\72\72\1\73\1\56\1\32\1\33\1\34" + + "\1\35\1\36\1\57\1\40\7\73\3\40\1\41\10\73" + + "\1\42\1\40\3\73\1\43\2\73\1\44\1\73\1\41" + + "\1\42\16\73\1\41\1\47\1\50\1\51\1\30\1\56" + + "\1\32\1\33\1\74\1\75\1\36\1\37\1\40\7\30" + + "\3\40\1\41\10\30\1\42\1\40\3\30\1\43\2\30" + + "\1\44\1\30\1\41\1\42\13\30\1\45\2\30\1\41" + + "\1\47\1\50\1\51\1\30\1\56\1\32\1\33\1\34" + + "\1\35\1\36\1\76\1\40\7\30\3\40\1\41\10\30" + + "\1\42\1\40\3\30\1\43\2\30\1\44\1\30\1\41" + + "\1\42\13\30\1\45\2\30\1\41\1\47\1\50\1\51" + + "\1\30\1\56\1\32\1\33\1\34\1\35\1\36\1\37" + + "\1\40\7\30\3\40\1\41\10\30\1\42\1\40\3\30" + + "\1\43\2\30\1\44\1\30\1\41\1\42\13\30\1\45" + + "\2\30\1\41\1\47\1\50\1\51\1\77\1\100\6\77" + + "\1\40\7\77\3\40\12\77\1\40\34\77\4\101\1\102" + + "\3\101\1\103\7\101\3\103\12\101\1\103\34\101\1\104" + + "\5\105\1\36\2\105\7\104\4\105\10\104\2\105\3\104" + + "\1\105\2\104\1\105\1\104\2\105\16\104\4\105\1\30" + + "\1\106\1\32\1\33\1\34\1\35\1\36\1\37\1\40" + + "\7\30\3\40\1\41\10\30\1\42\1\40\3\30\1\43" + + "\2\30\1\44\1\30\1\41\1\42\13\30\1\45\2\30" + + "\1\46\1\47\1\50\1\51\1\107\1\56\1\32\1\33" + + "\1\34\1\35\1\36\1\37\1\40\7\107\3\40\1\41" + + "\10\107\1\42\1\40\3\107\1\43\2\107\1\44\1\107" + + "\1\41\1\42\16\107\1\41\1\47\1\50\1\51\41\77" + + "\1\110\30\77\1\30\10\0\7\30\4\0\10\30\2\0" + + "\3\30\1\0\2\30\1\0\1\30\2\0\16\30\4\0" + + "\2\111\1\112\1\111\1\113\4\111\1\114\1\115\2\116" + + "\1\117\2\116\1\0\1\111\2\0\1\120\6\116\1\121" + + "\2\111\3\116\1\111\2\116\1\111\1\116\2\111\2\116" + + "\1\122\7\116\1\123\1\111\2\116\4\111\102\0\1\40" + + "\7\0\3\40\12\0\1\40\34\0\20\124\2\0\12\124" + + "\1\125\1\126\34\124\6\0\1\127\63\0\4\111\1\113" + + "\4\111\1\114\1\115\2\116\1\117\2\116\1\0\1\111" + + "\2\0\1\120\2\116\1\130\3\116\1\121\2\111\3\116" + + "\1\111\2\116\1\111\1\116\2\111\2\116\1\122\7\116" + + "\1\123\1\111\2\116\7\111\1\53\1\113\4\111\1\114" + + "\1\115\2\116\1\117\2\116\1\0\1\111\2\0\1\120" + + "\6\116\1\121\2\111\3\116\1\111\2\116\1\111\1\116" + + "\2\111\2\116\1\122\7\116\1\123\1\111\2\116\6\111" + + "\1\112\1\111\1\113\1\131\3\111\1\114\1\115\2\116" + + "\1\117\2\116\1\0\1\111\2\0\1\120\6\116\1\121" + + "\2\111\3\116\1\111\2\116\1\111\1\116\2\111\2\116" + + "\1\122\7\116\1\123\1\111\2\116\10\111\1\113\4\111" + + "\1\114\1\115\2\116\1\117\2\116\1\0\1\111\2\0" + + "\1\120\6\116\1\121\2\111\3\116\1\111\2\116\1\111" + + "\1\116\2\111\2\116\1\122\7\116\1\123\1\111\2\116" + + "\10\111\1\132\1\133\3\111\1\114\1\115\2\116\1\117" + + "\2\116\1\0\1\111\2\0\1\120\6\116\1\121\2\111" + + "\3\116\1\111\2\116\1\111\1\116\2\111\2\116\1\122" + + "\7\116\1\123\1\111\2\116\4\111\1\73\10\0\7\73" + + "\4\0\10\73\2\0\3\73\1\0\2\73\1\0\1\73" + + "\2\0\16\73\15\0\1\134\1\135\67\0\1\103\7\0" + + "\3\103\12\0\1\103\34\0\1\104\10\0\7\104\4\0" + + "\10\104\2\0\3\104\1\0\2\104\1\0\1\104\2\0" + + "\16\104\4\0\2\111\1\112\1\111\1\113\4\111\1\114" + + "\1\136\2\116\1\117\2\116\1\0\1\111\2\0\1\120" + + "\6\116\1\121\2\111\1\116\1\137\1\116\1\111\2\116" + + "\1\111\1\116\2\111\1\140\1\116\1\122\1\141\1\142" + + "\1\143\1\144\1\116\1\145\1\146\1\123\1\111\2\116" + + "\4\111\1\107\10\0\7\107\4\0\10\107\2\0\3\107" + + "\1\0\2\107\1\0\1\107\2\0\16\107\40\0\1\147" + + "\1\150\45\0\1\116\1\151\5\116\4\0\10\116\2\0" + + "\3\116\1\0\2\116\1\0\1\116\2\0\13\116\1\0" + + "\2\116\15\0\4\116\1\152\2\116\4\0\10\116\2\0" + + "\3\116\1\0\2\116\1\0\1\116\2\0\13\116\1\0" + + "\2\116\15\0\7\116\4\0\10\116\2\0\3\116\1\0" + + "\2\116\1\0\1\116\2\0\13\116\1\0\2\116\15\0" + + "\1\116\1\153\5\116\4\0\10\116\2\0\3\116\1\0" + + "\2\116\1\0\1\116\2\0\13\116\1\0\2\116\15\0" + + "\3\116\1\154\3\116\4\0\10\116\2\0\3\116\1\0" + + "\2\116\1\0\1\116\2\0\13\116\1\0\2\116\15\0" + + "\1\116\1\155\5\116\4\0\10\116\2\0\3\116\1\0" + + "\2\116\1\0\1\116\2\0\13\116\1\0\2\116\15\0" + + "\7\116\4\0\10\116\2\0\3\116\1\0\1\116\1\156" + + "\1\0\1\116\2\0\13\116\1\0\2\116\15\0\1\116" + + "\1\157\5\116\4\0\10\116\2\0\3\116\1\0\2\116" + + "\1\0\1\116\2\0\13\116\1\0\2\116\4\0\20\124" + + "\2\0\50\124\10\160\1\125\7\160\2\161\1\125\12\160" + + "\1\125\4\160\1\162\27\160\20\124\2\0\12\124\1\163" + + "\35\124\11\0\1\116\1\164\5\116\4\0\10\116\2\0" + + "\3\116\1\0\2\116\1\0\1\116\2\0\13\116\1\0" + + "\2\116\16\0\1\165\74\0\1\166\65\0\4\116\1\167" + + "\2\116\4\0\10\116\2\0\3\116\1\0\2\116\1\0" + + "\1\116\2\0\13\116\1\0\2\116\15\0\4\116\1\170" + + "\2\116\4\0\10\116\2\0\3\116\1\0\2\116\1\0" + + "\1\116\2\0\2\116\1\171\10\116\1\0\2\116\15\0" + + "\7\116\4\0\10\116\2\0\3\116\1\0\2\116\1\0" + + "\1\172\2\0\7\116\1\173\3\116\1\0\2\116\15\0" + + "\7\116\4\0\1\116\1\174\6\116\2\0\3\116\1\0" + + "\2\116\1\0\1\116\2\0\13\116\1\0\2\116\15\0" + + "\7\116\4\0\5\116\1\175\2\116\2\0\3\116\1\0" + + "\2\116\1\0\1\116\2\0\13\116\1\0\2\116\15\0" + + "\1\116\1\176\5\116\4\0\10\116\2\0\3\116\1\0" + + "\2\116\1\0\1\116\2\0\13\116\1\0\2\116\15\0" + + "\7\116\4\0\10\116\2\0\3\116\1\0\2\116\1\0" + + "\1\177\2\0\13\116\1\0\2\116\15\0\7\116\4\0" + + "\7\116\1\200\2\0\3\116\1\0\2\116\1\0\1\116" + + "\2\0\13\116\1\0\2\116\15\0\4\116\1\201\2\116" + + "\4\0\10\116\2\0\3\116\1\0\2\116\1\0\1\116" + + "\2\0\13\116\1\0\2\116\14\0\1\147\7\0\3\147" + + "\12\0\1\147\4\0\1\202\63\0\1\203\46\0\2\116" + + "\1\204\4\116\4\0\10\116\2\0\3\116\1\0\2\116" + + "\1\0\1\116\2\0\13\116\1\0\2\116\15\0\5\116" + + "\1\205\1\116\4\0\10\116\2\0\3\116\1\0\2\116" + + "\1\0\1\116\2\0\13\116\1\0\2\116\15\0\7\116" + + "\4\0\10\116\2\0\3\116\1\0\2\116\1\0\1\116" + + "\2\0\13\116\1\0\1\206\1\116\15\0\7\116\4\0" + + "\1\116\1\207\6\116\2\0\3\116\1\0\2\116\1\0" + + "\1\116\2\0\13\116\1\0\2\116\15\0\4\116\1\117" + + "\2\116\4\0\10\116\2\0\3\116\1\0\2\116\1\0" + + "\1\116\2\0\13\116\1\0\2\116\15\0\7\116\4\0" + + "\3\116\1\210\4\116\2\0\3\116\1\0\2\116\1\0" + + "\1\116\2\0\13\116\1\0\2\116\15\0\7\116\4\0" + + "\7\116\1\211\2\0\3\116\1\0\2\116\1\0\1\116" + + "\2\0\13\116\1\0\2\116\4\0\20\160\2\0\50\160" + + "\10\0\1\161\7\0\3\161\12\0\1\161\4\0\1\212" + + "\27\0\20\160\2\0\10\160\1\213\37\160\20\124\2\0" + + "\5\124\1\214\6\124\1\214\33\124\11\0\7\116\4\0" + + "\2\116\1\215\5\116\2\0\3\116\1\0\2\116\1\0" + + "\1\116\2\0\13\116\1\0\2\116\17\0\1\216\74\0" + + "\1\217\64\0\5\116\1\220\1\116\4\0\10\116\2\0" + + "\3\116\1\0\2\116\1\0\1\116\2\0\13\116\1\0" + + "\2\116\15\0\5\116\1\221\1\116\4\0\10\116\2\0" + + "\3\116\1\0\2\116\1\0\1\116\2\0\13\116\1\0" + + "\2\116\15\0\7\116\4\0\10\116\2\0\3\116\1\0" + + "\1\116\1\222\1\0\1\116\2\0\13\116\1\0\2\116" + + "\15\0\7\116\4\0\7\116\1\223\2\0\3\116\1\0" + + "\2\116\1\0\1\116\2\0\13\116\1\0\2\116\15\0" + + "\4\116\1\224\2\116\4\0\10\116\2\0\3\116\1\0" + + "\2\116\1\0\1\116\2\0\13\116\1\0\2\116\15\0" + + "\3\116\1\225\3\116\4\0\10\116\2\0\3\116\1\0" + + "\2\116\1\0\1\116\2\0\13\116\1\0\2\116\15\0" + + "\7\116\4\0\10\116\2\0\3\116\1\0\1\226\1\116" + + "\1\0\1\116\2\0\13\116\1\0\2\116\15\0\7\116" + + "\4\0\10\116\2\0\3\116\1\0\2\116\1\0\1\227" + + "\2\0\13\116\1\0\2\116\15\0\7\116\4\0\10\116" + + "\2\0\3\116\1\0\2\116\1\0\1\230\2\0\13\116" + + "\1\0\2\116\15\0\7\116\4\0\3\116\1\231\4\116" + + "\2\0\3\116\1\0\2\116\1\0\1\116\2\0\13\116" + + "\1\0\2\116\36\0\1\232\66\0\1\233\6\0\1\233" + + "\44\0\3\116\1\234\3\116\4\0\10\116\2\0\3\116" + + "\1\0\2\116\1\0\1\116\2\0\13\116\1\0\2\116" + + "\15\0\1\116\1\235\5\116\4\0\10\116\2\0\3\116" + + "\1\0\2\116\1\0\1\116\2\0\13\116\1\0\2\116" + + "\15\0\4\116\1\236\2\116\4\0\10\116\2\0\3\116" + + "\1\0\2\116\1\0\1\116\2\0\13\116\1\0\2\116" + + "\15\0\3\116\1\237\3\116\4\0\10\116\2\0\3\116" + + "\1\0\2\116\1\0\1\116\2\0\13\116\1\0\2\116" + + "\15\0\1\240\6\116\4\0\10\116\2\0\3\116\1\0" + + "\2\116\1\0\1\116\2\0\13\116\1\0\2\116\36\0" + + "\1\241\37\0\20\160\2\0\11\160\1\242\36\160\12\124" + + "\1\243\5\124\2\0\15\124\1\243\32\124\11\0\7\116" + + "\4\0\3\116\1\244\4\116\2\0\3\116\1\0\2\116" + + "\1\0\1\116\2\0\13\116\1\0\2\116\20\0\1\245" + + "\66\0\7\116\4\0\10\116\2\0\3\116\1\0\2\116" + + "\1\0\1\116\2\0\1\246\2\116\1\247\1\250\1\116" + + "\1\251\1\116\1\252\2\116\1\0\2\116\15\0\1\116" + + "\1\253\5\116\4\0\10\116\2\0\3\116\1\0\2\116" + + "\1\0\1\116\2\0\3\116\1\254\7\116\1\0\2\116" + + "\15\0\7\116\4\0\10\116\2\0\3\116\1\0\2\116" + + "\1\0\1\116\2\0\1\116\1\255\11\116\1\0\2\116" + + "\15\0\7\116\4\0\4\116\1\256\3\116\2\0\3\116" + + "\1\0\2\116\1\0\1\116\2\0\13\116\1\0\2\116" + + "\15\0\7\116\4\0\10\116\2\0\3\116\1\0\2\116" + + "\1\0\1\116\2\0\2\116\1\257\10\116\1\0\2\116" + + "\15\0\1\116\1\260\5\116\4\0\10\116\2\0\3\116" + + "\1\0\2\116\1\0\1\116\2\0\13\116\1\0\2\116" + + "\15\0\7\116\4\0\10\116\2\0\3\116\1\0\1\174" + + "\1\116\1\0\1\116\2\0\13\116\1\0\2\116\15\0" + + "\7\116\4\0\4\116\1\261\3\116\2\0\3\116\1\0" + + "\2\116\1\0\1\116\2\0\13\116\1\0\2\116\15\0" + + "\3\116\1\262\3\116\4\0\10\116\2\0\3\116\1\0" + + "\2\116\1\0\1\116\2\0\13\116\1\0\2\116\37\0" + + "\1\263\50\0\1\264\24\0\1\264\43\0\4\116\1\265" + + "\2\116\4\0\10\116\2\0\3\116\1\0\2\116\1\0" + + "\1\116\2\0\13\116\1\0\2\116\15\0\4\116\1\266" + + "\2\116\4\0\10\116\2\0\3\116\1\0\2\116\1\0" + + "\1\116\2\0\13\116\1\0\2\116\15\0\1\116\1\267" + + "\5\116\4\0\10\116\2\0\3\116\1\0\2\116\1\0" + + "\1\116\2\0\13\116\1\0\2\116\15\0\4\116\1\270" + + "\2\116\4\0\10\116\2\0\3\116\1\0\2\116\1\0" + + "\1\116\2\0\13\116\1\0\2\116\15\0\7\116\4\0" + + "\10\116\2\0\3\116\1\0\2\116\1\0\1\116\2\0" + + "\13\116\1\271\2\116\37\0\1\272\36\0\20\160\2\0" + + "\21\160\1\273\26\160\20\124\2\0\4\124\1\125\11\124" + + "\1\125\31\124\15\0\1\274\65\0\7\116\4\0\10\116" + + "\2\0\3\116\1\0\2\116\1\0\1\275\2\0\7\116" + + "\1\276\3\116\1\0\2\116\15\0\7\116\4\0\1\116" + + "\1\277\6\116\2\0\3\116\1\0\2\116\1\0\1\116" + + "\2\0\13\116\1\0\2\116\15\0\7\116\4\0\5\116" + + "\1\300\2\116\2\0\3\116\1\0\2\116\1\0\1\116" + + "\2\0\13\116\1\0\2\116\15\0\7\116\4\0\10\116" + + "\2\0\3\116\1\0\2\116\1\0\1\301\2\0\13\116" + + "\1\0\2\116\15\0\7\116\4\0\7\116\1\302\2\0" + + "\3\116\1\0\2\116\1\0\1\116\2\0\13\116\1\0" + + "\2\116\15\0\7\116\4\0\1\116\1\253\6\116\2\0" + + "\3\116\1\0\2\116\1\0\1\116\2\0\13\116\1\0" + + "\2\116\15\0\7\116\4\0\10\116\2\0\3\116\1\0" + + "\2\116\1\0\1\116\2\0\2\116\1\303\10\116\1\0" + + "\2\116\15\0\7\116\4\0\3\116\1\304\4\116\2\0" + + "\3\116\1\0\2\116\1\0\1\116\2\0\13\116\1\0" + + "\2\116\15\0\1\116\1\174\5\116\4\0\10\116\2\0" + + "\3\116\1\0\2\116\1\0\1\116\2\0\13\116\1\0" + + "\2\116\15\0\7\116\4\0\6\116\1\305\1\116\2\0" + + "\3\116\1\0\2\116\1\0\1\116\2\0\13\116\1\0" + + "\2\116\15\0\1\116\1\306\5\116\4\0\10\116\2\0" + + "\3\116\1\0\2\116\1\0\1\116\2\0\13\116\1\0" + + "\2\116\15\0\7\116\4\0\10\116\2\0\3\116\1\0" + + "\2\116\1\0\1\116\2\0\2\116\1\277\10\116\1\0" + + "\2\116\47\0\1\307\54\0\1\147\11\0\1\147\42\0" + + "\7\116\4\0\10\116\2\0\3\116\1\0\2\116\1\0" + + "\1\116\2\0\12\116\1\310\1\0\2\116\15\0\7\116" + + "\4\0\2\116\1\311\5\116\2\0\3\116\1\0\2\116" + + "\1\0\1\116\2\0\13\116\1\0\2\116\15\0\7\116" + + "\4\0\10\116\2\0\3\116\1\0\2\116\1\0\1\116" + + "\2\0\2\116\1\312\10\116\1\0\2\116\47\0\1\313" + + "\26\0\12\160\1\314\5\160\2\0\50\160\11\0\7\116" + + "\4\0\7\116\1\277\2\0\3\116\1\0\2\116\1\0" + + "\1\116\2\0\13\116\1\0\2\116\15\0\4\116\1\315" + + "\2\116\4\0\10\116\2\0\3\116\1\0\2\116\1\0" + + "\1\116\2\0\13\116\1\0\2\116\15\0\3\116\1\316" + + "\3\116\4\0\10\116\2\0\3\116\1\0\2\116\1\0" + + "\1\116\2\0\13\116\1\0\2\116\15\0\7\116\4\0" + + "\10\116\2\0\3\116\1\0\2\116\1\0\1\317\2\0" + + "\13\116\1\0\2\116\15\0\7\116\4\0\10\116\2\0" + + "\3\116\1\0\2\116\1\0\1\320\2\0\13\116\1\0" + + "\2\116\15\0\7\116\4\0\10\116\2\0\3\116\1\0" + + "\2\116\1\0\1\116\2\0\2\116\1\174\10\116\1\0" + + "\2\116\15\0\3\116\1\321\3\116\4\0\10\116\2\0" + + "\3\116\1\0\2\116\1\0\1\116\2\0\13\116\1\0" + + "\2\116\15\0\7\116\4\0\3\116\1\174\4\116\2\0" + + "\3\116\1\0\2\116\1\0\1\116\2\0\13\116\1\0" + + "\2\116\15\0\5\116\1\322\1\116\4\0\10\116\2\0" + + "\3\116\1\0\2\116\1\0\1\116\2\0\13\116\1\0" + + "\2\116\16\0\1\323\70\0\3\116\1\324\3\116\4\0" + + "\10\116\2\0\3\116\1\0\2\116\1\0\1\116\2\0" + + "\13\116\1\0\2\116\15\0\7\116\4\0\3\116\1\325" + + "\4\116\2\0\3\116\1\0\2\116\1\0\1\116\2\0" + + "\13\116\1\0\2\116\15\0\3\116\1\326\3\116\4\0" + + "\10\116\2\0\3\116\1\0\2\116\1\0\1\116\2\0" + + "\13\116\1\0\2\116\16\0\1\327\57\0\20\160\2\0" + + "\11\160\1\330\36\160\11\0\7\116\4\0\4\116\1\331" + + "\3\116\2\0\3\116\1\0\2\116\1\0\1\116\2\0" + + "\13\116\1\0\2\116\15\0\7\116\4\0\10\116\2\0" + + "\3\116\1\0\2\116\1\0\1\116\2\0\2\116\1\332" + + "\10\116\1\0\2\116\15\0\7\116\4\0\10\116\2\0" + + "\3\116\1\0\1\277\1\116\1\0\1\116\2\0\13\116" + + "\1\0\2\116\15\0\7\116\4\0\4\116\1\333\3\116" + + "\2\0\3\116\1\0\2\116\1\0\1\116\2\0\13\116" + + "\1\0\2\116\15\0\7\116\4\0\10\116\2\0\3\116" + + "\1\0\2\116\1\0\1\334\2\0\13\116\1\0\2\116" + + "\15\0\7\116\4\0\10\116\2\0\3\116\1\0\2\116" + + "\1\0\1\116\2\0\7\116\1\335\3\116\1\0\2\116" + + "\37\0\1\336\47\0\7\116\4\0\7\116\1\337\2\0" + + "\3\116\1\0\2\116\1\0\1\116\2\0\13\116\1\0" + + "\2\116\15\0\7\116\4\0\4\116\1\340\3\116\2\0" + + "\3\116\1\0\2\116\1\0\1\116\2\0\13\116\1\0" + + "\2\116\15\0\4\116\1\341\2\116\4\0\10\116\2\0" + + "\3\116\1\0\2\116\1\0\1\116\2\0\13\116\1\0" + + "\2\116\37\0\1\342\36\0\10\160\1\330\7\160\2\342" + + "\1\330\12\160\1\330\6\160\1\343\25\160\11\0\7\116" + + "\4\0\3\116\1\344\4\116\2\0\3\116\1\0\2\116" + + "\1\0\1\116\2\0\13\116\1\0\2\116\15\0\1\116" + + "\1\277\5\116\4\0\10\116\2\0\3\116\1\0\2\116" + + "\1\0\1\116\2\0\13\116\1\0\2\116\15\0\1\116" + + "\1\345\5\116\4\0\10\116\2\0\3\116\1\0\2\116" + + "\1\0\1\116\2\0\13\116\1\0\2\116\15\0\4\116" + + "\1\174\2\116\4\0\10\116\2\0\3\116\1\0\2\116" + + "\1\0\1\116\2\0\13\116\1\0\2\116\15\0\7\116" + + "\4\0\7\116\1\257\2\0\3\116\1\0\2\116\1\0" + + "\1\116\2\0\13\116\1\0\2\116\14\0\1\336\7\0" + + "\3\336\12\0\1\336\6\0\1\346\36\0\7\116\4\0" + + "\10\116\2\0\3\116\1\0\2\116\1\0\1\347\2\0" + + "\13\116\1\0\2\116\15\0\7\116\4\0\5\116\1\350" + + "\2\116\2\0\3\116\1\0\2\116\1\0\1\116\2\0" + + "\13\116\1\0\2\116\15\0\1\116\1\351\5\116\4\0" + + "\10\116\2\0\3\116\1\0\2\116\1\0\1\116\2\0" + + "\13\116\1\0\2\116\14\0\1\342\7\0\3\342\12\0" + + "\1\342\6\0\1\352\25\0\10\160\1\343\7\160\2\352" + + "\1\343\12\160\1\343\7\160\1\353\24\160\11\0\3\116" + + "\1\354\3\116\4\0\10\116\2\0\3\116\1\0\2\116" + + "\1\0\1\116\2\0\13\116\1\0\2\116\15\0\5\116" + + "\1\355\1\116\4\0\10\116\2\0\3\116\1\0\2\116" + + "\1\0\1\116\2\0\13\116\1\0\2\116\14\0\1\346" + + "\7\0\3\346\12\0\1\346\7\0\1\356\35\0\4\116" + + "\1\357\2\116\4\0\10\116\2\0\3\116\1\0\2\116" + + "\1\0\1\116\2\0\13\116\1\0\2\116\15\0\7\116" + + "\4\0\6\116\1\360\1\116\2\0\3\116\1\0\2\116" + + "\1\0\1\116\2\0\13\116\1\0\2\116\14\0\1\352" + + "\7\0\3\352\12\0\1\352\7\0\1\361\24\0\20\160" + + "\2\0\3\160\1\362\44\160\11\0\7\116\4\0\10\116" + + "\2\0\3\116\1\0\2\116\1\0\1\363\2\0\13\116" + + "\1\0\2\116\15\0\7\116\4\0\10\116\2\0\3\116" + + "\1\0\2\116\1\0\1\116\2\0\7\116\1\364\3\116" + + "\1\0\2\116\21\0\1\365\65\0\7\116\4\0\10\116" + + "\2\0\3\116\1\0\2\116\1\0\1\116\2\0\13\116" + + "\1\0\1\116\1\366\15\0\7\116\4\0\7\116\1\367" + + "\2\0\3\116\1\0\2\116\1\0\1\116\2\0\13\116" + + "\1\0\2\116\31\0\1\370\44\0\20\160\2\0\3\160" + + "\1\371\44\160\11\0\4\116\1\277\2\116\4\0\10\116" + + "\2\0\3\116\1\0\2\116\1\0\1\116\2\0\13\116" + + "\1\0\2\116\15\0\7\116\4\0\7\116\1\332\2\0" + + "\3\116\1\0\2\116\1\0\1\116\2\0\13\116\1\0" + + "\2\116\4\0\20\365\2\0\50\365\11\0\1\116\1\372" + + "\5\116\4\0\10\116\2\0\3\116\1\0\2\116\1\0" + + "\1\116\2\0\13\116\1\0\2\116\4\0\11\373\7\116" + + "\4\0\10\116\2\373\3\116\1\373\2\116\1\373\1\116" + + "\2\373\13\116\1\373\2\116\4\373\25\0\1\371\44\0" + + "\20\371\2\0\50\371\11\0\4\116\1\374\2\116\4\0" + + "\10\116\2\0\3\116\1\0\2\116\1\0\1\116\2\0" + + "\13\116\1\0\2\116\15\0\7\116\4\0\3\116\1\375" + + "\4\116\2\0\3\116\1\0\2\116\1\0\1\116\2\0" + + "\13\116\1\0\2\116\4\0"; private static int [] zzUnpackTrans() { - int [] result = new int[11514]; + int[] result = new int[11716]; int offset = 0; offset = zzUnpackTrans(ZZ_TRANS_PACKED_0, offset, result); return result; @@ -590,19 +592,20 @@ private static int zzUnpackTrans(String packed, int offset, int [] result) { private static final int [] ZZ_ATTRIBUTE = zzUnpackAttribute(); private static final String ZZ_ATTRIBUTE_PACKED_0 = - "\27\0\2\1\6\11\1\1\2\11\2\1\1\11\1\1"+ - "\1\11\1\1\1\11\3\1\4\11\1\1\7\11\1\1"+ - "\4\11\1\1\2\11\2\1\1\11\3\1\3\11\13\1"+ - "\1\11\1\1\3\11\2\0\11\1\2\0\10\1\1\0"+ - "\3\1\2\0\13\1\2\0\6\1\1\0\3\1\1\0"+ - "\1\11\12\1\2\0\5\1\1\0\3\1\1\0\15\1"+ - "\2\0\4\1\1\11\1\0\1\1\1\11\12\1\1\0"+ - "\3\1\1\0\7\1\1\0\3\1\1\0\6\1\1\0"+ - "\3\1\1\0\3\1\1\0\3\1\1\0\3\1\1\0"+ - "\2\1\1\0\6\1\1\0\2\1\1\11\2\1"; + "\27\0\2\1\6\11\1\1\2\11\1\1\1\11\1\1" + + "\1\11\1\1\2\11\1\1\1\11\3\1\4\11\1\1" + + "\7\11\1\1\4\11\1\1\2\11\2\1\1\11\3\1" + + "\3\11\13\1\1\11\1\1\3\11\2\0\11\1\2\0" + + "\10\1\1\0\3\1\2\0\13\1\2\0\6\1\1\0" + + "\3\1\1\0\1\11\12\1\2\0\5\1\1\0\3\1" + + "\1\0\15\1\2\0\4\1\1\11\1\0\1\1\1\11" + + "\12\1\1\0\3\1\1\0\7\1\1\0\3\1\1\0" + + "\6\1\1\0\3\1\1\0\3\1\1\0\3\1\1\0" + + "\3\1\1\0\2\1\1\0\6\1\1\0\2\1\1\11" + + "\2\1"; private static int [] zzUnpackAttribute() { - int [] result = new int[251]; + int[] result = new int[253]; int offset = 0; offset = zzUnpackAttribute(ZZ_ATTRIBUTE_PACKED_0, offset, result); return result; @@ -936,332 +939,448 @@ else if (zzAtEOF) { } else { switch (zzAction < 0 ? zzAction : ZZ_ACTION[zzAction]) { - case 1: - { return NORMAL_TEXT_WORD; - } - // fall through - case 59: break; - case 2: - { return NORMAL_TEXT_CHAR; - } - // fall through - case 60: break; - case 3: - { return OPEN_PAREN; - } - // fall through - case 61: break; - case 4: - { return CLOSE_PAREN; - } - // fall through - case 62: break; - case 5: - { return OPEN_BRACKET; - } - // fall through - case 63: break; - case 6: - { return CLOSE_BRACKET; - } - // fall through - case 64: break; - case 7: - { return OPEN_BRACE; - } - // fall through - case 65: break; - case 8: - { return CLOSE_BRACE; - } - // fall through - case 66: break; - case 9: - { return com.intellij.psi.TokenType.WHITE_SPACE; - } - // fall through - case 67: break; - case 10: - { return com.intellij.psi.TokenType.BAD_CHARACTER; - } - // fall through - case 68: break; - case 11: - { return COMMENT_TOKEN; - } - // fall through - case 69: break; - case 12: - { return STAR; - } - // fall through - case 70: break; - case 13: - { yypushState(INLINE_MATH); return INLINE_MATH_START; - } - // fall through - case 71: break; - case 14: - { return AMPERSAND; - } - // fall through - case 72: break; - case 15: - { yypopState(); return INLINE_MATH_END; - } - // fall through - case 73: break; - case 16: - { yypopState(); return CLOSE_BRACE; - } - // fall through - case 74: break; - case 17: - { yypushState(NESTED_INLINE_MATH); return INLINE_MATH_START; - } - // fall through - case 75: break; - case 18: - { yypopState(); yypushState(NEW_ENVIRONMENT_DEFINITION); return CLOSE_BRACE; - } - // fall through - case 76: break; - case 19: - { newEnvironmentBracesNesting++; return OPEN_BRACE; - } - // fall through - case 77: break; - case 20: - { newEnvironmentBracesNesting--; - if(newEnvironmentBracesNesting == 0) { - yypopState(); yypushState(NEW_ENVIRONMENT_SKIP_BRACE); - // We could have return normal text, but in this way the braces still match + case 1: { + return NORMAL_TEXT_WORD; + } + // fall through + case 61: + break; + case 2: { + return NORMAL_TEXT_CHAR; + } + // fall through + case 62: + break; + case 3: { + return OPEN_PAREN; + } + // fall through + case 63: + break; + case 4: { + return CLOSE_PAREN; + } + // fall through + case 64: + break; + case 5: { + return OPEN_BRACKET; + } + // fall through + case 65: + break; + case 6: { + return CLOSE_BRACKET; + } + // fall through + case 66: + break; + case 7: { return OPEN_BRACE; - } else { + } + // fall through + case 67: + break; + case 8: { return CLOSE_BRACE; - } - } - // fall through - case 78: break; - case 21: - { yypopState(); newEnvironmentBracesNesting = 1; yypushState(NEW_ENVIRONMENT_DEFINITION_END); return CLOSE_BRACE; - } - // fall through - case 79: break; - case 22: - { newEnvironmentBracesNesting--; - if(newEnvironmentBracesNesting == 0) { + } + // fall through + case 68: + break; + case 9: { + return com.intellij.psi.TokenType.WHITE_SPACE; + } + // fall through + case 69: + break; + case 10: { + return com.intellij.psi.TokenType.BAD_CHARACTER; + } + // fall through + case 70: + break; + case 11: { + return COMMENT_TOKEN; + } + // fall through + case 71: + break; + case 12: { + return KEYVAL_ASSIGN; + } + // fall through + case 72: + break; + case 13: { + return STAR; + } + // fall through + case 73: + break; + case 14: { + yypushState(INLINE_MATH); + return INLINE_MATH_START; + } + // fall through + case 74: + break; + case 15: { + return AMPERSAND; + } + // fall through + case 75: + break; + case 16: { + return PARAM_SEPARATOR; + } + // fall through + case 76: + break; + case 17: { yypopState(); - } - return CLOSE_BRACE; - } - // fall through - case 80: break; - case 23: - { yypopState(); verbatim_delimiter = yytext().toString(); yypushState(INLINE_VERBATIM); return OPEN_BRACE; - } - // fall through - case 81: break; - case 24: - { yypopState(); verbatim_delimiter = "}"; yypushState(INLINE_VERBATIM); return OPEN_BRACE; - } - // fall through - case 82: break; - case 25: - { if(yytext().toString().equals(verbatim_delimiter)) { yypopState(); return CLOSE_BRACE; } else { return RAW_TEXT_TOKEN; } - } - // fall through - case 83: break; - case 26: - { yypopState(); - // toString to fix comparisons of charsequence subsequences with string - if (Magic.Environment.verbatim.contains(yytext().toString())) { - yypushState(VERBATIM_START); - } - else if (yytext().toString().equals("algorithmic")) { - yypushState(PSEUDOCODE); - } - return NORMAL_TEXT_WORD; - } - // fall through - case 84: break; - case 27: - { verbatimOptionalArgumentBracketsCount++; return OPEN_BRACKET; - } - // fall through - case 85: break; - case 28: - { verbatimOptionalArgumentBracketsCount--; - if (verbatimOptionalArgumentBracketsCount == 0) { yypopState(); yypushState(VERBATIM); } - return CLOSE_BRACKET; - } - // fall through - case 86: break; - case 29: - { yypopState(); yypushState(POSSIBLE_VERBATIM_OPTIONAL_ARG); return CLOSE_BRACE; - } - // fall through - case 87: break; - case 30: - { return RAW_TEXT_TOKEN; - } - // fall through - case 88: break; - case 31: - { yypopState(); yypushState(VERBATIM); return RAW_TEXT_TOKEN; - } - // fall through - case 89: break; - case 32: - { verbatimOptionalArgumentBracketsCount++; yypopState(); yypushState(VERBATIM_OPTIONAL_ARG); return OPEN_BRACKET; - } - // fall through - case 90: break; - case 33: - { yypopState(); yypushState(VERBATIM); return com.intellij.psi.TokenType.WHITE_SPACE; - } - // fall through - case 91: break; - case 34: - { // Pop current state - yypopState(); - if (Magic.Environment.verbatim.contains(yytext().toString())) { - // Pop verbatim state + return INLINE_MATH_END; + } + // fall through + case 77: + break; + case 18: { yypopState(); + return CLOSE_BRACE; + } + // fall through + case 78: + break; + case 19: { + yypushState(NESTED_INLINE_MATH); + return INLINE_MATH_START; + } + // fall through + case 79: + break; + case 20: { + yypopState(); + yypushState(NEW_ENVIRONMENT_DEFINITION); + return CLOSE_BRACE; + } + // fall through + case 80: + break; + case 21: { + newEnvironmentBracesNesting++; + return OPEN_BRACE; + } + // fall through + case 81: + break; + case 22: { + newEnvironmentBracesNesting--; + if (newEnvironmentBracesNesting == 0) { + yypopState(); + yypushState(NEW_ENVIRONMENT_SKIP_BRACE); + // We could have return normal text, but in this way the braces still match + return OPEN_BRACE; + } else { + return CLOSE_BRACE; + } + } + // fall through + case 82: + break; + case 23: { + yypopState(); + newEnvironmentBracesNesting = 1; + yypushState(NEW_ENVIRONMENT_DEFINITION_END); + return CLOSE_BRACE; + } + // fall through + case 83: + break; + case 24: { + newEnvironmentBracesNesting--; + if (newEnvironmentBracesNesting == 0) { + yypopState(); + } + return CLOSE_BRACE; + } + // fall through + case 84: + break; + case 25: { + yypopState(); + verbatim_delimiter = yytext().toString(); + yypushState(INLINE_VERBATIM); + return OPEN_BRACE; + } + // fall through + case 85: + break; + case 26: { + yypopState(); + verbatim_delimiter = "}"; + yypushState(INLINE_VERBATIM); + return OPEN_BRACE; + } + // fall through + case 86: + break; + case 27: { + if (yytext().toString().equals(verbatim_delimiter)) { + yypopState(); + return CLOSE_BRACE; + } else { + return RAW_TEXT_TOKEN; + } + } + // fall through + case 87: + break; + case 28: { + yypopState(); + // toString to fix comparisons of charsequence subsequences with string + if (Magic.Environment.verbatim.contains(yytext().toString())) { + yypushState(VERBATIM_START); + } else if (yytext().toString().equals("algorithmic")) { + yypushState(PSEUDOCODE); + } return NORMAL_TEXT_WORD; - } - return RAW_TEXT_TOKEN; - } - // fall through - case 92: break; - case 35: - { yypopState(); return RAW_TEXT_TOKEN; - } - // fall through - case 93: break; - case 36: - { yypopState(); - if (yytext().toString().equals("algorithmic")) { - // Pop pseudocode state + } + // fall through + case 88: + break; + case 29: { + verbatimOptionalArgumentBracketsCount++; + return OPEN_BRACKET; + } + // fall through + case 89: + break; + case 30: { + verbatimOptionalArgumentBracketsCount--; + if (verbatimOptionalArgumentBracketsCount == 0) { + yypopState(); + yypushState(VERBATIM); + } + return CLOSE_BRACKET; + } + // fall through + case 90: + break; + case 31: { yypopState(); - } - return NORMAL_TEXT_WORD; - } - // fall through - case 94: break; - case 37: - { return COMMAND_TOKEN; - } - // fall through - case 95: break; - case 38: - { yypushState(INLINE_MATH_LATEX); return INLINE_MATH_START; - } - // fall through - case 96: break; - case 39: - { yypushState(DISPLAY_MATH); return DISPLAY_MATH_START; - } - // fall through - case 97: break; - case 40: - { return MAGIC_COMMENT_TOKEN; - } - // fall through - case 98: break; - case 41: - { yypushState(PREAMBLE_OPTION); return OPEN_BRACE; - } - // fall through - case 99: break; - case 42: - { yypopState(); return DISPLAY_MATH_END; - } - // fall through - case 100: break; - case 43: - { return DISPLAY_MATH_START; - } - // fall through - case 101: break; - case 44: - { return DISPLAY_MATH_END; - } - // fall through - case 102: break; - case 45: - { return BEGIN_PSEUDOCODE_BLOCK; - } - // fall through - case 103: break; - case 46: - { return END_TOKEN; - } - // fall through - case 104: break; - case 47: - { yypushState(POSSIBLE_VERBATIM_END); return END_TOKEN; - } - // fall through - case 105: break; - case 48: - { yypushState(POSSIBLE_PSEUDOCODE_END); return END_TOKEN; - } - // fall through - case 106: break; - case 49: - { yypushState(INLINE_VERBATIM_START); return COMMAND_TOKEN; - } - // fall through - case 107: break; - case 50: - { yypushState(TEXT_INSIDE_INLINE_MATH); return COMMAND_TOKEN; - } - // fall through - case 108: break; - case 51: - { return MIDDLE_PSEUDOCODE_BLOCK; - } - // fall through - case 109: break; - case 52: - { yypushState(POSSIBLE_VERBATIM_BEGIN); return BEGIN_TOKEN; - } - // fall through - case 110: break; - case 53: - { return BEGIN_TOKEN; - } - // fall through - case 111: break; - case 54: - { return END_PSEUDOCODE_BLOCK; - } - // fall through - case 112: break; - case 55: - { yypopState(); return COMMENT_TOKEN; - } - // fall through - case 113: break; - case 56: - { yypushState(OFF); return COMMENT_TOKEN; - } - // fall through - case 114: break; - case 57: - { return COMMAND_IFNEXTCHAR; - } - // fall through - case 115: break; - case 58: - { yypushState(NEW_ENVIRONMENT_DEFINITION_NAME); return COMMAND_TOKEN; - } - // fall through - case 116: break; + yypushState(POSSIBLE_VERBATIM_OPTIONAL_ARG); + return CLOSE_BRACE; + } + // fall through + case 91: + break; + case 32: { + return RAW_TEXT_TOKEN; + } + // fall through + case 92: + break; + case 33: { + yypopState(); + yypushState(VERBATIM); + return RAW_TEXT_TOKEN; + } + // fall through + case 93: + break; + case 34: { + verbatimOptionalArgumentBracketsCount++; + yypopState(); + yypushState(VERBATIM_OPTIONAL_ARG); + return OPEN_BRACKET; + } + // fall through + case 94: + break; + case 35: { + yypopState(); + yypushState(VERBATIM); + return com.intellij.psi.TokenType.WHITE_SPACE; + } + // fall through + case 95: + break; + case 36: { // Pop current state + yypopState(); + if (Magic.Environment.verbatim.contains(yytext().toString())) { + // Pop verbatim state + yypopState(); + return NORMAL_TEXT_WORD; + } + return RAW_TEXT_TOKEN; + } + // fall through + case 96: + break; + case 37: { + yypopState(); + return RAW_TEXT_TOKEN; + } + // fall through + case 97: + break; + case 38: { + yypopState(); + if (yytext().toString().equals("algorithmic")) { + // Pop pseudocode state + yypopState(); + } + return NORMAL_TEXT_WORD; + } + // fall through + case 98: + break; + case 39: { + return COMMAND_TOKEN; + } + // fall through + case 99: + break; + case 40: { + yypushState(INLINE_MATH_LATEX); + return INLINE_MATH_START; + } + // fall through + case 100: + break; + case 41: { + yypushState(DISPLAY_MATH); + return DISPLAY_MATH_START; + } + // fall through + case 101: + break; + case 42: { + return MAGIC_COMMENT_TOKEN; + } + // fall through + case 102: + break; + case 43: { + yypushState(PREAMBLE_OPTION); + return OPEN_BRACE; + } + // fall through + case 103: + break; + case 44: { + yypopState(); + return DISPLAY_MATH_END; + } + // fall through + case 104: + break; + case 45: { + return DISPLAY_MATH_START; + } + // fall through + case 105: + break; + case 46: { + return DISPLAY_MATH_END; + } + // fall through + case 106: + break; + case 47: { + return BEGIN_PSEUDOCODE_BLOCK; + } + // fall through + case 107: + break; + case 48: { + return END_TOKEN; + } + // fall through + case 108: + break; + case 49: { + yypushState(POSSIBLE_VERBATIM_END); + return END_TOKEN; + } + // fall through + case 109: + break; + case 50: { + yypushState(POSSIBLE_PSEUDOCODE_END); + return END_TOKEN; + } + // fall through + case 110: + break; + case 51: { + yypushState(INLINE_VERBATIM_START); + return COMMAND_TOKEN; + } + // fall through + case 111: + break; + case 52: { + yypushState(TEXT_INSIDE_INLINE_MATH); + return COMMAND_TOKEN; + } + // fall through + case 112: + break; + case 53: { + return MIDDLE_PSEUDOCODE_BLOCK; + } + // fall through + case 113: + break; + case 54: { + yypushState(POSSIBLE_VERBATIM_BEGIN); + return BEGIN_TOKEN; + } + // fall through + case 114: + break; + case 55: { + return BEGIN_TOKEN; + } + // fall through + case 115: + break; + case 56: { + return END_PSEUDOCODE_BLOCK; + } + // fall through + case 116: + break; + case 57: { + yypopState(); + return COMMENT_TOKEN; + } + // fall through + case 117: + break; + case 58: { + yypushState(OFF); + return COMMENT_TOKEN; + } + // fall through + case 118: + break; + case 59: { + return COMMAND_IFNEXTCHAR; + } + // fall through + case 119: + break; + case 60: { + yypushState(NEW_ENVIRONMENT_DEFINITION_NAME); + return COMMAND_TOKEN; + } + // fall through + case 120: + break; default: zzScanError(ZZ_NO_MATCH); - } + } } } } diff --git a/gen/nl/hannahsten/texifyidea/parser/LatexParser.java b/gen/nl/hannahsten/texifyidea/parser/LatexParser.java index e51c6ad27..5f0fa5f81 100644 --- a/gen/nl/hannahsten/texifyidea/parser/LatexParser.java +++ b/gen/nl/hannahsten/texifyidea/parser/LatexParser.java @@ -279,12 +279,13 @@ private static boolean inline_math_1(PsiBuilder b, int l) { } /* ********************************************************** */ - // keyval_text | parameter_group + // commands | keyval_text | parameter_group public static boolean keyval_content(PsiBuilder b, int l) { if (!recursion_guard_(b, l, "keyval_content")) return false; boolean r; Marker m = enter_section_(b, l, _NONE_, KEYVAL_CONTENT, ""); - r = keyval_text(b, l + 1); + r = commands(b, l + 1); + if (!r) r = keyval_text(b, l + 1); if (!r) r = parameter_group(b, l + 1); exit_section_(b, l, m, r, false, null); return r; @@ -307,7 +308,7 @@ public static boolean keyval_key(PsiBuilder b, int l) { } /* ********************************************************** */ - // keyval_key ("=" keyval_value)? + // keyval_key (KEYVAL_ASSIGN keyval_value)? public static boolean keyval_pair(PsiBuilder b, int l) { if (!recursion_guard_(b, l, "keyval_pair")) return false; boolean r; @@ -318,26 +319,26 @@ public static boolean keyval_pair(PsiBuilder b, int l) { return r; } - // ("=" keyval_value)? + // (KEYVAL_ASSIGN keyval_value)? private static boolean keyval_pair_1(PsiBuilder b, int l) { if (!recursion_guard_(b, l, "keyval_pair_1")) return false; keyval_pair_1_0(b, l + 1); return true; } - // "=" keyval_value + // KEYVAL_ASSIGN keyval_value private static boolean keyval_pair_1_0(PsiBuilder b, int l) { if (!recursion_guard_(b, l, "keyval_pair_1_0")) return false; boolean r; Marker m = enter_section_(b); - r = consumeToken(b, "="); + r = consumeToken(b, KEYVAL_ASSIGN); r = r && keyval_value(b, l + 1); exit_section_(b, m, null, r); return r; } /* ********************************************************** */ - // (NORMAL_TEXT_WORD | STAR | AMPERSAND | "|" | "!" | "\\" | "\"" | "&" | "<" | ">")+ + // (NORMAL_TEXT_WORD | STAR | AMPERSAND | "|" | "!" | "\\" | "\"" | "<" | ">")+ public static boolean keyval_text(PsiBuilder b, int l) { if (!recursion_guard_(b, l, "keyval_text")) return false; boolean r; @@ -352,7 +353,7 @@ public static boolean keyval_text(PsiBuilder b, int l) { return r; } - // NORMAL_TEXT_WORD | STAR | AMPERSAND | "|" | "!" | "\\" | "\"" | "&" | "<" | ">" + // NORMAL_TEXT_WORD | STAR | AMPERSAND | "|" | "!" | "\\" | "\"" | "<" | ">" private static boolean keyval_text_0(PsiBuilder b, int l) { if (!recursion_guard_(b, l, "keyval_text_0")) return false; boolean r; @@ -363,7 +364,6 @@ private static boolean keyval_text_0(PsiBuilder b, int l) { if (!r) r = consumeToken(b, "!"); if (!r) r = consumeToken(b, "\\"); if (!r) r = consumeToken(b, "\""); - if (!r) r = consumeToken(b, AMPERSAND); if (!r) r = consumeToken(b, "<"); if (!r) r = consumeToken(b, ">"); return r; @@ -464,7 +464,7 @@ public static boolean no_math_content(PsiBuilder b, int l) { } /* ********************************************************** */ - // (NORMAL_TEXT_WORD | STAR | AMPERSAND | NORMAL_TEXT_CHAR)+ + // (NORMAL_TEXT_WORD | STAR | AMPERSAND | NORMAL_TEXT_CHAR | KEYVAL_ASSIGN | PARAM_SEPARATOR )+ public static boolean normal_text(PsiBuilder b, int l) { if (!recursion_guard_(b, l, "normal_text")) return false; boolean r; @@ -479,7 +479,7 @@ public static boolean normal_text(PsiBuilder b, int l) { return r; } - // NORMAL_TEXT_WORD | STAR | AMPERSAND | NORMAL_TEXT_CHAR + // NORMAL_TEXT_WORD | STAR | AMPERSAND | NORMAL_TEXT_CHAR | KEYVAL_ASSIGN | PARAM_SEPARATOR private static boolean normal_text_0(PsiBuilder b, int l) { if (!recursion_guard_(b, l, "normal_text_0")) return false; boolean r; @@ -487,11 +487,13 @@ private static boolean normal_text_0(PsiBuilder b, int l) { if (!r) r = consumeToken(b, STAR); if (!r) r = consumeToken(b, AMPERSAND); if (!r) r = consumeToken(b, NORMAL_TEXT_CHAR); + if (!r) r = consumeToken(b, KEYVAL_ASSIGN); + if (!r) r = consumeToken(b, PARAM_SEPARATOR); return r; } /* ********************************************************** */ - // OPEN_BRACKET ( (keyval_pair ("," keyval_pair)*) | optional_param_content*) CLOSE_BRACKET + // OPEN_BRACKET ( (keyval_pair (PARAM_SEPARATOR keyval_pair)*) | optional_param_content*) CLOSE_BRACKET public static boolean optional_param(PsiBuilder b, int l) { if (!recursion_guard_(b, l, "optional_param")) return false; if (!nextTokenIs(b, OPEN_BRACKET)) return false; @@ -504,7 +506,7 @@ public static boolean optional_param(PsiBuilder b, int l) { return r; } - // (keyval_pair ("," keyval_pair)*) | optional_param_content* + // (keyval_pair (PARAM_SEPARATOR keyval_pair)*) | optional_param_content* private static boolean optional_param_1(PsiBuilder b, int l) { if (!recursion_guard_(b, l, "optional_param_1")) return false; boolean r; @@ -515,7 +517,7 @@ private static boolean optional_param_1(PsiBuilder b, int l) { return r; } - // keyval_pair ("," keyval_pair)* + // keyval_pair (PARAM_SEPARATOR keyval_pair)* private static boolean optional_param_1_0(PsiBuilder b, int l) { if (!recursion_guard_(b, l, "optional_param_1_0")) return false; boolean r; @@ -526,7 +528,7 @@ private static boolean optional_param_1_0(PsiBuilder b, int l) { return r; } - // ("," keyval_pair)* + // (PARAM_SEPARATOR keyval_pair)* private static boolean optional_param_1_0_1(PsiBuilder b, int l) { if (!recursion_guard_(b, l, "optional_param_1_0_1")) return false; while (true) { @@ -537,12 +539,12 @@ private static boolean optional_param_1_0_1(PsiBuilder b, int l) { return true; } - // "," keyval_pair + // PARAM_SEPARATOR keyval_pair private static boolean optional_param_1_0_1_0(PsiBuilder b, int l) { if (!recursion_guard_(b, l, "optional_param_1_0_1_0")) return false; boolean r; Marker m = enter_section_(b); - r = consumeToken(b, ","); + r = consumeToken(b, PARAM_SEPARATOR); r = r && keyval_pair(b, l + 1); exit_section_(b, m, null, r); return r; @@ -795,7 +797,7 @@ private static boolean required_param_1(PsiBuilder b, int l) { } /* ********************************************************** */ - // raw_text | magic_comment | comment | environment | pseudocode_block | math_environment | COMMAND_IFNEXTCHAR | group | OPEN_PAREN | CLOSE_PAREN | parameter_text | OPEN_BRACKET | CLOSE_BRACKET | NORMAL_TEXT_CHAR + // raw_text | magic_comment | comment | environment | pseudocode_block | math_environment | COMMAND_IFNEXTCHAR | group | OPEN_PAREN | CLOSE_PAREN | parameter_text | PARAM_SEPARATOR | KEYVAL_ASSIGN | OPEN_BRACKET | CLOSE_BRACKET | NORMAL_TEXT_CHAR public static boolean required_param_content(PsiBuilder b, int l) { if (!recursion_guard_(b, l, "required_param_content")) return false; boolean r; @@ -811,6 +813,8 @@ public static boolean required_param_content(PsiBuilder b, int l) { if (!r) r = consumeToken(b, OPEN_PAREN); if (!r) r = consumeToken(b, CLOSE_PAREN); if (!r) r = parameter_text(b, l + 1); + if (!r) r = consumeToken(b, PARAM_SEPARATOR); + if (!r) r = consumeToken(b, KEYVAL_ASSIGN); if (!r) r = consumeToken(b, OPEN_BRACKET); if (!r) r = consumeToken(b, CLOSE_BRACKET); if (!r) r = consumeToken(b, NORMAL_TEXT_CHAR); diff --git a/gen/nl/hannahsten/texifyidea/psi/LatexKeyvalContent.java b/gen/nl/hannahsten/texifyidea/psi/LatexKeyvalContent.java index 8019d79a7..88e33f1fc 100644 --- a/gen/nl/hannahsten/texifyidea/psi/LatexKeyvalContent.java +++ b/gen/nl/hannahsten/texifyidea/psi/LatexKeyvalContent.java @@ -6,10 +6,13 @@ public interface LatexKeyvalContent extends PsiElement { - @Nullable - LatexKeyvalText getKeyvalText(); + @Nullable + LatexCommands getCommands(); - @Nullable - LatexParameterGroup getParameterGroup(); + @Nullable + LatexKeyvalText getKeyvalText(); + + @Nullable + LatexParameterGroup getParameterGroup(); } diff --git a/gen/nl/hannahsten/texifyidea/psi/LatexTypes.java b/gen/nl/hannahsten/texifyidea/psi/LatexTypes.java index f43edb608..60eaeb28a 100644 --- a/gen/nl/hannahsten/texifyidea/psi/LatexTypes.java +++ b/gen/nl/hannahsten/texifyidea/psi/LatexTypes.java @@ -58,6 +58,7 @@ public interface LatexTypes { IElementType END_TOKEN = new LatexTokenType("\\end"); IElementType INLINE_MATH_END = new LatexTokenType("INLINE_MATH_END"); IElementType INLINE_MATH_START = new LatexTokenType("INLINE_MATH_START"); + IElementType KEYVAL_ASSIGN = new LatexTokenType("KEYVAL_ASSIGN"); IElementType MAGIC_COMMENT_TOKEN = new LatexTokenType("MAGIC_COMMENT_TOKEN"); IElementType MIDDLE_PSEUDOCODE_BLOCK = new LatexTokenType("MIDDLE_PSEUDOCODE_BLOCK"); IElementType NORMAL_TEXT_CHAR = new LatexTokenType("NORMAL_TEXT_CHAR"); @@ -65,6 +66,7 @@ public interface LatexTypes { IElementType OPEN_BRACE = new LatexTokenType("OPEN_BRACE"); IElementType OPEN_BRACKET = new LatexTokenType("OPEN_BRACKET"); IElementType OPEN_PAREN = new LatexTokenType("OPEN_PAREN"); + IElementType PARAM_SEPARATOR = new LatexTokenType("PARAM_SEPARATOR"); IElementType RAW_TEXT_TOKEN = new LatexTokenType("RAW_TEXT"); IElementType STAR = new LatexTokenType("*"); diff --git a/gen/nl/hannahsten/texifyidea/psi/impl/LatexKeyvalContentImpl.java b/gen/nl/hannahsten/texifyidea/psi/impl/LatexKeyvalContentImpl.java index f14033796..025f85f34 100644 --- a/gen/nl/hannahsten/texifyidea/psi/impl/LatexKeyvalContentImpl.java +++ b/gen/nl/hannahsten/texifyidea/psi/impl/LatexKeyvalContentImpl.java @@ -5,10 +5,7 @@ import com.intellij.lang.ASTNode; import com.intellij.psi.PsiElementVisitor; import com.intellij.psi.util.PsiTreeUtil; -import nl.hannahsten.texifyidea.psi.LatexKeyvalContent; -import nl.hannahsten.texifyidea.psi.LatexKeyvalText; -import nl.hannahsten.texifyidea.psi.LatexParameterGroup; -import nl.hannahsten.texifyidea.psi.LatexVisitor; +import nl.hannahsten.texifyidea.psi.*; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -24,10 +21,16 @@ public void accept(@NotNull LatexVisitor visitor) { @Override public void accept(@NotNull PsiElementVisitor visitor) { - if (visitor instanceof LatexVisitor) accept((LatexVisitor)visitor); + if (visitor instanceof LatexVisitor) accept((LatexVisitor) visitor); else super.accept(visitor); } + @Override + @Nullable + public LatexCommands getCommands() { + return PsiTreeUtil.getChildOfType(this, LatexCommands.class); + } + @Override @Nullable public LatexKeyvalText getKeyvalText() { diff --git a/src/nl/hannahsten/texifyidea/grammar/Latex.bnf b/src/nl/hannahsten/texifyidea/grammar/Latex.bnf index e8dbf7637..094a23d88 100644 --- a/src/nl/hannahsten/texifyidea/grammar/Latex.bnf +++ b/src/nl/hannahsten/texifyidea/grammar/Latex.bnf @@ -63,7 +63,7 @@ content ::= no_math_content no_math_content ::= raw_text | magic_comment | comment | environment | pseudocode_block | math_environment | COMMAND_IFNEXTCHAR | commands | group | OPEN_PAREN | CLOSE_PAREN | OPEN_BRACKET | CLOSE_BRACKET | normal_text -normal_text ::= (NORMAL_TEXT_WORD | STAR | AMPERSAND | NORMAL_TEXT_CHAR)+ +normal_text ::= (NORMAL_TEXT_WORD | STAR | AMPERSAND | NORMAL_TEXT_CHAR | KEYVAL_ASSIGN | PARAM_SEPARATOR )+ environment ::= begin_command environment_content? end_command { pin=1 @@ -101,7 +101,7 @@ parameter ::= optional_param | required_param // will be seen as simply an open bracket, but '[x]' at the same location will // be parsed as optional parameter. // https://stackoverflow.com/a/48709143/6629569 -optional_param ::= OPEN_BRACKET ( (keyval_pair ("," keyval_pair)*) | optional_param_content*) CLOSE_BRACKET { pin=3 } +optional_param ::= OPEN_BRACKET ( (keyval_pair (PARAM_SEPARATOR keyval_pair)*) | optional_param_content*) CLOSE_BRACKET { pin=3 } required_param ::= OPEN_BRACE required_param_content* CLOSE_BRACE { pin=1 } @@ -109,22 +109,20 @@ required_param ::= OPEN_BRACE required_param_content* CLOSE_BRACE { pin=1 } // We have to separate optional and required parameter content, because required parameter content // can contain mismatched brackets, but optional parameters not (then we wouldn't know what to match) optional_param_content ::= raw_text | magic_comment | comment | environment | pseudocode_block | math_environment | COMMAND_IFNEXTCHAR | commands | group | OPEN_PAREN | CLOSE_PAREN | parameter_text | NORMAL_TEXT_CHAR -required_param_content ::= raw_text | magic_comment | comment | environment | pseudocode_block | math_environment | COMMAND_IFNEXTCHAR | group | OPEN_PAREN | CLOSE_PAREN | parameter_text | OPEN_BRACKET | CLOSE_BRACKET | NORMAL_TEXT_CHAR +required_param_content ::= raw_text | magic_comment | comment | environment | pseudocode_block | math_environment | COMMAND_IFNEXTCHAR | group | OPEN_PAREN | CLOSE_PAREN | parameter_text | PARAM_SEPARATOR | KEYVAL_ASSIGN | OPEN_BRACKET | CLOSE_BRACKET | NORMAL_TEXT_CHAR -// These non-terminals are used to match the key value pairs of optional parameters. We cannot (currently) define -// "=" and "," as tokens because the lexer would create them as tokens everywhere, including in normal text. -keyval_pair ::= keyval_key ("=" keyval_value)? +keyval_pair ::= keyval_key (KEYVAL_ASSIGN keyval_value)? keyval_key ::= keyval_content+ { methods=[toString] } keyval_value ::= keyval_content+ { methods=[toString getNameIdentifier getName setName] } -keyval_content ::= keyval_text | parameter_group +keyval_content ::= commands | keyval_text | parameter_group // We need to include the special characters here because changing NORMAL_TEXT_CHAR would alter the lexer's behaviour -// and break several other things. -keyval_text ::= (NORMAL_TEXT_WORD | STAR | AMPERSAND | "|" | "!" | "\\" | "\"" | "&" | "<" | ">")+ +// in several other places. +keyval_text ::= (NORMAL_TEXT_WORD | STAR | AMPERSAND | "|" | "!" | "\\" | "\"" | "<" | ">")+ // The lowest level of a parameter must have the getReferences etc. implemented diff --git a/src/nl/hannahsten/texifyidea/grammar/LatexLexer.flex b/src/nl/hannahsten/texifyidea/grammar/LatexLexer.flex index 26d6cce09..5039ab142 100644 --- a/src/nl/hannahsten/texifyidea/grammar/LatexLexer.flex +++ b/src/nl/hannahsten/texifyidea/grammar/LatexLexer.flex @@ -80,7 +80,7 @@ LEXER_ON_TOKEN={MAGIC_COMMENT_LEXER_SWITCH} "on" [^\r\n]* NORMAL_TEXT_WORD=[^\s\\\{\}%\[\]$\(\)|!\"=&<>,]+ // Separate from normal text, e.g. because they can be \verb delimiters or should not appear in normal text words for other reasons -NORMAL_TEXT_CHAR=[|!\"=&<>,] +NORMAL_TEXT_CHAR=[|!\"&<>] ANY_CHAR=[^] // Algorithmicx @@ -363,4 +363,9 @@ END_PSEUDOCODE_BLOCK="\\EndFor" | "\\EndIf" | "\\EndWhile" | "\\Until" | "\\EndL {COMMENT_TOKEN} { return COMMENT_TOKEN; } {NORMAL_TEXT_WORD} { return NORMAL_TEXT_WORD; } {NORMAL_TEXT_CHAR} { return NORMAL_TEXT_CHAR; } + +// Tokens for parameter separators (e.g., \cite{param1,param2}) and +// keyval assigns (e.g. \lstinputlisting[label=somelabel]) +"=" { return KEYVAL_ASSIGN; } +"," { return PARAM_SEPARATOR; } [^] { return com.intellij.psi.TokenType.BAD_CHARACTER; } diff --git a/src/nl/hannahsten/texifyidea/psi/LatexCommandsImplUtil.kt b/src/nl/hannahsten/texifyidea/psi/LatexCommandsImplUtil.kt index b15058533..69da280b8 100644 --- a/src/nl/hannahsten/texifyidea/psi/LatexCommandsImplUtil.kt +++ b/src/nl/hannahsten/texifyidea/psi/LatexCommandsImplUtil.kt @@ -173,7 +173,7 @@ fun getOptionalParameterMap(parameters: List): LinkedHashMap): List? { +fun getRequiredParameters(parameters: List): List { return parameters.mapNotNull { it.requiredParam } .map { param -> param.text.dropWhile { it == '{' }.dropLastWhile { it == '}' }.trim() @@ -212,10 +212,18 @@ fun setName(element: LatexCommands, newName: String): PsiElement { return element } -fun toString(element: LatexKeyvalKey): String = - element.keyvalContentList.map { it -> it.keyvalText?.text ?: it.parameterGroup!!.parameterGroupText!!.text } - .joinToString(separator = "") +fun keyValContentToString(element: LatexKeyvalKey): String = + keyValContentToString(element.keyvalContentList) -fun toString(element: LatexKeyvalValue): String = - element.keyvalContentList.map { it -> it.keyvalText?.text ?: it.parameterGroup!!.parameterGroupText!!.text } - .joinToString(separator = "") +fun keyValContentToString(list: List): String = + list.joinToString(separator = "") { + when { + it.keyvalText != null -> it.keyvalText!!.text + it.parameterGroup != null -> it.parameterGroup!!.parameterGroupText!!.text + it.commands != null -> it.commands!!.text + else -> "" + } + } + +fun keyValContentToString(element: LatexKeyvalValue): String = + keyValContentToString(element.keyvalContentList) diff --git a/src/nl/hannahsten/texifyidea/psi/LatexPsiHelper.kt b/src/nl/hannahsten/texifyidea/psi/LatexPsiHelper.kt index 7a2b7233f..ddcb0b06a 100644 --- a/src/nl/hannahsten/texifyidea/psi/LatexPsiHelper.kt +++ b/src/nl/hannahsten/texifyidea/psi/LatexPsiHelper.kt @@ -6,6 +6,7 @@ import com.intellij.psi.PsiFileFactory import com.intellij.psi.impl.source.tree.LeafPsiElement import nl.hannahsten.texifyidea.LatexLanguage import nl.hannahsten.texifyidea.psi.LatexTypes.CLOSE_BRACKET +import nl.hannahsten.texifyidea.psi.LatexTypes.KEYVAL_ASSIGN import nl.hannahsten.texifyidea.util.childrenOfType import nl.hannahsten.texifyidea.util.findFirstChild import nl.hannahsten.texifyidea.util.firstChildOfType @@ -95,7 +96,9 @@ class LatexPsiHelper(private val project: Project) { val existing = optionalParam.keyvalPairList.find { kv -> kv.keyvalKey.text == name } if (existing != null && value != null) { existing.keyvalValue?.delete() - existing.addAfter(pair.keyvalValue!!, existing.childrenOfType().first { it.text == "=" }) + existing.addAfter( + pair.keyvalValue!!, + existing.childrenOfType().first { it.elementType == KEYVAL_ASSIGN }) existing } else { diff --git a/src/nl/hannahsten/texifyidea/psi/LatexPsiImplUtil.java b/src/nl/hannahsten/texifyidea/psi/LatexPsiImplUtil.java index 28deedc1a..a9aea4be0 100644 --- a/src/nl/hannahsten/texifyidea/psi/LatexPsiImplUtil.java +++ b/src/nl/hannahsten/texifyidea/psi/LatexPsiImplUtil.java @@ -40,11 +40,11 @@ public static PsiReference getReference(@NotNull LatexCommands element) { } public static String toString(@NotNull LatexKeyvalKey element) { - return LatexCommandsImplUtilKt.toString(element); + return LatexCommandsImplUtilKt.keyValContentToString(element); } public static String toString(@NotNull LatexKeyvalValue element) { - return LatexCommandsImplUtilKt.toString(element); + return LatexCommandsImplUtilKt.keyValContentToString(element); } public static LinkedHashMap getOptionalParameterMap(@NotNull LatexCommands element) { diff --git a/test/nl/hannahsten/texifyidea/psi/LatexCommandsImplUtilTest.kt b/test/nl/hannahsten/texifyidea/psi/LatexCommandsImplUtilTest.kt index ab0a17975..7cf548119 100644 --- a/test/nl/hannahsten/texifyidea/psi/LatexCommandsImplUtilTest.kt +++ b/test/nl/hannahsten/texifyidea/psi/LatexCommandsImplUtilTest.kt @@ -138,4 +138,29 @@ class LatexCommandsImplUtilTest : BasePlatformTestCase() { assertEquals("value1", map["param1"]) assertEquals("value2", map["param2"]) } + + @Test + fun `test command value optional parameters map`() { + // given + myFixture.configureByText( + LatexFileType, + """ + \begin{document} + \lstinputlisting[linewidth=\textwidth]{some/file} + \end{document} + """.trimIndent() + ) + + // when + val parameters = PsiDocumentManager.getInstance(myFixture.project) + .getPsiFile(myFixture.editor.document)!! + .children + .first() + .firstChildOfType(LatexCommands::class)!! + .parameterList + + val map = getOptionalParameterMap(parameters).toStringMap() + assertSize(1, map.keys) + assertEquals("\\textwidth", map["linewidth"]) + } } \ No newline at end of file diff --git a/test/nl/hannahsten/texifyidea/reference/LabelDefinitionReferenceTest.kt b/test/nl/hannahsten/texifyidea/reference/LabelDefinitionReferenceTest.kt index 71bcd770e..7281b9cf9 100644 --- a/test/nl/hannahsten/texifyidea/reference/LabelDefinitionReferenceTest.kt +++ b/test/nl/hannahsten/texifyidea/reference/LabelDefinitionReferenceTest.kt @@ -34,7 +34,7 @@ class LabelDefinitionReferenceTest : BasePlatformTestCase() { myFixture.configureByText( LatexFileType, """ - \begin{lstlisting}[label=test,escapechar=|] + \begin{lstlisting}[label=test,escapechar=|!\"&] \end{lstlisting} \ref{test} """.trimMargin() @@ -42,7 +42,7 @@ class LabelDefinitionReferenceTest : BasePlatformTestCase() { myFixture.renameElementAtCaret("renamed") myFixture.checkResult( """ - \begin{lstlisting}[label={renamed},escapechar=|] + \begin{lstlisting}[label={renamed},escapechar=|!\"&] \end{lstlisting} \ref{renamed} """.trimMargin() From 35a253995c15a23fa42113bca2882c9534e40484 Mon Sep 17 00:00:00 2001 From: Felix Berlakovich Date: Tue, 29 Dec 2020 16:01:34 +0100 Subject: [PATCH 15/20] Fix merge issues --- .../texifyidea/grammar/LatexLexer.java | 1666 +++++++++-------- .../texifyidea/psi/LatexKeyvalContent.java | 12 +- .../texifyidea/psi/LatexLanguageInjector.kt | 4 +- 3 files changed, 900 insertions(+), 782 deletions(-) diff --git a/gen/nl/hannahsten/texifyidea/grammar/LatexLexer.java b/gen/nl/hannahsten/texifyidea/grammar/LatexLexer.java index 406254d5e..21f8455bf 100644 --- a/gen/nl/hannahsten/texifyidea/grammar/LatexLexer.java +++ b/gen/nl/hannahsten/texifyidea/grammar/LatexLexer.java @@ -2,13 +2,13 @@ package nl.hannahsten.texifyidea.grammar; -import java.util.*; - import com.intellij.lexer.FlexLexer; -import com.intellij.psi.TokenType; import com.intellij.psi.tree.IElementType; import nl.hannahsten.texifyidea.util.Magic; +import java.util.ArrayDeque; +import java.util.Deque; + import static nl.hannahsten.texifyidea.psi.LatexTypes.*; @@ -81,13 +81,13 @@ public static int ZZ_CMAP(int ch) { /* The ZZ_CMAP_A table has 640 entries */ static final char ZZ_CMAP_A[] = zzUnpackCMap( - "\11\0\1\10\1\20\2\22\1\21\22\0\1\35\1\34\1\47\1\0\1\66\1\41\1\70\1\0\1\2\1"+ - "\3\1\63\17\0\1\17\1\0\1\67\1\44\1\67\1\0\1\24\1\51\3\17\1\37\1\50\2\17\1\53"+ - "\2\17\1\56\3\17\1\60\1\17\1\55\1\17\1\36\1\61\1\17\1\54\1\40\2\17\1\4\1\1"+ - "\1\5\1\0\1\17\1\0\1\32\1\11\1\30\1\16\1\12\1\25\1\13\1\31\1\14\2\17\1\52\1"+ - "\65\1\15\1\45\1\42\1\17\1\33\1\43\1\27\1\57\1\62\1\64\1\26\2\17\1\6\1\47\1"+ - "\7\7\0\1\23\32\0\1\46\337\0\1\46\177\0\13\46\35\0\2\23\5\0\1\46\57\0\1\46"+ - "\40\0"); + "\11\0\1\10\1\20\2\22\1\21\22\0\1\35\1\34\1\47\1\0\1\66\1\41\1\70\1\0\1\2\1" + + "\3\1\63\1\0\1\71\15\0\1\17\1\0\1\67\1\44\1\67\1\0\1\24\1\51\3\17\1\37\1\50" + + "\2\17\1\53\2\17\1\56\3\17\1\60\1\17\1\55\1\17\1\36\1\61\1\17\1\54\1\40\2\17" + + "\1\4\1\1\1\5\1\0\1\17\1\0\1\32\1\11\1\30\1\16\1\12\1\25\1\13\1\31\1\14\2\17" + + "\1\52\1\65\1\15\1\45\1\42\1\17\1\33\1\43\1\27\1\57\1\62\1\64\1\26\2\17\1\6" + + "\1\47\1\7\7\0\1\23\32\0\1\46\337\0\1\46\177\0\13\46\35\0\2\23\5\0\1\46\57" + + "\0\1\46\40\0"); /** * Translates DFA states to action switch labels. @@ -95,27 +95,27 @@ public static int ZZ_CMAP(int ch) { private static final int [] ZZ_ACTION = zzUnpackAction(); private static final String ZZ_ACTION_PACKED_0 = - "\27\0\1\1\1\2\1\3\1\4\1\5\1\6\1\7"+ - "\1\10\1\11\1\12\1\2\1\13\1\14\1\15\1\2"+ - "\1\16\1\2\1\17\3\2\1\20\1\21\1\1\1\22"+ - "\1\2\1\23\1\24\1\25\1\26\1\27\1\30\1\31"+ - "\1\32\1\33\1\34\1\35\2\36\1\37\1\40\1\41"+ - "\1\42\1\43\1\2\1\44\1\36\1\45\1\46\1\47"+ - "\11\45\1\13\1\50\1\13\1\51\1\45\1\52\1\53"+ - "\1\54\2\0\11\45\2\0\11\45\1\50\1\0\1\50"+ - "\1\13\1\45\2\0\5\45\1\55\5\45\2\0\1\45"+ - "\1\56\6\45\1\0\1\50\1\13\1\45\1\0\1\57"+ - "\1\60\2\45\1\55\6\45\2\0\6\45\1\61\1\0"+ - "\1\50\1\13\1\62\1\0\5\45\1\63\7\45\2\0"+ - "\1\64\5\45\1\61\1\0\1\50\1\65\2\45\1\66"+ - "\7\45\1\0\5\45\1\0\1\50\6\45\1\0\4\45"+ - "\1\61\1\0\1\50\5\45\1\0\4\45\1\0\1\50"+ - "\2\45\1\0\2\45\1\0\1\50\2\45\1\0\2\45"+ - "\1\0\1\50\2\45\1\67\2\45\1\0\1\70\1\45"+ - "\1\71\1\45\1\72"; + "\27\0\1\1\1\2\1\3\1\4\1\5\1\6\1\7" + + "\1\10\1\11\1\12\1\2\1\13\1\14\1\15\1\16" + + "\1\2\1\17\1\20\1\2\1\21\3\2\1\22\1\23" + + "\1\1\1\24\1\2\1\25\1\26\1\27\1\30\1\31" + + "\1\32\1\33\1\34\1\35\1\36\1\37\2\40\1\41" + + "\1\42\1\43\1\44\1\45\1\2\1\46\1\40\1\47" + + "\1\50\1\51\11\47\1\13\1\52\1\13\1\53\1\47" + + "\1\54\1\55\1\56\2\0\11\47\2\0\11\47\1\52" + + "\1\0\1\52\1\13\1\47\2\0\5\47\1\57\5\47" + + "\2\0\1\47\1\60\6\47\1\0\1\52\1\13\1\47" + + "\1\0\1\61\1\62\2\47\1\57\6\47\2\0\6\47" + + "\1\63\1\0\1\52\1\13\1\64\1\0\5\47\1\65" + + "\7\47\2\0\1\66\5\47\1\63\1\0\1\52\1\67" + + "\2\47\1\70\7\47\1\0\5\47\1\0\1\52\6\47" + + "\1\0\4\47\1\63\1\0\1\52\5\47\1\0\4\47" + + "\1\0\1\52\2\47\1\0\2\47\1\0\1\52\2\47" + + "\1\0\2\47\1\0\1\52\2\47\1\71\2\47\1\0" + + "\1\72\1\47\1\73\1\47\1\74"; private static int [] zzUnpackAction() { - int [] result = new int[264]; + int[] result = new int[266]; int offset = 0; offset = zzUnpackAction(ZZ_ACTION_PACKED_0, offset, result); return result; @@ -140,42 +140,43 @@ private static int zzUnpackAction(String packed, int offset, int [] result) { private static final int [] ZZ_ROWMAP = zzUnpackRowMap(); private static final String ZZ_ROWMAP_PACKED_0 = - "\0\0\0\71\0\162\0\253\0\344\0\u011d\0\u0156\0\u018f"+ - "\0\u01c8\0\u0201\0\u023a\0\u0273\0\u02ac\0\u02e5\0\u031e\0\u0357"+ - "\0\u0390\0\u03c9\0\u0402\0\u043b\0\u0474\0\u04ad\0\u04e6\0\u051f"+ - "\0\u0558\0\u0591\0\u0591\0\u0591\0\u0591\0\u0591\0\u0591\0\u05ca"+ - "\0\u0591\0\u0591\0\u0603\0\u051f\0\u0591\0\u063c\0\u0591\0\u0675"+ - "\0\u0591\0\u06ae\0\u06e7\0\u0720\0\u0591\0\u0591\0\u0591\0\u0591"+ - "\0\u0759\0\u0591\0\u0591\0\u0591\0\u0591\0\u0591\0\u0591\0\u0591"+ - "\0\u0792\0\u0591\0\u0591\0\u0591\0\u0591\0\u07cb\0\u0591\0\u0591"+ - "\0\u0804\0\u083d\0\u0591\0\u0876\0\u08af\0\u08e8\0\u0591\0\u0591"+ - "\0\u0591\0\u0921\0\u095a\0\u0993\0\u09cc\0\u0a05\0\u0a3e\0\u0a77"+ - "\0\u0ab0\0\u0ae9\0\u0b22\0\u0b5b\0\u0b94\0\u0591\0\u0bcd\0\u0591"+ - "\0\u0591\0\u0591\0\u0c06\0\u0c3f\0\u0c78\0\u0cb1\0\u0cea\0\u0d23"+ - "\0\u0d5c\0\u0d95\0\u0dce\0\u0e07\0\u0e40\0\u0e79\0\u0eb2\0\u0eeb"+ - "\0\u0f24\0\u0f5d\0\u0f96\0\u0fcf\0\u1008\0\u1041\0\u107a\0\u10b3"+ - "\0\u10ec\0\u1125\0\u115e\0\u1197\0\u11d0\0\u1209\0\u1242\0\u127b"+ - "\0\u12b4\0\u12ed\0\u1326\0\u135f\0\u0993\0\u1398\0\u13d1\0\u140a"+ - "\0\u1443\0\u147c\0\u14b5\0\u14ee\0\u1527\0\u0993\0\u1560\0\u1599"+ - "\0\u15d2\0\u160b\0\u1644\0\u167d\0\u16b6\0\u16ef\0\u1728\0\u1761"+ - "\0\u179a\0\u0591\0\u0993\0\u17d3\0\u180c\0\u1845\0\u187e\0\u18b7"+ - "\0\u18f0\0\u1929\0\u1962\0\u199b\0\u19d4\0\u1a0d\0\u1a46\0\u1a7f"+ - "\0\u1ab8\0\u1af1\0\u1b2a\0\u1b63\0\u1b9c\0\u1bd5\0\u1c0e\0\u1c47"+ - "\0\u0993\0\u1c80\0\u1cb9\0\u1cf2\0\u1d2b\0\u1d64\0\u1d9d\0\u0993"+ - "\0\u1dd6\0\u1e0f\0\u1e48\0\u1e81\0\u1eba\0\u1ef3\0\u1f2c\0\u1f65"+ - "\0\u1f9e\0\u0993\0\u1fd7\0\u2010\0\u2049\0\u2082\0\u20bb\0\u0591"+ - "\0\u20f4\0\u212d\0\u0591\0\u2166\0\u219f\0\u0993\0\u21d8\0\u2211"+ - "\0\u224a\0\u2283\0\u22bc\0\u22f5\0\u232e\0\u2367\0\u23a0\0\u23d9"+ - "\0\u2412\0\u244b\0\u2484\0\u24bd\0\u24f6\0\u252f\0\u2568\0\u25a1"+ - "\0\u25da\0\u2613\0\u264c\0\u2685\0\u26be\0\u26f7\0\u2730\0\u2769"+ - "\0\u0993\0\u27a2\0\u27db\0\u2814\0\u284d\0\u2886\0\u28bf\0\u28f8"+ - "\0\u2931\0\u296a\0\u29a3\0\u29dc\0\u2a15\0\u2a4e\0\u2a87\0\u2ac0"+ - "\0\u2af9\0\u2b32\0\u2b6b\0\u2ba4\0\u2bdd\0\u2c16\0\u2c4f\0\u2c88"+ - "\0\u2cc1\0\u2cfa\0\u2d33\0\u2d6c\0\u2da5\0\u2dde\0\u2e17\0\u2e50"+ - "\0\u2e89\0\u2ec2\0\u2efb\0\u2f34\0\u2f6d\0\u0591\0\u2fa6\0\u0993"; + "\0\0\0\72\0\164\0\256\0\350\0\u0122\0\u015c\0\u0196" + + "\0\u01d0\0\u020a\0\u0244\0\u027e\0\u02b8\0\u02f2\0\u032c\0\u0366" + + "\0\u03a0\0\u03da\0\u0414\0\u044e\0\u0488\0\u04c2\0\u04fc\0\u0536" + + "\0\u0570\0\u05aa\0\u05aa\0\u05aa\0\u05aa\0\u05aa\0\u05aa\0\u05e4" + + "\0\u05aa\0\u05aa\0\u061e\0\u05aa\0\u0536\0\u05aa\0\u0658\0\u05aa" + + "\0\u05aa\0\u0692\0\u05aa\0\u06cc\0\u0706\0\u0740\0\u05aa\0\u05aa" + + "\0\u05aa\0\u05aa\0\u077a\0\u05aa\0\u05aa\0\u05aa\0\u05aa\0\u05aa" + + "\0\u05aa\0\u05aa\0\u07b4\0\u05aa\0\u05aa\0\u05aa\0\u05aa\0\u07ee" + + "\0\u05aa\0\u05aa\0\u0828\0\u0862\0\u05aa\0\u089c\0\u08d6\0\u0910" + + "\0\u05aa\0\u05aa\0\u05aa\0\u094a\0\u0984\0\u09be\0\u09f8\0\u0a32" + + "\0\u0a6c\0\u0aa6\0\u0ae0\0\u0b1a\0\u0b54\0\u0b8e\0\u0bc8\0\u05aa" + + "\0\u0c02\0\u05aa\0\u05aa\0\u05aa\0\u0c3c\0\u0c76\0\u0cb0\0\u0cea" + + "\0\u0d24\0\u0d5e\0\u0d98\0\u0dd2\0\u0e0c\0\u0e46\0\u0e80\0\u0eba" + + "\0\u0ef4\0\u0f2e\0\u0f68\0\u0fa2\0\u0fdc\0\u1016\0\u1050\0\u108a" + + "\0\u10c4\0\u10fe\0\u1138\0\u1172\0\u11ac\0\u11e6\0\u1220\0\u125a" + + "\0\u1294\0\u12ce\0\u1308\0\u1342\0\u137c\0\u13b6\0\u09be\0\u13f0" + + "\0\u142a\0\u1464\0\u149e\0\u14d8\0\u1512\0\u154c\0\u1586\0\u09be" + + "\0\u15c0\0\u15fa\0\u1634\0\u166e\0\u16a8\0\u16e2\0\u171c\0\u1756" + + "\0\u1790\0\u17ca\0\u1804\0\u05aa\0\u09be\0\u183e\0\u1878\0\u18b2" + + "\0\u18ec\0\u1926\0\u1960\0\u199a\0\u19d4\0\u1a0e\0\u1a48\0\u1a82" + + "\0\u1abc\0\u1af6\0\u1b30\0\u1b6a\0\u1ba4\0\u1bde\0\u1c18\0\u1c52" + + "\0\u1c8c\0\u1cc6\0\u09be\0\u1d00\0\u1d3a\0\u1d74\0\u1dae\0\u1de8" + + "\0\u1e22\0\u09be\0\u1e5c\0\u1e96\0\u1ed0\0\u1f0a\0\u1f44\0\u1f7e" + + "\0\u1fb8\0\u1ff2\0\u202c\0\u09be\0\u2066\0\u20a0\0\u20da\0\u2114" + + "\0\u214e\0\u05aa\0\u2188\0\u21c2\0\u05aa\0\u21fc\0\u2236\0\u09be" + + "\0\u2270\0\u22aa\0\u22e4\0\u231e\0\u2358\0\u2392\0\u23cc\0\u2406" + + "\0\u2440\0\u247a\0\u24b4\0\u24ee\0\u2528\0\u2562\0\u259c\0\u25d6" + + "\0\u2610\0\u264a\0\u2684\0\u26be\0\u26f8\0\u2732\0\u276c\0\u27a6" + + "\0\u27e0\0\u281a\0\u09be\0\u2854\0\u288e\0\u28c8\0\u2902\0\u293c" + + "\0\u2976\0\u29b0\0\u29ea\0\u2a24\0\u2a5e\0\u2a98\0\u2ad2\0\u2b0c" + + "\0\u2b46\0\u2b80\0\u2bba\0\u2bf4\0\u2c2e\0\u2c68\0\u2ca2\0\u2cdc" + + "\0\u2d16\0\u2d50\0\u2d8a\0\u2dc4\0\u2dfe\0\u2e38\0\u2e72\0\u2eac" + + "\0\u2ee6\0\u2f20\0\u2f5a\0\u2f94\0\u2fce\0\u3008\0\u3042\0\u05aa" + + "\0\u307c\0\u09be"; private static int [] zzUnpackRowMap() { - int [] result = new int[264]; + int[] result = new int[266]; int offset = 0; offset = zzUnpackRowMap(ZZ_ROWMAP_PACKED_0, offset, result); return result; @@ -198,389 +199,391 @@ private static int zzUnpackRowMap(String packed, int offset, int [] result) { private static final int [] ZZ_TRANS = zzUnpackTrans(); private static final String ZZ_TRANS_PACKED_0 = - "\1\30\1\31\1\32\1\33\1\34\1\35\1\36\1\37"+ - "\1\40\7\30\3\40\1\41\10\30\1\42\1\40\3\30"+ - "\1\43\2\30\1\42\1\30\1\41\1\42\13\30\1\44"+ - "\2\30\1\45\1\46\1\47\1\30\1\50\1\32\1\33"+ - "\1\34\1\35\1\36\1\37\1\40\7\30\3\40\1\41"+ - "\10\30\1\42\1\40\3\30\1\43\2\30\1\42\1\30"+ - "\1\41\1\42\13\30\1\44\2\30\1\51\1\46\1\47"+ - "\1\30\1\52\1\32\1\33\1\34\1\35\1\36\1\37"+ - "\1\40\7\30\3\40\1\41\10\30\1\42\1\40\3\30"+ - "\1\43\2\30\1\42\1\30\1\41\1\42\13\30\1\44"+ - "\2\30\1\41\1\46\1\47\1\30\1\53\1\32\1\33"+ - "\1\34\1\35\1\36\1\37\1\40\7\30\3\40\1\41"+ - "\10\30\1\42\1\40\3\30\1\43\2\30\1\42\1\30"+ - "\1\41\1\42\13\30\1\44\2\30\1\45\1\46\1\47"+ - "\1\30\1\54\1\32\1\33\1\34\1\35\1\36\1\55"+ - "\1\40\7\30\3\40\1\41\10\30\1\42\1\40\3\30"+ - "\1\43\2\30\1\42\1\30\1\41\1\42\13\30\1\44"+ - "\2\30\1\56\1\46\1\47\1\30\1\54\1\32\1\33"+ - "\1\34\1\35\1\36\1\37\1\40\7\30\3\40\1\41"+ - "\10\30\1\42\1\40\3\30\1\43\2\30\1\42\1\30"+ - "\1\41\1\42\13\30\1\44\2\30\1\51\1\46\1\47"+ - "\1\30\1\54\1\32\1\33\1\34\1\35\1\36\1\55"+ - "\1\40\7\30\3\40\1\41\10\30\1\42\1\40\3\30"+ - "\1\43\2\30\1\42\1\30\1\41\1\42\13\30\1\44"+ - "\2\30\1\57\1\46\1\47\1\30\1\54\1\32\1\33"+ - "\1\34\1\35\1\36\1\60\1\40\7\30\3\40\1\41"+ - "\10\30\1\42\1\40\3\30\1\43\2\30\1\42\1\30"+ - "\1\41\1\42\13\30\1\44\2\30\1\41\1\46\1\47"+ - "\1\30\1\61\1\32\1\33\1\34\1\35\1\62\1\63"+ - "\1\40\7\30\3\40\1\41\10\30\1\42\1\40\3\30"+ - "\1\43\2\30\1\42\1\30\1\41\1\42\13\30\1\44"+ - "\2\30\1\57\1\46\1\47\1\30\1\54\1\32\1\33"+ - "\1\34\1\35\1\64\1\37\1\40\7\30\3\40\1\41"+ - "\10\30\1\42\1\40\3\30\1\43\2\30\1\42\1\30"+ - "\1\41\1\42\13\30\1\44\2\30\1\41\1\46\1\47"+ - "\1\30\1\61\1\32\1\33\1\34\1\35\1\62\1\65"+ - "\1\40\7\30\3\40\1\41\10\30\1\42\1\40\3\30"+ - "\1\43\2\30\1\42\1\30\1\41\1\42\13\30\1\44"+ - "\2\30\1\57\1\46\1\47\6\66\1\67\62\66\71\70"+ - "\1\71\1\54\1\32\1\33\1\34\1\35\1\36\1\55"+ - "\1\40\7\71\3\40\1\41\10\71\1\42\1\40\3\71"+ - "\1\43\2\71\1\42\1\71\1\41\1\42\16\71\1\41"+ - "\1\46\1\47\1\30\1\54\1\32\1\33\1\72\1\73"+ - "\1\36\1\37\1\40\7\30\3\40\1\41\10\30\1\42"+ - "\1\40\3\30\1\43\2\30\1\42\1\30\1\41\1\42"+ - "\13\30\1\44\2\30\1\41\1\46\1\47\1\30\1\54"+ - "\1\32\1\33\1\34\1\35\1\36\1\74\1\40\7\30"+ - "\3\40\1\41\10\30\1\42\1\40\3\30\1\43\2\30"+ - "\1\42\1\30\1\41\1\42\13\30\1\44\2\30\1\41"+ - "\1\46\1\47\1\30\1\54\1\32\1\33\1\34\1\35"+ - "\1\36\1\37\1\40\7\30\3\40\1\41\10\30\1\42"+ - "\1\40\3\30\1\43\2\30\1\42\1\30\1\41\1\42"+ - "\13\30\1\44\2\30\1\41\1\46\1\47\1\75\1\76"+ - "\6\75\1\40\7\75\3\40\12\75\1\40\33\75\4\77"+ - "\1\100\3\77\1\101\7\77\3\101\12\77\1\101\33\77"+ - "\1\102\5\103\1\36\2\103\7\102\4\103\10\102\2\103"+ - "\3\102\1\103\2\102\1\103\1\102\2\103\16\102\3\103"+ - "\1\30\1\104\1\32\1\33\1\34\1\35\1\36\1\37"+ - "\1\40\7\30\3\40\1\41\10\30\1\42\1\40\3\30"+ - "\1\43\2\30\1\42\1\30\1\41\1\42\13\30\1\44"+ - "\2\30\1\45\1\46\1\47\1\105\1\54\1\32\1\33"+ - "\1\34\1\35\1\36\1\37\1\40\7\105\3\40\1\41"+ - "\10\105\1\42\1\40\3\105\1\43\2\105\1\42\1\105"+ - "\1\41\1\42\16\105\1\41\1\46\1\47\41\75\1\106"+ - "\27\75\1\30\10\0\7\30\4\0\10\30\2\0\3\30"+ - "\1\0\2\30\1\0\1\30\2\0\16\30\3\0\2\107"+ - "\1\110\1\107\1\111\4\107\1\112\1\113\2\114\1\115"+ - "\1\116\1\114\1\0\1\107\2\0\1\117\6\114\1\120"+ - "\2\107\3\114\1\107\2\114\1\107\1\114\2\107\2\114"+ - "\1\121\7\114\1\122\1\107\2\114\3\107\101\0\1\40"+ - "\7\0\3\40\12\0\1\40\33\0\20\123\2\0\12\123"+ - "\1\124\1\125\33\123\6\0\1\126\62\0\4\107\1\111"+ - "\4\107\1\112\1\113\2\114\1\115\1\116\1\114\1\0"+ - "\1\107\2\0\1\117\2\114\1\127\3\114\1\120\2\107"+ - "\3\114\1\107\2\114\1\107\1\114\2\107\2\114\1\121"+ - "\7\114\1\122\1\107\2\114\6\107\1\51\1\111\4\107"+ - "\1\112\1\113\2\114\1\115\1\116\1\114\1\0\1\107"+ - "\2\0\1\117\6\114\1\120\2\107\3\114\1\107\2\114"+ - "\1\107\1\114\2\107\2\114\1\121\7\114\1\122\1\107"+ - "\2\114\5\107\1\110\1\107\1\111\1\130\3\107\1\112"+ - "\1\113\2\114\1\115\1\116\1\114\1\0\1\107\2\0"+ - "\1\117\6\114\1\120\2\107\3\114\1\107\2\114\1\107"+ - "\1\114\2\107\2\114\1\121\7\114\1\122\1\107\2\114"+ - "\7\107\1\111\4\107\1\112\1\113\2\114\1\115\1\116"+ - "\1\114\1\0\1\107\2\0\1\117\6\114\1\120\2\107"+ - "\3\114\1\107\2\114\1\107\1\114\2\107\2\114\1\121"+ - "\7\114\1\122\1\107\2\114\7\107\1\131\1\132\3\107"+ - "\1\112\1\113\2\114\1\115\1\116\1\114\1\0\1\107"+ - "\2\0\1\117\6\114\1\120\2\107\3\114\1\107\2\114"+ - "\1\107\1\114\2\107\2\114\1\121\7\114\1\122\1\107"+ - "\2\114\3\107\1\71\10\0\7\71\4\0\10\71\2\0"+ - "\3\71\1\0\2\71\1\0\1\71\2\0\16\71\14\0"+ - "\1\133\1\134\66\0\1\101\7\0\3\101\12\0\1\101"+ - "\33\0\1\102\10\0\7\102\4\0\10\102\2\0\3\102"+ - "\1\0\2\102\1\0\1\102\2\0\16\102\3\0\2\107"+ - "\1\110\1\107\1\111\4\107\1\112\1\135\2\114\1\115"+ - "\1\116\1\114\1\0\1\107\2\0\1\117\6\114\1\120"+ - "\2\107\1\114\1\136\1\114\1\107\2\114\1\107\1\114"+ - "\2\107\1\137\1\114\1\121\1\140\1\141\1\142\1\143"+ - "\1\114\1\144\1\145\1\122\1\107\2\114\3\107\1\105"+ - "\10\0\7\105\4\0\10\105\2\0\3\105\1\0\2\105"+ - "\1\0\1\105\2\0\16\105\37\0\1\146\1\147\44\0"+ - "\1\114\1\150\5\114\4\0\10\114\2\0\3\114\1\0"+ - "\2\114\1\0\1\114\2\0\13\114\1\0\2\114\14\0"+ - "\4\114\1\151\2\114\4\0\10\114\2\0\3\114\1\0"+ - "\2\114\1\0\1\114\2\0\13\114\1\0\2\114\14\0"+ - "\7\114\4\0\10\114\2\0\3\114\1\0\2\114\1\0"+ - "\1\114\2\0\13\114\1\0\2\114\14\0\1\114\1\152"+ - "\5\114\4\0\10\114\2\0\3\114\1\0\2\114\1\0"+ - "\1\114\2\0\13\114\1\0\2\114\14\0\3\114\1\153"+ - "\3\114\4\0\10\114\2\0\3\114\1\0\2\114\1\0"+ - "\1\114\2\0\13\114\1\0\2\114\14\0\3\114\1\154"+ - "\3\114\4\0\10\114\2\0\3\114\1\0\2\114\1\0"+ - "\1\114\2\0\13\114\1\0\2\114\14\0\1\114\1\155"+ - "\5\114\4\0\10\114\2\0\3\114\1\0\2\114\1\0"+ - "\1\114\2\0\13\114\1\0\2\114\14\0\7\114\4\0"+ - "\10\114\2\0\3\114\1\0\1\114\1\156\1\0\1\114"+ - "\2\0\7\114\1\157\3\114\1\0\2\114\14\0\1\114"+ - "\1\160\5\114\4\0\10\114\2\0\3\114\1\0\2\114"+ - "\1\0\1\114\2\0\13\114\1\0\2\114\3\0\20\123"+ - "\2\0\47\123\10\161\1\124\7\161\2\162\1\124\12\161"+ - "\1\124\4\161\1\163\26\161\20\123\2\0\12\123\1\164"+ - "\34\123\11\0\1\114\1\165\5\114\4\0\10\114\2\0"+ - "\3\114\1\0\2\114\1\0\1\114\2\0\13\114\1\0"+ - "\2\114\15\0\1\166\73\0\1\167\64\0\4\114\1\170"+ - "\2\114\4\0\10\114\2\0\3\114\1\0\2\114\1\0"+ - "\1\114\2\0\13\114\1\0\2\114\14\0\4\114\1\171"+ - "\2\114\4\0\10\114\2\0\3\114\1\0\2\114\1\0"+ - "\1\114\2\0\2\114\1\172\10\114\1\0\2\114\14\0"+ - "\7\114\4\0\10\114\2\0\3\114\1\0\2\114\1\0"+ - "\1\173\2\0\7\114\1\174\3\114\1\0\2\114\14\0"+ - "\7\114\4\0\1\114\1\175\6\114\2\0\3\114\1\0"+ - "\2\114\1\0\1\114\2\0\13\114\1\0\2\114\14\0"+ - "\7\114\4\0\5\114\1\176\2\114\2\0\3\114\1\0"+ - "\2\114\1\0\1\114\2\0\13\114\1\0\2\114\14\0"+ - "\1\114\1\177\5\114\4\0\10\114\2\0\3\114\1\0"+ - "\2\114\1\0\1\114\2\0\13\114\1\0\2\114\14\0"+ - "\7\114\4\0\10\114\2\0\3\114\1\0\2\114\1\0"+ - "\1\200\2\0\13\114\1\0\2\114\14\0\7\114\4\0"+ - "\7\114\1\201\2\0\3\114\1\0\2\114\1\0\1\114"+ - "\2\0\13\114\1\0\2\114\14\0\4\114\1\202\2\114"+ - "\4\0\10\114\2\0\3\114\1\0\2\114\1\0\1\114"+ - "\2\0\13\114\1\0\2\114\13\0\1\146\7\0\3\146"+ - "\12\0\1\146\4\0\1\203\62\0\1\204\45\0\2\114"+ - "\1\205\4\114\4\0\10\114\2\0\3\114\1\0\2\114"+ - "\1\0\1\114\2\0\13\114\1\0\2\114\14\0\5\114"+ - "\1\206\1\114\4\0\10\114\2\0\3\114\1\0\2\114"+ - "\1\0\1\114\2\0\13\114\1\0\2\114\14\0\7\114"+ - "\4\0\10\114\2\0\3\114\1\0\2\114\1\0\1\114"+ - "\2\0\13\114\1\0\1\207\1\114\14\0\7\114\4\0"+ - "\7\114\1\210\2\0\3\114\1\0\2\114\1\0\1\114"+ - "\2\0\13\114\1\0\2\114\14\0\7\114\4\0\1\114"+ - "\1\211\6\114\2\0\3\114\1\0\2\114\1\0\1\114"+ - "\2\0\13\114\1\0\2\114\14\0\4\114\1\115\2\114"+ - "\4\0\10\114\2\0\3\114\1\0\2\114\1\0\1\114"+ - "\2\0\13\114\1\0\2\114\14\0\7\114\4\0\3\114"+ - "\1\212\4\114\2\0\3\114\1\0\2\114\1\0\1\114"+ - "\2\0\13\114\1\0\2\114\14\0\7\114\4\0\6\114"+ - "\1\213\1\114\2\0\3\114\1\0\2\114\1\0\1\114"+ - "\2\0\13\114\1\0\2\114\14\0\7\114\4\0\7\114"+ - "\1\214\2\0\3\114\1\0\2\114\1\0\1\114\2\0"+ - "\13\114\1\0\2\114\3\0\20\161\2\0\47\161\10\0"+ - "\1\162\7\0\3\162\12\0\1\162\4\0\1\215\26\0"+ - "\20\161\2\0\10\161\1\216\36\161\20\123\2\0\5\123"+ - "\1\217\6\123\1\217\32\123\11\0\7\114\4\0\2\114"+ - "\1\220\5\114\2\0\3\114\1\0\2\114\1\0\1\114"+ - "\2\0\13\114\1\0\2\114\16\0\1\221\73\0\1\222"+ - "\63\0\5\114\1\223\1\114\4\0\10\114\2\0\3\114"+ - "\1\0\2\114\1\0\1\114\2\0\13\114\1\0\2\114"+ - "\14\0\5\114\1\224\1\114\4\0\10\114\2\0\3\114"+ - "\1\0\2\114\1\0\1\114\2\0\13\114\1\0\2\114"+ - "\14\0\7\114\4\0\10\114\2\0\3\114\1\0\1\114"+ - "\1\225\1\0\1\114\2\0\13\114\1\0\2\114\14\0"+ - "\7\114\4\0\7\114\1\226\2\0\3\114\1\0\2\114"+ - "\1\0\1\114\2\0\13\114\1\0\2\114\14\0\4\114"+ - "\1\227\2\114\4\0\10\114\2\0\3\114\1\0\2\114"+ - "\1\0\1\114\2\0\13\114\1\0\2\114\14\0\3\114"+ - "\1\230\3\114\4\0\10\114\2\0\3\114\1\0\2\114"+ - "\1\0\1\114\2\0\13\114\1\0\2\114\14\0\7\114"+ - "\4\0\10\114\2\0\3\114\1\0\1\231\1\114\1\0"+ - "\1\114\2\0\13\114\1\0\2\114\14\0\7\114\4\0"+ - "\10\114\2\0\3\114\1\0\2\114\1\0\1\232\2\0"+ - "\13\114\1\0\2\114\14\0\7\114\4\0\10\114\2\0"+ - "\3\114\1\0\2\114\1\0\1\233\2\0\13\114\1\0"+ - "\2\114\14\0\7\114\4\0\3\114\1\234\4\114\2\0"+ - "\3\114\1\0\2\114\1\0\1\114\2\0\13\114\1\0"+ - "\2\114\35\0\1\235\65\0\1\236\6\0\1\236\43\0"+ - "\3\114\1\237\3\114\4\0\10\114\2\0\3\114\1\0"+ - "\2\114\1\0\1\114\2\0\13\114\1\0\2\114\14\0"+ - "\1\114\1\240\5\114\4\0\10\114\2\0\3\114\1\0"+ - "\2\114\1\0\1\114\2\0\13\114\1\0\2\114\14\0"+ - "\1\114\1\241\5\114\4\0\10\114\2\0\3\114\1\0"+ - "\2\114\1\0\1\114\2\0\13\114\1\0\2\114\14\0"+ - "\4\114\1\242\2\114\4\0\10\114\2\0\3\114\1\0"+ - "\2\114\1\0\1\114\2\0\13\114\1\0\2\114\14\0"+ - "\3\114\1\243\3\114\4\0\10\114\2\0\3\114\1\0"+ - "\2\114\1\0\1\114\2\0\13\114\1\0\2\114\14\0"+ - "\1\114\1\244\5\114\4\0\10\114\2\0\3\114\1\0"+ - "\2\114\1\0\1\114\2\0\13\114\1\0\2\114\14\0"+ - "\1\245\6\114\4\0\10\114\2\0\3\114\1\0\2\114"+ - "\1\0\1\114\2\0\13\114\1\0\2\114\35\0\1\246"+ - "\36\0\20\161\2\0\11\161\1\247\35\161\12\123\1\250"+ - "\5\123\2\0\15\123\1\250\31\123\11\0\7\114\4\0"+ - "\3\114\1\251\4\114\2\0\3\114\1\0\2\114\1\0"+ - "\1\114\2\0\13\114\1\0\2\114\17\0\1\252\65\0"+ - "\7\114\4\0\10\114\2\0\3\114\1\0\2\114\1\0"+ - "\1\114\2\0\1\253\2\114\1\254\1\255\1\114\1\256"+ - "\1\114\1\257\2\114\1\0\2\114\14\0\1\114\1\260"+ - "\5\114\4\0\10\114\2\0\3\114\1\0\2\114\1\0"+ - "\1\114\2\0\3\114\1\261\7\114\1\0\2\114\14\0"+ - "\7\114\4\0\10\114\2\0\3\114\1\0\2\114\1\0"+ - "\1\114\2\0\1\114\1\262\11\114\1\0\2\114\14\0"+ - "\7\114\4\0\4\114\1\263\3\114\2\0\3\114\1\0"+ - "\2\114\1\0\1\114\2\0\13\114\1\0\2\114\14\0"+ - "\7\114\4\0\10\114\2\0\3\114\1\0\2\114\1\0"+ - "\1\114\2\0\2\114\1\264\10\114\1\0\2\114\14\0"+ - "\1\114\1\265\5\114\4\0\10\114\2\0\3\114\1\0"+ - "\2\114\1\0\1\114\2\0\13\114\1\0\2\114\14\0"+ - "\7\114\4\0\10\114\2\0\3\114\1\0\1\175\1\114"+ - "\1\0\1\114\2\0\13\114\1\0\2\114\14\0\7\114"+ - "\4\0\4\114\1\266\3\114\2\0\3\114\1\0\2\114"+ - "\1\0\1\114\2\0\13\114\1\0\2\114\14\0\3\114"+ - "\1\267\3\114\4\0\10\114\2\0\3\114\1\0\2\114"+ - "\1\0\1\114\2\0\13\114\1\0\2\114\36\0\1\270"+ - "\47\0\1\271\24\0\1\271\42\0\4\114\1\272\2\114"+ - "\4\0\10\114\2\0\3\114\1\0\2\114\1\0\1\114"+ - "\2\0\13\114\1\0\2\114\14\0\4\114\1\273\2\114"+ - "\4\0\10\114\2\0\3\114\1\0\2\114\1\0\1\114"+ - "\2\0\13\114\1\0\2\114\14\0\7\114\4\0\4\114"+ - "\1\274\3\114\2\0\3\114\1\0\2\114\1\0\1\114"+ - "\2\0\13\114\1\0\2\114\14\0\1\114\1\275\5\114"+ - "\4\0\10\114\2\0\3\114\1\0\2\114\1\0\1\114"+ - "\2\0\13\114\1\0\2\114\14\0\4\114\1\276\2\114"+ - "\4\0\10\114\2\0\3\114\1\0\2\114\1\0\1\114"+ - "\2\0\13\114\1\0\2\114\14\0\7\114\4\0\2\114"+ - "\1\277\5\114\2\0\3\114\1\0\2\114\1\0\1\114"+ - "\2\0\13\114\1\0\2\114\14\0\7\114\4\0\10\114"+ - "\2\0\3\114\1\0\2\114\1\0\1\114\2\0\13\114"+ - "\1\300\2\114\36\0\1\301\35\0\20\161\2\0\21\161"+ - "\1\302\25\161\20\123\2\0\4\123\1\124\11\123\1\124"+ - "\30\123\15\0\1\303\64\0\7\114\4\0\10\114\2\0"+ - "\3\114\1\0\2\114\1\0\1\304\2\0\7\114\1\305"+ - "\3\114\1\0\2\114\14\0\7\114\4\0\1\114\1\306"+ - "\6\114\2\0\3\114\1\0\2\114\1\0\1\114\2\0"+ - "\13\114\1\0\2\114\14\0\7\114\4\0\5\114\1\307"+ - "\2\114\2\0\3\114\1\0\2\114\1\0\1\114\2\0"+ - "\13\114\1\0\2\114\14\0\7\114\4\0\10\114\2\0"+ - "\3\114\1\0\2\114\1\0\1\310\2\0\13\114\1\0"+ - "\2\114\14\0\7\114\4\0\7\114\1\311\2\0\3\114"+ - "\1\0\2\114\1\0\1\114\2\0\13\114\1\0\2\114"+ - "\14\0\7\114\4\0\1\114\1\260\6\114\2\0\3\114"+ - "\1\0\2\114\1\0\1\114\2\0\13\114\1\0\2\114"+ - "\14\0\7\114\4\0\10\114\2\0\3\114\1\0\2\114"+ - "\1\0\1\114\2\0\2\114\1\312\10\114\1\0\2\114"+ - "\14\0\7\114\4\0\3\114\1\313\4\114\2\0\3\114"+ - "\1\0\2\114\1\0\1\114\2\0\13\114\1\0\2\114"+ - "\14\0\1\114\1\175\5\114\4\0\10\114\2\0\3\114"+ - "\1\0\2\114\1\0\1\114\2\0\13\114\1\0\2\114"+ - "\14\0\7\114\4\0\6\114\1\314\1\114\2\0\3\114"+ - "\1\0\2\114\1\0\1\114\2\0\13\114\1\0\2\114"+ - "\14\0\1\114\1\315\5\114\4\0\10\114\2\0\3\114"+ - "\1\0\2\114\1\0\1\114\2\0\13\114\1\0\2\114"+ - "\14\0\7\114\4\0\10\114\2\0\3\114\1\0\2\114"+ - "\1\0\1\114\2\0\2\114\1\306\10\114\1\0\2\114"+ - "\46\0\1\316\53\0\1\146\11\0\1\146\41\0\7\114"+ - "\4\0\10\114\2\0\3\114\1\0\2\114\1\0\1\114"+ - "\2\0\12\114\1\317\1\0\2\114\14\0\7\114\4\0"+ - "\3\114\1\320\4\114\2\0\3\114\1\0\2\114\1\0"+ - "\1\114\2\0\13\114\1\0\2\114\14\0\7\114\4\0"+ - "\2\114\1\321\5\114\2\0\3\114\1\0\2\114\1\0"+ - "\1\114\2\0\13\114\1\0\2\114\14\0\7\114\4\0"+ - "\10\114\2\0\3\114\1\0\2\114\1\0\1\114\2\0"+ - "\2\114\1\322\10\114\1\0\2\114\14\0\1\114\1\323"+ - "\5\114\4\0\10\114\2\0\3\114\1\0\2\114\1\0"+ - "\1\114\2\0\13\114\1\0\2\114\46\0\1\324\25\0"+ - "\12\161\1\325\5\161\2\0\47\161\11\0\7\114\4\0"+ - "\7\114\1\306\2\0\3\114\1\0\2\114\1\0\1\114"+ - "\2\0\13\114\1\0\2\114\14\0\4\114\1\326\2\114"+ - "\4\0\10\114\2\0\3\114\1\0\2\114\1\0\1\114"+ - "\2\0\13\114\1\0\2\114\14\0\3\114\1\327\3\114"+ - "\4\0\10\114\2\0\3\114\1\0\2\114\1\0\1\114"+ - "\2\0\13\114\1\0\2\114\14\0\7\114\4\0\10\114"+ - "\2\0\3\114\1\0\2\114\1\0\1\330\2\0\13\114"+ - "\1\0\2\114\14\0\7\114\4\0\10\114\2\0\3\114"+ - "\1\0\2\114\1\0\1\331\2\0\13\114\1\0\2\114"+ - "\14\0\7\114\4\0\10\114\2\0\3\114\1\0\2\114"+ - "\1\0\1\114\2\0\2\114\1\175\10\114\1\0\2\114"+ - "\14\0\3\114\1\332\3\114\4\0\10\114\2\0\3\114"+ - "\1\0\2\114\1\0\1\114\2\0\13\114\1\0\2\114"+ - "\14\0\7\114\4\0\3\114\1\175\4\114\2\0\3\114"+ - "\1\0\2\114\1\0\1\114\2\0\13\114\1\0\2\114"+ - "\14\0\5\114\1\333\1\114\4\0\10\114\2\0\3\114"+ - "\1\0\2\114\1\0\1\114\2\0\13\114\1\0\2\114"+ - "\15\0\1\334\67\0\3\114\1\335\3\114\4\0\10\114"+ - "\2\0\3\114\1\0\2\114\1\0\1\114\2\0\13\114"+ - "\1\0\2\114\14\0\7\114\4\0\10\114\2\0\3\114"+ - "\1\0\2\114\1\0\1\114\2\0\2\114\1\336\10\114"+ - "\1\0\2\114\14\0\7\114\4\0\3\114\1\337\4\114"+ - "\2\0\3\114\1\0\2\114\1\0\1\114\2\0\13\114"+ - "\1\0\2\114\14\0\3\114\1\340\3\114\4\0\10\114"+ - "\2\0\3\114\1\0\2\114\1\0\1\114\2\0\13\114"+ - "\1\0\2\114\14\0\7\114\4\0\4\114\1\341\3\114"+ - "\2\0\3\114\1\0\2\114\1\0\1\114\2\0\13\114"+ - "\1\0\2\114\15\0\1\342\56\0\20\161\2\0\11\161"+ - "\1\343\35\161\11\0\7\114\4\0\4\114\1\344\3\114"+ - "\2\0\3\114\1\0\2\114\1\0\1\114\2\0\13\114"+ - "\1\0\2\114\14\0\7\114\4\0\10\114\2\0\3\114"+ - "\1\0\2\114\1\0\1\114\2\0\2\114\1\345\10\114"+ - "\1\0\2\114\14\0\7\114\4\0\10\114\2\0\3\114"+ - "\1\0\1\306\1\114\1\0\1\114\2\0\13\114\1\0"+ - "\2\114\14\0\7\114\4\0\4\114\1\346\3\114\2\0"+ - "\3\114\1\0\2\114\1\0\1\114\2\0\13\114\1\0"+ - "\2\114\14\0\7\114\4\0\10\114\2\0\3\114\1\0"+ - "\2\114\1\0\1\347\2\0\13\114\1\0\2\114\14\0"+ - "\7\114\4\0\10\114\2\0\3\114\1\0\2\114\1\0"+ - "\1\114\2\0\7\114\1\350\3\114\1\0\2\114\36\0"+ - "\1\351\46\0\7\114\4\0\7\114\1\352\2\0\3\114"+ - "\1\0\2\114\1\0\1\114\2\0\13\114\1\0\2\114"+ - "\14\0\7\114\4\0\10\114\2\0\3\114\1\0\2\114"+ - "\1\0\1\114\2\0\7\114\1\353\3\114\1\0\2\114"+ - "\14\0\7\114\4\0\4\114\1\354\3\114\2\0\3\114"+ - "\1\0\2\114\1\0\1\114\2\0\13\114\1\0\2\114"+ - "\14\0\4\114\1\355\2\114\4\0\10\114\2\0\3\114"+ - "\1\0\2\114\1\0\1\114\2\0\13\114\1\0\2\114"+ - "\36\0\1\356\35\0\10\161\1\343\7\161\2\356\1\343"+ - "\12\161\1\343\6\161\1\357\24\161\11\0\7\114\4\0"+ - "\3\114\1\360\4\114\2\0\3\114\1\0\2\114\1\0"+ - "\1\114\2\0\13\114\1\0\2\114\14\0\1\114\1\306"+ - "\5\114\4\0\10\114\2\0\3\114\1\0\2\114\1\0"+ - "\1\114\2\0\13\114\1\0\2\114\14\0\1\114\1\361"+ - "\5\114\4\0\10\114\2\0\3\114\1\0\2\114\1\0"+ - "\1\114\2\0\13\114\1\0\2\114\14\0\4\114\1\175"+ - "\2\114\4\0\10\114\2\0\3\114\1\0\2\114\1\0"+ - "\1\114\2\0\13\114\1\0\2\114\14\0\7\114\4\0"+ - "\7\114\1\264\2\0\3\114\1\0\2\114\1\0\1\114"+ - "\2\0\13\114\1\0\2\114\13\0\1\351\7\0\3\351"+ - "\12\0\1\351\6\0\1\362\35\0\7\114\4\0\10\114"+ - "\2\0\3\114\1\0\2\114\1\0\1\363\2\0\13\114"+ - "\1\0\2\114\14\0\7\114\4\0\6\114\1\341\1\114"+ - "\2\0\3\114\1\0\2\114\1\0\1\114\2\0\13\114"+ - "\1\0\2\114\14\0\7\114\4\0\5\114\1\364\2\114"+ - "\2\0\3\114\1\0\2\114\1\0\1\114\2\0\13\114"+ - "\1\0\2\114\14\0\1\114\1\341\5\114\4\0\10\114"+ - "\2\0\3\114\1\0\2\114\1\0\1\114\2\0\13\114"+ - "\1\0\2\114\13\0\1\356\7\0\3\356\12\0\1\356"+ - "\6\0\1\365\24\0\10\161\1\357\7\161\2\365\1\357"+ - "\12\161\1\357\7\161\1\366\23\161\11\0\3\114\1\367"+ - "\3\114\4\0\10\114\2\0\3\114\1\0\2\114\1\0"+ - "\1\114\2\0\13\114\1\0\2\114\14\0\5\114\1\370"+ - "\1\114\4\0\10\114\2\0\3\114\1\0\2\114\1\0"+ - "\1\114\2\0\13\114\1\0\2\114\13\0\1\362\7\0"+ - "\3\362\12\0\1\362\7\0\1\371\34\0\4\114\1\372"+ - "\2\114\4\0\10\114\2\0\3\114\1\0\2\114\1\0"+ - "\1\114\2\0\13\114\1\0\2\114\14\0\7\114\4\0"+ - "\6\114\1\373\1\114\2\0\3\114\1\0\2\114\1\0"+ - "\1\114\2\0\13\114\1\0\2\114\13\0\1\365\7\0"+ - "\3\365\12\0\1\365\7\0\1\374\23\0\20\161\2\0"+ - "\3\161\1\375\43\161\11\0\7\114\4\0\10\114\2\0"+ - "\3\114\1\0\2\114\1\0\1\376\2\0\13\114\1\0"+ - "\2\114\14\0\7\114\4\0\10\114\2\0\3\114\1\0"+ - "\2\114\1\0\1\114\2\0\7\114\1\377\3\114\1\0"+ - "\2\114\20\0\1\u0100\64\0\7\114\4\0\10\114\2\0"+ - "\3\114\1\0\2\114\1\0\1\114\2\0\13\114\1\0"+ - "\1\114\1\u0101\14\0\7\114\4\0\7\114\1\u0102\2\0"+ - "\3\114\1\0\2\114\1\0\1\114\2\0\13\114\1\0"+ - "\2\114\30\0\1\u0103\43\0\20\161\2\0\3\161\1\u0104"+ - "\43\161\11\0\4\114\1\306\2\114\4\0\10\114\2\0"+ - "\3\114\1\0\2\114\1\0\1\114\2\0\13\114\1\0"+ - "\2\114\14\0\7\114\4\0\7\114\1\345\2\0\3\114"+ - "\1\0\2\114\1\0\1\114\2\0\13\114\1\0\2\114"+ - "\3\0\20\u0100\2\0\47\u0100\11\0\1\114\1\u0105\5\114"+ - "\4\0\10\114\2\0\3\114\1\0\2\114\1\0\1\114"+ - "\2\0\13\114\1\0\2\114\3\0\11\u0106\7\114\4\0"+ - "\10\114\2\u0106\3\114\1\u0106\2\114\1\u0106\1\114\2\u0106"+ - "\13\114\1\u0106\2\114\3\u0106\25\0\1\u0104\43\0\20\u0104"+ - "\2\0\47\u0104\11\0\4\114\1\u0107\2\114\4\0\10\114"+ - "\2\0\3\114\1\0\2\114\1\0\1\114\2\0\13\114"+ - "\1\0\2\114\14\0\7\114\4\0\3\114\1\u0108\4\114"+ - "\2\0\3\114\1\0\2\114\1\0\1\114\2\0\13\114"+ - "\1\0\2\114\3\0"; + "\1\30\1\31\1\32\1\33\1\34\1\35\1\36\1\37" + + "\1\40\7\30\3\40\1\41\10\30\1\42\1\40\3\30" + + "\1\43\2\30\1\44\1\30\1\41\1\42\13\30\1\45" + + "\2\30\1\46\1\47\1\50\1\51\1\30\1\52\1\32" + + "\1\33\1\34\1\35\1\36\1\37\1\40\7\30\3\40" + + "\1\41\10\30\1\42\1\40\3\30\1\43\2\30\1\44" + + "\1\30\1\41\1\42\13\30\1\45\2\30\1\53\1\47" + + "\1\50\1\51\1\30\1\54\1\32\1\33\1\34\1\35" + + "\1\36\1\37\1\40\7\30\3\40\1\41\10\30\1\42" + + "\1\40\3\30\1\43\2\30\1\44\1\30\1\41\1\42" + + "\13\30\1\45\2\30\1\41\1\47\1\50\1\51\1\30" + + "\1\55\1\32\1\33\1\34\1\35\1\36\1\37\1\40" + + "\7\30\3\40\1\41\10\30\1\42\1\40\3\30\1\43" + + "\2\30\1\44\1\30\1\41\1\42\13\30\1\45\2\30" + + "\1\46\1\47\1\50\1\51\1\30\1\56\1\32\1\33" + + "\1\34\1\35\1\36\1\57\1\40\7\30\3\40\1\41" + + "\10\30\1\42\1\40\3\30\1\43\2\30\1\44\1\30" + + "\1\41\1\42\13\30\1\45\2\30\1\60\1\47\1\50" + + "\1\51\1\30\1\56\1\32\1\33\1\34\1\35\1\36" + + "\1\37\1\40\7\30\3\40\1\41\10\30\1\42\1\40" + + "\3\30\1\43\2\30\1\44\1\30\1\41\1\42\13\30" + + "\1\45\2\30\1\53\1\47\1\50\1\51\1\30\1\56" + + "\1\32\1\33\1\34\1\35\1\36\1\57\1\40\7\30" + + "\3\40\1\41\10\30\1\42\1\40\3\30\1\43\2\30" + + "\1\44\1\30\1\41\1\42\13\30\1\45\2\30\1\61" + + "\1\47\1\50\1\51\1\30\1\56\1\32\1\33\1\34" + + "\1\35\1\36\1\62\1\40\7\30\3\40\1\41\10\30" + + "\1\42\1\40\3\30\1\43\2\30\1\44\1\30\1\41" + + "\1\42\13\30\1\45\2\30\1\41\1\47\1\50\1\51" + + "\1\30\1\63\1\32\1\33\1\34\1\35\1\64\1\65" + + "\1\40\7\30\3\40\1\41\10\30\1\42\1\40\3\30" + + "\1\43\2\30\1\44\1\30\1\41\1\42\13\30\1\45" + + "\2\30\1\61\1\47\1\50\1\51\1\30\1\56\1\32" + + "\1\33\1\34\1\35\1\66\1\37\1\40\7\30\3\40" + + "\1\41\10\30\1\42\1\40\3\30\1\43\2\30\1\44" + + "\1\30\1\41\1\42\13\30\1\45\2\30\1\41\1\47" + + "\1\50\1\51\1\30\1\63\1\32\1\33\1\34\1\35" + + "\1\64\1\67\1\40\7\30\3\40\1\41\10\30\1\42" + + "\1\40\3\30\1\43\2\30\1\44\1\30\1\41\1\42" + + "\13\30\1\45\2\30\1\61\1\47\1\50\1\51\6\70" + + "\1\71\63\70\72\72\1\73\1\56\1\32\1\33\1\34" + + "\1\35\1\36\1\57\1\40\7\73\3\40\1\41\10\73" + + "\1\42\1\40\3\73\1\43\2\73\1\44\1\73\1\41" + + "\1\42\16\73\1\41\1\47\1\50\1\51\1\30\1\56" + + "\1\32\1\33\1\74\1\75\1\36\1\37\1\40\7\30" + + "\3\40\1\41\10\30\1\42\1\40\3\30\1\43\2\30" + + "\1\44\1\30\1\41\1\42\13\30\1\45\2\30\1\41" + + "\1\47\1\50\1\51\1\30\1\56\1\32\1\33\1\34" + + "\1\35\1\36\1\76\1\40\7\30\3\40\1\41\10\30" + + "\1\42\1\40\3\30\1\43\2\30\1\44\1\30\1\41" + + "\1\42\13\30\1\45\2\30\1\41\1\47\1\50\1\51" + + "\1\30\1\56\1\32\1\33\1\34\1\35\1\36\1\37" + + "\1\40\7\30\3\40\1\41\10\30\1\42\1\40\3\30" + + "\1\43\2\30\1\44\1\30\1\41\1\42\13\30\1\45" + + "\2\30\1\41\1\47\1\50\1\51\1\77\1\100\6\77" + + "\1\40\7\77\3\40\12\77\1\40\34\77\4\101\1\102" + + "\3\101\1\103\7\101\3\103\12\101\1\103\34\101\1\104" + + "\5\105\1\36\2\105\7\104\4\105\10\104\2\105\3\104" + + "\1\105\2\104\1\105\1\104\2\105\16\104\4\105\1\30" + + "\1\106\1\32\1\33\1\34\1\35\1\36\1\37\1\40" + + "\7\30\3\40\1\41\10\30\1\42\1\40\3\30\1\43" + + "\2\30\1\44\1\30\1\41\1\42\13\30\1\45\2\30" + + "\1\46\1\47\1\50\1\51\1\107\1\56\1\32\1\33" + + "\1\34\1\35\1\36\1\37\1\40\7\107\3\40\1\41" + + "\10\107\1\42\1\40\3\107\1\43\2\107\1\44\1\107" + + "\1\41\1\42\16\107\1\41\1\47\1\50\1\51\41\77" + + "\1\110\30\77\1\30\10\0\7\30\4\0\10\30\2\0" + + "\3\30\1\0\2\30\1\0\1\30\2\0\16\30\4\0" + + "\2\111\1\112\1\111\1\113\4\111\1\114\1\115\2\116" + + "\1\117\1\120\1\116\1\0\1\111\2\0\1\121\6\116" + + "\1\122\2\111\3\116\1\111\2\116\1\111\1\116\2\111" + + "\2\116\1\123\7\116\1\124\1\111\2\116\4\111\102\0" + + "\1\40\7\0\3\40\12\0\1\40\34\0\20\125\2\0" + + "\12\125\1\126\1\127\34\125\6\0\1\130\63\0\4\111" + + "\1\113\4\111\1\114\1\115\2\116\1\117\1\120\1\116" + + "\1\0\1\111\2\0\1\121\2\116\1\131\3\116\1\122" + + "\2\111\3\116\1\111\2\116\1\111\1\116\2\111\2\116" + + "\1\123\7\116\1\124\1\111\2\116\7\111\1\53\1\113" + + "\4\111\1\114\1\115\2\116\1\117\1\120\1\116\1\0" + + "\1\111\2\0\1\121\6\116\1\122\2\111\3\116\1\111" + + "\2\116\1\111\1\116\2\111\2\116\1\123\7\116\1\124" + + "\1\111\2\116\6\111\1\112\1\111\1\113\1\132\3\111" + + "\1\114\1\115\2\116\1\117\1\120\1\116\1\0\1\111" + + "\2\0\1\121\6\116\1\122\2\111\3\116\1\111\2\116" + + "\1\111\1\116\2\111\2\116\1\123\7\116\1\124\1\111" + + "\2\116\10\111\1\113\4\111\1\114\1\115\2\116\1\117" + + "\1\120\1\116\1\0\1\111\2\0\1\121\6\116\1\122" + + "\2\111\3\116\1\111\2\116\1\111\1\116\2\111\2\116" + + "\1\123\7\116\1\124\1\111\2\116\10\111\1\133\1\134" + + "\3\111\1\114\1\115\2\116\1\117\1\120\1\116\1\0" + + "\1\111\2\0\1\121\6\116\1\122\2\111\3\116\1\111" + + "\2\116\1\111\1\116\2\111\2\116\1\123\7\116\1\124" + + "\1\111\2\116\4\111\1\73\10\0\7\73\4\0\10\73" + + "\2\0\3\73\1\0\2\73\1\0\1\73\2\0\16\73" + + "\15\0\1\135\1\136\67\0\1\103\7\0\3\103\12\0" + + "\1\103\34\0\1\104\10\0\7\104\4\0\10\104\2\0" + + "\3\104\1\0\2\104\1\0\1\104\2\0\16\104\4\0" + + "\2\111\1\112\1\111\1\113\4\111\1\114\1\137\2\116" + + "\1\117\1\120\1\116\1\0\1\111\2\0\1\121\6\116" + + "\1\122\2\111\1\116\1\140\1\116\1\111\2\116\1\111" + + "\1\116\2\111\1\141\1\116\1\123\1\142\1\143\1\144" + + "\1\145\1\116\1\146\1\147\1\124\1\111\2\116\4\111" + + "\1\107\10\0\7\107\4\0\10\107\2\0\3\107\1\0" + + "\2\107\1\0\1\107\2\0\16\107\40\0\1\150\1\151" + + "\45\0\1\116\1\152\5\116\4\0\10\116\2\0\3\116" + + "\1\0\2\116\1\0\1\116\2\0\13\116\1\0\2\116" + + "\15\0\4\116\1\153\2\116\4\0\10\116\2\0\3\116" + + "\1\0\2\116\1\0\1\116\2\0\13\116\1\0\2\116" + + "\15\0\7\116\4\0\10\116\2\0\3\116\1\0\2\116" + + "\1\0\1\116\2\0\13\116\1\0\2\116\15\0\1\116" + + "\1\154\5\116\4\0\10\116\2\0\3\116\1\0\2\116" + + "\1\0\1\116\2\0\13\116\1\0\2\116\15\0\3\116" + + "\1\155\3\116\4\0\10\116\2\0\3\116\1\0\2\116" + + "\1\0\1\116\2\0\13\116\1\0\2\116\15\0\3\116" + + "\1\156\3\116\4\0\10\116\2\0\3\116\1\0\2\116" + + "\1\0\1\116\2\0\13\116\1\0\2\116\15\0\1\116" + + "\1\157\5\116\4\0\10\116\2\0\3\116\1\0\2\116" + + "\1\0\1\116\2\0\13\116\1\0\2\116\15\0\7\116" + + "\4\0\10\116\2\0\3\116\1\0\1\116\1\160\1\0" + + "\1\116\2\0\7\116\1\161\3\116\1\0\2\116\15\0" + + "\1\116\1\162\5\116\4\0\10\116\2\0\3\116\1\0" + + "\2\116\1\0\1\116\2\0\13\116\1\0\2\116\4\0" + + "\20\125\2\0\50\125\10\163\1\126\7\163\2\164\1\126" + + "\12\163\1\126\4\163\1\165\27\163\20\125\2\0\12\125" + + "\1\166\35\125\11\0\1\116\1\167\5\116\4\0\10\116" + + "\2\0\3\116\1\0\2\116\1\0\1\116\2\0\13\116" + + "\1\0\2\116\16\0\1\170\74\0\1\171\65\0\4\116" + + "\1\172\2\116\4\0\10\116\2\0\3\116\1\0\2\116" + + "\1\0\1\116\2\0\13\116\1\0\2\116\15\0\4\116" + + "\1\173\2\116\4\0\10\116\2\0\3\116\1\0\2\116" + + "\1\0\1\116\2\0\2\116\1\174\10\116\1\0\2\116" + + "\15\0\7\116\4\0\10\116\2\0\3\116\1\0\2\116" + + "\1\0\1\175\2\0\7\116\1\176\3\116\1\0\2\116" + + "\15\0\7\116\4\0\1\116\1\177\6\116\2\0\3\116" + + "\1\0\2\116\1\0\1\116\2\0\13\116\1\0\2\116" + + "\15\0\7\116\4\0\5\116\1\200\2\116\2\0\3\116" + + "\1\0\2\116\1\0\1\116\2\0\13\116\1\0\2\116" + + "\15\0\1\116\1\201\5\116\4\0\10\116\2\0\3\116" + + "\1\0\2\116\1\0\1\116\2\0\13\116\1\0\2\116" + + "\15\0\7\116\4\0\10\116\2\0\3\116\1\0\2\116" + + "\1\0\1\202\2\0\13\116\1\0\2\116\15\0\7\116" + + "\4\0\7\116\1\203\2\0\3\116\1\0\2\116\1\0" + + "\1\116\2\0\13\116\1\0\2\116\15\0\4\116\1\204" + + "\2\116\4\0\10\116\2\0\3\116\1\0\2\116\1\0" + + "\1\116\2\0\13\116\1\0\2\116\14\0\1\150\7\0" + + "\3\150\12\0\1\150\4\0\1\205\63\0\1\206\46\0" + + "\2\116\1\207\4\116\4\0\10\116\2\0\3\116\1\0" + + "\2\116\1\0\1\116\2\0\13\116\1\0\2\116\15\0" + + "\5\116\1\210\1\116\4\0\10\116\2\0\3\116\1\0" + + "\2\116\1\0\1\116\2\0\13\116\1\0\2\116\15\0" + + "\7\116\4\0\10\116\2\0\3\116\1\0\2\116\1\0" + + "\1\116\2\0\13\116\1\0\1\211\1\116\15\0\7\116" + + "\4\0\7\116\1\212\2\0\3\116\1\0\2\116\1\0" + + "\1\116\2\0\13\116\1\0\2\116\15\0\7\116\4\0" + + "\1\116\1\213\6\116\2\0\3\116\1\0\2\116\1\0" + + "\1\116\2\0\13\116\1\0\2\116\15\0\4\116\1\117" + + "\2\116\4\0\10\116\2\0\3\116\1\0\2\116\1\0" + + "\1\116\2\0\13\116\1\0\2\116\15\0\7\116\4\0" + + "\3\116\1\214\4\116\2\0\3\116\1\0\2\116\1\0" + + "\1\116\2\0\13\116\1\0\2\116\15\0\7\116\4\0" + + "\6\116\1\215\1\116\2\0\3\116\1\0\2\116\1\0" + + "\1\116\2\0\13\116\1\0\2\116\15\0\7\116\4\0" + + "\7\116\1\216\2\0\3\116\1\0\2\116\1\0\1\116" + + "\2\0\13\116\1\0\2\116\4\0\20\163\2\0\50\163" + + "\10\0\1\164\7\0\3\164\12\0\1\164\4\0\1\217" + + "\27\0\20\163\2\0\10\163\1\220\37\163\20\125\2\0" + + "\5\125\1\221\6\125\1\221\33\125\11\0\7\116\4\0" + + "\2\116\1\222\5\116\2\0\3\116\1\0\2\116\1\0" + + "\1\116\2\0\13\116\1\0\2\116\17\0\1\223\74\0" + + "\1\224\64\0\5\116\1\225\1\116\4\0\10\116\2\0" + + "\3\116\1\0\2\116\1\0\1\116\2\0\13\116\1\0" + + "\2\116\15\0\5\116\1\226\1\116\4\0\10\116\2\0" + + "\3\116\1\0\2\116\1\0\1\116\2\0\13\116\1\0" + + "\2\116\15\0\7\116\4\0\10\116\2\0\3\116\1\0" + + "\1\116\1\227\1\0\1\116\2\0\13\116\1\0\2\116" + + "\15\0\7\116\4\0\7\116\1\230\2\0\3\116\1\0" + + "\2\116\1\0\1\116\2\0\13\116\1\0\2\116\15\0" + + "\4\116\1\231\2\116\4\0\10\116\2\0\3\116\1\0" + + "\2\116\1\0\1\116\2\0\13\116\1\0\2\116\15\0" + + "\3\116\1\232\3\116\4\0\10\116\2\0\3\116\1\0" + + "\2\116\1\0\1\116\2\0\13\116\1\0\2\116\15\0" + + "\7\116\4\0\10\116\2\0\3\116\1\0\1\233\1\116" + + "\1\0\1\116\2\0\13\116\1\0\2\116\15\0\7\116" + + "\4\0\10\116\2\0\3\116\1\0\2\116\1\0\1\234" + + "\2\0\13\116\1\0\2\116\15\0\7\116\4\0\10\116" + + "\2\0\3\116\1\0\2\116\1\0\1\235\2\0\13\116" + + "\1\0\2\116\15\0\7\116\4\0\3\116\1\236\4\116" + + "\2\0\3\116\1\0\2\116\1\0\1\116\2\0\13\116" + + "\1\0\2\116\36\0\1\237\66\0\1\240\6\0\1\240" + + "\44\0\3\116\1\241\3\116\4\0\10\116\2\0\3\116" + + "\1\0\2\116\1\0\1\116\2\0\13\116\1\0\2\116" + + "\15\0\1\116\1\242\5\116\4\0\10\116\2\0\3\116" + + "\1\0\2\116\1\0\1\116\2\0\13\116\1\0\2\116" + + "\15\0\1\116\1\243\5\116\4\0\10\116\2\0\3\116" + + "\1\0\2\116\1\0\1\116\2\0\13\116\1\0\2\116" + + "\15\0\4\116\1\244\2\116\4\0\10\116\2\0\3\116" + + "\1\0\2\116\1\0\1\116\2\0\13\116\1\0\2\116" + + "\15\0\3\116\1\245\3\116\4\0\10\116\2\0\3\116" + + "\1\0\2\116\1\0\1\116\2\0\13\116\1\0\2\116" + + "\15\0\1\116\1\246\5\116\4\0\10\116\2\0\3\116" + + "\1\0\2\116\1\0\1\116\2\0\13\116\1\0\2\116" + + "\15\0\1\247\6\116\4\0\10\116\2\0\3\116\1\0" + + "\2\116\1\0\1\116\2\0\13\116\1\0\2\116\36\0" + + "\1\250\37\0\20\163\2\0\11\163\1\251\36\163\12\125" + + "\1\252\5\125\2\0\15\125\1\252\32\125\11\0\7\116" + + "\4\0\3\116\1\253\4\116\2\0\3\116\1\0\2\116" + + "\1\0\1\116\2\0\13\116\1\0\2\116\20\0\1\254" + + "\66\0\7\116\4\0\10\116\2\0\3\116\1\0\2\116" + + "\1\0\1\116\2\0\1\255\2\116\1\256\1\257\1\116" + + "\1\260\1\116\1\261\2\116\1\0\2\116\15\0\1\116" + + "\1\262\5\116\4\0\10\116\2\0\3\116\1\0\2\116" + + "\1\0\1\116\2\0\3\116\1\263\7\116\1\0\2\116" + + "\15\0\7\116\4\0\10\116\2\0\3\116\1\0\2\116" + + "\1\0\1\116\2\0\1\116\1\264\11\116\1\0\2\116" + + "\15\0\7\116\4\0\4\116\1\265\3\116\2\0\3\116" + + "\1\0\2\116\1\0\1\116\2\0\13\116\1\0\2\116" + + "\15\0\7\116\4\0\10\116\2\0\3\116\1\0\2\116" + + "\1\0\1\116\2\0\2\116\1\266\10\116\1\0\2\116" + + "\15\0\1\116\1\267\5\116\4\0\10\116\2\0\3\116" + + "\1\0\2\116\1\0\1\116\2\0\13\116\1\0\2\116" + + "\15\0\7\116\4\0\10\116\2\0\3\116\1\0\1\177" + + "\1\116\1\0\1\116\2\0\13\116\1\0\2\116\15\0" + + "\7\116\4\0\4\116\1\270\3\116\2\0\3\116\1\0" + + "\2\116\1\0\1\116\2\0\13\116\1\0\2\116\15\0" + + "\3\116\1\271\3\116\4\0\10\116\2\0\3\116\1\0" + + "\2\116\1\0\1\116\2\0\13\116\1\0\2\116\37\0" + + "\1\272\50\0\1\273\24\0\1\273\43\0\4\116\1\274" + + "\2\116\4\0\10\116\2\0\3\116\1\0\2\116\1\0" + + "\1\116\2\0\13\116\1\0\2\116\15\0\4\116\1\275" + + "\2\116\4\0\10\116\2\0\3\116\1\0\2\116\1\0" + + "\1\116\2\0\13\116\1\0\2\116\15\0\7\116\4\0" + + "\4\116\1\276\3\116\2\0\3\116\1\0\2\116\1\0" + + "\1\116\2\0\13\116\1\0\2\116\15\0\1\116\1\277" + + "\5\116\4\0\10\116\2\0\3\116\1\0\2\116\1\0" + + "\1\116\2\0\13\116\1\0\2\116\15\0\4\116\1\300" + + "\2\116\4\0\10\116\2\0\3\116\1\0\2\116\1\0" + + "\1\116\2\0\13\116\1\0\2\116\15\0\7\116\4\0" + + "\2\116\1\301\5\116\2\0\3\116\1\0\2\116\1\0" + + "\1\116\2\0\13\116\1\0\2\116\15\0\7\116\4\0" + + "\10\116\2\0\3\116\1\0\2\116\1\0\1\116\2\0" + + "\13\116\1\302\2\116\37\0\1\303\36\0\20\163\2\0" + + "\21\163\1\304\26\163\20\125\2\0\4\125\1\126\11\125" + + "\1\126\31\125\15\0\1\305\65\0\7\116\4\0\10\116" + + "\2\0\3\116\1\0\2\116\1\0\1\306\2\0\7\116" + + "\1\307\3\116\1\0\2\116\15\0\7\116\4\0\1\116" + + "\1\310\6\116\2\0\3\116\1\0\2\116\1\0\1\116" + + "\2\0\13\116\1\0\2\116\15\0\7\116\4\0\5\116" + + "\1\311\2\116\2\0\3\116\1\0\2\116\1\0\1\116" + + "\2\0\13\116\1\0\2\116\15\0\7\116\4\0\10\116" + + "\2\0\3\116\1\0\2\116\1\0\1\312\2\0\13\116" + + "\1\0\2\116\15\0\7\116\4\0\7\116\1\313\2\0" + + "\3\116\1\0\2\116\1\0\1\116\2\0\13\116\1\0" + + "\2\116\15\0\7\116\4\0\1\116\1\262\6\116\2\0" + + "\3\116\1\0\2\116\1\0\1\116\2\0\13\116\1\0" + + "\2\116\15\0\7\116\4\0\10\116\2\0\3\116\1\0" + + "\2\116\1\0\1\116\2\0\2\116\1\314\10\116\1\0" + + "\2\116\15\0\7\116\4\0\3\116\1\315\4\116\2\0" + + "\3\116\1\0\2\116\1\0\1\116\2\0\13\116\1\0" + + "\2\116\15\0\1\116\1\177\5\116\4\0\10\116\2\0" + + "\3\116\1\0\2\116\1\0\1\116\2\0\13\116\1\0" + + "\2\116\15\0\7\116\4\0\6\116\1\316\1\116\2\0" + + "\3\116\1\0\2\116\1\0\1\116\2\0\13\116\1\0" + + "\2\116\15\0\1\116\1\317\5\116\4\0\10\116\2\0" + + "\3\116\1\0\2\116\1\0\1\116\2\0\13\116\1\0" + + "\2\116\15\0\7\116\4\0\10\116\2\0\3\116\1\0" + + "\2\116\1\0\1\116\2\0\2\116\1\310\10\116\1\0" + + "\2\116\47\0\1\320\54\0\1\150\11\0\1\150\42\0" + + "\7\116\4\0\10\116\2\0\3\116\1\0\2\116\1\0" + + "\1\116\2\0\12\116\1\321\1\0\2\116\15\0\7\116" + + "\4\0\3\116\1\322\4\116\2\0\3\116\1\0\2\116" + + "\1\0\1\116\2\0\13\116\1\0\2\116\15\0\7\116" + + "\4\0\2\116\1\323\5\116\2\0\3\116\1\0\2\116" + + "\1\0\1\116\2\0\13\116\1\0\2\116\15\0\7\116" + + "\4\0\10\116\2\0\3\116\1\0\2\116\1\0\1\116" + + "\2\0\2\116\1\324\10\116\1\0\2\116\15\0\1\116" + + "\1\325\5\116\4\0\10\116\2\0\3\116\1\0\2\116" + + "\1\0\1\116\2\0\13\116\1\0\2\116\47\0\1\326" + + "\26\0\12\163\1\327\5\163\2\0\50\163\11\0\7\116" + + "\4\0\7\116\1\310\2\0\3\116\1\0\2\116\1\0" + + "\1\116\2\0\13\116\1\0\2\116\15\0\4\116\1\330" + + "\2\116\4\0\10\116\2\0\3\116\1\0\2\116\1\0" + + "\1\116\2\0\13\116\1\0\2\116\15\0\3\116\1\331" + + "\3\116\4\0\10\116\2\0\3\116\1\0\2\116\1\0" + + "\1\116\2\0\13\116\1\0\2\116\15\0\7\116\4\0" + + "\10\116\2\0\3\116\1\0\2\116\1\0\1\332\2\0" + + "\13\116\1\0\2\116\15\0\7\116\4\0\10\116\2\0" + + "\3\116\1\0\2\116\1\0\1\333\2\0\13\116\1\0" + + "\2\116\15\0\7\116\4\0\10\116\2\0\3\116\1\0" + + "\2\116\1\0\1\116\2\0\2\116\1\177\10\116\1\0" + + "\2\116\15\0\3\116\1\334\3\116\4\0\10\116\2\0" + + "\3\116\1\0\2\116\1\0\1\116\2\0\13\116\1\0" + + "\2\116\15\0\7\116\4\0\3\116\1\177\4\116\2\0" + + "\3\116\1\0\2\116\1\0\1\116\2\0\13\116\1\0" + + "\2\116\15\0\5\116\1\335\1\116\4\0\10\116\2\0" + + "\3\116\1\0\2\116\1\0\1\116\2\0\13\116\1\0" + + "\2\116\16\0\1\336\70\0\3\116\1\337\3\116\4\0" + + "\10\116\2\0\3\116\1\0\2\116\1\0\1\116\2\0" + + "\13\116\1\0\2\116\15\0\7\116\4\0\10\116\2\0" + + "\3\116\1\0\2\116\1\0\1\116\2\0\2\116\1\340" + + "\10\116\1\0\2\116\15\0\7\116\4\0\3\116\1\341" + + "\4\116\2\0\3\116\1\0\2\116\1\0\1\116\2\0" + + "\13\116\1\0\2\116\15\0\3\116\1\342\3\116\4\0" + + "\10\116\2\0\3\116\1\0\2\116\1\0\1\116\2\0" + + "\13\116\1\0\2\116\15\0\7\116\4\0\4\116\1\343" + + "\3\116\2\0\3\116\1\0\2\116\1\0\1\116\2\0" + + "\13\116\1\0\2\116\16\0\1\344\57\0\20\163\2\0" + + "\11\163\1\345\36\163\11\0\7\116\4\0\4\116\1\346" + + "\3\116\2\0\3\116\1\0\2\116\1\0\1\116\2\0" + + "\13\116\1\0\2\116\15\0\7\116\4\0\10\116\2\0" + + "\3\116\1\0\2\116\1\0\1\116\2\0\2\116\1\347" + + "\10\116\1\0\2\116\15\0\7\116\4\0\10\116\2\0" + + "\3\116\1\0\1\310\1\116\1\0\1\116\2\0\13\116" + + "\1\0\2\116\15\0\7\116\4\0\4\116\1\350\3\116" + + "\2\0\3\116\1\0\2\116\1\0\1\116\2\0\13\116" + + "\1\0\2\116\15\0\7\116\4\0\10\116\2\0\3\116" + + "\1\0\2\116\1\0\1\351\2\0\13\116\1\0\2\116" + + "\15\0\7\116\4\0\10\116\2\0\3\116\1\0\2\116" + + "\1\0\1\116\2\0\7\116\1\352\3\116\1\0\2\116" + + "\37\0\1\353\47\0\7\116\4\0\7\116\1\354\2\0" + + "\3\116\1\0\2\116\1\0\1\116\2\0\13\116\1\0" + + "\2\116\15\0\7\116\4\0\10\116\2\0\3\116\1\0" + + "\2\116\1\0\1\116\2\0\7\116\1\355\3\116\1\0" + + "\2\116\15\0\7\116\4\0\4\116\1\356\3\116\2\0" + + "\3\116\1\0\2\116\1\0\1\116\2\0\13\116\1\0" + + "\2\116\15\0\4\116\1\357\2\116\4\0\10\116\2\0" + + "\3\116\1\0\2\116\1\0\1\116\2\0\13\116\1\0" + + "\2\116\37\0\1\360\36\0\10\163\1\345\7\163\2\360" + + "\1\345\12\163\1\345\6\163\1\361\25\163\11\0\7\116" + + "\4\0\3\116\1\362\4\116\2\0\3\116\1\0\2\116" + + "\1\0\1\116\2\0\13\116\1\0\2\116\15\0\1\116" + + "\1\310\5\116\4\0\10\116\2\0\3\116\1\0\2\116" + + "\1\0\1\116\2\0\13\116\1\0\2\116\15\0\1\116" + + "\1\363\5\116\4\0\10\116\2\0\3\116\1\0\2\116" + + "\1\0\1\116\2\0\13\116\1\0\2\116\15\0\4\116" + + "\1\177\2\116\4\0\10\116\2\0\3\116\1\0\2\116" + + "\1\0\1\116\2\0\13\116\1\0\2\116\15\0\7\116" + + "\4\0\7\116\1\266\2\0\3\116\1\0\2\116\1\0" + + "\1\116\2\0\13\116\1\0\2\116\14\0\1\353\7\0" + + "\3\353\12\0\1\353\6\0\1\364\36\0\7\116\4\0" + + "\10\116\2\0\3\116\1\0\2\116\1\0\1\365\2\0" + + "\13\116\1\0\2\116\15\0\7\116\4\0\6\116\1\343" + + "\1\116\2\0\3\116\1\0\2\116\1\0\1\116\2\0" + + "\13\116\1\0\2\116\15\0\7\116\4\0\5\116\1\366" + + "\2\116\2\0\3\116\1\0\2\116\1\0\1\116\2\0" + + "\13\116\1\0\2\116\15\0\1\116\1\343\5\116\4\0" + + "\10\116\2\0\3\116\1\0\2\116\1\0\1\116\2\0" + + "\13\116\1\0\2\116\14\0\1\360\7\0\3\360\12\0" + + "\1\360\6\0\1\367\25\0\10\163\1\361\7\163\2\367" + + "\1\361\12\163\1\361\7\163\1\370\24\163\11\0\3\116" + + "\1\371\3\116\4\0\10\116\2\0\3\116\1\0\2\116" + + "\1\0\1\116\2\0\13\116\1\0\2\116\15\0\5\116" + + "\1\372\1\116\4\0\10\116\2\0\3\116\1\0\2\116" + + "\1\0\1\116\2\0\13\116\1\0\2\116\14\0\1\364" + + "\7\0\3\364\12\0\1\364\7\0\1\373\35\0\4\116" + + "\1\374\2\116\4\0\10\116\2\0\3\116\1\0\2\116" + + "\1\0\1\116\2\0\13\116\1\0\2\116\15\0\7\116" + + "\4\0\6\116\1\375\1\116\2\0\3\116\1\0\2\116" + + "\1\0\1\116\2\0\13\116\1\0\2\116\14\0\1\367" + + "\7\0\3\367\12\0\1\367\7\0\1\376\24\0\20\163" + + "\2\0\3\163\1\377\44\163\11\0\7\116\4\0\10\116" + + "\2\0\3\116\1\0\2\116\1\0\1\u0100\2\0\13\116" + + "\1\0\2\116\15\0\7\116\4\0\10\116\2\0\3\116" + + "\1\0\2\116\1\0\1\116\2\0\7\116\1\u0101\3\116" + + "\1\0\2\116\21\0\1\u0102\65\0\7\116\4\0\10\116" + + "\2\0\3\116\1\0\2\116\1\0\1\116\2\0\13\116" + + "\1\0\1\116\1\u0103\15\0\7\116\4\0\7\116\1\u0104" + + "\2\0\3\116\1\0\2\116\1\0\1\116\2\0\13\116" + + "\1\0\2\116\31\0\1\u0105\44\0\20\163\2\0\3\163" + + "\1\u0106\44\163\11\0\4\116\1\310\2\116\4\0\10\116" + + "\2\0\3\116\1\0\2\116\1\0\1\116\2\0\13\116" + + "\1\0\2\116\15\0\7\116\4\0\7\116\1\347\2\0" + + "\3\116\1\0\2\116\1\0\1\116\2\0\13\116\1\0" + + "\2\116\4\0\20\u0102\2\0\50\u0102\11\0\1\116\1\u0107" + + "\5\116\4\0\10\116\2\0\3\116\1\0\2\116\1\0" + + "\1\116\2\0\13\116\1\0\2\116\4\0\11\u0108\7\116" + + "\4\0\10\116\2\u0108\3\116\1\u0108\2\116\1\u0108\1\116" + + "\2\u0108\13\116\1\u0108\2\116\4\u0108\25\0\1\u0106\44\0" + + "\20\u0106\2\0\50\u0106\11\0\4\116\1\u0109\2\116\4\0" + + "\10\116\2\0\3\116\1\0\2\116\1\0\1\116\2\0" + + "\13\116\1\0\2\116\15\0\7\116\4\0\3\116\1\u010a" + + "\4\116\2\0\3\116\1\0\2\116\1\0\1\116\2\0" + + "\13\116\1\0\2\116\4\0"; private static int [] zzUnpackTrans() { - int [] result = new int[12255]; + int[] result = new int[12470]; int offset = 0; offset = zzUnpackTrans(ZZ_TRANS_PACKED_0, offset, result); return result; @@ -618,19 +621,20 @@ private static int zzUnpackTrans(String packed, int offset, int [] result) { private static final int [] ZZ_ATTRIBUTE = zzUnpackAttribute(); private static final String ZZ_ATTRIBUTE_PACKED_0 = - "\27\0\2\1\6\11\1\1\2\11\2\1\1\11\1\1"+ - "\1\11\1\1\1\11\3\1\4\11\1\1\7\11\1\1"+ - "\4\11\1\1\2\11\2\1\1\11\3\1\3\11\14\1"+ - "\1\11\1\1\3\11\2\0\11\1\2\0\12\1\1\0"+ - "\3\1\2\0\13\1\2\0\10\1\1\0\3\1\1\0"+ - "\1\11\12\1\2\0\7\1\1\0\3\1\1\0\15\1"+ - "\2\0\6\1\1\11\1\0\1\1\1\11\12\1\1\0"+ - "\5\1\1\0\7\1\1\0\5\1\1\0\6\1\1\0"+ - "\4\1\1\0\3\1\1\0\2\1\1\0\3\1\1\0"+ - "\2\1\1\0\6\1\1\0\2\1\1\11\2\1"; + "\27\0\2\1\6\11\1\1\2\11\1\1\1\11\1\1" + + "\1\11\1\1\2\11\1\1\1\11\3\1\4\11\1\1" + + "\7\11\1\1\4\11\1\1\2\11\2\1\1\11\3\1" + + "\3\11\14\1\1\11\1\1\3\11\2\0\11\1\2\0" + + "\12\1\1\0\3\1\2\0\13\1\2\0\10\1\1\0" + + "\3\1\1\0\1\11\12\1\2\0\7\1\1\0\3\1" + + "\1\0\15\1\2\0\6\1\1\11\1\0\1\1\1\11" + + "\12\1\1\0\5\1\1\0\7\1\1\0\5\1\1\0" + + "\6\1\1\0\4\1\1\0\3\1\1\0\2\1\1\0" + + "\3\1\1\0\2\1\1\0\6\1\1\0\2\1\1\11" + + "\2\1"; private static int [] zzUnpackAttribute() { - int [] result = new int[264]; + int[] result = new int[266]; int offset = 0; offset = zzUnpackAttribute(ZZ_ATTRIBUTE_PACKED_0, offset, result); return result; @@ -964,332 +968,448 @@ else if (zzAtEOF) { } else { switch (zzAction < 0 ? zzAction : ZZ_ACTION[zzAction]) { - case 1: - { return NORMAL_TEXT_WORD; - } - // fall through - case 59: break; - case 2: - { return NORMAL_TEXT_CHAR; - } - // fall through - case 60: break; - case 3: - { return OPEN_PAREN; - } - // fall through - case 61: break; - case 4: - { return CLOSE_PAREN; - } - // fall through - case 62: break; - case 5: - { return OPEN_BRACKET; - } - // fall through - case 63: break; - case 6: - { return CLOSE_BRACKET; - } - // fall through - case 64: break; - case 7: - { return OPEN_BRACE; - } - // fall through - case 65: break; - case 8: - { return CLOSE_BRACE; - } - // fall through - case 66: break; - case 9: - { return com.intellij.psi.TokenType.WHITE_SPACE; - } - // fall through - case 67: break; - case 10: - { return com.intellij.psi.TokenType.BAD_CHARACTER; - } - // fall through - case 68: break; - case 11: - { return COMMENT_TOKEN; - } - // fall through - case 69: break; - case 12: - { return STAR; - } - // fall through - case 70: break; - case 13: - { yypushState(INLINE_MATH); return INLINE_MATH_START; - } - // fall through - case 71: break; - case 14: - { return AMPERSAND; - } - // fall through - case 72: break; - case 15: - { yypopState(); return INLINE_MATH_END; - } - // fall through - case 73: break; - case 16: - { yypopState(); return CLOSE_BRACE; - } - // fall through - case 74: break; - case 17: - { yypushState(NESTED_INLINE_MATH); return INLINE_MATH_START; - } - // fall through - case 75: break; - case 18: - { yypopState(); yypushState(NEW_ENVIRONMENT_DEFINITION); return CLOSE_BRACE; - } - // fall through - case 76: break; - case 19: - { newEnvironmentBracesNesting++; return OPEN_BRACE; - } - // fall through - case 77: break; - case 20: - { newEnvironmentBracesNesting--; - if(newEnvironmentBracesNesting == 0) { - yypopState(); yypushState(NEW_ENVIRONMENT_SKIP_BRACE); - // We could have return normal text, but in this way the braces still match + case 1: { + return NORMAL_TEXT_WORD; + } + // fall through + case 61: + break; + case 2: { + return NORMAL_TEXT_CHAR; + } + // fall through + case 62: + break; + case 3: { + return OPEN_PAREN; + } + // fall through + case 63: + break; + case 4: { + return CLOSE_PAREN; + } + // fall through + case 64: + break; + case 5: { + return OPEN_BRACKET; + } + // fall through + case 65: + break; + case 6: { + return CLOSE_BRACKET; + } + // fall through + case 66: + break; + case 7: { return OPEN_BRACE; - } else { + } + // fall through + case 67: + break; + case 8: { return CLOSE_BRACE; - } - } - // fall through - case 78: break; - case 21: - { yypopState(); newEnvironmentBracesNesting = 1; yypushState(NEW_ENVIRONMENT_DEFINITION_END); return CLOSE_BRACE; - } - // fall through - case 79: break; - case 22: - { newEnvironmentBracesNesting--; - if(newEnvironmentBracesNesting == 0) { + } + // fall through + case 68: + break; + case 9: { + return com.intellij.psi.TokenType.WHITE_SPACE; + } + // fall through + case 69: + break; + case 10: { + return com.intellij.psi.TokenType.BAD_CHARACTER; + } + // fall through + case 70: + break; + case 11: { + return COMMENT_TOKEN; + } + // fall through + case 71: + break; + case 12: { + return KEYVAL_ASSIGN; + } + // fall through + case 72: + break; + case 13: { + return STAR; + } + // fall through + case 73: + break; + case 14: { + yypushState(INLINE_MATH); + return INLINE_MATH_START; + } + // fall through + case 74: + break; + case 15: { + return AMPERSAND; + } + // fall through + case 75: + break; + case 16: { + return PARAM_SEPARATOR; + } + // fall through + case 76: + break; + case 17: { yypopState(); - } - return CLOSE_BRACE; - } - // fall through - case 80: break; - case 23: - { yypopState(); verbatim_delimiter = yytext().toString(); yypushState(INLINE_VERBATIM); return OPEN_BRACE; - } - // fall through - case 81: break; - case 24: - { yypopState(); verbatim_delimiter = "}"; yypushState(INLINE_VERBATIM); return OPEN_BRACE; - } - // fall through - case 82: break; - case 25: - { if(yytext().toString().equals(verbatim_delimiter)) { yypopState(); return CLOSE_BRACE; } else { return RAW_TEXT_TOKEN; } - } - // fall through - case 83: break; - case 26: - { yypopState(); - // toString to fix comparisons of charsequence subsequences with string - if (Magic.Environment.verbatim.contains(yytext().toString())) { - yypushState(VERBATIM_START); - } - else if (yytext().toString().equals("algorithmic")) { - yypushState(PSEUDOCODE); - } - return NORMAL_TEXT_WORD; - } - // fall through - case 84: break; - case 27: - { verbatimOptionalArgumentBracketsCount++; return OPEN_BRACKET; - } - // fall through - case 85: break; - case 28: - { verbatimOptionalArgumentBracketsCount--; - if (verbatimOptionalArgumentBracketsCount == 0) { yypopState(); yypushState(VERBATIM); } - return CLOSE_BRACKET; - } - // fall through - case 86: break; - case 29: - { yypopState(); yypushState(POSSIBLE_VERBATIM_OPTIONAL_ARG); return CLOSE_BRACE; - } - // fall through - case 87: break; - case 30: - { return RAW_TEXT_TOKEN; - } - // fall through - case 88: break; - case 31: - { yypopState(); yypushState(VERBATIM); return RAW_TEXT_TOKEN; - } - // fall through - case 89: break; - case 32: - { verbatimOptionalArgumentBracketsCount++; yypopState(); yypushState(VERBATIM_OPTIONAL_ARG); return OPEN_BRACKET; - } - // fall through - case 90: break; - case 33: - { yypopState(); yypushState(VERBATIM); return com.intellij.psi.TokenType.WHITE_SPACE; - } - // fall through - case 91: break; - case 34: - { // Pop current state - yypopState(); - if (Magic.Environment.verbatim.contains(yytext().toString())) { - // Pop verbatim state + return INLINE_MATH_END; + } + // fall through + case 77: + break; + case 18: { yypopState(); + return CLOSE_BRACE; + } + // fall through + case 78: + break; + case 19: { + yypushState(NESTED_INLINE_MATH); + return INLINE_MATH_START; + } + // fall through + case 79: + break; + case 20: { + yypopState(); + yypushState(NEW_ENVIRONMENT_DEFINITION); + return CLOSE_BRACE; + } + // fall through + case 80: + break; + case 21: { + newEnvironmentBracesNesting++; + return OPEN_BRACE; + } + // fall through + case 81: + break; + case 22: { + newEnvironmentBracesNesting--; + if (newEnvironmentBracesNesting == 0) { + yypopState(); + yypushState(NEW_ENVIRONMENT_SKIP_BRACE); + // We could have return normal text, but in this way the braces still match + return OPEN_BRACE; + } else { + return CLOSE_BRACE; + } + } + // fall through + case 82: + break; + case 23: { + yypopState(); + newEnvironmentBracesNesting = 1; + yypushState(NEW_ENVIRONMENT_DEFINITION_END); + return CLOSE_BRACE; + } + // fall through + case 83: + break; + case 24: { + newEnvironmentBracesNesting--; + if (newEnvironmentBracesNesting == 0) { + yypopState(); + } + return CLOSE_BRACE; + } + // fall through + case 84: + break; + case 25: { + yypopState(); + verbatim_delimiter = yytext().toString(); + yypushState(INLINE_VERBATIM); + return OPEN_BRACE; + } + // fall through + case 85: + break; + case 26: { + yypopState(); + verbatim_delimiter = "}"; + yypushState(INLINE_VERBATIM); + return OPEN_BRACE; + } + // fall through + case 86: + break; + case 27: { + if (yytext().toString().equals(verbatim_delimiter)) { + yypopState(); + return CLOSE_BRACE; + } else { + return RAW_TEXT_TOKEN; + } + } + // fall through + case 87: + break; + case 28: { + yypopState(); + // toString to fix comparisons of charsequence subsequences with string + if (Magic.Environment.verbatim.contains(yytext().toString())) { + yypushState(VERBATIM_START); + } else if (yytext().toString().equals("algorithmic")) { + yypushState(PSEUDOCODE); + } return NORMAL_TEXT_WORD; - } - return RAW_TEXT_TOKEN; - } - // fall through - case 92: break; - case 35: - { yypopState(); return RAW_TEXT_TOKEN; - } - // fall through - case 93: break; - case 36: - { yypopState(); - if (yytext().toString().equals("algorithmic")) { - // Pop pseudocode state + } + // fall through + case 88: + break; + case 29: { + verbatimOptionalArgumentBracketsCount++; + return OPEN_BRACKET; + } + // fall through + case 89: + break; + case 30: { + verbatimOptionalArgumentBracketsCount--; + if (verbatimOptionalArgumentBracketsCount == 0) { + yypopState(); + yypushState(VERBATIM); + } + return CLOSE_BRACKET; + } + // fall through + case 90: + break; + case 31: { yypopState(); - } - return NORMAL_TEXT_WORD; - } - // fall through - case 94: break; - case 37: - { return COMMAND_TOKEN; - } - // fall through - case 95: break; - case 38: - { yypushState(INLINE_MATH_LATEX); return INLINE_MATH_START; - } - // fall through - case 96: break; - case 39: - { yypushState(DISPLAY_MATH); return DISPLAY_MATH_START; - } - // fall through - case 97: break; - case 40: - { return MAGIC_COMMENT_TOKEN; - } - // fall through - case 98: break; - case 41: - { yypushState(PREAMBLE_OPTION); return OPEN_BRACE; - } - // fall through - case 99: break; - case 42: - { yypopState(); return DISPLAY_MATH_END; - } - // fall through - case 100: break; - case 43: - { return DISPLAY_MATH_START; - } - // fall through - case 101: break; - case 44: - { return DISPLAY_MATH_END; - } - // fall through - case 102: break; - case 45: - { return BEGIN_PSEUDOCODE_BLOCK; - } - // fall through - case 103: break; - case 46: - { return END_TOKEN; - } - // fall through - case 104: break; - case 47: - { yypushState(POSSIBLE_VERBATIM_END); return END_TOKEN; - } - // fall through - case 105: break; - case 48: - { yypushState(POSSIBLE_PSEUDOCODE_END); return END_TOKEN; - } - // fall through - case 106: break; - case 49: - { yypushState(INLINE_VERBATIM_START); return COMMAND_TOKEN; - } - // fall through - case 107: break; - case 50: - { yypushState(TEXT_INSIDE_INLINE_MATH); return COMMAND_TOKEN; - } - // fall through - case 108: break; - case 51: - { return MIDDLE_PSEUDOCODE_BLOCK; - } - // fall through - case 109: break; - case 52: - { yypushState(POSSIBLE_VERBATIM_BEGIN); return BEGIN_TOKEN; - } - // fall through - case 110: break; - case 53: - { return BEGIN_TOKEN; - } - // fall through - case 111: break; - case 54: - { return END_PSEUDOCODE_BLOCK; - } - // fall through - case 112: break; - case 55: - { yypopState(); return COMMENT_TOKEN; - } - // fall through - case 113: break; - case 56: - { yypushState(OFF); return COMMENT_TOKEN; - } - // fall through - case 114: break; - case 57: - { return COMMAND_IFNEXTCHAR; - } - // fall through - case 115: break; - case 58: - { yypushState(NEW_ENVIRONMENT_DEFINITION_NAME); return COMMAND_TOKEN; - } - // fall through - case 116: break; + yypushState(POSSIBLE_VERBATIM_OPTIONAL_ARG); + return CLOSE_BRACE; + } + // fall through + case 91: + break; + case 32: { + return RAW_TEXT_TOKEN; + } + // fall through + case 92: + break; + case 33: { + yypopState(); + yypushState(VERBATIM); + return RAW_TEXT_TOKEN; + } + // fall through + case 93: + break; + case 34: { + verbatimOptionalArgumentBracketsCount++; + yypopState(); + yypushState(VERBATIM_OPTIONAL_ARG); + return OPEN_BRACKET; + } + // fall through + case 94: + break; + case 35: { + yypopState(); + yypushState(VERBATIM); + return com.intellij.psi.TokenType.WHITE_SPACE; + } + // fall through + case 95: + break; + case 36: { // Pop current state + yypopState(); + if (Magic.Environment.verbatim.contains(yytext().toString())) { + // Pop verbatim state + yypopState(); + return NORMAL_TEXT_WORD; + } + return RAW_TEXT_TOKEN; + } + // fall through + case 96: + break; + case 37: { + yypopState(); + return RAW_TEXT_TOKEN; + } + // fall through + case 97: + break; + case 38: { + yypopState(); + if (yytext().toString().equals("algorithmic")) { + // Pop pseudocode state + yypopState(); + } + return NORMAL_TEXT_WORD; + } + // fall through + case 98: + break; + case 39: { + return COMMAND_TOKEN; + } + // fall through + case 99: + break; + case 40: { + yypushState(INLINE_MATH_LATEX); + return INLINE_MATH_START; + } + // fall through + case 100: + break; + case 41: { + yypushState(DISPLAY_MATH); + return DISPLAY_MATH_START; + } + // fall through + case 101: + break; + case 42: { + return MAGIC_COMMENT_TOKEN; + } + // fall through + case 102: + break; + case 43: { + yypushState(PREAMBLE_OPTION); + return OPEN_BRACE; + } + // fall through + case 103: + break; + case 44: { + yypopState(); + return DISPLAY_MATH_END; + } + // fall through + case 104: + break; + case 45: { + return DISPLAY_MATH_START; + } + // fall through + case 105: + break; + case 46: { + return DISPLAY_MATH_END; + } + // fall through + case 106: + break; + case 47: { + return BEGIN_PSEUDOCODE_BLOCK; + } + // fall through + case 107: + break; + case 48: { + return END_TOKEN; + } + // fall through + case 108: + break; + case 49: { + yypushState(POSSIBLE_VERBATIM_END); + return END_TOKEN; + } + // fall through + case 109: + break; + case 50: { + yypushState(POSSIBLE_PSEUDOCODE_END); + return END_TOKEN; + } + // fall through + case 110: + break; + case 51: { + yypushState(INLINE_VERBATIM_START); + return COMMAND_TOKEN; + } + // fall through + case 111: + break; + case 52: { + yypushState(TEXT_INSIDE_INLINE_MATH); + return COMMAND_TOKEN; + } + // fall through + case 112: + break; + case 53: { + return MIDDLE_PSEUDOCODE_BLOCK; + } + // fall through + case 113: + break; + case 54: { + yypushState(POSSIBLE_VERBATIM_BEGIN); + return BEGIN_TOKEN; + } + // fall through + case 114: + break; + case 55: { + return BEGIN_TOKEN; + } + // fall through + case 115: + break; + case 56: { + return END_PSEUDOCODE_BLOCK; + } + // fall through + case 116: + break; + case 57: { + yypopState(); + return COMMENT_TOKEN; + } + // fall through + case 117: + break; + case 58: { + yypushState(OFF); + return COMMENT_TOKEN; + } + // fall through + case 118: + break; + case 59: { + return COMMAND_IFNEXTCHAR; + } + // fall through + case 119: + break; + case 60: { + yypushState(NEW_ENVIRONMENT_DEFINITION_NAME); + return COMMAND_TOKEN; + } + // fall through + case 120: + break; default: zzScanError(ZZ_NO_MATCH); - } + } } } } diff --git a/gen/nl/hannahsten/texifyidea/psi/LatexKeyvalContent.java b/gen/nl/hannahsten/texifyidea/psi/LatexKeyvalContent.java index 88e33f1fc..8c28667d5 100644 --- a/gen/nl/hannahsten/texifyidea/psi/LatexKeyvalContent.java +++ b/gen/nl/hannahsten/texifyidea/psi/LatexKeyvalContent.java @@ -6,13 +6,13 @@ public interface LatexKeyvalContent extends PsiElement { - @Nullable - LatexCommands getCommands(); + @Nullable + LatexCommands getCommands(); - @Nullable - LatexKeyvalText getKeyvalText(); + @Nullable + LatexKeyvalText getKeyvalText(); - @Nullable - LatexParameterGroup getParameterGroup(); + @Nullable + LatexParameterGroup getParameterGroup(); } diff --git a/src/nl/hannahsten/texifyidea/psi/LatexLanguageInjector.kt b/src/nl/hannahsten/texifyidea/psi/LatexLanguageInjector.kt index 51163d20e..00436441d 100644 --- a/src/nl/hannahsten/texifyidea/psi/LatexLanguageInjector.kt +++ b/src/nl/hannahsten/texifyidea/psi/LatexLanguageInjector.kt @@ -5,8 +5,6 @@ import com.intellij.openapi.util.TextRange import com.intellij.psi.InjectedLanguagePlaces import com.intellij.psi.LanguageInjector import com.intellij.psi.PsiLanguageInjectionHost -import com.intellij.refactoring.suggested.endOffset -import com.intellij.refactoring.suggested.startOffset import nl.hannahsten.texifyidea.lang.magic.DefaultMagicKeys import nl.hannahsten.texifyidea.lang.magic.magicComment import nl.hannahsten.texifyidea.util.Magic @@ -30,7 +28,7 @@ class LatexLanguageInjector : LanguageInjector { magicComment.value(DefaultMagicKeys.INJECT_LANGUAGE) } host.environmentName == "lstlisting" -> { - host.beginCommand.optionalParameters.getOrDefault("language", null) + host.beginCommand.optionalParameterMap.toStringMap().getOrDefault("language", null) } else -> { Magic.Environment.languageInjections[host.environmentName] From 7e7dfc4a4f282afa863139f6d59bddb8e44673bb Mon Sep 17 00:00:00 2001 From: Felix Berlakovich Date: Sat, 2 Jan 2021 14:07:11 +0100 Subject: [PATCH 16/20] Change lexer token names to be more general --- .../texifyidea/grammar/LatexLexer.java | 4 +-- .../texifyidea/parser/LatexParser.java | 34 +++++++++---------- .../hannahsten/texifyidea/psi/LatexTypes.java | 4 +-- .../hannahsten/texifyidea/grammar/Latex.bnf | 8 ++--- .../texifyidea/grammar/LatexLexer.flex | 4 +-- .../texifyidea/psi/LatexPsiHelper.kt | 4 +-- 6 files changed, 29 insertions(+), 29 deletions(-) diff --git a/gen/nl/hannahsten/texifyidea/grammar/LatexLexer.java b/gen/nl/hannahsten/texifyidea/grammar/LatexLexer.java index 21f8455bf..7af991e08 100644 --- a/gen/nl/hannahsten/texifyidea/grammar/LatexLexer.java +++ b/gen/nl/hannahsten/texifyidea/grammar/LatexLexer.java @@ -1035,7 +1035,7 @@ else if (zzAtEOF) { case 71: break; case 12: { - return KEYVAL_ASSIGN; + return EQUALS; } // fall through case 72: @@ -1060,7 +1060,7 @@ else if (zzAtEOF) { case 75: break; case 16: { - return PARAM_SEPARATOR; + return COMMA; } // fall through case 76: diff --git a/gen/nl/hannahsten/texifyidea/parser/LatexParser.java b/gen/nl/hannahsten/texifyidea/parser/LatexParser.java index 5f0fa5f81..47282ecd8 100644 --- a/gen/nl/hannahsten/texifyidea/parser/LatexParser.java +++ b/gen/nl/hannahsten/texifyidea/parser/LatexParser.java @@ -308,7 +308,7 @@ public static boolean keyval_key(PsiBuilder b, int l) { } /* ********************************************************** */ - // keyval_key (KEYVAL_ASSIGN keyval_value)? + // keyval_key (EQUALS keyval_value)? public static boolean keyval_pair(PsiBuilder b, int l) { if (!recursion_guard_(b, l, "keyval_pair")) return false; boolean r; @@ -319,19 +319,19 @@ public static boolean keyval_pair(PsiBuilder b, int l) { return r; } - // (KEYVAL_ASSIGN keyval_value)? + // (EQUALS keyval_value)? private static boolean keyval_pair_1(PsiBuilder b, int l) { if (!recursion_guard_(b, l, "keyval_pair_1")) return false; keyval_pair_1_0(b, l + 1); return true; } - // KEYVAL_ASSIGN keyval_value + // EQUALS keyval_value private static boolean keyval_pair_1_0(PsiBuilder b, int l) { if (!recursion_guard_(b, l, "keyval_pair_1_0")) return false; boolean r; Marker m = enter_section_(b); - r = consumeToken(b, KEYVAL_ASSIGN); + r = consumeToken(b, EQUALS); r = r && keyval_value(b, l + 1); exit_section_(b, m, null, r); return r; @@ -464,7 +464,7 @@ public static boolean no_math_content(PsiBuilder b, int l) { } /* ********************************************************** */ - // (NORMAL_TEXT_WORD | STAR | AMPERSAND | NORMAL_TEXT_CHAR | KEYVAL_ASSIGN | PARAM_SEPARATOR )+ + // (NORMAL_TEXT_WORD | STAR | AMPERSAND | NORMAL_TEXT_CHAR | EQUALS | COMMA )+ public static boolean normal_text(PsiBuilder b, int l) { if (!recursion_guard_(b, l, "normal_text")) return false; boolean r; @@ -479,7 +479,7 @@ public static boolean normal_text(PsiBuilder b, int l) { return r; } - // NORMAL_TEXT_WORD | STAR | AMPERSAND | NORMAL_TEXT_CHAR | KEYVAL_ASSIGN | PARAM_SEPARATOR + // NORMAL_TEXT_WORD | STAR | AMPERSAND | NORMAL_TEXT_CHAR | EQUALS | COMMA private static boolean normal_text_0(PsiBuilder b, int l) { if (!recursion_guard_(b, l, "normal_text_0")) return false; boolean r; @@ -487,13 +487,13 @@ private static boolean normal_text_0(PsiBuilder b, int l) { if (!r) r = consumeToken(b, STAR); if (!r) r = consumeToken(b, AMPERSAND); if (!r) r = consumeToken(b, NORMAL_TEXT_CHAR); - if (!r) r = consumeToken(b, KEYVAL_ASSIGN); - if (!r) r = consumeToken(b, PARAM_SEPARATOR); + if (!r) r = consumeToken(b, EQUALS); + if (!r) r = consumeToken(b, COMMA); return r; } /* ********************************************************** */ - // OPEN_BRACKET ( (keyval_pair (PARAM_SEPARATOR keyval_pair)*) | optional_param_content*) CLOSE_BRACKET + // OPEN_BRACKET ( (keyval_pair (COMMA keyval_pair)*) | optional_param_content*) CLOSE_BRACKET public static boolean optional_param(PsiBuilder b, int l) { if (!recursion_guard_(b, l, "optional_param")) return false; if (!nextTokenIs(b, OPEN_BRACKET)) return false; @@ -506,7 +506,7 @@ public static boolean optional_param(PsiBuilder b, int l) { return r; } - // (keyval_pair (PARAM_SEPARATOR keyval_pair)*) | optional_param_content* + // (keyval_pair (COMMA keyval_pair)*) | optional_param_content* private static boolean optional_param_1(PsiBuilder b, int l) { if (!recursion_guard_(b, l, "optional_param_1")) return false; boolean r; @@ -517,7 +517,7 @@ private static boolean optional_param_1(PsiBuilder b, int l) { return r; } - // keyval_pair (PARAM_SEPARATOR keyval_pair)* + // keyval_pair (COMMA keyval_pair)* private static boolean optional_param_1_0(PsiBuilder b, int l) { if (!recursion_guard_(b, l, "optional_param_1_0")) return false; boolean r; @@ -528,7 +528,7 @@ private static boolean optional_param_1_0(PsiBuilder b, int l) { return r; } - // (PARAM_SEPARATOR keyval_pair)* + // (COMMA keyval_pair)* private static boolean optional_param_1_0_1(PsiBuilder b, int l) { if (!recursion_guard_(b, l, "optional_param_1_0_1")) return false; while (true) { @@ -539,12 +539,12 @@ private static boolean optional_param_1_0_1(PsiBuilder b, int l) { return true; } - // PARAM_SEPARATOR keyval_pair + // COMMA keyval_pair private static boolean optional_param_1_0_1_0(PsiBuilder b, int l) { if (!recursion_guard_(b, l, "optional_param_1_0_1_0")) return false; boolean r; Marker m = enter_section_(b); - r = consumeToken(b, PARAM_SEPARATOR); + r = consumeToken(b, COMMA); r = r && keyval_pair(b, l + 1); exit_section_(b, m, null, r); return r; @@ -797,7 +797,7 @@ private static boolean required_param_1(PsiBuilder b, int l) { } /* ********************************************************** */ - // raw_text | magic_comment | comment | environment | pseudocode_block | math_environment | COMMAND_IFNEXTCHAR | group | OPEN_PAREN | CLOSE_PAREN | parameter_text | PARAM_SEPARATOR | KEYVAL_ASSIGN | OPEN_BRACKET | CLOSE_BRACKET | NORMAL_TEXT_CHAR + // raw_text | magic_comment | comment | environment | pseudocode_block | math_environment | COMMAND_IFNEXTCHAR | group | OPEN_PAREN | CLOSE_PAREN | parameter_text | COMMA | EQUALS | OPEN_BRACKET | CLOSE_BRACKET | NORMAL_TEXT_CHAR public static boolean required_param_content(PsiBuilder b, int l) { if (!recursion_guard_(b, l, "required_param_content")) return false; boolean r; @@ -813,8 +813,8 @@ public static boolean required_param_content(PsiBuilder b, int l) { if (!r) r = consumeToken(b, OPEN_PAREN); if (!r) r = consumeToken(b, CLOSE_PAREN); if (!r) r = parameter_text(b, l + 1); - if (!r) r = consumeToken(b, PARAM_SEPARATOR); - if (!r) r = consumeToken(b, KEYVAL_ASSIGN); + if (!r) r = consumeToken(b, COMMA); + if (!r) r = consumeToken(b, EQUALS); if (!r) r = consumeToken(b, OPEN_BRACKET); if (!r) r = consumeToken(b, CLOSE_BRACKET); if (!r) r = consumeToken(b, NORMAL_TEXT_CHAR); diff --git a/gen/nl/hannahsten/texifyidea/psi/LatexTypes.java b/gen/nl/hannahsten/texifyidea/psi/LatexTypes.java index 60eaeb28a..019093c79 100644 --- a/gen/nl/hannahsten/texifyidea/psi/LatexTypes.java +++ b/gen/nl/hannahsten/texifyidea/psi/LatexTypes.java @@ -49,6 +49,7 @@ public interface LatexTypes { IElementType CLOSE_BRACE = new LatexTokenType("CLOSE_BRACE"); IElementType CLOSE_BRACKET = new LatexTokenType("CLOSE_BRACKET"); IElementType CLOSE_PAREN = new LatexTokenType("CLOSE_PAREN"); + IElementType COMMA = new LatexTokenType("COMMA"); IElementType COMMAND_IFNEXTCHAR = new LatexTokenType("COMMAND_IFNEXTCHAR"); IElementType COMMAND_TOKEN = new LatexTokenType("COMMAND_TOKEN"); IElementType COMMENT_TOKEN = new LatexTokenType("COMMENT_TOKEN"); @@ -56,9 +57,9 @@ public interface LatexTypes { IElementType DISPLAY_MATH_START = new LatexTokenType("\\["); IElementType END_PSEUDOCODE_BLOCK = new LatexTokenType("END_PSEUDOCODE_BLOCK"); IElementType END_TOKEN = new LatexTokenType("\\end"); + IElementType EQUALS = new LatexTokenType("EQUALS"); IElementType INLINE_MATH_END = new LatexTokenType("INLINE_MATH_END"); IElementType INLINE_MATH_START = new LatexTokenType("INLINE_MATH_START"); - IElementType KEYVAL_ASSIGN = new LatexTokenType("KEYVAL_ASSIGN"); IElementType MAGIC_COMMENT_TOKEN = new LatexTokenType("MAGIC_COMMENT_TOKEN"); IElementType MIDDLE_PSEUDOCODE_BLOCK = new LatexTokenType("MIDDLE_PSEUDOCODE_BLOCK"); IElementType NORMAL_TEXT_CHAR = new LatexTokenType("NORMAL_TEXT_CHAR"); @@ -66,7 +67,6 @@ public interface LatexTypes { IElementType OPEN_BRACE = new LatexTokenType("OPEN_BRACE"); IElementType OPEN_BRACKET = new LatexTokenType("OPEN_BRACKET"); IElementType OPEN_PAREN = new LatexTokenType("OPEN_PAREN"); - IElementType PARAM_SEPARATOR = new LatexTokenType("PARAM_SEPARATOR"); IElementType RAW_TEXT_TOKEN = new LatexTokenType("RAW_TEXT"); IElementType STAR = new LatexTokenType("*"); diff --git a/src/nl/hannahsten/texifyidea/grammar/Latex.bnf b/src/nl/hannahsten/texifyidea/grammar/Latex.bnf index e62ceafb0..3e936949f 100644 --- a/src/nl/hannahsten/texifyidea/grammar/Latex.bnf +++ b/src/nl/hannahsten/texifyidea/grammar/Latex.bnf @@ -64,7 +64,7 @@ content ::= no_math_content no_math_content ::= raw_text | magic_comment | comment | environment | pseudocode_block | math_environment | COMMAND_IFNEXTCHAR | commands | group | OPEN_PAREN | CLOSE_PAREN | OPEN_BRACKET | CLOSE_BRACKET | normal_text -normal_text ::= (NORMAL_TEXT_WORD | STAR | AMPERSAND | NORMAL_TEXT_CHAR | KEYVAL_ASSIGN | PARAM_SEPARATOR )+ +normal_text ::= (NORMAL_TEXT_WORD | STAR | AMPERSAND | NORMAL_TEXT_CHAR | EQUALS | COMMA )+ environment ::= begin_command environment_content? end_command { pin=1 @@ -104,7 +104,7 @@ parameter ::= optional_param | required_param { // will be seen as simply an open bracket, but '[x]' at the same location will // be parsed as optional parameter. // https://stackoverflow.com/a/48709143/6629569 -optional_param ::= OPEN_BRACKET ( (keyval_pair (PARAM_SEPARATOR keyval_pair)*) | optional_param_content*) CLOSE_BRACKET { pin=3 } +optional_param ::= OPEN_BRACKET ( (keyval_pair (COMMA keyval_pair)*) | optional_param_content*) CLOSE_BRACKET { pin=3 } required_param ::= OPEN_BRACE required_param_content* CLOSE_BRACE { pin=1 } @@ -112,9 +112,9 @@ required_param ::= OPEN_BRACE required_param_content* CLOSE_BRACE { pin=1 } // We have to separate optional and required parameter content, because required parameter content // can contain mismatched brackets, but optional parameters not (then we wouldn't know what to match) optional_param_content ::= raw_text | magic_comment | comment | environment | pseudocode_block | math_environment | COMMAND_IFNEXTCHAR | commands | group | OPEN_PAREN | CLOSE_PAREN | parameter_text | NORMAL_TEXT_CHAR -required_param_content ::= raw_text | magic_comment | comment | environment | pseudocode_block | math_environment | COMMAND_IFNEXTCHAR | group | OPEN_PAREN | CLOSE_PAREN | parameter_text | PARAM_SEPARATOR | KEYVAL_ASSIGN | OPEN_BRACKET | CLOSE_BRACKET | NORMAL_TEXT_CHAR +required_param_content ::= raw_text | magic_comment | comment | environment | pseudocode_block | math_environment | COMMAND_IFNEXTCHAR | group | OPEN_PAREN | CLOSE_PAREN | parameter_text | COMMA | EQUALS | OPEN_BRACKET | CLOSE_BRACKET | NORMAL_TEXT_CHAR -keyval_pair ::= keyval_key (KEYVAL_ASSIGN keyval_value)? +keyval_pair ::= keyval_key (EQUALS keyval_value)? keyval_key ::= keyval_content+ { methods=[toString] } diff --git a/src/nl/hannahsten/texifyidea/grammar/LatexLexer.flex b/src/nl/hannahsten/texifyidea/grammar/LatexLexer.flex index 30407af53..999ff7131 100644 --- a/src/nl/hannahsten/texifyidea/grammar/LatexLexer.flex +++ b/src/nl/hannahsten/texifyidea/grammar/LatexLexer.flex @@ -368,6 +368,6 @@ END_PSEUDOCODE_BLOCK="\\EndFor" | "\\EndIf" | "\\EndWhile" | "\\Until" | "\\EndL // Tokens for parameter separators (e.g., \cite{param1,param2}) and // keyval assigns (e.g. \lstinputlisting[label=somelabel]) -"=" { return KEYVAL_ASSIGN; } -"," { return PARAM_SEPARATOR; } +"=" { return EQUALS; } +"," { return COMMA; } [^] { return com.intellij.psi.TokenType.BAD_CHARACTER; } diff --git a/src/nl/hannahsten/texifyidea/psi/LatexPsiHelper.kt b/src/nl/hannahsten/texifyidea/psi/LatexPsiHelper.kt index ddcb0b06a..8164d69ce 100644 --- a/src/nl/hannahsten/texifyidea/psi/LatexPsiHelper.kt +++ b/src/nl/hannahsten/texifyidea/psi/LatexPsiHelper.kt @@ -6,7 +6,7 @@ import com.intellij.psi.PsiFileFactory import com.intellij.psi.impl.source.tree.LeafPsiElement import nl.hannahsten.texifyidea.LatexLanguage import nl.hannahsten.texifyidea.psi.LatexTypes.CLOSE_BRACKET -import nl.hannahsten.texifyidea.psi.LatexTypes.KEYVAL_ASSIGN +import nl.hannahsten.texifyidea.psi.LatexTypes.EQUALS import nl.hannahsten.texifyidea.util.childrenOfType import nl.hannahsten.texifyidea.util.findFirstChild import nl.hannahsten.texifyidea.util.firstChildOfType @@ -98,7 +98,7 @@ class LatexPsiHelper(private val project: Project) { existing.keyvalValue?.delete() existing.addAfter( pair.keyvalValue!!, - existing.childrenOfType().first { it.elementType == KEYVAL_ASSIGN }) + existing.childrenOfType().first { it.elementType == EQUALS }) existing } else { From c71e1eaff7dd79b0f017e3c5a3d9f8939cc819d4 Mon Sep 17 00:00:00 2001 From: Felix Berlakovich Date: Sat, 2 Jan 2021 14:43:59 +0100 Subject: [PATCH 17/20] Dissolve NORMAL_TEXT_CHAR into dedicated lexer tokens --- .../texifyidea/grammar/LatexLexer.java | 1703 ++++++++--------- .../texifyidea/parser/LatexParser.java | 44 +- .../psi/LatexOptionalParamContent.java | 6 +- .../psi/LatexRequiredParamContent.java | 6 +- .../hannahsten/texifyidea/psi/LatexTypes.java | 60 +- .../psi/impl/LatexKeyvalContentImpl.java | 2 +- .../psi/impl/LatexKeyvalTextImpl.java | 2 +- .../impl/LatexOptionalParamContentImpl.java | 15 +- .../psi/impl/LatexParameterGroupTextImpl.java | 2 +- .../impl/LatexRequiredParamContentImpl.java | 15 +- .../hannahsten/texifyidea/grammar/Latex.bnf | 10 +- .../texifyidea/grammar/LatexLexer.flex | 18 +- .../psi/parser/ParsingInlineVerbatim.txt | 4 +- 13 files changed, 915 insertions(+), 972 deletions(-) diff --git a/gen/nl/hannahsten/texifyidea/grammar/LatexLexer.java b/gen/nl/hannahsten/texifyidea/grammar/LatexLexer.java index 7af991e08..d5b55c121 100644 --- a/gen/nl/hannahsten/texifyidea/grammar/LatexLexer.java +++ b/gen/nl/hannahsten/texifyidea/grammar/LatexLexer.java @@ -81,13 +81,13 @@ public static int ZZ_CMAP(int ch) { /* The ZZ_CMAP_A table has 640 entries */ static final char ZZ_CMAP_A[] = zzUnpackCMap( - "\11\0\1\10\1\20\2\22\1\21\22\0\1\35\1\34\1\47\1\0\1\66\1\41\1\70\1\0\1\2\1" + - "\3\1\63\1\0\1\71\15\0\1\17\1\0\1\67\1\44\1\67\1\0\1\24\1\51\3\17\1\37\1\50" + - "\2\17\1\53\2\17\1\56\3\17\1\60\1\17\1\55\1\17\1\36\1\61\1\17\1\54\1\40\2\17" + - "\1\4\1\1\1\5\1\0\1\17\1\0\1\32\1\11\1\30\1\16\1\12\1\25\1\13\1\31\1\14\2\17" + - "\1\52\1\65\1\15\1\45\1\42\1\17\1\33\1\43\1\27\1\57\1\62\1\64\1\26\2\17\1\6" + - "\1\47\1\7\7\0\1\23\32\0\1\46\337\0\1\46\177\0\13\46\35\0\2\23\5\0\1\46\57" + - "\0\1\46\40\0"); + "\11\0\1\10\1\20\2\22\1\21\22\0\1\35\1\34\1\72\1\0\1\65\1\41\1\70\1\0\1\2\1"+ + "\3\1\62\1\0\1\71\15\0\1\17\1\0\1\66\1\44\1\67\1\0\1\24\1\50\3\17\1\37\1\47"+ + "\2\17\1\52\2\17\1\55\3\17\1\57\1\17\1\54\1\17\1\36\1\60\1\17\1\53\1\40\2\17"+ + "\1\4\1\1\1\5\1\0\1\17\1\0\1\32\1\11\1\30\1\16\1\12\1\25\1\13\1\31\1\14\2\17"+ + "\1\51\1\64\1\15\1\45\1\42\1\17\1\33\1\43\1\27\1\56\1\61\1\63\1\26\2\17\1\6"+ + "\1\73\1\7\7\0\1\23\32\0\1\46\337\0\1\46\177\0\13\46\35\0\2\23\5\0\1\46\57"+ + "\0\1\46\40\0"); /** * Translates DFA states to action switch labels. @@ -95,27 +95,27 @@ public static int ZZ_CMAP(int ch) { private static final int [] ZZ_ACTION = zzUnpackAction(); private static final String ZZ_ACTION_PACKED_0 = - "\27\0\1\1\1\2\1\3\1\4\1\5\1\6\1\7" + - "\1\10\1\11\1\12\1\2\1\13\1\14\1\15\1\16" + - "\1\2\1\17\1\20\1\2\1\21\3\2\1\22\1\23" + - "\1\1\1\24\1\2\1\25\1\26\1\27\1\30\1\31" + - "\1\32\1\33\1\34\1\35\1\36\1\37\2\40\1\41" + - "\1\42\1\43\1\44\1\45\1\2\1\46\1\40\1\47" + - "\1\50\1\51\11\47\1\13\1\52\1\13\1\53\1\47" + - "\1\54\1\55\1\56\2\0\11\47\2\0\11\47\1\52" + - "\1\0\1\52\1\13\1\47\2\0\5\47\1\57\5\47" + - "\2\0\1\47\1\60\6\47\1\0\1\52\1\13\1\47" + - "\1\0\1\61\1\62\2\47\1\57\6\47\2\0\6\47" + - "\1\63\1\0\1\52\1\13\1\64\1\0\5\47\1\65" + - "\7\47\2\0\1\66\5\47\1\63\1\0\1\52\1\67" + - "\2\47\1\70\7\47\1\0\5\47\1\0\1\52\6\47" + - "\1\0\4\47\1\63\1\0\1\52\5\47\1\0\4\47" + - "\1\0\1\52\2\47\1\0\2\47\1\0\1\52\2\47" + - "\1\0\2\47\1\0\1\52\2\47\1\71\2\47\1\0" + - "\1\72\1\47\1\73\1\47\1\74"; + "\27\0\1\1\1\2\1\3\1\4\1\5\1\6\1\7"+ + "\1\10\1\11\1\12\1\13\1\14\1\15\1\16\1\17"+ + "\1\20\1\21\1\22\1\23\1\24\1\25\1\2\1\26"+ + "\3\2\1\27\1\30\1\1\1\31\1\2\1\32\1\33"+ + "\1\34\1\35\1\36\1\37\1\40\1\41\1\42\1\43"+ + "\1\44\2\45\1\46\1\47\1\50\1\51\1\52\1\2"+ + "\1\53\1\45\1\54\1\55\1\56\11\54\1\14\1\57"+ + "\1\14\1\60\1\54\1\61\1\62\1\63\2\0\11\54"+ + "\2\0\11\54\1\57\1\0\1\57\1\14\1\54\2\0"+ + "\5\54\1\64\5\54\2\0\1\54\1\65\6\54\1\0"+ + "\1\57\1\14\1\54\1\0\1\66\1\67\2\54\1\64"+ + "\6\54\2\0\6\54\1\70\1\0\1\57\1\14\1\71"+ + "\1\0\5\54\1\72\7\54\2\0\1\73\5\54\1\70"+ + "\1\0\1\57\1\74\2\54\1\75\7\54\1\0\5\54"+ + "\1\0\1\57\6\54\1\0\4\54\1\70\1\0\1\57"+ + "\5\54\1\0\4\54\1\0\1\57\2\54\1\0\2\54"+ + "\1\0\1\57\2\54\1\0\2\54\1\0\1\57\2\54"+ + "\1\76\2\54\1\0\1\77\1\54\1\100\1\54\1\101"; private static int [] zzUnpackAction() { - int[] result = new int[266]; + int [] result = new int[269]; int offset = 0; offset = zzUnpackAction(ZZ_ACTION_PACKED_0, offset, result); return result; @@ -140,43 +140,43 @@ private static int zzUnpackAction(String packed, int offset, int [] result) { private static final int [] ZZ_ROWMAP = zzUnpackRowMap(); private static final String ZZ_ROWMAP_PACKED_0 = - "\0\0\0\72\0\164\0\256\0\350\0\u0122\0\u015c\0\u0196" + - "\0\u01d0\0\u020a\0\u0244\0\u027e\0\u02b8\0\u02f2\0\u032c\0\u0366" + - "\0\u03a0\0\u03da\0\u0414\0\u044e\0\u0488\0\u04c2\0\u04fc\0\u0536" + - "\0\u0570\0\u05aa\0\u05aa\0\u05aa\0\u05aa\0\u05aa\0\u05aa\0\u05e4" + - "\0\u05aa\0\u05aa\0\u061e\0\u05aa\0\u0536\0\u05aa\0\u0658\0\u05aa" + - "\0\u05aa\0\u0692\0\u05aa\0\u06cc\0\u0706\0\u0740\0\u05aa\0\u05aa" + - "\0\u05aa\0\u05aa\0\u077a\0\u05aa\0\u05aa\0\u05aa\0\u05aa\0\u05aa" + - "\0\u05aa\0\u05aa\0\u07b4\0\u05aa\0\u05aa\0\u05aa\0\u05aa\0\u07ee" + - "\0\u05aa\0\u05aa\0\u0828\0\u0862\0\u05aa\0\u089c\0\u08d6\0\u0910" + - "\0\u05aa\0\u05aa\0\u05aa\0\u094a\0\u0984\0\u09be\0\u09f8\0\u0a32" + - "\0\u0a6c\0\u0aa6\0\u0ae0\0\u0b1a\0\u0b54\0\u0b8e\0\u0bc8\0\u05aa" + - "\0\u0c02\0\u05aa\0\u05aa\0\u05aa\0\u0c3c\0\u0c76\0\u0cb0\0\u0cea" + - "\0\u0d24\0\u0d5e\0\u0d98\0\u0dd2\0\u0e0c\0\u0e46\0\u0e80\0\u0eba" + - "\0\u0ef4\0\u0f2e\0\u0f68\0\u0fa2\0\u0fdc\0\u1016\0\u1050\0\u108a" + - "\0\u10c4\0\u10fe\0\u1138\0\u1172\0\u11ac\0\u11e6\0\u1220\0\u125a" + - "\0\u1294\0\u12ce\0\u1308\0\u1342\0\u137c\0\u13b6\0\u09be\0\u13f0" + - "\0\u142a\0\u1464\0\u149e\0\u14d8\0\u1512\0\u154c\0\u1586\0\u09be" + - "\0\u15c0\0\u15fa\0\u1634\0\u166e\0\u16a8\0\u16e2\0\u171c\0\u1756" + - "\0\u1790\0\u17ca\0\u1804\0\u05aa\0\u09be\0\u183e\0\u1878\0\u18b2" + - "\0\u18ec\0\u1926\0\u1960\0\u199a\0\u19d4\0\u1a0e\0\u1a48\0\u1a82" + - "\0\u1abc\0\u1af6\0\u1b30\0\u1b6a\0\u1ba4\0\u1bde\0\u1c18\0\u1c52" + - "\0\u1c8c\0\u1cc6\0\u09be\0\u1d00\0\u1d3a\0\u1d74\0\u1dae\0\u1de8" + - "\0\u1e22\0\u09be\0\u1e5c\0\u1e96\0\u1ed0\0\u1f0a\0\u1f44\0\u1f7e" + - "\0\u1fb8\0\u1ff2\0\u202c\0\u09be\0\u2066\0\u20a0\0\u20da\0\u2114" + - "\0\u214e\0\u05aa\0\u2188\0\u21c2\0\u05aa\0\u21fc\0\u2236\0\u09be" + - "\0\u2270\0\u22aa\0\u22e4\0\u231e\0\u2358\0\u2392\0\u23cc\0\u2406" + - "\0\u2440\0\u247a\0\u24b4\0\u24ee\0\u2528\0\u2562\0\u259c\0\u25d6" + - "\0\u2610\0\u264a\0\u2684\0\u26be\0\u26f8\0\u2732\0\u276c\0\u27a6" + - "\0\u27e0\0\u281a\0\u09be\0\u2854\0\u288e\0\u28c8\0\u2902\0\u293c" + - "\0\u2976\0\u29b0\0\u29ea\0\u2a24\0\u2a5e\0\u2a98\0\u2ad2\0\u2b0c" + - "\0\u2b46\0\u2b80\0\u2bba\0\u2bf4\0\u2c2e\0\u2c68\0\u2ca2\0\u2cdc" + - "\0\u2d16\0\u2d50\0\u2d8a\0\u2dc4\0\u2dfe\0\u2e38\0\u2e72\0\u2eac" + - "\0\u2ee6\0\u2f20\0\u2f5a\0\u2f94\0\u2fce\0\u3008\0\u3042\0\u05aa" + - "\0\u307c\0\u09be"; + "\0\0\0\74\0\170\0\264\0\360\0\u012c\0\u0168\0\u01a4"+ + "\0\u01e0\0\u021c\0\u0258\0\u0294\0\u02d0\0\u030c\0\u0348\0\u0384"+ + "\0\u03c0\0\u03fc\0\u0438\0\u0474\0\u04b0\0\u04ec\0\u0528\0\u0564"+ + "\0\u05a0\0\u05dc\0\u05dc\0\u05dc\0\u05dc\0\u05dc\0\u05dc\0\u0618"+ + "\0\u05dc\0\u05dc\0\u0654\0\u05dc\0\u0564\0\u05dc\0\u0690\0\u0690"+ + "\0\u05dc\0\u05dc\0\u05dc\0\u05dc\0\u06cc\0\u05dc\0\u0708\0\u0744"+ + "\0\u0780\0\u05dc\0\u05dc\0\u05dc\0\u05dc\0\u07bc\0\u05dc\0\u05dc"+ + "\0\u05dc\0\u05dc\0\u05dc\0\u05dc\0\u05dc\0\u07f8\0\u05dc\0\u05dc"+ + "\0\u05dc\0\u05dc\0\u0834\0\u05dc\0\u05dc\0\u0870\0\u08ac\0\u05dc"+ + "\0\u08e8\0\u0924\0\u0960\0\u05dc\0\u05dc\0\u05dc\0\u099c\0\u09d8"+ + "\0\u0a14\0\u0a50\0\u0a8c\0\u0ac8\0\u0b04\0\u0b40\0\u0b7c\0\u0bb8"+ + "\0\u0bf4\0\u0c30\0\u05dc\0\u0c6c\0\u05dc\0\u05dc\0\u05dc\0\u0ca8"+ + "\0\u0ce4\0\u0d20\0\u0d5c\0\u0d98\0\u0dd4\0\u0e10\0\u0e4c\0\u0e88"+ + "\0\u0ec4\0\u0f00\0\u0f3c\0\u0f78\0\u0fb4\0\u0ff0\0\u102c\0\u1068"+ + "\0\u10a4\0\u10e0\0\u111c\0\u1158\0\u1194\0\u11d0\0\u120c\0\u1248"+ + "\0\u1284\0\u12c0\0\u12fc\0\u1338\0\u1374\0\u13b0\0\u13ec\0\u1428"+ + "\0\u1464\0\u0a14\0\u14a0\0\u14dc\0\u1518\0\u1554\0\u1590\0\u15cc"+ + "\0\u1608\0\u1644\0\u0a14\0\u1680\0\u16bc\0\u16f8\0\u1734\0\u1770"+ + "\0\u17ac\0\u17e8\0\u1824\0\u1860\0\u189c\0\u18d8\0\u05dc\0\u0a14"+ + "\0\u1914\0\u1950\0\u198c\0\u19c8\0\u1a04\0\u1a40\0\u1a7c\0\u1ab8"+ + "\0\u1af4\0\u1b30\0\u1b6c\0\u1ba8\0\u1be4\0\u1c20\0\u1c5c\0\u1c98"+ + "\0\u1cd4\0\u1d10\0\u1d4c\0\u1d88\0\u1dc4\0\u0a14\0\u1e00\0\u1e3c"+ + "\0\u1e78\0\u1eb4\0\u1ef0\0\u1f2c\0\u0a14\0\u1f68\0\u1fa4\0\u1fe0"+ + "\0\u201c\0\u2058\0\u2094\0\u20d0\0\u210c\0\u2148\0\u0a14\0\u2184"+ + "\0\u21c0\0\u21fc\0\u2238\0\u2274\0\u05dc\0\u22b0\0\u22ec\0\u05dc"+ + "\0\u2328\0\u2364\0\u0a14\0\u23a0\0\u23dc\0\u2418\0\u2454\0\u2490"+ + "\0\u24cc\0\u2508\0\u2544\0\u2580\0\u25bc\0\u25f8\0\u2634\0\u2670"+ + "\0\u26ac\0\u26e8\0\u2724\0\u2760\0\u279c\0\u27d8\0\u2814\0\u2850"+ + "\0\u288c\0\u28c8\0\u2904\0\u2940\0\u297c\0\u0a14\0\u29b8\0\u29f4"+ + "\0\u2a30\0\u2a6c\0\u2aa8\0\u2ae4\0\u2b20\0\u2b5c\0\u2b98\0\u2bd4"+ + "\0\u2c10\0\u2c4c\0\u2c88\0\u2cc4\0\u2d00\0\u2d3c\0\u2d78\0\u2db4"+ + "\0\u2df0\0\u2e2c\0\u2e68\0\u2ea4\0\u2ee0\0\u2f1c\0\u2f58\0\u2f94"+ + "\0\u2fd0\0\u300c\0\u3048\0\u3084\0\u30c0\0\u30fc\0\u3138\0\u3174"+ + "\0\u31b0\0\u31ec\0\u05dc\0\u3228\0\u0a14"; private static int [] zzUnpackRowMap() { - int[] result = new int[266]; + int [] result = new int[269]; int offset = 0; offset = zzUnpackRowMap(ZZ_ROWMAP_PACKED_0, offset, result); return result; @@ -199,391 +199,395 @@ private static int zzUnpackRowMap(String packed, int offset, int [] result) { private static final int [] ZZ_TRANS = zzUnpackTrans(); private static final String ZZ_TRANS_PACKED_0 = - "\1\30\1\31\1\32\1\33\1\34\1\35\1\36\1\37" + - "\1\40\7\30\3\40\1\41\10\30\1\42\1\40\3\30" + - "\1\43\2\30\1\44\1\30\1\41\1\42\13\30\1\45" + - "\2\30\1\46\1\47\1\50\1\51\1\30\1\52\1\32" + - "\1\33\1\34\1\35\1\36\1\37\1\40\7\30\3\40" + - "\1\41\10\30\1\42\1\40\3\30\1\43\2\30\1\44" + - "\1\30\1\41\1\42\13\30\1\45\2\30\1\53\1\47" + - "\1\50\1\51\1\30\1\54\1\32\1\33\1\34\1\35" + - "\1\36\1\37\1\40\7\30\3\40\1\41\10\30\1\42" + - "\1\40\3\30\1\43\2\30\1\44\1\30\1\41\1\42" + - "\13\30\1\45\2\30\1\41\1\47\1\50\1\51\1\30" + - "\1\55\1\32\1\33\1\34\1\35\1\36\1\37\1\40" + - "\7\30\3\40\1\41\10\30\1\42\1\40\3\30\1\43" + - "\2\30\1\44\1\30\1\41\1\42\13\30\1\45\2\30" + - "\1\46\1\47\1\50\1\51\1\30\1\56\1\32\1\33" + - "\1\34\1\35\1\36\1\57\1\40\7\30\3\40\1\41" + - "\10\30\1\42\1\40\3\30\1\43\2\30\1\44\1\30" + - "\1\41\1\42\13\30\1\45\2\30\1\60\1\47\1\50" + - "\1\51\1\30\1\56\1\32\1\33\1\34\1\35\1\36" + - "\1\37\1\40\7\30\3\40\1\41\10\30\1\42\1\40" + - "\3\30\1\43\2\30\1\44\1\30\1\41\1\42\13\30" + - "\1\45\2\30\1\53\1\47\1\50\1\51\1\30\1\56" + - "\1\32\1\33\1\34\1\35\1\36\1\57\1\40\7\30" + - "\3\40\1\41\10\30\1\42\1\40\3\30\1\43\2\30" + - "\1\44\1\30\1\41\1\42\13\30\1\45\2\30\1\61" + - "\1\47\1\50\1\51\1\30\1\56\1\32\1\33\1\34" + - "\1\35\1\36\1\62\1\40\7\30\3\40\1\41\10\30" + - "\1\42\1\40\3\30\1\43\2\30\1\44\1\30\1\41" + - "\1\42\13\30\1\45\2\30\1\41\1\47\1\50\1\51" + - "\1\30\1\63\1\32\1\33\1\34\1\35\1\64\1\65" + - "\1\40\7\30\3\40\1\41\10\30\1\42\1\40\3\30" + - "\1\43\2\30\1\44\1\30\1\41\1\42\13\30\1\45" + - "\2\30\1\61\1\47\1\50\1\51\1\30\1\56\1\32" + - "\1\33\1\34\1\35\1\66\1\37\1\40\7\30\3\40" + - "\1\41\10\30\1\42\1\40\3\30\1\43\2\30\1\44" + - "\1\30\1\41\1\42\13\30\1\45\2\30\1\41\1\47" + - "\1\50\1\51\1\30\1\63\1\32\1\33\1\34\1\35" + - "\1\64\1\67\1\40\7\30\3\40\1\41\10\30\1\42" + - "\1\40\3\30\1\43\2\30\1\44\1\30\1\41\1\42" + - "\13\30\1\45\2\30\1\61\1\47\1\50\1\51\6\70" + - "\1\71\63\70\72\72\1\73\1\56\1\32\1\33\1\34" + - "\1\35\1\36\1\57\1\40\7\73\3\40\1\41\10\73" + - "\1\42\1\40\3\73\1\43\2\73\1\44\1\73\1\41" + - "\1\42\16\73\1\41\1\47\1\50\1\51\1\30\1\56" + - "\1\32\1\33\1\74\1\75\1\36\1\37\1\40\7\30" + - "\3\40\1\41\10\30\1\42\1\40\3\30\1\43\2\30" + - "\1\44\1\30\1\41\1\42\13\30\1\45\2\30\1\41" + - "\1\47\1\50\1\51\1\30\1\56\1\32\1\33\1\34" + - "\1\35\1\36\1\76\1\40\7\30\3\40\1\41\10\30" + - "\1\42\1\40\3\30\1\43\2\30\1\44\1\30\1\41" + - "\1\42\13\30\1\45\2\30\1\41\1\47\1\50\1\51" + - "\1\30\1\56\1\32\1\33\1\34\1\35\1\36\1\37" + - "\1\40\7\30\3\40\1\41\10\30\1\42\1\40\3\30" + - "\1\43\2\30\1\44\1\30\1\41\1\42\13\30\1\45" + - "\2\30\1\41\1\47\1\50\1\51\1\77\1\100\6\77" + - "\1\40\7\77\3\40\12\77\1\40\34\77\4\101\1\102" + - "\3\101\1\103\7\101\3\103\12\101\1\103\34\101\1\104" + - "\5\105\1\36\2\105\7\104\4\105\10\104\2\105\3\104" + - "\1\105\2\104\1\105\1\104\2\105\16\104\4\105\1\30" + - "\1\106\1\32\1\33\1\34\1\35\1\36\1\37\1\40" + - "\7\30\3\40\1\41\10\30\1\42\1\40\3\30\1\43" + - "\2\30\1\44\1\30\1\41\1\42\13\30\1\45\2\30" + - "\1\46\1\47\1\50\1\51\1\107\1\56\1\32\1\33" + - "\1\34\1\35\1\36\1\37\1\40\7\107\3\40\1\41" + - "\10\107\1\42\1\40\3\107\1\43\2\107\1\44\1\107" + - "\1\41\1\42\16\107\1\41\1\47\1\50\1\51\41\77" + - "\1\110\30\77\1\30\10\0\7\30\4\0\10\30\2\0" + - "\3\30\1\0\2\30\1\0\1\30\2\0\16\30\4\0" + - "\2\111\1\112\1\111\1\113\4\111\1\114\1\115\2\116" + - "\1\117\1\120\1\116\1\0\1\111\2\0\1\121\6\116" + - "\1\122\2\111\3\116\1\111\2\116\1\111\1\116\2\111" + - "\2\116\1\123\7\116\1\124\1\111\2\116\4\111\102\0" + - "\1\40\7\0\3\40\12\0\1\40\34\0\20\125\2\0" + - "\12\125\1\126\1\127\34\125\6\0\1\130\63\0\4\111" + - "\1\113\4\111\1\114\1\115\2\116\1\117\1\120\1\116" + - "\1\0\1\111\2\0\1\121\2\116\1\131\3\116\1\122" + - "\2\111\3\116\1\111\2\116\1\111\1\116\2\111\2\116" + - "\1\123\7\116\1\124\1\111\2\116\7\111\1\53\1\113" + - "\4\111\1\114\1\115\2\116\1\117\1\120\1\116\1\0" + - "\1\111\2\0\1\121\6\116\1\122\2\111\3\116\1\111" + - "\2\116\1\111\1\116\2\111\2\116\1\123\7\116\1\124" + - "\1\111\2\116\6\111\1\112\1\111\1\113\1\132\3\111" + - "\1\114\1\115\2\116\1\117\1\120\1\116\1\0\1\111" + - "\2\0\1\121\6\116\1\122\2\111\3\116\1\111\2\116" + - "\1\111\1\116\2\111\2\116\1\123\7\116\1\124\1\111" + - "\2\116\10\111\1\113\4\111\1\114\1\115\2\116\1\117" + - "\1\120\1\116\1\0\1\111\2\0\1\121\6\116\1\122" + - "\2\111\3\116\1\111\2\116\1\111\1\116\2\111\2\116" + - "\1\123\7\116\1\124\1\111\2\116\10\111\1\133\1\134" + - "\3\111\1\114\1\115\2\116\1\117\1\120\1\116\1\0" + - "\1\111\2\0\1\121\6\116\1\122\2\111\3\116\1\111" + - "\2\116\1\111\1\116\2\111\2\116\1\123\7\116\1\124" + - "\1\111\2\116\4\111\1\73\10\0\7\73\4\0\10\73" + - "\2\0\3\73\1\0\2\73\1\0\1\73\2\0\16\73" + - "\15\0\1\135\1\136\67\0\1\103\7\0\3\103\12\0" + - "\1\103\34\0\1\104\10\0\7\104\4\0\10\104\2\0" + - "\3\104\1\0\2\104\1\0\1\104\2\0\16\104\4\0" + - "\2\111\1\112\1\111\1\113\4\111\1\114\1\137\2\116" + - "\1\117\1\120\1\116\1\0\1\111\2\0\1\121\6\116" + - "\1\122\2\111\1\116\1\140\1\116\1\111\2\116\1\111" + - "\1\116\2\111\1\141\1\116\1\123\1\142\1\143\1\144" + - "\1\145\1\116\1\146\1\147\1\124\1\111\2\116\4\111" + - "\1\107\10\0\7\107\4\0\10\107\2\0\3\107\1\0" + - "\2\107\1\0\1\107\2\0\16\107\40\0\1\150\1\151" + - "\45\0\1\116\1\152\5\116\4\0\10\116\2\0\3\116" + - "\1\0\2\116\1\0\1\116\2\0\13\116\1\0\2\116" + - "\15\0\4\116\1\153\2\116\4\0\10\116\2\0\3\116" + - "\1\0\2\116\1\0\1\116\2\0\13\116\1\0\2\116" + - "\15\0\7\116\4\0\10\116\2\0\3\116\1\0\2\116" + - "\1\0\1\116\2\0\13\116\1\0\2\116\15\0\1\116" + - "\1\154\5\116\4\0\10\116\2\0\3\116\1\0\2\116" + - "\1\0\1\116\2\0\13\116\1\0\2\116\15\0\3\116" + - "\1\155\3\116\4\0\10\116\2\0\3\116\1\0\2\116" + - "\1\0\1\116\2\0\13\116\1\0\2\116\15\0\3\116" + - "\1\156\3\116\4\0\10\116\2\0\3\116\1\0\2\116" + - "\1\0\1\116\2\0\13\116\1\0\2\116\15\0\1\116" + - "\1\157\5\116\4\0\10\116\2\0\3\116\1\0\2\116" + - "\1\0\1\116\2\0\13\116\1\0\2\116\15\0\7\116" + - "\4\0\10\116\2\0\3\116\1\0\1\116\1\160\1\0" + - "\1\116\2\0\7\116\1\161\3\116\1\0\2\116\15\0" + - "\1\116\1\162\5\116\4\0\10\116\2\0\3\116\1\0" + - "\2\116\1\0\1\116\2\0\13\116\1\0\2\116\4\0" + - "\20\125\2\0\50\125\10\163\1\126\7\163\2\164\1\126" + - "\12\163\1\126\4\163\1\165\27\163\20\125\2\0\12\125" + - "\1\166\35\125\11\0\1\116\1\167\5\116\4\0\10\116" + - "\2\0\3\116\1\0\2\116\1\0\1\116\2\0\13\116" + - "\1\0\2\116\16\0\1\170\74\0\1\171\65\0\4\116" + - "\1\172\2\116\4\0\10\116\2\0\3\116\1\0\2\116" + - "\1\0\1\116\2\0\13\116\1\0\2\116\15\0\4\116" + - "\1\173\2\116\4\0\10\116\2\0\3\116\1\0\2\116" + - "\1\0\1\116\2\0\2\116\1\174\10\116\1\0\2\116" + - "\15\0\7\116\4\0\10\116\2\0\3\116\1\0\2\116" + - "\1\0\1\175\2\0\7\116\1\176\3\116\1\0\2\116" + - "\15\0\7\116\4\0\1\116\1\177\6\116\2\0\3\116" + - "\1\0\2\116\1\0\1\116\2\0\13\116\1\0\2\116" + - "\15\0\7\116\4\0\5\116\1\200\2\116\2\0\3\116" + - "\1\0\2\116\1\0\1\116\2\0\13\116\1\0\2\116" + - "\15\0\1\116\1\201\5\116\4\0\10\116\2\0\3\116" + - "\1\0\2\116\1\0\1\116\2\0\13\116\1\0\2\116" + - "\15\0\7\116\4\0\10\116\2\0\3\116\1\0\2\116" + - "\1\0\1\202\2\0\13\116\1\0\2\116\15\0\7\116" + - "\4\0\7\116\1\203\2\0\3\116\1\0\2\116\1\0" + - "\1\116\2\0\13\116\1\0\2\116\15\0\4\116\1\204" + - "\2\116\4\0\10\116\2\0\3\116\1\0\2\116\1\0" + - "\1\116\2\0\13\116\1\0\2\116\14\0\1\150\7\0" + - "\3\150\12\0\1\150\4\0\1\205\63\0\1\206\46\0" + - "\2\116\1\207\4\116\4\0\10\116\2\0\3\116\1\0" + - "\2\116\1\0\1\116\2\0\13\116\1\0\2\116\15\0" + - "\5\116\1\210\1\116\4\0\10\116\2\0\3\116\1\0" + - "\2\116\1\0\1\116\2\0\13\116\1\0\2\116\15\0" + - "\7\116\4\0\10\116\2\0\3\116\1\0\2\116\1\0" + - "\1\116\2\0\13\116\1\0\1\211\1\116\15\0\7\116" + - "\4\0\7\116\1\212\2\0\3\116\1\0\2\116\1\0" + - "\1\116\2\0\13\116\1\0\2\116\15\0\7\116\4\0" + - "\1\116\1\213\6\116\2\0\3\116\1\0\2\116\1\0" + - "\1\116\2\0\13\116\1\0\2\116\15\0\4\116\1\117" + - "\2\116\4\0\10\116\2\0\3\116\1\0\2\116\1\0" + - "\1\116\2\0\13\116\1\0\2\116\15\0\7\116\4\0" + - "\3\116\1\214\4\116\2\0\3\116\1\0\2\116\1\0" + - "\1\116\2\0\13\116\1\0\2\116\15\0\7\116\4\0" + - "\6\116\1\215\1\116\2\0\3\116\1\0\2\116\1\0" + - "\1\116\2\0\13\116\1\0\2\116\15\0\7\116\4\0" + - "\7\116\1\216\2\0\3\116\1\0\2\116\1\0\1\116" + - "\2\0\13\116\1\0\2\116\4\0\20\163\2\0\50\163" + - "\10\0\1\164\7\0\3\164\12\0\1\164\4\0\1\217" + - "\27\0\20\163\2\0\10\163\1\220\37\163\20\125\2\0" + - "\5\125\1\221\6\125\1\221\33\125\11\0\7\116\4\0" + - "\2\116\1\222\5\116\2\0\3\116\1\0\2\116\1\0" + - "\1\116\2\0\13\116\1\0\2\116\17\0\1\223\74\0" + - "\1\224\64\0\5\116\1\225\1\116\4\0\10\116\2\0" + - "\3\116\1\0\2\116\1\0\1\116\2\0\13\116\1\0" + - "\2\116\15\0\5\116\1\226\1\116\4\0\10\116\2\0" + - "\3\116\1\0\2\116\1\0\1\116\2\0\13\116\1\0" + - "\2\116\15\0\7\116\4\0\10\116\2\0\3\116\1\0" + - "\1\116\1\227\1\0\1\116\2\0\13\116\1\0\2\116" + - "\15\0\7\116\4\0\7\116\1\230\2\0\3\116\1\0" + - "\2\116\1\0\1\116\2\0\13\116\1\0\2\116\15\0" + - "\4\116\1\231\2\116\4\0\10\116\2\0\3\116\1\0" + - "\2\116\1\0\1\116\2\0\13\116\1\0\2\116\15\0" + - "\3\116\1\232\3\116\4\0\10\116\2\0\3\116\1\0" + - "\2\116\1\0\1\116\2\0\13\116\1\0\2\116\15\0" + - "\7\116\4\0\10\116\2\0\3\116\1\0\1\233\1\116" + - "\1\0\1\116\2\0\13\116\1\0\2\116\15\0\7\116" + - "\4\0\10\116\2\0\3\116\1\0\2\116\1\0\1\234" + - "\2\0\13\116\1\0\2\116\15\0\7\116\4\0\10\116" + - "\2\0\3\116\1\0\2\116\1\0\1\235\2\0\13\116" + - "\1\0\2\116\15\0\7\116\4\0\3\116\1\236\4\116" + - "\2\0\3\116\1\0\2\116\1\0\1\116\2\0\13\116" + - "\1\0\2\116\36\0\1\237\66\0\1\240\6\0\1\240" + - "\44\0\3\116\1\241\3\116\4\0\10\116\2\0\3\116" + - "\1\0\2\116\1\0\1\116\2\0\13\116\1\0\2\116" + - "\15\0\1\116\1\242\5\116\4\0\10\116\2\0\3\116" + - "\1\0\2\116\1\0\1\116\2\0\13\116\1\0\2\116" + - "\15\0\1\116\1\243\5\116\4\0\10\116\2\0\3\116" + - "\1\0\2\116\1\0\1\116\2\0\13\116\1\0\2\116" + - "\15\0\4\116\1\244\2\116\4\0\10\116\2\0\3\116" + - "\1\0\2\116\1\0\1\116\2\0\13\116\1\0\2\116" + - "\15\0\3\116\1\245\3\116\4\0\10\116\2\0\3\116" + - "\1\0\2\116\1\0\1\116\2\0\13\116\1\0\2\116" + - "\15\0\1\116\1\246\5\116\4\0\10\116\2\0\3\116" + - "\1\0\2\116\1\0\1\116\2\0\13\116\1\0\2\116" + - "\15\0\1\247\6\116\4\0\10\116\2\0\3\116\1\0" + - "\2\116\1\0\1\116\2\0\13\116\1\0\2\116\36\0" + - "\1\250\37\0\20\163\2\0\11\163\1\251\36\163\12\125" + - "\1\252\5\125\2\0\15\125\1\252\32\125\11\0\7\116" + - "\4\0\3\116\1\253\4\116\2\0\3\116\1\0\2\116" + - "\1\0\1\116\2\0\13\116\1\0\2\116\20\0\1\254" + - "\66\0\7\116\4\0\10\116\2\0\3\116\1\0\2\116" + - "\1\0\1\116\2\0\1\255\2\116\1\256\1\257\1\116" + - "\1\260\1\116\1\261\2\116\1\0\2\116\15\0\1\116" + - "\1\262\5\116\4\0\10\116\2\0\3\116\1\0\2\116" + - "\1\0\1\116\2\0\3\116\1\263\7\116\1\0\2\116" + - "\15\0\7\116\4\0\10\116\2\0\3\116\1\0\2\116" + - "\1\0\1\116\2\0\1\116\1\264\11\116\1\0\2\116" + - "\15\0\7\116\4\0\4\116\1\265\3\116\2\0\3\116" + - "\1\0\2\116\1\0\1\116\2\0\13\116\1\0\2\116" + - "\15\0\7\116\4\0\10\116\2\0\3\116\1\0\2\116" + - "\1\0\1\116\2\0\2\116\1\266\10\116\1\0\2\116" + - "\15\0\1\116\1\267\5\116\4\0\10\116\2\0\3\116" + - "\1\0\2\116\1\0\1\116\2\0\13\116\1\0\2\116" + - "\15\0\7\116\4\0\10\116\2\0\3\116\1\0\1\177" + - "\1\116\1\0\1\116\2\0\13\116\1\0\2\116\15\0" + - "\7\116\4\0\4\116\1\270\3\116\2\0\3\116\1\0" + - "\2\116\1\0\1\116\2\0\13\116\1\0\2\116\15\0" + - "\3\116\1\271\3\116\4\0\10\116\2\0\3\116\1\0" + - "\2\116\1\0\1\116\2\0\13\116\1\0\2\116\37\0" + - "\1\272\50\0\1\273\24\0\1\273\43\0\4\116\1\274" + - "\2\116\4\0\10\116\2\0\3\116\1\0\2\116\1\0" + - "\1\116\2\0\13\116\1\0\2\116\15\0\4\116\1\275" + - "\2\116\4\0\10\116\2\0\3\116\1\0\2\116\1\0" + - "\1\116\2\0\13\116\1\0\2\116\15\0\7\116\4\0" + - "\4\116\1\276\3\116\2\0\3\116\1\0\2\116\1\0" + - "\1\116\2\0\13\116\1\0\2\116\15\0\1\116\1\277" + - "\5\116\4\0\10\116\2\0\3\116\1\0\2\116\1\0" + - "\1\116\2\0\13\116\1\0\2\116\15\0\4\116\1\300" + - "\2\116\4\0\10\116\2\0\3\116\1\0\2\116\1\0" + - "\1\116\2\0\13\116\1\0\2\116\15\0\7\116\4\0" + - "\2\116\1\301\5\116\2\0\3\116\1\0\2\116\1\0" + - "\1\116\2\0\13\116\1\0\2\116\15\0\7\116\4\0" + - "\10\116\2\0\3\116\1\0\2\116\1\0\1\116\2\0" + - "\13\116\1\302\2\116\37\0\1\303\36\0\20\163\2\0" + - "\21\163\1\304\26\163\20\125\2\0\4\125\1\126\11\125" + - "\1\126\31\125\15\0\1\305\65\0\7\116\4\0\10\116" + - "\2\0\3\116\1\0\2\116\1\0\1\306\2\0\7\116" + - "\1\307\3\116\1\0\2\116\15\0\7\116\4\0\1\116" + - "\1\310\6\116\2\0\3\116\1\0\2\116\1\0\1\116" + - "\2\0\13\116\1\0\2\116\15\0\7\116\4\0\5\116" + - "\1\311\2\116\2\0\3\116\1\0\2\116\1\0\1\116" + - "\2\0\13\116\1\0\2\116\15\0\7\116\4\0\10\116" + - "\2\0\3\116\1\0\2\116\1\0\1\312\2\0\13\116" + - "\1\0\2\116\15\0\7\116\4\0\7\116\1\313\2\0" + - "\3\116\1\0\2\116\1\0\1\116\2\0\13\116\1\0" + - "\2\116\15\0\7\116\4\0\1\116\1\262\6\116\2\0" + - "\3\116\1\0\2\116\1\0\1\116\2\0\13\116\1\0" + - "\2\116\15\0\7\116\4\0\10\116\2\0\3\116\1\0" + - "\2\116\1\0\1\116\2\0\2\116\1\314\10\116\1\0" + - "\2\116\15\0\7\116\4\0\3\116\1\315\4\116\2\0" + - "\3\116\1\0\2\116\1\0\1\116\2\0\13\116\1\0" + - "\2\116\15\0\1\116\1\177\5\116\4\0\10\116\2\0" + - "\3\116\1\0\2\116\1\0\1\116\2\0\13\116\1\0" + - "\2\116\15\0\7\116\4\0\6\116\1\316\1\116\2\0" + - "\3\116\1\0\2\116\1\0\1\116\2\0\13\116\1\0" + - "\2\116\15\0\1\116\1\317\5\116\4\0\10\116\2\0" + - "\3\116\1\0\2\116\1\0\1\116\2\0\13\116\1\0" + - "\2\116\15\0\7\116\4\0\10\116\2\0\3\116\1\0" + - "\2\116\1\0\1\116\2\0\2\116\1\310\10\116\1\0" + - "\2\116\47\0\1\320\54\0\1\150\11\0\1\150\42\0" + - "\7\116\4\0\10\116\2\0\3\116\1\0\2\116\1\0" + - "\1\116\2\0\12\116\1\321\1\0\2\116\15\0\7\116" + - "\4\0\3\116\1\322\4\116\2\0\3\116\1\0\2\116" + - "\1\0\1\116\2\0\13\116\1\0\2\116\15\0\7\116" + - "\4\0\2\116\1\323\5\116\2\0\3\116\1\0\2\116" + - "\1\0\1\116\2\0\13\116\1\0\2\116\15\0\7\116" + - "\4\0\10\116\2\0\3\116\1\0\2\116\1\0\1\116" + - "\2\0\2\116\1\324\10\116\1\0\2\116\15\0\1\116" + - "\1\325\5\116\4\0\10\116\2\0\3\116\1\0\2\116" + - "\1\0\1\116\2\0\13\116\1\0\2\116\47\0\1\326" + - "\26\0\12\163\1\327\5\163\2\0\50\163\11\0\7\116" + - "\4\0\7\116\1\310\2\0\3\116\1\0\2\116\1\0" + - "\1\116\2\0\13\116\1\0\2\116\15\0\4\116\1\330" + - "\2\116\4\0\10\116\2\0\3\116\1\0\2\116\1\0" + - "\1\116\2\0\13\116\1\0\2\116\15\0\3\116\1\331" + - "\3\116\4\0\10\116\2\0\3\116\1\0\2\116\1\0" + - "\1\116\2\0\13\116\1\0\2\116\15\0\7\116\4\0" + - "\10\116\2\0\3\116\1\0\2\116\1\0\1\332\2\0" + - "\13\116\1\0\2\116\15\0\7\116\4\0\10\116\2\0" + - "\3\116\1\0\2\116\1\0\1\333\2\0\13\116\1\0" + - "\2\116\15\0\7\116\4\0\10\116\2\0\3\116\1\0" + - "\2\116\1\0\1\116\2\0\2\116\1\177\10\116\1\0" + - "\2\116\15\0\3\116\1\334\3\116\4\0\10\116\2\0" + - "\3\116\1\0\2\116\1\0\1\116\2\0\13\116\1\0" + - "\2\116\15\0\7\116\4\0\3\116\1\177\4\116\2\0" + - "\3\116\1\0\2\116\1\0\1\116\2\0\13\116\1\0" + - "\2\116\15\0\5\116\1\335\1\116\4\0\10\116\2\0" + - "\3\116\1\0\2\116\1\0\1\116\2\0\13\116\1\0" + - "\2\116\16\0\1\336\70\0\3\116\1\337\3\116\4\0" + - "\10\116\2\0\3\116\1\0\2\116\1\0\1\116\2\0" + - "\13\116\1\0\2\116\15\0\7\116\4\0\10\116\2\0" + - "\3\116\1\0\2\116\1\0\1\116\2\0\2\116\1\340" + - "\10\116\1\0\2\116\15\0\7\116\4\0\3\116\1\341" + - "\4\116\2\0\3\116\1\0\2\116\1\0\1\116\2\0" + - "\13\116\1\0\2\116\15\0\3\116\1\342\3\116\4\0" + - "\10\116\2\0\3\116\1\0\2\116\1\0\1\116\2\0" + - "\13\116\1\0\2\116\15\0\7\116\4\0\4\116\1\343" + - "\3\116\2\0\3\116\1\0\2\116\1\0\1\116\2\0" + - "\13\116\1\0\2\116\16\0\1\344\57\0\20\163\2\0" + - "\11\163\1\345\36\163\11\0\7\116\4\0\4\116\1\346" + - "\3\116\2\0\3\116\1\0\2\116\1\0\1\116\2\0" + - "\13\116\1\0\2\116\15\0\7\116\4\0\10\116\2\0" + - "\3\116\1\0\2\116\1\0\1\116\2\0\2\116\1\347" + - "\10\116\1\0\2\116\15\0\7\116\4\0\10\116\2\0" + - "\3\116\1\0\1\310\1\116\1\0\1\116\2\0\13\116" + - "\1\0\2\116\15\0\7\116\4\0\4\116\1\350\3\116" + - "\2\0\3\116\1\0\2\116\1\0\1\116\2\0\13\116" + - "\1\0\2\116\15\0\7\116\4\0\10\116\2\0\3\116" + - "\1\0\2\116\1\0\1\351\2\0\13\116\1\0\2\116" + - "\15\0\7\116\4\0\10\116\2\0\3\116\1\0\2\116" + - "\1\0\1\116\2\0\7\116\1\352\3\116\1\0\2\116" + - "\37\0\1\353\47\0\7\116\4\0\7\116\1\354\2\0" + - "\3\116\1\0\2\116\1\0\1\116\2\0\13\116\1\0" + - "\2\116\15\0\7\116\4\0\10\116\2\0\3\116\1\0" + - "\2\116\1\0\1\116\2\0\7\116\1\355\3\116\1\0" + - "\2\116\15\0\7\116\4\0\4\116\1\356\3\116\2\0" + - "\3\116\1\0\2\116\1\0\1\116\2\0\13\116\1\0" + - "\2\116\15\0\4\116\1\357\2\116\4\0\10\116\2\0" + - "\3\116\1\0\2\116\1\0\1\116\2\0\13\116\1\0" + - "\2\116\37\0\1\360\36\0\10\163\1\345\7\163\2\360" + - "\1\345\12\163\1\345\6\163\1\361\25\163\11\0\7\116" + - "\4\0\3\116\1\362\4\116\2\0\3\116\1\0\2\116" + - "\1\0\1\116\2\0\13\116\1\0\2\116\15\0\1\116" + - "\1\310\5\116\4\0\10\116\2\0\3\116\1\0\2\116" + - "\1\0\1\116\2\0\13\116\1\0\2\116\15\0\1\116" + - "\1\363\5\116\4\0\10\116\2\0\3\116\1\0\2\116" + - "\1\0\1\116\2\0\13\116\1\0\2\116\15\0\4\116" + - "\1\177\2\116\4\0\10\116\2\0\3\116\1\0\2\116" + - "\1\0\1\116\2\0\13\116\1\0\2\116\15\0\7\116" + - "\4\0\7\116\1\266\2\0\3\116\1\0\2\116\1\0" + - "\1\116\2\0\13\116\1\0\2\116\14\0\1\353\7\0" + - "\3\353\12\0\1\353\6\0\1\364\36\0\7\116\4\0" + - "\10\116\2\0\3\116\1\0\2\116\1\0\1\365\2\0" + - "\13\116\1\0\2\116\15\0\7\116\4\0\6\116\1\343" + - "\1\116\2\0\3\116\1\0\2\116\1\0\1\116\2\0" + - "\13\116\1\0\2\116\15\0\7\116\4\0\5\116\1\366" + - "\2\116\2\0\3\116\1\0\2\116\1\0\1\116\2\0" + - "\13\116\1\0\2\116\15\0\1\116\1\343\5\116\4\0" + - "\10\116\2\0\3\116\1\0\2\116\1\0\1\116\2\0" + - "\13\116\1\0\2\116\14\0\1\360\7\0\3\360\12\0" + - "\1\360\6\0\1\367\25\0\10\163\1\361\7\163\2\367" + - "\1\361\12\163\1\361\7\163\1\370\24\163\11\0\3\116" + - "\1\371\3\116\4\0\10\116\2\0\3\116\1\0\2\116" + - "\1\0\1\116\2\0\13\116\1\0\2\116\15\0\5\116" + - "\1\372\1\116\4\0\10\116\2\0\3\116\1\0\2\116" + - "\1\0\1\116\2\0\13\116\1\0\2\116\14\0\1\364" + - "\7\0\3\364\12\0\1\364\7\0\1\373\35\0\4\116" + - "\1\374\2\116\4\0\10\116\2\0\3\116\1\0\2\116" + - "\1\0\1\116\2\0\13\116\1\0\2\116\15\0\7\116" + - "\4\0\6\116\1\375\1\116\2\0\3\116\1\0\2\116" + - "\1\0\1\116\2\0\13\116\1\0\2\116\14\0\1\367" + - "\7\0\3\367\12\0\1\367\7\0\1\376\24\0\20\163" + - "\2\0\3\163\1\377\44\163\11\0\7\116\4\0\10\116" + - "\2\0\3\116\1\0\2\116\1\0\1\u0100\2\0\13\116" + - "\1\0\2\116\15\0\7\116\4\0\10\116\2\0\3\116" + - "\1\0\2\116\1\0\1\116\2\0\7\116\1\u0101\3\116" + - "\1\0\2\116\21\0\1\u0102\65\0\7\116\4\0\10\116" + - "\2\0\3\116\1\0\2\116\1\0\1\116\2\0\13\116" + - "\1\0\1\116\1\u0103\15\0\7\116\4\0\7\116\1\u0104" + - "\2\0\3\116\1\0\2\116\1\0\1\116\2\0\13\116" + - "\1\0\2\116\31\0\1\u0105\44\0\20\163\2\0\3\163" + - "\1\u0106\44\163\11\0\4\116\1\310\2\116\4\0\10\116" + - "\2\0\3\116\1\0\2\116\1\0\1\116\2\0\13\116" + - "\1\0\2\116\15\0\7\116\4\0\7\116\1\347\2\0" + - "\3\116\1\0\2\116\1\0\1\116\2\0\13\116\1\0" + - "\2\116\4\0\20\u0102\2\0\50\u0102\11\0\1\116\1\u0107" + - "\5\116\4\0\10\116\2\0\3\116\1\0\2\116\1\0" + - "\1\116\2\0\13\116\1\0\2\116\4\0\11\u0108\7\116" + - "\4\0\10\116\2\u0108\3\116\1\u0108\2\116\1\u0108\1\116" + - "\2\u0108\13\116\1\u0108\2\116\4\u0108\25\0\1\u0106\44\0" + - "\20\u0106\2\0\50\u0106\11\0\4\116\1\u0109\2\116\4\0" + - "\10\116\2\0\3\116\1\0\2\116\1\0\1\116\2\0" + - "\13\116\1\0\2\116\15\0\7\116\4\0\3\116\1\u010a" + - "\4\116\2\0\3\116\1\0\2\116\1\0\1\116\2\0" + - "\13\116\1\0\2\116\4\0"; + "\1\30\1\31\1\32\1\33\1\34\1\35\1\36\1\37"+ + "\1\40\7\30\3\40\1\41\10\30\1\42\1\40\3\30"+ + "\1\43\2\30\1\44\1\30\1\41\13\30\1\45\2\30"+ + "\1\46\1\47\1\50\1\51\1\52\1\53\1\54\1\30"+ + "\1\55\1\32\1\33\1\34\1\35\1\36\1\37\1\40"+ + "\7\30\3\40\1\41\10\30\1\42\1\40\3\30\1\43"+ + "\2\30\1\44\1\30\1\41\13\30\1\45\2\30\1\56"+ + "\1\47\1\50\1\51\1\52\1\53\1\54\1\30\1\57"+ + "\1\32\1\33\1\34\1\35\1\36\1\37\1\40\7\30"+ + "\3\40\1\41\10\30\1\42\1\40\3\30\1\43\2\30"+ + "\1\44\1\30\1\41\13\30\1\45\2\30\1\41\1\47"+ + "\1\50\1\51\1\52\1\53\1\54\1\30\1\60\1\32"+ + "\1\33\1\34\1\35\1\36\1\37\1\40\7\30\3\40"+ + "\1\41\10\30\1\42\1\40\3\30\1\43\2\30\1\44"+ + "\1\30\1\41\13\30\1\45\2\30\1\46\1\47\1\50"+ + "\1\51\1\52\1\53\1\54\1\30\1\61\1\32\1\33"+ + "\1\34\1\35\1\36\1\62\1\40\7\30\3\40\1\41"+ + "\10\30\1\42\1\40\3\30\1\43\2\30\1\44\1\30"+ + "\1\41\13\30\1\45\2\30\1\63\1\47\1\50\1\51"+ + "\1\52\1\53\1\54\1\30\1\61\1\32\1\33\1\34"+ + "\1\35\1\36\1\37\1\40\7\30\3\40\1\41\10\30"+ + "\1\42\1\40\3\30\1\43\2\30\1\44\1\30\1\41"+ + "\13\30\1\45\2\30\1\56\1\47\1\50\1\51\1\52"+ + "\1\53\1\54\1\30\1\61\1\32\1\33\1\34\1\35"+ + "\1\36\1\62\1\40\7\30\3\40\1\41\10\30\1\42"+ + "\1\40\3\30\1\43\2\30\1\44\1\30\1\41\13\30"+ + "\1\45\2\30\1\64\1\47\1\50\1\51\1\52\1\53"+ + "\1\54\1\30\1\61\1\32\1\33\1\34\1\35\1\36"+ + "\1\65\1\40\7\30\3\40\1\41\10\30\1\42\1\40"+ + "\3\30\1\43\2\30\1\44\1\30\1\41\13\30\1\45"+ + "\2\30\1\41\1\47\1\50\1\51\1\52\1\53\1\54"+ + "\1\30\1\66\1\32\1\33\1\34\1\35\1\67\1\70"+ + "\1\40\7\30\3\40\1\41\10\30\1\42\1\40\3\30"+ + "\1\43\2\30\1\44\1\30\1\41\13\30\1\45\2\30"+ + "\1\64\1\47\1\50\1\51\1\52\1\53\1\54\1\30"+ + "\1\61\1\32\1\33\1\34\1\35\1\71\1\37\1\40"+ + "\7\30\3\40\1\41\10\30\1\42\1\40\3\30\1\43"+ + "\2\30\1\44\1\30\1\41\13\30\1\45\2\30\1\41"+ + "\1\47\1\50\1\51\1\52\1\53\1\54\1\30\1\66"+ + "\1\32\1\33\1\34\1\35\1\67\1\72\1\40\7\30"+ + "\3\40\1\41\10\30\1\42\1\40\3\30\1\43\2\30"+ + "\1\44\1\30\1\41\13\30\1\45\2\30\1\64\1\47"+ + "\1\50\1\51\1\52\1\53\1\54\6\73\1\74\65\73"+ + "\74\75\1\76\1\61\1\32\1\33\1\34\1\35\1\36"+ + "\1\62\1\40\7\76\3\40\1\41\10\76\1\42\1\40"+ + "\3\76\1\43\2\76\1\44\1\76\1\41\16\76\1\41"+ + "\1\47\1\50\1\51\1\52\1\53\1\54\1\30\1\61"+ + "\1\32\1\33\1\77\1\100\1\36\1\37\1\40\7\30"+ + "\3\40\1\41\10\30\1\42\1\40\3\30\1\43\2\30"+ + "\1\44\1\30\1\41\13\30\1\45\2\30\1\41\1\47"+ + "\1\50\1\51\1\52\1\53\1\54\1\30\1\61\1\32"+ + "\1\33\1\34\1\35\1\36\1\101\1\40\7\30\3\40"+ + "\1\41\10\30\1\42\1\40\3\30\1\43\2\30\1\44"+ + "\1\30\1\41\13\30\1\45\2\30\1\41\1\47\1\50"+ + "\1\51\1\52\1\53\1\54\1\30\1\61\1\32\1\33"+ + "\1\34\1\35\1\36\1\37\1\40\7\30\3\40\1\41"+ + "\10\30\1\42\1\40\3\30\1\43\2\30\1\44\1\30"+ + "\1\41\13\30\1\45\2\30\1\41\1\47\1\50\1\51"+ + "\1\52\1\53\1\54\1\102\1\103\6\102\1\40\7\102"+ + "\3\40\12\102\1\40\36\102\4\104\1\105\3\104\1\106"+ + "\7\104\3\106\12\104\1\106\36\104\1\107\5\110\1\36"+ + "\2\110\7\107\4\110\10\107\2\110\3\107\1\110\2\107"+ + "\1\110\1\107\1\110\16\107\7\110\1\30\1\111\1\32"+ + "\1\33\1\34\1\35\1\36\1\37\1\40\7\30\3\40"+ + "\1\41\10\30\1\42\1\40\3\30\1\43\2\30\1\44"+ + "\1\30\1\41\13\30\1\45\2\30\1\46\1\47\1\50"+ + "\1\51\1\52\1\53\1\54\1\112\1\61\1\32\1\33"+ + "\1\34\1\35\1\36\1\37\1\40\7\112\3\40\1\41"+ + "\10\112\1\42\1\40\3\112\1\43\2\112\1\44\1\112"+ + "\1\41\16\112\1\41\1\47\1\50\1\51\1\52\1\53"+ + "\1\54\41\102\1\113\32\102\1\30\10\0\7\30\4\0"+ + "\10\30\2\0\3\30\1\0\2\30\1\0\1\30\1\0"+ + "\16\30\7\0\2\114\1\115\1\114\1\116\4\114\1\117"+ + "\1\120\2\121\1\122\1\123\1\121\1\0\1\114\2\0"+ + "\1\124\6\121\1\125\2\114\3\121\1\114\2\121\1\114"+ + "\1\121\1\114\2\121\1\126\7\121\1\127\1\114\2\121"+ + "\7\114\104\0\1\40\7\0\3\40\12\0\1\40\36\0"+ + "\20\130\2\0\12\130\1\131\1\132\36\130\6\0\1\133"+ + "\65\0\4\114\1\116\4\114\1\117\1\120\2\121\1\122"+ + "\1\123\1\121\1\0\1\114\2\0\1\124\2\121\1\134"+ + "\3\121\1\125\2\114\3\121\1\114\2\121\1\114\1\121"+ + "\1\114\2\121\1\126\7\121\1\127\1\114\2\121\12\114"+ + "\1\56\1\116\4\114\1\117\1\120\2\121\1\122\1\123"+ + "\1\121\1\0\1\114\2\0\1\124\6\121\1\125\2\114"+ + "\3\121\1\114\2\121\1\114\1\121\1\114\2\121\1\126"+ + "\7\121\1\127\1\114\2\121\11\114\1\115\1\114\1\116"+ + "\1\135\3\114\1\117\1\120\2\121\1\122\1\123\1\121"+ + "\1\0\1\114\2\0\1\124\6\121\1\125\2\114\3\121"+ + "\1\114\2\121\1\114\1\121\1\114\2\121\1\126\7\121"+ + "\1\127\1\114\2\121\13\114\1\116\4\114\1\117\1\120"+ + "\2\121\1\122\1\123\1\121\1\0\1\114\2\0\1\124"+ + "\6\121\1\125\2\114\3\121\1\114\2\121\1\114\1\121"+ + "\1\114\2\121\1\126\7\121\1\127\1\114\2\121\13\114"+ + "\1\136\1\137\3\114\1\117\1\120\2\121\1\122\1\123"+ + "\1\121\1\0\1\114\2\0\1\124\6\121\1\125\2\114"+ + "\3\121\1\114\2\121\1\114\1\121\1\114\2\121\1\126"+ + "\7\121\1\127\1\114\2\121\7\114\1\76\10\0\7\76"+ + "\4\0\10\76\2\0\3\76\1\0\2\76\1\0\1\76"+ + "\1\0\16\76\20\0\1\140\1\141\71\0\1\106\7\0"+ + "\3\106\12\0\1\106\36\0\1\107\10\0\7\107\4\0"+ + "\10\107\2\0\3\107\1\0\2\107\1\0\1\107\1\0"+ + "\16\107\7\0\2\114\1\115\1\114\1\116\4\114\1\117"+ + "\1\142\2\121\1\122\1\123\1\121\1\0\1\114\2\0"+ + "\1\124\6\121\1\125\2\114\1\121\1\143\1\121\1\114"+ + "\2\121\1\114\1\121\1\114\1\144\1\121\1\126\1\145"+ + "\1\146\1\147\1\150\1\121\1\151\1\152\1\127\1\114"+ + "\2\121\7\114\1\112\10\0\7\112\4\0\10\112\2\0"+ + "\3\112\1\0\2\112\1\0\1\112\1\0\16\112\43\0"+ + "\1\153\1\154\47\0\1\121\1\155\5\121\4\0\10\121"+ + "\2\0\3\121\1\0\2\121\1\0\1\121\1\0\13\121"+ + "\1\0\2\121\20\0\4\121\1\156\2\121\4\0\10\121"+ + "\2\0\3\121\1\0\2\121\1\0\1\121\1\0\13\121"+ + "\1\0\2\121\20\0\7\121\4\0\10\121\2\0\3\121"+ + "\1\0\2\121\1\0\1\121\1\0\13\121\1\0\2\121"+ + "\20\0\1\121\1\157\5\121\4\0\10\121\2\0\3\121"+ + "\1\0\2\121\1\0\1\121\1\0\13\121\1\0\2\121"+ + "\20\0\3\121\1\160\3\121\4\0\10\121\2\0\3\121"+ + "\1\0\2\121\1\0\1\121\1\0\13\121\1\0\2\121"+ + "\20\0\3\121\1\161\3\121\4\0\10\121\2\0\3\121"+ + "\1\0\2\121\1\0\1\121\1\0\13\121\1\0\2\121"+ + "\20\0\1\121\1\162\5\121\4\0\10\121\2\0\3\121"+ + "\1\0\2\121\1\0\1\121\1\0\13\121\1\0\2\121"+ + "\20\0\7\121\4\0\10\121\2\0\3\121\1\0\1\121"+ + "\1\163\1\0\1\121\1\0\7\121\1\164\3\121\1\0"+ + "\2\121\20\0\1\121\1\165\5\121\4\0\10\121\2\0"+ + "\3\121\1\0\2\121\1\0\1\121\1\0\13\121\1\0"+ + "\2\121\7\0\20\130\2\0\52\130\10\166\1\131\7\166"+ + "\2\167\1\131\12\166\1\131\4\166\1\170\31\166\20\130"+ + "\2\0\12\130\1\171\37\130\11\0\1\121\1\172\5\121"+ + "\4\0\10\121\2\0\3\121\1\0\2\121\1\0\1\121"+ + "\1\0\13\121\1\0\2\121\21\0\1\173\76\0\1\174"+ + "\67\0\4\121\1\175\2\121\4\0\10\121\2\0\3\121"+ + "\1\0\2\121\1\0\1\121\1\0\13\121\1\0\2\121"+ + "\20\0\4\121\1\176\2\121\4\0\10\121\2\0\3\121"+ + "\1\0\2\121\1\0\1\121\1\0\2\121\1\177\10\121"+ + "\1\0\2\121\20\0\7\121\4\0\10\121\2\0\3\121"+ + "\1\0\2\121\1\0\1\200\1\0\7\121\1\201\3\121"+ + "\1\0\2\121\20\0\7\121\4\0\1\121\1\202\6\121"+ + "\2\0\3\121\1\0\2\121\1\0\1\121\1\0\13\121"+ + "\1\0\2\121\20\0\7\121\4\0\5\121\1\203\2\121"+ + "\2\0\3\121\1\0\2\121\1\0\1\121\1\0\13\121"+ + "\1\0\2\121\20\0\1\121\1\204\5\121\4\0\10\121"+ + "\2\0\3\121\1\0\2\121\1\0\1\121\1\0\13\121"+ + "\1\0\2\121\20\0\7\121\4\0\10\121\2\0\3\121"+ + "\1\0\2\121\1\0\1\205\1\0\13\121\1\0\2\121"+ + "\20\0\7\121\4\0\7\121\1\206\2\0\3\121\1\0"+ + "\2\121\1\0\1\121\1\0\13\121\1\0\2\121\20\0"+ + "\4\121\1\207\2\121\4\0\10\121\2\0\3\121\1\0"+ + "\2\121\1\0\1\121\1\0\13\121\1\0\2\121\17\0"+ + "\1\153\7\0\3\153\12\0\1\153\4\0\1\210\65\0"+ + "\1\211\50\0\2\121\1\212\4\121\4\0\10\121\2\0"+ + "\3\121\1\0\2\121\1\0\1\121\1\0\13\121\1\0"+ + "\2\121\20\0\5\121\1\213\1\121\4\0\10\121\2\0"+ + "\3\121\1\0\2\121\1\0\1\121\1\0\13\121\1\0"+ + "\2\121\20\0\7\121\4\0\10\121\2\0\3\121\1\0"+ + "\2\121\1\0\1\121\1\0\13\121\1\0\1\214\1\121"+ + "\20\0\7\121\4\0\7\121\1\215\2\0\3\121\1\0"+ + "\2\121\1\0\1\121\1\0\13\121\1\0\2\121\20\0"+ + "\7\121\4\0\1\121\1\216\6\121\2\0\3\121\1\0"+ + "\2\121\1\0\1\121\1\0\13\121\1\0\2\121\20\0"+ + "\4\121\1\122\2\121\4\0\10\121\2\0\3\121\1\0"+ + "\2\121\1\0\1\121\1\0\13\121\1\0\2\121\20\0"+ + "\7\121\4\0\3\121\1\217\4\121\2\0\3\121\1\0"+ + "\2\121\1\0\1\121\1\0\13\121\1\0\2\121\20\0"+ + "\7\121\4\0\6\121\1\220\1\121\2\0\3\121\1\0"+ + "\2\121\1\0\1\121\1\0\13\121\1\0\2\121\20\0"+ + "\7\121\4\0\7\121\1\221\2\0\3\121\1\0\2\121"+ + "\1\0\1\121\1\0\13\121\1\0\2\121\7\0\20\166"+ + "\2\0\52\166\10\0\1\167\7\0\3\167\12\0\1\167"+ + "\4\0\1\222\31\0\20\166\2\0\10\166\1\223\41\166"+ + "\20\130\2\0\5\130\1\224\6\130\1\224\35\130\11\0"+ + "\7\121\4\0\2\121\1\225\5\121\2\0\3\121\1\0"+ + "\2\121\1\0\1\121\1\0\13\121\1\0\2\121\22\0"+ + "\1\226\76\0\1\227\66\0\5\121\1\230\1\121\4\0"+ + "\10\121\2\0\3\121\1\0\2\121\1\0\1\121\1\0"+ + "\13\121\1\0\2\121\20\0\5\121\1\231\1\121\4\0"+ + "\10\121\2\0\3\121\1\0\2\121\1\0\1\121\1\0"+ + "\13\121\1\0\2\121\20\0\7\121\4\0\10\121\2\0"+ + "\3\121\1\0\1\121\1\232\1\0\1\121\1\0\13\121"+ + "\1\0\2\121\20\0\7\121\4\0\7\121\1\233\2\0"+ + "\3\121\1\0\2\121\1\0\1\121\1\0\13\121\1\0"+ + "\2\121\20\0\4\121\1\234\2\121\4\0\10\121\2\0"+ + "\3\121\1\0\2\121\1\0\1\121\1\0\13\121\1\0"+ + "\2\121\20\0\3\121\1\235\3\121\4\0\10\121\2\0"+ + "\3\121\1\0\2\121\1\0\1\121\1\0\13\121\1\0"+ + "\2\121\20\0\7\121\4\0\10\121\2\0\3\121\1\0"+ + "\1\236\1\121\1\0\1\121\1\0\13\121\1\0\2\121"+ + "\20\0\7\121\4\0\10\121\2\0\3\121\1\0\2\121"+ + "\1\0\1\237\1\0\13\121\1\0\2\121\20\0\7\121"+ + "\4\0\10\121\2\0\3\121\1\0\2\121\1\0\1\240"+ + "\1\0\13\121\1\0\2\121\20\0\7\121\4\0\3\121"+ + "\1\241\4\121\2\0\3\121\1\0\2\121\1\0\1\121"+ + "\1\0\13\121\1\0\2\121\41\0\1\242\70\0\1\243"+ + "\6\0\1\243\46\0\3\121\1\244\3\121\4\0\10\121"+ + "\2\0\3\121\1\0\2\121\1\0\1\121\1\0\13\121"+ + "\1\0\2\121\20\0\1\121\1\245\5\121\4\0\10\121"+ + "\2\0\3\121\1\0\2\121\1\0\1\121\1\0\13\121"+ + "\1\0\2\121\20\0\1\121\1\246\5\121\4\0\10\121"+ + "\2\0\3\121\1\0\2\121\1\0\1\121\1\0\13\121"+ + "\1\0\2\121\20\0\4\121\1\247\2\121\4\0\10\121"+ + "\2\0\3\121\1\0\2\121\1\0\1\121\1\0\13\121"+ + "\1\0\2\121\20\0\3\121\1\250\3\121\4\0\10\121"+ + "\2\0\3\121\1\0\2\121\1\0\1\121\1\0\13\121"+ + "\1\0\2\121\20\0\1\121\1\251\5\121\4\0\10\121"+ + "\2\0\3\121\1\0\2\121\1\0\1\121\1\0\13\121"+ + "\1\0\2\121\20\0\1\252\6\121\4\0\10\121\2\0"+ + "\3\121\1\0\2\121\1\0\1\121\1\0\13\121\1\0"+ + "\2\121\41\0\1\253\41\0\20\166\2\0\11\166\1\254"+ + "\40\166\12\130\1\255\5\130\2\0\15\130\1\255\34\130"+ + "\11\0\7\121\4\0\3\121\1\256\4\121\2\0\3\121"+ + "\1\0\2\121\1\0\1\121\1\0\13\121\1\0\2\121"+ + "\23\0\1\257\70\0\7\121\4\0\10\121\2\0\3\121"+ + "\1\0\2\121\1\0\1\121\1\0\1\260\2\121\1\261"+ + "\1\262\1\121\1\263\1\121\1\264\2\121\1\0\2\121"+ + "\20\0\1\121\1\265\5\121\4\0\10\121\2\0\3\121"+ + "\1\0\2\121\1\0\1\121\1\0\3\121\1\266\7\121"+ + "\1\0\2\121\20\0\7\121\4\0\10\121\2\0\3\121"+ + "\1\0\2\121\1\0\1\121\1\0\1\121\1\267\11\121"+ + "\1\0\2\121\20\0\7\121\4\0\4\121\1\270\3\121"+ + "\2\0\3\121\1\0\2\121\1\0\1\121\1\0\13\121"+ + "\1\0\2\121\20\0\7\121\4\0\10\121\2\0\3\121"+ + "\1\0\2\121\1\0\1\121\1\0\2\121\1\271\10\121"+ + "\1\0\2\121\20\0\1\121\1\272\5\121\4\0\10\121"+ + "\2\0\3\121\1\0\2\121\1\0\1\121\1\0\13\121"+ + "\1\0\2\121\20\0\7\121\4\0\10\121\2\0\3\121"+ + "\1\0\1\202\1\121\1\0\1\121\1\0\13\121\1\0"+ + "\2\121\20\0\7\121\4\0\4\121\1\273\3\121\2\0"+ + "\3\121\1\0\2\121\1\0\1\121\1\0\13\121\1\0"+ + "\2\121\20\0\3\121\1\274\3\121\4\0\10\121\2\0"+ + "\3\121\1\0\2\121\1\0\1\121\1\0\13\121\1\0"+ + "\2\121\42\0\1\275\52\0\1\276\24\0\1\276\45\0"+ + "\4\121\1\277\2\121\4\0\10\121\2\0\3\121\1\0"+ + "\2\121\1\0\1\121\1\0\13\121\1\0\2\121\20\0"+ + "\4\121\1\300\2\121\4\0\10\121\2\0\3\121\1\0"+ + "\2\121\1\0\1\121\1\0\13\121\1\0\2\121\20\0"+ + "\7\121\4\0\4\121\1\301\3\121\2\0\3\121\1\0"+ + "\2\121\1\0\1\121\1\0\13\121\1\0\2\121\20\0"+ + "\1\121\1\302\5\121\4\0\10\121\2\0\3\121\1\0"+ + "\2\121\1\0\1\121\1\0\13\121\1\0\2\121\20\0"+ + "\4\121\1\303\2\121\4\0\10\121\2\0\3\121\1\0"+ + "\2\121\1\0\1\121\1\0\13\121\1\0\2\121\20\0"+ + "\7\121\4\0\2\121\1\304\5\121\2\0\3\121\1\0"+ + "\2\121\1\0\1\121\1\0\13\121\1\0\2\121\20\0"+ + "\7\121\4\0\10\121\2\0\3\121\1\0\2\121\1\0"+ + "\1\121\1\0\13\121\1\305\2\121\42\0\1\306\40\0"+ + "\20\166\2\0\21\166\1\307\30\166\20\130\2\0\4\130"+ + "\1\131\11\130\1\131\33\130\15\0\1\310\67\0\7\121"+ + "\4\0\10\121\2\0\3\121\1\0\2\121\1\0\1\311"+ + "\1\0\7\121\1\312\3\121\1\0\2\121\20\0\7\121"+ + "\4\0\1\121\1\313\6\121\2\0\3\121\1\0\2\121"+ + "\1\0\1\121\1\0\13\121\1\0\2\121\20\0\7\121"+ + "\4\0\5\121\1\314\2\121\2\0\3\121\1\0\2\121"+ + "\1\0\1\121\1\0\13\121\1\0\2\121\20\0\7\121"+ + "\4\0\10\121\2\0\3\121\1\0\2\121\1\0\1\315"+ + "\1\0\13\121\1\0\2\121\20\0\7\121\4\0\7\121"+ + "\1\316\2\0\3\121\1\0\2\121\1\0\1\121\1\0"+ + "\13\121\1\0\2\121\20\0\7\121\4\0\1\121\1\265"+ + "\6\121\2\0\3\121\1\0\2\121\1\0\1\121\1\0"+ + "\13\121\1\0\2\121\20\0\7\121\4\0\10\121\2\0"+ + "\3\121\1\0\2\121\1\0\1\121\1\0\2\121\1\317"+ + "\10\121\1\0\2\121\20\0\7\121\4\0\3\121\1\320"+ + "\4\121\2\0\3\121\1\0\2\121\1\0\1\121\1\0"+ + "\13\121\1\0\2\121\20\0\1\121\1\202\5\121\4\0"+ + "\10\121\2\0\3\121\1\0\2\121\1\0\1\121\1\0"+ + "\13\121\1\0\2\121\20\0\7\121\4\0\6\121\1\321"+ + "\1\121\2\0\3\121\1\0\2\121\1\0\1\121\1\0"+ + "\13\121\1\0\2\121\20\0\1\121\1\322\5\121\4\0"+ + "\10\121\2\0\3\121\1\0\2\121\1\0\1\121\1\0"+ + "\13\121\1\0\2\121\20\0\7\121\4\0\10\121\2\0"+ + "\3\121\1\0\2\121\1\0\1\121\1\0\2\121\1\313"+ + "\10\121\1\0\2\121\52\0\1\323\56\0\1\153\11\0"+ + "\1\153\44\0\7\121\4\0\10\121\2\0\3\121\1\0"+ + "\2\121\1\0\1\121\1\0\12\121\1\324\1\0\2\121"+ + "\20\0\7\121\4\0\3\121\1\325\4\121\2\0\3\121"+ + "\1\0\2\121\1\0\1\121\1\0\13\121\1\0\2\121"+ + "\20\0\7\121\4\0\2\121\1\326\5\121\2\0\3\121"+ + "\1\0\2\121\1\0\1\121\1\0\13\121\1\0\2\121"+ + "\20\0\7\121\4\0\10\121\2\0\3\121\1\0\2\121"+ + "\1\0\1\121\1\0\2\121\1\327\10\121\1\0\2\121"+ + "\20\0\1\121\1\330\5\121\4\0\10\121\2\0\3\121"+ + "\1\0\2\121\1\0\1\121\1\0\13\121\1\0\2\121"+ + "\52\0\1\331\30\0\12\166\1\332\5\166\2\0\52\166"+ + "\11\0\7\121\4\0\7\121\1\313\2\0\3\121\1\0"+ + "\2\121\1\0\1\121\1\0\13\121\1\0\2\121\20\0"+ + "\4\121\1\333\2\121\4\0\10\121\2\0\3\121\1\0"+ + "\2\121\1\0\1\121\1\0\13\121\1\0\2\121\20\0"+ + "\3\121\1\334\3\121\4\0\10\121\2\0\3\121\1\0"+ + "\2\121\1\0\1\121\1\0\13\121\1\0\2\121\20\0"+ + "\7\121\4\0\10\121\2\0\3\121\1\0\2\121\1\0"+ + "\1\335\1\0\13\121\1\0\2\121\20\0\7\121\4\0"+ + "\10\121\2\0\3\121\1\0\2\121\1\0\1\336\1\0"+ + "\13\121\1\0\2\121\20\0\7\121\4\0\10\121\2\0"+ + "\3\121\1\0\2\121\1\0\1\121\1\0\2\121\1\202"+ + "\10\121\1\0\2\121\20\0\3\121\1\337\3\121\4\0"+ + "\10\121\2\0\3\121\1\0\2\121\1\0\1\121\1\0"+ + "\13\121\1\0\2\121\20\0\7\121\4\0\3\121\1\202"+ + "\4\121\2\0\3\121\1\0\2\121\1\0\1\121\1\0"+ + "\13\121\1\0\2\121\20\0\5\121\1\340\1\121\4\0"+ + "\10\121\2\0\3\121\1\0\2\121\1\0\1\121\1\0"+ + "\13\121\1\0\2\121\21\0\1\341\72\0\3\121\1\342"+ + "\3\121\4\0\10\121\2\0\3\121\1\0\2\121\1\0"+ + "\1\121\1\0\13\121\1\0\2\121\20\0\7\121\4\0"+ + "\10\121\2\0\3\121\1\0\2\121\1\0\1\121\1\0"+ + "\2\121\1\343\10\121\1\0\2\121\20\0\7\121\4\0"+ + "\3\121\1\344\4\121\2\0\3\121\1\0\2\121\1\0"+ + "\1\121\1\0\13\121\1\0\2\121\20\0\3\121\1\345"+ + "\3\121\4\0\10\121\2\0\3\121\1\0\2\121\1\0"+ + "\1\121\1\0\13\121\1\0\2\121\20\0\7\121\4\0"+ + "\4\121\1\346\3\121\2\0\3\121\1\0\2\121\1\0"+ + "\1\121\1\0\13\121\1\0\2\121\21\0\1\347\61\0"+ + "\20\166\2\0\11\166\1\350\40\166\11\0\7\121\4\0"+ + "\4\121\1\351\3\121\2\0\3\121\1\0\2\121\1\0"+ + "\1\121\1\0\13\121\1\0\2\121\20\0\7\121\4\0"+ + "\10\121\2\0\3\121\1\0\2\121\1\0\1\121\1\0"+ + "\2\121\1\352\10\121\1\0\2\121\20\0\7\121\4\0"+ + "\10\121\2\0\3\121\1\0\1\313\1\121\1\0\1\121"+ + "\1\0\13\121\1\0\2\121\20\0\7\121\4\0\4\121"+ + "\1\353\3\121\2\0\3\121\1\0\2\121\1\0\1\121"+ + "\1\0\13\121\1\0\2\121\20\0\7\121\4\0\10\121"+ + "\2\0\3\121\1\0\2\121\1\0\1\354\1\0\13\121"+ + "\1\0\2\121\20\0\7\121\4\0\10\121\2\0\3\121"+ + "\1\0\2\121\1\0\1\121\1\0\7\121\1\355\3\121"+ + "\1\0\2\121\42\0\1\356\51\0\7\121\4\0\7\121"+ + "\1\357\2\0\3\121\1\0\2\121\1\0\1\121\1\0"+ + "\13\121\1\0\2\121\20\0\7\121\4\0\10\121\2\0"+ + "\3\121\1\0\2\121\1\0\1\121\1\0\7\121\1\360"+ + "\3\121\1\0\2\121\20\0\7\121\4\0\4\121\1\361"+ + "\3\121\2\0\3\121\1\0\2\121\1\0\1\121\1\0"+ + "\13\121\1\0\2\121\20\0\4\121\1\362\2\121\4\0"+ + "\10\121\2\0\3\121\1\0\2\121\1\0\1\121\1\0"+ + "\13\121\1\0\2\121\42\0\1\363\40\0\10\166\1\350"+ + "\7\166\2\363\1\350\12\166\1\350\6\166\1\364\27\166"+ + "\11\0\7\121\4\0\3\121\1\365\4\121\2\0\3\121"+ + "\1\0\2\121\1\0\1\121\1\0\13\121\1\0\2\121"+ + "\20\0\1\121\1\313\5\121\4\0\10\121\2\0\3\121"+ + "\1\0\2\121\1\0\1\121\1\0\13\121\1\0\2\121"+ + "\20\0\1\121\1\366\5\121\4\0\10\121\2\0\3\121"+ + "\1\0\2\121\1\0\1\121\1\0\13\121\1\0\2\121"+ + "\20\0\4\121\1\202\2\121\4\0\10\121\2\0\3\121"+ + "\1\0\2\121\1\0\1\121\1\0\13\121\1\0\2\121"+ + "\20\0\7\121\4\0\7\121\1\271\2\0\3\121\1\0"+ + "\2\121\1\0\1\121\1\0\13\121\1\0\2\121\17\0"+ + "\1\356\7\0\3\356\12\0\1\356\6\0\1\367\40\0"+ + "\7\121\4\0\10\121\2\0\3\121\1\0\2\121\1\0"+ + "\1\370\1\0\13\121\1\0\2\121\20\0\7\121\4\0"+ + "\6\121\1\346\1\121\2\0\3\121\1\0\2\121\1\0"+ + "\1\121\1\0\13\121\1\0\2\121\20\0\7\121\4\0"+ + "\5\121\1\371\2\121\2\0\3\121\1\0\2\121\1\0"+ + "\1\121\1\0\13\121\1\0\2\121\20\0\1\121\1\346"+ + "\5\121\4\0\10\121\2\0\3\121\1\0\2\121\1\0"+ + "\1\121\1\0\13\121\1\0\2\121\17\0\1\363\7\0"+ + "\3\363\12\0\1\363\6\0\1\372\27\0\10\166\1\364"+ + "\7\166\2\372\1\364\12\166\1\364\7\166\1\373\26\166"+ + "\11\0\3\121\1\374\3\121\4\0\10\121\2\0\3\121"+ + "\1\0\2\121\1\0\1\121\1\0\13\121\1\0\2\121"+ + "\20\0\5\121\1\375\1\121\4\0\10\121\2\0\3\121"+ + "\1\0\2\121\1\0\1\121\1\0\13\121\1\0\2\121"+ + "\17\0\1\367\7\0\3\367\12\0\1\367\7\0\1\376"+ + "\37\0\4\121\1\377\2\121\4\0\10\121\2\0\3\121"+ + "\1\0\2\121\1\0\1\121\1\0\13\121\1\0\2\121"+ + "\20\0\7\121\4\0\6\121\1\u0100\1\121\2\0\3\121"+ + "\1\0\2\121\1\0\1\121\1\0\13\121\1\0\2\121"+ + "\17\0\1\372\7\0\3\372\12\0\1\372\7\0\1\u0101"+ + "\26\0\20\166\2\0\3\166\1\u0102\46\166\11\0\7\121"+ + "\4\0\10\121\2\0\3\121\1\0\2\121\1\0\1\u0103"+ + "\1\0\13\121\1\0\2\121\20\0\7\121\4\0\10\121"+ + "\2\0\3\121\1\0\2\121\1\0\1\121\1\0\7\121"+ + "\1\u0104\3\121\1\0\2\121\24\0\1\u0105\67\0\7\121"+ + "\4\0\10\121\2\0\3\121\1\0\2\121\1\0\1\121"+ + "\1\0\13\121\1\0\1\121\1\u0106\20\0\7\121\4\0"+ + "\7\121\1\u0107\2\0\3\121\1\0\2\121\1\0\1\121"+ + "\1\0\13\121\1\0\2\121\34\0\1\u0108\46\0\20\166"+ + "\2\0\3\166\1\u0109\46\166\11\0\4\121\1\313\2\121"+ + "\4\0\10\121\2\0\3\121\1\0\2\121\1\0\1\121"+ + "\1\0\13\121\1\0\2\121\20\0\7\121\4\0\7\121"+ + "\1\352\2\0\3\121\1\0\2\121\1\0\1\121\1\0"+ + "\13\121\1\0\2\121\7\0\20\u0105\2\0\52\u0105\11\0"+ + "\1\121\1\u010a\5\121\4\0\10\121\2\0\3\121\1\0"+ + "\2\121\1\0\1\121\1\0\13\121\1\0\2\121\7\0"+ + "\11\u010b\7\121\4\0\10\121\2\u010b\3\121\1\u010b\2\121"+ + "\1\u010b\1\121\1\u010b\13\121\1\u010b\2\121\7\u010b\25\0"+ + "\1\u0109\46\0\20\u0109\2\0\52\u0109\11\0\4\121\1\u010c"+ + "\2\121\4\0\10\121\2\0\3\121\1\0\2\121\1\0"+ + "\1\121\1\0\13\121\1\0\2\121\20\0\7\121\4\0"+ + "\3\121\1\u010d\4\121\2\0\3\121\1\0\2\121\1\0"+ + "\1\121\1\0\13\121\1\0\2\121\7\0"; private static int [] zzUnpackTrans() { - int[] result = new int[12470]; + int [] result = new int[12900]; int offset = 0; offset = zzUnpackTrans(ZZ_TRANS_PACKED_0, offset, result); return result; @@ -621,20 +625,20 @@ private static int zzUnpackTrans(String packed, int offset, int [] result) { private static final int [] ZZ_ATTRIBUTE = zzUnpackAttribute(); private static final String ZZ_ATTRIBUTE_PACKED_0 = - "\27\0\2\1\6\11\1\1\2\11\1\1\1\11\1\1" + - "\1\11\1\1\2\11\1\1\1\11\3\1\4\11\1\1" + - "\7\11\1\1\4\11\1\1\2\11\2\1\1\11\3\1" + - "\3\11\14\1\1\11\1\1\3\11\2\0\11\1\2\0" + - "\12\1\1\0\3\1\2\0\13\1\2\0\10\1\1\0" + - "\3\1\1\0\1\11\12\1\2\0\7\1\1\0\3\1" + - "\1\0\15\1\2\0\6\1\1\11\1\0\1\1\1\11" + - "\12\1\1\0\5\1\1\0\7\1\1\0\5\1\1\0" + - "\6\1\1\0\4\1\1\0\3\1\1\0\2\1\1\0" + - "\3\1\1\0\2\1\1\0\6\1\1\0\2\1\1\11" + - "\2\1"; + "\27\0\2\1\6\11\1\1\2\11\1\1\1\11\1\1"+ + "\1\11\2\1\4\11\1\1\1\11\3\1\4\11\1\1"+ + "\7\11\1\1\4\11\1\1\2\11\2\1\1\11\3\1"+ + "\3\11\14\1\1\11\1\1\3\11\2\0\11\1\2\0"+ + "\12\1\1\0\3\1\2\0\13\1\2\0\10\1\1\0"+ + "\3\1\1\0\1\11\12\1\2\0\7\1\1\0\3\1"+ + "\1\0\15\1\2\0\6\1\1\11\1\0\1\1\1\11"+ + "\12\1\1\0\5\1\1\0\7\1\1\0\5\1\1\0"+ + "\6\1\1\0\4\1\1\0\3\1\1\0\2\1\1\0"+ + "\3\1\1\0\2\1\1\0\6\1\1\0\2\1\1\11"+ + "\2\1"; private static int [] zzUnpackAttribute() { - int[] result = new int[266]; + int [] result = new int[269]; int offset = 0; offset = zzUnpackAttribute(ZZ_ATTRIBUTE_PACKED_0, offset, result); return result; @@ -968,448 +972,367 @@ else if (zzAtEOF) { } else { switch (zzAction < 0 ? zzAction : ZZ_ACTION[zzAction]) { - case 1: { - return NORMAL_TEXT_WORD; - } - // fall through - case 61: - break; - case 2: { - return NORMAL_TEXT_CHAR; - } - // fall through - case 62: - break; - case 3: { - return OPEN_PAREN; - } - // fall through - case 63: - break; - case 4: { - return CLOSE_PAREN; - } - // fall through - case 64: - break; - case 5: { - return OPEN_BRACKET; - } - // fall through - case 65: - break; - case 6: { - return CLOSE_BRACKET; - } - // fall through - case 66: - break; - case 7: { - return OPEN_BRACE; - } - // fall through - case 67: - break; - case 8: { - return CLOSE_BRACE; - } - // fall through - case 68: - break; - case 9: { - return com.intellij.psi.TokenType.WHITE_SPACE; - } - // fall through - case 69: - break; - case 10: { - return com.intellij.psi.TokenType.BAD_CHARACTER; - } - // fall through - case 70: - break; - case 11: { - return COMMENT_TOKEN; - } - // fall through - case 71: - break; - case 12: { - return EQUALS; - } - // fall through - case 72: - break; - case 13: { - return STAR; - } - // fall through - case 73: - break; - case 14: { - yypushState(INLINE_MATH); - return INLINE_MATH_START; - } - // fall through - case 74: - break; - case 15: { - return AMPERSAND; - } - // fall through - case 75: - break; - case 16: { - return COMMA; - } - // fall through - case 76: - break; - case 17: { - yypopState(); - return INLINE_MATH_END; - } - // fall through - case 77: - break; - case 18: { - yypopState(); - return CLOSE_BRACE; - } - // fall through - case 78: - break; - case 19: { - yypushState(NESTED_INLINE_MATH); - return INLINE_MATH_START; - } - // fall through - case 79: - break; - case 20: { - yypopState(); - yypushState(NEW_ENVIRONMENT_DEFINITION); - return CLOSE_BRACE; - } - // fall through - case 80: - break; - case 21: { - newEnvironmentBracesNesting++; + case 1: + { return NORMAL_TEXT_WORD; + } + // fall through + case 66: break; + case 2: + { return BACKSLASH; + } + // fall through + case 67: break; + case 3: + { return OPEN_PAREN; + } + // fall through + case 68: break; + case 4: + { return CLOSE_PAREN; + } + // fall through + case 69: break; + case 5: + { return OPEN_BRACKET; + } + // fall through + case 70: break; + case 6: + { return CLOSE_BRACKET; + } + // fall through + case 71: break; + case 7: + { return OPEN_BRACE; + } + // fall through + case 72: break; + case 8: + { return CLOSE_BRACE; + } + // fall through + case 73: break; + case 9: + { return com.intellij.psi.TokenType.WHITE_SPACE; + } + // fall through + case 74: break; + case 10: + { return com.intellij.psi.TokenType.BAD_CHARACTER; + } + // fall through + case 75: break; + case 11: + { return EXCLAMATION_MARK; + } + // fall through + case 76: break; + case 12: + { return COMMENT_TOKEN; + } + // fall through + case 77: break; + case 13: + { return EQUALS; + } + // fall through + case 78: break; + case 14: + { return STAR; + } + // fall through + case 79: break; + case 15: + { yypushState(INLINE_MATH); return INLINE_MATH_START; + } + // fall through + case 80: break; + case 16: + { return OPEN_ANGLE_BRACKET; + } + // fall through + case 81: break; + case 17: + { return CLOSE_ANGLE_BRACKET; + } + // fall through + case 82: break; + case 18: + { return AMPERSAND; + } + // fall through + case 83: break; + case 19: + { return COMMA; + } + // fall through + case 84: break; + case 20: + { return QUOTATION_MARK; + } + // fall through + case 85: break; + case 21: + { return PIPE; + } + // fall through + case 86: break; + case 22: + { yypopState(); return INLINE_MATH_END; + } + // fall through + case 87: break; + case 23: + { yypopState(); return CLOSE_BRACE; + } + // fall through + case 88: break; + case 24: + { yypushState(NESTED_INLINE_MATH); return INLINE_MATH_START; + } + // fall through + case 89: break; + case 25: + { yypopState(); yypushState(NEW_ENVIRONMENT_DEFINITION); return CLOSE_BRACE; + } + // fall through + case 90: break; + case 26: + { newEnvironmentBracesNesting++; return OPEN_BRACE; + } + // fall through + case 91: break; + case 27: + { newEnvironmentBracesNesting--; + if(newEnvironmentBracesNesting == 0) { + yypopState(); yypushState(NEW_ENVIRONMENT_SKIP_BRACE); + // We could have return normal text, but in this way the braces still match return OPEN_BRACE; - } - // fall through - case 81: - break; - case 22: { - newEnvironmentBracesNesting--; - if (newEnvironmentBracesNesting == 0) { - yypopState(); - yypushState(NEW_ENVIRONMENT_SKIP_BRACE); - // We could have return normal text, but in this way the braces still match - return OPEN_BRACE; - } else { - return CLOSE_BRACE; - } - } - // fall through - case 82: - break; - case 23: { - yypopState(); - newEnvironmentBracesNesting = 1; - yypushState(NEW_ENVIRONMENT_DEFINITION_END); + } else { return CLOSE_BRACE; - } - // fall through - case 83: - break; - case 24: { - newEnvironmentBracesNesting--; - if (newEnvironmentBracesNesting == 0) { - yypopState(); - } - return CLOSE_BRACE; - } - // fall through - case 84: - break; - case 25: { - yypopState(); - verbatim_delimiter = yytext().toString(); - yypushState(INLINE_VERBATIM); - return OPEN_BRACE; - } - // fall through - case 85: - break; - case 26: { - yypopState(); - verbatim_delimiter = "}"; - yypushState(INLINE_VERBATIM); - return OPEN_BRACE; - } - // fall through - case 86: - break; - case 27: { - if (yytext().toString().equals(verbatim_delimiter)) { - yypopState(); - return CLOSE_BRACE; - } else { - return RAW_TEXT_TOKEN; - } - } - // fall through - case 87: - break; - case 28: { - yypopState(); - // toString to fix comparisons of charsequence subsequences with string - if (Magic.Environment.verbatim.contains(yytext().toString())) { - yypushState(VERBATIM_START); - } else if (yytext().toString().equals("algorithmic")) { - yypushState(PSEUDOCODE); - } - return NORMAL_TEXT_WORD; - } - // fall through - case 88: - break; - case 29: { - verbatimOptionalArgumentBracketsCount++; - return OPEN_BRACKET; - } - // fall through - case 89: - break; - case 30: { - verbatimOptionalArgumentBracketsCount--; - if (verbatimOptionalArgumentBracketsCount == 0) { - yypopState(); - yypushState(VERBATIM); - } - return CLOSE_BRACKET; - } - // fall through - case 90: - break; - case 31: { - yypopState(); - yypushState(POSSIBLE_VERBATIM_OPTIONAL_ARG); - return CLOSE_BRACE; - } - // fall through - case 91: - break; - case 32: { - return RAW_TEXT_TOKEN; - } - // fall through - case 92: - break; - case 33: { - yypopState(); - yypushState(VERBATIM); - return RAW_TEXT_TOKEN; - } - // fall through - case 93: - break; - case 34: { - verbatimOptionalArgumentBracketsCount++; - yypopState(); - yypushState(VERBATIM_OPTIONAL_ARG); - return OPEN_BRACKET; - } - // fall through - case 94: - break; - case 35: { - yypopState(); - yypushState(VERBATIM); - return com.intellij.psi.TokenType.WHITE_SPACE; - } - // fall through - case 95: - break; - case 36: { // Pop current state - yypopState(); - if (Magic.Environment.verbatim.contains(yytext().toString())) { - // Pop verbatim state - yypopState(); - return NORMAL_TEXT_WORD; - } - return RAW_TEXT_TOKEN; - } - // fall through - case 96: - break; - case 37: { + } + } + // fall through + case 92: break; + case 28: + { yypopState(); newEnvironmentBracesNesting = 1; yypushState(NEW_ENVIRONMENT_DEFINITION_END); return CLOSE_BRACE; + } + // fall through + case 93: break; + case 29: + { newEnvironmentBracesNesting--; + if(newEnvironmentBracesNesting == 0) { yypopState(); - return RAW_TEXT_TOKEN; - } - // fall through - case 97: - break; - case 38: { + } + return CLOSE_BRACE; + } + // fall through + case 94: break; + case 30: + { yypopState(); verbatim_delimiter = yytext().toString(); yypushState(INLINE_VERBATIM); return OPEN_BRACE; + } + // fall through + case 95: break; + case 31: + { yypopState(); verbatim_delimiter = "}"; yypushState(INLINE_VERBATIM); return OPEN_BRACE; + } + // fall through + case 96: break; + case 32: + { if(yytext().toString().equals(verbatim_delimiter)) { yypopState(); return CLOSE_BRACE; } else { return RAW_TEXT_TOKEN; } + } + // fall through + case 97: break; + case 33: + { yypopState(); + // toString to fix comparisons of charsequence subsequences with string + if (Magic.Environment.verbatim.contains(yytext().toString())) { + yypushState(VERBATIM_START); + } + else if (yytext().toString().equals("algorithmic")) { + yypushState(PSEUDOCODE); + } + return NORMAL_TEXT_WORD; + } + // fall through + case 98: break; + case 34: + { verbatimOptionalArgumentBracketsCount++; return OPEN_BRACKET; + } + // fall through + case 99: break; + case 35: + { verbatimOptionalArgumentBracketsCount--; + if (verbatimOptionalArgumentBracketsCount == 0) { yypopState(); yypushState(VERBATIM); } + return CLOSE_BRACKET; + } + // fall through + case 100: break; + case 36: + { yypopState(); yypushState(POSSIBLE_VERBATIM_OPTIONAL_ARG); return CLOSE_BRACE; + } + // fall through + case 101: break; + case 37: + { return RAW_TEXT_TOKEN; + } + // fall through + case 102: break; + case 38: + { yypopState(); yypushState(VERBATIM); return RAW_TEXT_TOKEN; + } + // fall through + case 103: break; + case 39: + { verbatimOptionalArgumentBracketsCount++; yypopState(); yypushState(VERBATIM_OPTIONAL_ARG); return OPEN_BRACKET; + } + // fall through + case 104: break; + case 40: + { yypopState(); yypushState(VERBATIM); return com.intellij.psi.TokenType.WHITE_SPACE; + } + // fall through + case 105: break; + case 41: + { // Pop current state + yypopState(); + if (Magic.Environment.verbatim.contains(yytext().toString())) { + // Pop verbatim state yypopState(); - if (yytext().toString().equals("algorithmic")) { - // Pop pseudocode state - yypopState(); - } return NORMAL_TEXT_WORD; - } - // fall through - case 98: - break; - case 39: { - return COMMAND_TOKEN; - } - // fall through - case 99: - break; - case 40: { - yypushState(INLINE_MATH_LATEX); - return INLINE_MATH_START; - } - // fall through - case 100: - break; - case 41: { - yypushState(DISPLAY_MATH); - return DISPLAY_MATH_START; - } - // fall through - case 101: - break; - case 42: { - return MAGIC_COMMENT_TOKEN; - } - // fall through - case 102: - break; - case 43: { - yypushState(PREAMBLE_OPTION); - return OPEN_BRACE; - } - // fall through - case 103: - break; - case 44: { - yypopState(); - return DISPLAY_MATH_END; - } - // fall through - case 104: - break; - case 45: { - return DISPLAY_MATH_START; - } - // fall through - case 105: - break; - case 46: { - return DISPLAY_MATH_END; - } - // fall through - case 106: - break; - case 47: { - return BEGIN_PSEUDOCODE_BLOCK; - } - // fall through - case 107: - break; - case 48: { - return END_TOKEN; - } - // fall through - case 108: - break; - case 49: { - yypushState(POSSIBLE_VERBATIM_END); - return END_TOKEN; - } - // fall through - case 109: - break; - case 50: { - yypushState(POSSIBLE_PSEUDOCODE_END); - return END_TOKEN; - } - // fall through - case 110: - break; - case 51: { - yypushState(INLINE_VERBATIM_START); - return COMMAND_TOKEN; - } - // fall through - case 111: - break; - case 52: { - yypushState(TEXT_INSIDE_INLINE_MATH); - return COMMAND_TOKEN; - } - // fall through - case 112: - break; - case 53: { - return MIDDLE_PSEUDOCODE_BLOCK; - } - // fall through - case 113: - break; - case 54: { - yypushState(POSSIBLE_VERBATIM_BEGIN); - return BEGIN_TOKEN; - } - // fall through - case 114: - break; - case 55: { - return BEGIN_TOKEN; - } - // fall through - case 115: - break; - case 56: { - return END_PSEUDOCODE_BLOCK; - } - // fall through - case 116: - break; - case 57: { + } + return RAW_TEXT_TOKEN; + } + // fall through + case 106: break; + case 42: + { yypopState(); return RAW_TEXT_TOKEN; + } + // fall through + case 107: break; + case 43: + { yypopState(); + if (yytext().toString().equals("algorithmic")) { + // Pop pseudocode state yypopState(); - return COMMENT_TOKEN; - } - // fall through - case 117: - break; - case 58: { - yypushState(OFF); - return COMMENT_TOKEN; - } - // fall through - case 118: - break; - case 59: { - return COMMAND_IFNEXTCHAR; - } - // fall through - case 119: - break; - case 60: { - yypushState(NEW_ENVIRONMENT_DEFINITION_NAME); - return COMMAND_TOKEN; - } - // fall through - case 120: - break; + } + return NORMAL_TEXT_WORD; + } + // fall through + case 108: break; + case 44: + { return COMMAND_TOKEN; + } + // fall through + case 109: break; + case 45: + { yypushState(INLINE_MATH_LATEX); return INLINE_MATH_START; + } + // fall through + case 110: break; + case 46: + { yypushState(DISPLAY_MATH); return DISPLAY_MATH_START; + } + // fall through + case 111: break; + case 47: + { return MAGIC_COMMENT_TOKEN; + } + // fall through + case 112: break; + case 48: + { yypushState(PREAMBLE_OPTION); return OPEN_BRACE; + } + // fall through + case 113: break; + case 49: + { yypopState(); return DISPLAY_MATH_END; + } + // fall through + case 114: break; + case 50: + { return DISPLAY_MATH_START; + } + // fall through + case 115: break; + case 51: + { return DISPLAY_MATH_END; + } + // fall through + case 116: break; + case 52: + { return BEGIN_PSEUDOCODE_BLOCK; + } + // fall through + case 117: break; + case 53: + { return END_TOKEN; + } + // fall through + case 118: break; + case 54: + { yypushState(POSSIBLE_VERBATIM_END); return END_TOKEN; + } + // fall through + case 119: break; + case 55: + { yypushState(POSSIBLE_PSEUDOCODE_END); return END_TOKEN; + } + // fall through + case 120: break; + case 56: + { yypushState(INLINE_VERBATIM_START); return COMMAND_TOKEN; + } + // fall through + case 121: break; + case 57: + { yypushState(TEXT_INSIDE_INLINE_MATH); return COMMAND_TOKEN; + } + // fall through + case 122: break; + case 58: + { return MIDDLE_PSEUDOCODE_BLOCK; + } + // fall through + case 123: break; + case 59: + { yypushState(POSSIBLE_VERBATIM_BEGIN); return BEGIN_TOKEN; + } + // fall through + case 124: break; + case 60: + { return BEGIN_TOKEN; + } + // fall through + case 125: break; + case 61: + { return END_PSEUDOCODE_BLOCK; + } + // fall through + case 126: break; + case 62: + { yypopState(); return COMMENT_TOKEN; + } + // fall through + case 127: break; + case 63: + { yypushState(OFF); return COMMENT_TOKEN; + } + // fall through + case 128: break; + case 64: + { return COMMAND_IFNEXTCHAR; + } + // fall through + case 129: break; + case 65: + { yypushState(NEW_ENVIRONMENT_DEFINITION_NAME); return COMMAND_TOKEN; + } + // fall through + case 130: break; default: zzScanError(ZZ_NO_MATCH); - } + } } } } diff --git a/gen/nl/hannahsten/texifyidea/parser/LatexParser.java b/gen/nl/hannahsten/texifyidea/parser/LatexParser.java index 47282ecd8..018644af6 100644 --- a/gen/nl/hannahsten/texifyidea/parser/LatexParser.java +++ b/gen/nl/hannahsten/texifyidea/parser/LatexParser.java @@ -338,7 +338,7 @@ private static boolean keyval_pair_1_0(PsiBuilder b, int l) { } /* ********************************************************** */ - // (NORMAL_TEXT_WORD | STAR | AMPERSAND | "|" | "!" | "\\" | "\"" | "<" | ">")+ + // (NORMAL_TEXT_WORD | STAR | AMPERSAND |PIPE | EXCLAMATION_MARK | BACKSLASH | QUOTATION_MARK | OPEN_ANGLE_BRACKET | CLOSE_ANGLE_BRACKET)+ public static boolean keyval_text(PsiBuilder b, int l) { if (!recursion_guard_(b, l, "keyval_text")) return false; boolean r; @@ -353,19 +353,19 @@ public static boolean keyval_text(PsiBuilder b, int l) { return r; } - // NORMAL_TEXT_WORD | STAR | AMPERSAND | "|" | "!" | "\\" | "\"" | "<" | ">" + // NORMAL_TEXT_WORD | STAR | AMPERSAND |PIPE | EXCLAMATION_MARK | BACKSLASH | QUOTATION_MARK | OPEN_ANGLE_BRACKET | CLOSE_ANGLE_BRACKET private static boolean keyval_text_0(PsiBuilder b, int l) { if (!recursion_guard_(b, l, "keyval_text_0")) return false; boolean r; r = consumeToken(b, NORMAL_TEXT_WORD); if (!r) r = consumeToken(b, STAR); if (!r) r = consumeToken(b, AMPERSAND); - if (!r) r = consumeToken(b, "|"); - if (!r) r = consumeToken(b, "!"); - if (!r) r = consumeToken(b, "\\"); - if (!r) r = consumeToken(b, "\""); - if (!r) r = consumeToken(b, "<"); - if (!r) r = consumeToken(b, ">"); + if (!r) r = consumeToken(b, PIPE); + if (!r) r = consumeToken(b, EXCLAMATION_MARK); + if (!r) r = consumeToken(b, BACKSLASH); + if (!r) r = consumeToken(b, QUOTATION_MARK); + if (!r) r = consumeToken(b, OPEN_ANGLE_BRACKET); + if (!r) r = consumeToken(b, CLOSE_ANGLE_BRACKET); return r; } @@ -464,7 +464,7 @@ public static boolean no_math_content(PsiBuilder b, int l) { } /* ********************************************************** */ - // (NORMAL_TEXT_WORD | STAR | AMPERSAND | NORMAL_TEXT_CHAR | EQUALS | COMMA )+ + // (NORMAL_TEXT_WORD | STAR | AMPERSAND | QUOTATION_MARK | OPEN_ANGLE_BRACKET | CLOSE_ANGLE_BRACKET | PIPE | EXCLAMATION_MARK | BACKSLASH | EQUALS | COMMA )+ public static boolean normal_text(PsiBuilder b, int l) { if (!recursion_guard_(b, l, "normal_text")) return false; boolean r; @@ -479,14 +479,19 @@ public static boolean normal_text(PsiBuilder b, int l) { return r; } - // NORMAL_TEXT_WORD | STAR | AMPERSAND | NORMAL_TEXT_CHAR | EQUALS | COMMA + // NORMAL_TEXT_WORD | STAR | AMPERSAND | QUOTATION_MARK | OPEN_ANGLE_BRACKET | CLOSE_ANGLE_BRACKET | PIPE | EXCLAMATION_MARK | BACKSLASH | EQUALS | COMMA private static boolean normal_text_0(PsiBuilder b, int l) { if (!recursion_guard_(b, l, "normal_text_0")) return false; boolean r; r = consumeToken(b, NORMAL_TEXT_WORD); if (!r) r = consumeToken(b, STAR); if (!r) r = consumeToken(b, AMPERSAND); - if (!r) r = consumeToken(b, NORMAL_TEXT_CHAR); + if (!r) r = consumeToken(b, QUOTATION_MARK); + if (!r) r = consumeToken(b, OPEN_ANGLE_BRACKET); + if (!r) r = consumeToken(b, CLOSE_ANGLE_BRACKET); + if (!r) r = consumeToken(b, PIPE); + if (!r) r = consumeToken(b, EXCLAMATION_MARK); + if (!r) r = consumeToken(b, BACKSLASH); if (!r) r = consumeToken(b, EQUALS); if (!r) r = consumeToken(b, COMMA); return r; @@ -562,7 +567,7 @@ private static boolean optional_param_1_1(PsiBuilder b, int l) { } /* ********************************************************** */ - // raw_text | magic_comment | comment | environment | pseudocode_block | math_environment | COMMAND_IFNEXTCHAR | commands | group | OPEN_PAREN | CLOSE_PAREN | parameter_text | NORMAL_TEXT_CHAR + // raw_text | magic_comment | comment | environment | pseudocode_block | math_environment | COMMAND_IFNEXTCHAR | commands | group | OPEN_PAREN | CLOSE_PAREN | parameter_text | BACKSLASH public static boolean optional_param_content(PsiBuilder b, int l) { if (!recursion_guard_(b, l, "optional_param_content")) return false; boolean r; @@ -579,7 +584,7 @@ public static boolean optional_param_content(PsiBuilder b, int l) { if (!r) r = consumeToken(b, OPEN_PAREN); if (!r) r = consumeToken(b, CLOSE_PAREN); if (!r) r = parameter_text(b, l + 1); - if (!r) r = consumeToken(b, NORMAL_TEXT_CHAR); + if (!r) r = consumeToken(b, BACKSLASH); exit_section_(b, l, m, r, false, null); return r; } @@ -628,7 +633,7 @@ public static boolean parameter_group_text(PsiBuilder b, int l) { } /* ********************************************************** */ - // (commands | NORMAL_TEXT_WORD | STAR | AMPERSAND)+ + // (commands | NORMAL_TEXT_WORD | STAR | AMPERSAND | OPEN_ANGLE_BRACKET | CLOSE_ANGLE_BRACKET | QUOTATION_MARK | PIPE | EXCLAMATION_MARK)+ public static boolean parameter_text(PsiBuilder b, int l) { if (!recursion_guard_(b, l, "parameter_text")) return false; boolean r; @@ -643,7 +648,7 @@ public static boolean parameter_text(PsiBuilder b, int l) { return r; } - // commands | NORMAL_TEXT_WORD | STAR | AMPERSAND + // commands | NORMAL_TEXT_WORD | STAR | AMPERSAND | OPEN_ANGLE_BRACKET | CLOSE_ANGLE_BRACKET | QUOTATION_MARK | PIPE | EXCLAMATION_MARK private static boolean parameter_text_0(PsiBuilder b, int l) { if (!recursion_guard_(b, l, "parameter_text_0")) return false; boolean r; @@ -651,6 +656,11 @@ private static boolean parameter_text_0(PsiBuilder b, int l) { if (!r) r = consumeToken(b, NORMAL_TEXT_WORD); if (!r) r = consumeToken(b, STAR); if (!r) r = consumeToken(b, AMPERSAND); + if (!r) r = consumeToken(b, OPEN_ANGLE_BRACKET); + if (!r) r = consumeToken(b, CLOSE_ANGLE_BRACKET); + if (!r) r = consumeToken(b, QUOTATION_MARK); + if (!r) r = consumeToken(b, PIPE); + if (!r) r = consumeToken(b, EXCLAMATION_MARK); return r; } @@ -797,7 +807,7 @@ private static boolean required_param_1(PsiBuilder b, int l) { } /* ********************************************************** */ - // raw_text | magic_comment | comment | environment | pseudocode_block | math_environment | COMMAND_IFNEXTCHAR | group | OPEN_PAREN | CLOSE_PAREN | parameter_text | COMMA | EQUALS | OPEN_BRACKET | CLOSE_BRACKET | NORMAL_TEXT_CHAR + // raw_text | magic_comment | comment | environment | pseudocode_block | math_environment | COMMAND_IFNEXTCHAR | group | OPEN_PAREN | CLOSE_PAREN | parameter_text | COMMA | EQUALS | OPEN_BRACKET | CLOSE_BRACKET | BACKSLASH public static boolean required_param_content(PsiBuilder b, int l) { if (!recursion_guard_(b, l, "required_param_content")) return false; boolean r; @@ -817,7 +827,7 @@ public static boolean required_param_content(PsiBuilder b, int l) { if (!r) r = consumeToken(b, EQUALS); if (!r) r = consumeToken(b, OPEN_BRACKET); if (!r) r = consumeToken(b, CLOSE_BRACKET); - if (!r) r = consumeToken(b, NORMAL_TEXT_CHAR); + if (!r) r = consumeToken(b, BACKSLASH); exit_section_(b, l, m, r, false, null); return r; } diff --git a/gen/nl/hannahsten/texifyidea/psi/LatexOptionalParamContent.java b/gen/nl/hannahsten/texifyidea/psi/LatexOptionalParamContent.java index d5386c795..56ec42291 100644 --- a/gen/nl/hannahsten/texifyidea/psi/LatexOptionalParamContent.java +++ b/gen/nl/hannahsten/texifyidea/psi/LatexOptionalParamContent.java @@ -1,9 +1,8 @@ // This is a generated file. Not intended for manual editing. package nl.hannahsten.texifyidea.psi; -import java.util.List; -import org.jetbrains.annotations.*; import com.intellij.psi.PsiElement; +import org.jetbrains.annotations.Nullable; public interface LatexOptionalParamContent extends PsiElement { @@ -37,7 +36,4 @@ public interface LatexOptionalParamContent extends PsiElement { @Nullable PsiElement getCommandIfnextchar(); - @Nullable - PsiElement getNormalTextChar(); - } diff --git a/gen/nl/hannahsten/texifyidea/psi/LatexRequiredParamContent.java b/gen/nl/hannahsten/texifyidea/psi/LatexRequiredParamContent.java index 506428d94..e4fff4108 100644 --- a/gen/nl/hannahsten/texifyidea/psi/LatexRequiredParamContent.java +++ b/gen/nl/hannahsten/texifyidea/psi/LatexRequiredParamContent.java @@ -1,9 +1,8 @@ // This is a generated file. Not intended for manual editing. package nl.hannahsten.texifyidea.psi; -import java.util.List; -import org.jetbrains.annotations.*; import com.intellij.psi.PsiElement; +import org.jetbrains.annotations.Nullable; public interface LatexRequiredParamContent extends PsiElement { @@ -34,7 +33,4 @@ public interface LatexRequiredParamContent extends PsiElement { @Nullable PsiElement getCommandIfnextchar(); - @Nullable - PsiElement getNormalTextChar(); - } diff --git a/gen/nl/hannahsten/texifyidea/psi/LatexTypes.java b/gen/nl/hannahsten/texifyidea/psi/LatexTypes.java index 019093c79..8b886d1e7 100644 --- a/gen/nl/hannahsten/texifyidea/psi/LatexTypes.java +++ b/gen/nl/hannahsten/texifyidea/psi/LatexTypes.java @@ -44,8 +44,10 @@ public interface LatexTypes { IElementType REQUIRED_PARAM_CONTENT = new LatexElementType("REQUIRED_PARAM_CONTENT"); IElementType AMPERSAND = new LatexTokenType("&"); + IElementType BACKSLASH = new LatexTokenType("BACKSLASH"); IElementType BEGIN_PSEUDOCODE_BLOCK = new LatexTokenType("BEGIN_PSEUDOCODE_BLOCK"); IElementType BEGIN_TOKEN = new LatexTokenType("\\begin"); + IElementType CLOSE_ANGLE_BRACKET = new LatexTokenType("CLOSE_ANGLE_BRACKET"); IElementType CLOSE_BRACE = new LatexTokenType("CLOSE_BRACE"); IElementType CLOSE_BRACKET = new LatexTokenType("CLOSE_BRACKET"); IElementType CLOSE_PAREN = new LatexTokenType("CLOSE_PAREN"); @@ -58,15 +60,19 @@ public interface LatexTypes { IElementType END_PSEUDOCODE_BLOCK = new LatexTokenType("END_PSEUDOCODE_BLOCK"); IElementType END_TOKEN = new LatexTokenType("\\end"); IElementType EQUALS = new LatexTokenType("EQUALS"); + IElementType EXCLAMATION_MARK = new LatexTokenType("EXCLAMATION_MARK"); IElementType INLINE_MATH_END = new LatexTokenType("INLINE_MATH_END"); IElementType INLINE_MATH_START = new LatexTokenType("INLINE_MATH_START"); IElementType MAGIC_COMMENT_TOKEN = new LatexTokenType("MAGIC_COMMENT_TOKEN"); IElementType MIDDLE_PSEUDOCODE_BLOCK = new LatexTokenType("MIDDLE_PSEUDOCODE_BLOCK"); IElementType NORMAL_TEXT_CHAR = new LatexTokenType("NORMAL_TEXT_CHAR"); IElementType NORMAL_TEXT_WORD = new LatexTokenType("NORMAL_TEXT_WORD"); + IElementType OPEN_ANGLE_BRACKET = new LatexTokenType("OPEN_ANGLE_BRACKET"); IElementType OPEN_BRACE = new LatexTokenType("OPEN_BRACE"); IElementType OPEN_BRACKET = new LatexTokenType("OPEN_BRACKET"); IElementType OPEN_PAREN = new LatexTokenType("OPEN_PAREN"); + IElementType PIPE = new LatexTokenType("PIPE"); + IElementType QUOTATION_MARK = new LatexTokenType("QUOTATION_MARK"); IElementType RAW_TEXT_TOKEN = new LatexTokenType("RAW_TEXT"); IElementType STAR = new LatexTokenType("*"); @@ -111,41 +117,59 @@ else if (type == KEYVAL_KEY) { } else if (type == KEYVAL_PAIR) { return new LatexKeyvalPairImpl(node); - } else if (type == KEYVAL_TEXT) { + } + else if (type == KEYVAL_TEXT) { return new LatexKeyvalTextImpl(node); - } else if (type == KEYVAL_VALUE) { + } + else if (type == KEYVAL_VALUE) { return new LatexKeyvalValueImpl(node); - } else if (type == MAGIC_COMMENT) { + } + else if (type == MAGIC_COMMENT) { return new LatexMagicCommentImpl(node); - } else if (type == MATH_CONTENT) { + } + else if (type == MATH_CONTENT) { return new LatexMathContentImpl(node); - } else if (type == MATH_ENVIRONMENT) { + } + else if (type == MATH_ENVIRONMENT) { return new LatexMathEnvironmentImpl(node); - } else if (type == NORMAL_TEXT) { + } + else if (type == NORMAL_TEXT) { return new LatexNormalTextImpl(node); - } else if (type == NO_MATH_CONTENT) { + } + else if (type == NO_MATH_CONTENT) { return new LatexNoMathContentImpl(node); - } else if (type == OPTIONAL_PARAM) { + } + else if (type == OPTIONAL_PARAM) { return new LatexOptionalParamImpl(node); - } else if (type == OPTIONAL_PARAM_CONTENT) { + } + else if (type == OPTIONAL_PARAM_CONTENT) { return new LatexOptionalParamContentImpl(node); - } else if (type == PARAMETER) { + } + else if (type == PARAMETER) { return new LatexParameterImpl(node); - } else if (type == PARAMETER_GROUP) { + } + else if (type == PARAMETER_GROUP) { return new LatexParameterGroupImpl(node); - } else if (type == PARAMETER_GROUP_TEXT) { + } + else if (type == PARAMETER_GROUP_TEXT) { return new LatexParameterGroupTextImpl(node); - } else if (type == PARAMETER_TEXT) { + } + else if (type == PARAMETER_TEXT) { return new LatexParameterTextImpl(node); - } else if (type == PSEUDOCODE_BLOCK) { + } + else if (type == PSEUDOCODE_BLOCK) { return new LatexPseudocodeBlockImpl(node); - } else if (type == PSEUDOCODE_BLOCK_CONTENT) { + } + else if (type == PSEUDOCODE_BLOCK_CONTENT) { return new LatexPseudocodeBlockContentImpl(node); - } else if (type == RAW_TEXT) { + } + else if (type == RAW_TEXT) { return new LatexRawTextImpl(node); - } else if (type == REQUIRED_PARAM) { + } + else if (type == REQUIRED_PARAM) { return new LatexRequiredParamImpl(node); - } else if (type == REQUIRED_PARAM_CONTENT) { + } + else if (type == REQUIRED_PARAM_CONTENT) { return new LatexRequiredParamContentImpl(node); } throw new AssertionError("Unknown element type: " + type); diff --git a/gen/nl/hannahsten/texifyidea/psi/impl/LatexKeyvalContentImpl.java b/gen/nl/hannahsten/texifyidea/psi/impl/LatexKeyvalContentImpl.java index 025f85f34..6c64703ab 100644 --- a/gen/nl/hannahsten/texifyidea/psi/impl/LatexKeyvalContentImpl.java +++ b/gen/nl/hannahsten/texifyidea/psi/impl/LatexKeyvalContentImpl.java @@ -21,7 +21,7 @@ public void accept(@NotNull LatexVisitor visitor) { @Override public void accept(@NotNull PsiElementVisitor visitor) { - if (visitor instanceof LatexVisitor) accept((LatexVisitor) visitor); + if (visitor instanceof LatexVisitor) accept((LatexVisitor)visitor); else super.accept(visitor); } diff --git a/gen/nl/hannahsten/texifyidea/psi/impl/LatexKeyvalTextImpl.java b/gen/nl/hannahsten/texifyidea/psi/impl/LatexKeyvalTextImpl.java index 19cf75b96..6a6f97504 100644 --- a/gen/nl/hannahsten/texifyidea/psi/impl/LatexKeyvalTextImpl.java +++ b/gen/nl/hannahsten/texifyidea/psi/impl/LatexKeyvalTextImpl.java @@ -20,7 +20,7 @@ public void accept(@NotNull LatexVisitor visitor) { @Override public void accept(@NotNull PsiElementVisitor visitor) { - if (visitor instanceof LatexVisitor) accept((LatexVisitor) visitor); + if (visitor instanceof LatexVisitor) accept((LatexVisitor)visitor); else super.accept(visitor); } diff --git a/gen/nl/hannahsten/texifyidea/psi/impl/LatexOptionalParamContentImpl.java b/gen/nl/hannahsten/texifyidea/psi/impl/LatexOptionalParamContentImpl.java index 1e93e5221..2847bd244 100644 --- a/gen/nl/hannahsten/texifyidea/psi/impl/LatexOptionalParamContentImpl.java +++ b/gen/nl/hannahsten/texifyidea/psi/impl/LatexOptionalParamContentImpl.java @@ -1,15 +1,16 @@ // This is a generated file. Not intended for manual editing. package nl.hannahsten.texifyidea.psi.impl; -import java.util.List; -import org.jetbrains.annotations.*; +import com.intellij.extapi.psi.ASTWrapperPsiElement; import com.intellij.lang.ASTNode; import com.intellij.psi.PsiElement; import com.intellij.psi.PsiElementVisitor; import com.intellij.psi.util.PsiTreeUtil; -import static nl.hannahsten.texifyidea.psi.LatexTypes.*; -import com.intellij.extapi.psi.ASTWrapperPsiElement; import nl.hannahsten.texifyidea.psi.*; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import static nl.hannahsten.texifyidea.psi.LatexTypes.COMMAND_IFNEXTCHAR; public class LatexOptionalParamContentImpl extends ASTWrapperPsiElement implements LatexOptionalParamContent { @@ -87,10 +88,4 @@ public PsiElement getCommandIfnextchar() { return findChildByType(COMMAND_IFNEXTCHAR); } - @Override - @Nullable - public PsiElement getNormalTextChar() { - return findChildByType(NORMAL_TEXT_CHAR); - } - } diff --git a/gen/nl/hannahsten/texifyidea/psi/impl/LatexParameterGroupTextImpl.java b/gen/nl/hannahsten/texifyidea/psi/impl/LatexParameterGroupTextImpl.java index d031d0b72..1d3af716f 100644 --- a/gen/nl/hannahsten/texifyidea/psi/impl/LatexParameterGroupTextImpl.java +++ b/gen/nl/hannahsten/texifyidea/psi/impl/LatexParameterGroupTextImpl.java @@ -24,7 +24,7 @@ public void accept(@NotNull LatexVisitor visitor) { @Override public void accept(@NotNull PsiElementVisitor visitor) { - if (visitor instanceof LatexVisitor) accept((LatexVisitor) visitor); + if (visitor instanceof LatexVisitor) accept((LatexVisitor)visitor); else super.accept(visitor); } diff --git a/gen/nl/hannahsten/texifyidea/psi/impl/LatexRequiredParamContentImpl.java b/gen/nl/hannahsten/texifyidea/psi/impl/LatexRequiredParamContentImpl.java index 4fdfaa8ff..0479fae82 100644 --- a/gen/nl/hannahsten/texifyidea/psi/impl/LatexRequiredParamContentImpl.java +++ b/gen/nl/hannahsten/texifyidea/psi/impl/LatexRequiredParamContentImpl.java @@ -1,15 +1,16 @@ // This is a generated file. Not intended for manual editing. package nl.hannahsten.texifyidea.psi.impl; -import java.util.List; -import org.jetbrains.annotations.*; +import com.intellij.extapi.psi.ASTWrapperPsiElement; import com.intellij.lang.ASTNode; import com.intellij.psi.PsiElement; import com.intellij.psi.PsiElementVisitor; import com.intellij.psi.util.PsiTreeUtil; -import static nl.hannahsten.texifyidea.psi.LatexTypes.*; -import com.intellij.extapi.psi.ASTWrapperPsiElement; import nl.hannahsten.texifyidea.psi.*; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import static nl.hannahsten.texifyidea.psi.LatexTypes.COMMAND_IFNEXTCHAR; public class LatexRequiredParamContentImpl extends ASTWrapperPsiElement implements LatexRequiredParamContent { @@ -81,10 +82,4 @@ public PsiElement getCommandIfnextchar() { return findChildByType(COMMAND_IFNEXTCHAR); } - @Override - @Nullable - public PsiElement getNormalTextChar() { - return findChildByType(NORMAL_TEXT_CHAR); - } - } diff --git a/src/nl/hannahsten/texifyidea/grammar/Latex.bnf b/src/nl/hannahsten/texifyidea/grammar/Latex.bnf index 3e936949f..142c0aa61 100644 --- a/src/nl/hannahsten/texifyidea/grammar/Latex.bnf +++ b/src/nl/hannahsten/texifyidea/grammar/Latex.bnf @@ -64,7 +64,7 @@ content ::= no_math_content no_math_content ::= raw_text | magic_comment | comment | environment | pseudocode_block | math_environment | COMMAND_IFNEXTCHAR | commands | group | OPEN_PAREN | CLOSE_PAREN | OPEN_BRACKET | CLOSE_BRACKET | normal_text -normal_text ::= (NORMAL_TEXT_WORD | STAR | AMPERSAND | NORMAL_TEXT_CHAR | EQUALS | COMMA )+ +normal_text ::= (NORMAL_TEXT_WORD | STAR | AMPERSAND | QUOTATION_MARK | OPEN_ANGLE_BRACKET | CLOSE_ANGLE_BRACKET | PIPE | EXCLAMATION_MARK | BACKSLASH | EQUALS | COMMA )+ environment ::= begin_command environment_content? end_command { pin=1 @@ -111,8 +111,8 @@ required_param ::= OPEN_BRACE required_param_content* CLOSE_BRACE { pin=1 } // These are like content, but no brackets and with parameter_text instead of normal_text // We have to separate optional and required parameter content, because required parameter content // can contain mismatched brackets, but optional parameters not (then we wouldn't know what to match) -optional_param_content ::= raw_text | magic_comment | comment | environment | pseudocode_block | math_environment | COMMAND_IFNEXTCHAR | commands | group | OPEN_PAREN | CLOSE_PAREN | parameter_text | NORMAL_TEXT_CHAR -required_param_content ::= raw_text | magic_comment | comment | environment | pseudocode_block | math_environment | COMMAND_IFNEXTCHAR | group | OPEN_PAREN | CLOSE_PAREN | parameter_text | COMMA | EQUALS | OPEN_BRACKET | CLOSE_BRACKET | NORMAL_TEXT_CHAR +optional_param_content ::= raw_text | magic_comment | comment | environment | pseudocode_block | math_environment | COMMAND_IFNEXTCHAR | commands | group | OPEN_PAREN | CLOSE_PAREN | parameter_text | BACKSLASH +required_param_content ::= raw_text | magic_comment | comment | environment | pseudocode_block | math_environment | COMMAND_IFNEXTCHAR | group | OPEN_PAREN | CLOSE_PAREN | parameter_text | COMMA | EQUALS | OPEN_BRACKET | CLOSE_BRACKET | BACKSLASH keyval_pair ::= keyval_key (EQUALS keyval_value)? keyval_key ::= keyval_content+ { @@ -125,7 +125,7 @@ keyval_content ::= commands | keyval_text | parameter_group // We need to include the special characters here because changing NORMAL_TEXT_CHAR would alter the lexer's behaviour // in several other places. -keyval_text ::= (NORMAL_TEXT_WORD | STAR | AMPERSAND | "|" | "!" | "\\" | "\"" | "<" | ">")+ +keyval_text ::= (NORMAL_TEXT_WORD | STAR | AMPERSAND |PIPE | EXCLAMATION_MARK | BACKSLASH | QUOTATION_MARK | OPEN_ANGLE_BRACKET | CLOSE_ANGLE_BRACKET)+ // The lowest level of a parameter must have the getReferences etc. implemented @@ -133,7 +133,7 @@ keyval_text ::= (NORMAL_TEXT_WORD | STAR | AMPERSAND | "|" | "!" | "\\" | "\"" | // So, the following is like normal_text // This assumes that parameter text which is a reference, appears directly under param_content // Commands is here instead of in required_param_content because it can be part of reference text for example to a file -parameter_text ::= (commands | NORMAL_TEXT_WORD | STAR | AMPERSAND)+ { +parameter_text ::= (commands | NORMAL_TEXT_WORD | STAR | AMPERSAND | OPEN_ANGLE_BRACKET | CLOSE_ANGLE_BRACKET | QUOTATION_MARK | PIPE | EXCLAMATION_MARK)+ { methods=[getReferences getReference getNameIdentifier getName setName] } diff --git a/src/nl/hannahsten/texifyidea/grammar/LatexLexer.flex b/src/nl/hannahsten/texifyidea/grammar/LatexLexer.flex index 999ff7131..35f47face 100644 --- a/src/nl/hannahsten/texifyidea/grammar/LatexLexer.flex +++ b/src/nl/hannahsten/texifyidea/grammar/LatexLexer.flex @@ -80,7 +80,6 @@ LEXER_ON_TOKEN={MAGIC_COMMENT_LEXER_SWITCH} "on" [^\r\n]* NORMAL_TEXT_WORD=[^\s\\\{\}%\[\]$\(\)|!\"=&<>,]+ // Separate from normal text, e.g. because they can be \verb delimiters or should not appear in normal text words for other reasons -NORMAL_TEXT_CHAR=[|!\"&<>] ANY_CHAR=[^] // Algorithmicx @@ -344,11 +343,21 @@ END_PSEUDOCODE_BLOCK="\\EndFor" | "\\EndIf" | "\\EndWhile" | "\\Until" | "\\EndL // In case a backslash is not a command, probably because a line ends with a backslash, then we do not want to lex the following newline as a command token, // because that will confuse the formatter because it will see the next line as being on this line -\\ { return NORMAL_TEXT_CHAR; } +\\ { return BACKSLASH; } "*" { return STAR; } // A separate token, used for example for aligning & in tables "&" { return AMPERSAND; } + +// Tokens for special characters of which certain grammar elements might support only a few +"=" { return EQUALS; } +"," { return COMMA; } +"\"" { return QUOTATION_MARK; } +"<" { return OPEN_ANGLE_BRACKET; } +">" { return CLOSE_ANGLE_BRACKET; } +"|" { return PIPE;} +"!" { return EXCLAMATION_MARK; } + {OPEN_BRACKET} { return OPEN_BRACKET; } {CLOSE_BRACKET} { return CLOSE_BRACKET; } {OPEN_BRACE} { return OPEN_BRACE; } @@ -364,10 +373,5 @@ END_PSEUDOCODE_BLOCK="\\EndFor" | "\\EndIf" | "\\EndWhile" | "\\Until" | "\\EndL {MAGIC_COMMENT_TOKEN} { return MAGIC_COMMENT_TOKEN; } {COMMENT_TOKEN} { return COMMENT_TOKEN; } {NORMAL_TEXT_WORD} { return NORMAL_TEXT_WORD; } -{NORMAL_TEXT_CHAR} { return NORMAL_TEXT_CHAR; } -// Tokens for parameter separators (e.g., \cite{param1,param2}) and -// keyval assigns (e.g. \lstinputlisting[label=somelabel]) -"=" { return EQUALS; } -"," { return COMMA; } [^] { return com.intellij.psi.TokenType.BAD_CHARACTER; } diff --git a/test/resources/psi/parser/ParsingInlineVerbatim.txt b/test/resources/psi/parser/ParsingInlineVerbatim.txt index 574b79512..bdf9be891 100644 --- a/test/resources/psi/parser/ParsingInlineVerbatim.txt +++ b/test/resources/psi/parser/ParsingInlineVerbatim.txt @@ -46,9 +46,9 @@ LaTeX source file(0,177) PsiWhiteSpace(' ')(35,36) PsiElement(LatexTokenType.NORMAL_TEXT_WORD)('verb:')(36,41) PsiWhiteSpace(' ')(41,42) - PsiElement(LatexTokenType.NORMAL_TEXT_CHAR)('|')(42,43) + PsiElement(LatexTokenType.PIPE)('|')(42,43) PsiElement(LatexTokenType.NORMAL_TEXT_WORD)('a')(43,44) - PsiElement(LatexTokenType.NORMAL_TEXT_CHAR)('|')(44,45) + PsiElement(LatexTokenType.PIPE)('|')(44,45) PsiWhiteSpace('\n')(45,46) LatexContentImpl(CONTENT)(46,65) LatexNoMathContentImpl(NO_MATH_CONTENT)(46,65) From 544ff7f2efe3c2294bef094e89cedf06c7d87b4e Mon Sep 17 00:00:00 2001 From: Felix Berlakovich Date: Sun, 3 Jan 2021 17:25:53 +0100 Subject: [PATCH 18/20] Use parameter_text for labels in optional parameters --- .../texifyidea/parser/LatexParser.java | 53 ++++++------------- .../texifyidea/psi/LatexKeyvalContent.java | 9 ++-- .../texifyidea/psi/LatexKeyvalText.java | 8 --- .../texifyidea/psi/LatexKeyvalValue.java | 13 ++--- .../psi/LatexParameterGroupText.java | 2 +- .../hannahsten/texifyidea/psi/LatexTypes.java | 4 -- .../texifyidea/psi/LatexVisitor.java | 6 +-- .../psi/impl/LatexKeyvalContentImpl.java | 37 ++++++------- .../psi/impl/LatexKeyvalTextImpl.java | 27 ---------- .../psi/impl/LatexKeyvalValueImpl.java | 16 ------ .../psi/impl/LatexParameterGroupTextImpl.java | 12 ++--- .../hannahsten/texifyidea/grammar/Latex.bnf | 13 ++--- .../texifyidea/psi/LatexCommandsImplUtil.kt | 3 +- .../texifyidea/psi/LatexParameterTextUtil.kt | 14 ++++- .../texifyidea/psi/LatexPsiHelper.kt | 7 +++ .../LatexRefactoringSupportProvider.kt | 2 - src/nl/hannahsten/texifyidea/util/Labels.kt | 15 ++++-- .../reference/LabelDefinitionReferenceTest.kt | 24 ++------- 18 files changed, 84 insertions(+), 181 deletions(-) delete mode 100644 gen/nl/hannahsten/texifyidea/psi/LatexKeyvalText.java delete mode 100644 gen/nl/hannahsten/texifyidea/psi/impl/LatexKeyvalTextImpl.java diff --git a/gen/nl/hannahsten/texifyidea/parser/LatexParser.java b/gen/nl/hannahsten/texifyidea/parser/LatexParser.java index 018644af6..700559468 100644 --- a/gen/nl/hannahsten/texifyidea/parser/LatexParser.java +++ b/gen/nl/hannahsten/texifyidea/parser/LatexParser.java @@ -279,13 +279,12 @@ private static boolean inline_math_1(PsiBuilder b, int l) { } /* ********************************************************** */ - // commands | keyval_text | parameter_group + // parameter_text | parameter_group public static boolean keyval_content(PsiBuilder b, int l) { if (!recursion_guard_(b, l, "keyval_content")) return false; boolean r; Marker m = enter_section_(b, l, _NONE_, KEYVAL_CONTENT, ""); - r = commands(b, l + 1); - if (!r) r = keyval_text(b, l + 1); + r = parameter_text(b, l + 1); if (!r) r = parameter_group(b, l + 1); exit_section_(b, l, m, r, false, null); return r; @@ -337,38 +336,6 @@ private static boolean keyval_pair_1_0(PsiBuilder b, int l) { return r; } - /* ********************************************************** */ - // (NORMAL_TEXT_WORD | STAR | AMPERSAND |PIPE | EXCLAMATION_MARK | BACKSLASH | QUOTATION_MARK | OPEN_ANGLE_BRACKET | CLOSE_ANGLE_BRACKET)+ - public static boolean keyval_text(PsiBuilder b, int l) { - if (!recursion_guard_(b, l, "keyval_text")) return false; - boolean r; - Marker m = enter_section_(b, l, _NONE_, KEYVAL_TEXT, ""); - r = keyval_text_0(b, l + 1); - while (r) { - int c = current_position_(b); - if (!keyval_text_0(b, l + 1)) break; - if (!empty_element_parsed_guard_(b, "keyval_text", c)) break; - } - exit_section_(b, l, m, r, false, null); - return r; - } - - // NORMAL_TEXT_WORD | STAR | AMPERSAND |PIPE | EXCLAMATION_MARK | BACKSLASH | QUOTATION_MARK | OPEN_ANGLE_BRACKET | CLOSE_ANGLE_BRACKET - private static boolean keyval_text_0(PsiBuilder b, int l) { - if (!recursion_guard_(b, l, "keyval_text_0")) return false; - boolean r; - r = consumeToken(b, NORMAL_TEXT_WORD); - if (!r) r = consumeToken(b, STAR); - if (!r) r = consumeToken(b, AMPERSAND); - if (!r) r = consumeToken(b, PIPE); - if (!r) r = consumeToken(b, EXCLAMATION_MARK); - if (!r) r = consumeToken(b, BACKSLASH); - if (!r) r = consumeToken(b, QUOTATION_MARK); - if (!r) r = consumeToken(b, OPEN_ANGLE_BRACKET); - if (!r) r = consumeToken(b, CLOSE_ANGLE_BRACKET); - return r; - } - /* ********************************************************** */ // keyval_content+ public static boolean keyval_value(PsiBuilder b, int l) { @@ -618,13 +585,13 @@ public static boolean parameter_group(PsiBuilder b, int l) { } /* ********************************************************** */ - // content* + // (parameter_text | COMMA | EQUALS | OPEN_BRACKET | CLOSE_BRACKET)* public static boolean parameter_group_text(PsiBuilder b, int l) { if (!recursion_guard_(b, l, "parameter_group_text")) return false; Marker m = enter_section_(b, l, _NONE_, PARAMETER_GROUP_TEXT, ""); while (true) { int c = current_position_(b); - if (!content(b, l + 1)) break; + if (!parameter_group_text_0(b, l + 1)) break; if (!empty_element_parsed_guard_(b, "parameter_group_text", c)) break; } register_hook_(b, WS_BINDERS, GREEDY_LEFT_BINDER, GREEDY_RIGHT_BINDER); @@ -632,6 +599,18 @@ public static boolean parameter_group_text(PsiBuilder b, int l) { return true; } + // parameter_text | COMMA | EQUALS | OPEN_BRACKET | CLOSE_BRACKET + private static boolean parameter_group_text_0(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "parameter_group_text_0")) return false; + boolean r; + r = parameter_text(b, l + 1); + if (!r) r = consumeToken(b, COMMA); + if (!r) r = consumeToken(b, EQUALS); + if (!r) r = consumeToken(b, OPEN_BRACKET); + if (!r) r = consumeToken(b, CLOSE_BRACKET); + return r; + } + /* ********************************************************** */ // (commands | NORMAL_TEXT_WORD | STAR | AMPERSAND | OPEN_ANGLE_BRACKET | CLOSE_ANGLE_BRACKET | QUOTATION_MARK | PIPE | EXCLAMATION_MARK)+ public static boolean parameter_text(PsiBuilder b, int l) { diff --git a/gen/nl/hannahsten/texifyidea/psi/LatexKeyvalContent.java b/gen/nl/hannahsten/texifyidea/psi/LatexKeyvalContent.java index 8c28667d5..dd3d4a9b0 100644 --- a/gen/nl/hannahsten/texifyidea/psi/LatexKeyvalContent.java +++ b/gen/nl/hannahsten/texifyidea/psi/LatexKeyvalContent.java @@ -6,13 +6,10 @@ public interface LatexKeyvalContent extends PsiElement { - @Nullable - LatexCommands getCommands(); - - @Nullable - LatexKeyvalText getKeyvalText(); - @Nullable LatexParameterGroup getParameterGroup(); + @Nullable + LatexParameterText getParameterText(); + } diff --git a/gen/nl/hannahsten/texifyidea/psi/LatexKeyvalText.java b/gen/nl/hannahsten/texifyidea/psi/LatexKeyvalText.java deleted file mode 100644 index a78acfc3a..000000000 --- a/gen/nl/hannahsten/texifyidea/psi/LatexKeyvalText.java +++ /dev/null @@ -1,8 +0,0 @@ -// This is a generated file. Not intended for manual editing. -package nl.hannahsten.texifyidea.psi; - -import com.intellij.psi.PsiElement; - -public interface LatexKeyvalText extends PsiElement { - -} diff --git a/gen/nl/hannahsten/texifyidea/psi/LatexKeyvalValue.java b/gen/nl/hannahsten/texifyidea/psi/LatexKeyvalValue.java index f6a917c23..b6938a014 100644 --- a/gen/nl/hannahsten/texifyidea/psi/LatexKeyvalValue.java +++ b/gen/nl/hannahsten/texifyidea/psi/LatexKeyvalValue.java @@ -2,20 +2,13 @@ package nl.hannahsten.texifyidea.psi; import com.intellij.psi.PsiElement; -import com.intellij.psi.PsiNameIdentifierOwner; import org.jetbrains.annotations.NotNull; import java.util.List; -public interface LatexKeyvalValue extends PsiNameIdentifierOwner { +public interface LatexKeyvalValue extends PsiElement { - @NotNull - List getKeyvalContentList(); - - PsiElement getNameIdentifier(); - - String getName(); - - PsiElement setName(String name); + @NotNull + List getKeyvalContentList(); } diff --git a/gen/nl/hannahsten/texifyidea/psi/LatexParameterGroupText.java b/gen/nl/hannahsten/texifyidea/psi/LatexParameterGroupText.java index 198e9e0bf..7bb94fcf5 100644 --- a/gen/nl/hannahsten/texifyidea/psi/LatexParameterGroupText.java +++ b/gen/nl/hannahsten/texifyidea/psi/LatexParameterGroupText.java @@ -9,6 +9,6 @@ public interface LatexParameterGroupText extends PsiElement { @NotNull - List getContentList(); + List getParameterTextList(); } diff --git a/gen/nl/hannahsten/texifyidea/psi/LatexTypes.java b/gen/nl/hannahsten/texifyidea/psi/LatexTypes.java index 8b886d1e7..8d4a697c7 100644 --- a/gen/nl/hannahsten/texifyidea/psi/LatexTypes.java +++ b/gen/nl/hannahsten/texifyidea/psi/LatexTypes.java @@ -24,7 +24,6 @@ public interface LatexTypes { IElementType KEYVAL_CONTENT = new LatexElementType("KEYVAL_CONTENT"); IElementType KEYVAL_KEY = new LatexElementType("KEYVAL_KEY"); IElementType KEYVAL_PAIR = new LatexElementType("KEYVAL_PAIR"); - IElementType KEYVAL_TEXT = new LatexElementType("KEYVAL_TEXT"); IElementType KEYVAL_VALUE = new LatexElementType("KEYVAL_VALUE"); IElementType MAGIC_COMMENT = new LatexMagicCommentStubElementType("MAGIC_COMMENT"); IElementType MATH_CONTENT = new LatexElementType("MATH_CONTENT"); @@ -118,9 +117,6 @@ else if (type == KEYVAL_KEY) { else if (type == KEYVAL_PAIR) { return new LatexKeyvalPairImpl(node); } - else if (type == KEYVAL_TEXT) { - return new LatexKeyvalTextImpl(node); - } else if (type == KEYVAL_VALUE) { return new LatexKeyvalValueImpl(node); } diff --git a/gen/nl/hannahsten/texifyidea/psi/LatexVisitor.java b/gen/nl/hannahsten/texifyidea/psi/LatexVisitor.java index 3e3f4c1c5..ebf85c1a6 100644 --- a/gen/nl/hannahsten/texifyidea/psi/LatexVisitor.java +++ b/gen/nl/hannahsten/texifyidea/psi/LatexVisitor.java @@ -62,12 +62,8 @@ public void visitKeyvalPair(@NotNull LatexKeyvalPair o) { visitPsiElement(o); } - public void visitKeyvalText(@NotNull LatexKeyvalText o) { - visitPsiElement(o); - } - public void visitKeyvalValue(@NotNull LatexKeyvalValue o) { - visitPsiNameIdentifierOwner(o); + visitPsiElement(o); } public void visitMagicComment(@NotNull LatexMagicComment o) { diff --git a/gen/nl/hannahsten/texifyidea/psi/impl/LatexKeyvalContentImpl.java b/gen/nl/hannahsten/texifyidea/psi/impl/LatexKeyvalContentImpl.java index 6c64703ab..b1869d889 100644 --- a/gen/nl/hannahsten/texifyidea/psi/impl/LatexKeyvalContentImpl.java +++ b/gen/nl/hannahsten/texifyidea/psi/impl/LatexKeyvalContentImpl.java @@ -5,7 +5,10 @@ import com.intellij.lang.ASTNode; import com.intellij.psi.PsiElementVisitor; import com.intellij.psi.util.PsiTreeUtil; -import nl.hannahsten.texifyidea.psi.*; +import nl.hannahsten.texifyidea.psi.LatexKeyvalContent; +import nl.hannahsten.texifyidea.psi.LatexParameterGroup; +import nl.hannahsten.texifyidea.psi.LatexParameterText; +import nl.hannahsten.texifyidea.psi.LatexVisitor; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -21,26 +24,20 @@ public void accept(@NotNull LatexVisitor visitor) { @Override public void accept(@NotNull PsiElementVisitor visitor) { - if (visitor instanceof LatexVisitor) accept((LatexVisitor)visitor); - else super.accept(visitor); + if (visitor instanceof LatexVisitor) accept((LatexVisitor) visitor); + else super.accept(visitor); } - @Override - @Nullable - public LatexCommands getCommands() { - return PsiTreeUtil.getChildOfType(this, LatexCommands.class); - } - - @Override - @Nullable - public LatexKeyvalText getKeyvalText() { - return PsiTreeUtil.getChildOfType(this, LatexKeyvalText.class); - } - - @Override - @Nullable - public LatexParameterGroup getParameterGroup() { - return PsiTreeUtil.getChildOfType(this, LatexParameterGroup.class); - } + @Override + @Nullable + public LatexParameterGroup getParameterGroup() { + return PsiTreeUtil.getChildOfType(this, LatexParameterGroup.class); + } + + @Override + @Nullable + public LatexParameterText getParameterText() { + return PsiTreeUtil.getChildOfType(this, LatexParameterText.class); + } } diff --git a/gen/nl/hannahsten/texifyidea/psi/impl/LatexKeyvalTextImpl.java b/gen/nl/hannahsten/texifyidea/psi/impl/LatexKeyvalTextImpl.java deleted file mode 100644 index 6a6f97504..000000000 --- a/gen/nl/hannahsten/texifyidea/psi/impl/LatexKeyvalTextImpl.java +++ /dev/null @@ -1,27 +0,0 @@ -// This is a generated file. Not intended for manual editing. -package nl.hannahsten.texifyidea.psi.impl; - -import com.intellij.extapi.psi.ASTWrapperPsiElement; -import com.intellij.lang.ASTNode; -import com.intellij.psi.PsiElementVisitor; -import nl.hannahsten.texifyidea.psi.LatexKeyvalText; -import nl.hannahsten.texifyidea.psi.LatexVisitor; -import org.jetbrains.annotations.NotNull; - -public class LatexKeyvalTextImpl extends ASTWrapperPsiElement implements LatexKeyvalText { - - public LatexKeyvalTextImpl(@NotNull ASTNode node) { - super(node); - } - - public void accept(@NotNull LatexVisitor visitor) { - visitor.visitKeyvalText(this); - } - - @Override - public void accept(@NotNull PsiElementVisitor visitor) { - if (visitor instanceof LatexVisitor) accept((LatexVisitor)visitor); - else super.accept(visitor); - } - -} diff --git a/gen/nl/hannahsten/texifyidea/psi/impl/LatexKeyvalValueImpl.java b/gen/nl/hannahsten/texifyidea/psi/impl/LatexKeyvalValueImpl.java index dabdf2c82..238397908 100644 --- a/gen/nl/hannahsten/texifyidea/psi/impl/LatexKeyvalValueImpl.java +++ b/gen/nl/hannahsten/texifyidea/psi/impl/LatexKeyvalValueImpl.java @@ -3,7 +3,6 @@ import com.intellij.extapi.psi.ASTWrapperPsiElement; import com.intellij.lang.ASTNode; -import com.intellij.psi.PsiElement; import com.intellij.psi.PsiElementVisitor; import com.intellij.psi.util.PsiTreeUtil; import nl.hannahsten.texifyidea.psi.LatexKeyvalContent; @@ -41,19 +40,4 @@ public String toString() { return LatexPsiImplUtil.toString(this); } - @Override - public PsiElement getNameIdentifier() { - return LatexPsiImplUtil.getNameIdentifier(this); - } - - @Override - public String getName() { - return LatexPsiImplUtil.getName(this); - } - - @Override - public PsiElement setName(String name) { - return LatexPsiImplUtil.setName(this, name); - } - } diff --git a/gen/nl/hannahsten/texifyidea/psi/impl/LatexParameterGroupTextImpl.java b/gen/nl/hannahsten/texifyidea/psi/impl/LatexParameterGroupTextImpl.java index 1d3af716f..35f60d231 100644 --- a/gen/nl/hannahsten/texifyidea/psi/impl/LatexParameterGroupTextImpl.java +++ b/gen/nl/hannahsten/texifyidea/psi/impl/LatexParameterGroupTextImpl.java @@ -5,8 +5,8 @@ import com.intellij.lang.ASTNode; import com.intellij.psi.PsiElementVisitor; import com.intellij.psi.util.PsiTreeUtil; -import nl.hannahsten.texifyidea.psi.LatexContent; import nl.hannahsten.texifyidea.psi.LatexParameterGroupText; +import nl.hannahsten.texifyidea.psi.LatexParameterText; import nl.hannahsten.texifyidea.psi.LatexVisitor; import org.jetbrains.annotations.NotNull; @@ -28,10 +28,10 @@ public void accept(@NotNull PsiElementVisitor visitor) { else super.accept(visitor); } - @Override - @NotNull - public List getContentList() { - return PsiTreeUtil.getChildrenOfTypeAsList(this, LatexContent.class); - } + @Override + @NotNull + public List getParameterTextList() { + return PsiTreeUtil.getChildrenOfTypeAsList(this, LatexParameterText.class); + } } diff --git a/src/nl/hannahsten/texifyidea/grammar/Latex.bnf b/src/nl/hannahsten/texifyidea/grammar/Latex.bnf index 142c0aa61..9a70b53b4 100644 --- a/src/nl/hannahsten/texifyidea/grammar/Latex.bnf +++ b/src/nl/hannahsten/texifyidea/grammar/Latex.bnf @@ -26,9 +26,6 @@ // Make text have an identifier, to be able to Ctrl+B for \label parameters implements("parameter_text")="com.intellij.psi.PsiNameIdentifierOwner" - // Make text in parameter group have an identifier, to be able to Ctrl+B for \label parameters - implements("keyval_value")="com.intellij.psi.PsiNameIdentifierOwner" - implements("parameter")="com.intellij.psi.PsiLanguageInjectionHost" // See the lexer tokens=[ @@ -119,13 +116,9 @@ keyval_key ::= keyval_content+ { methods=[toString] } keyval_value ::= keyval_content+ { - methods=[toString getNameIdentifier getName setName] + methods=[toString] } -keyval_content ::= commands | keyval_text | parameter_group - -// We need to include the special characters here because changing NORMAL_TEXT_CHAR would alter the lexer's behaviour -// in several other places. -keyval_text ::= (NORMAL_TEXT_WORD | STAR | AMPERSAND |PIPE | EXCLAMATION_MARK | BACKSLASH | QUOTATION_MARK | OPEN_ANGLE_BRACKET | CLOSE_ANGLE_BRACKET)+ +keyval_content ::= parameter_text | parameter_group // The lowest level of a parameter must have the getReferences etc. implemented @@ -143,7 +136,7 @@ parameter_group ::= OPEN_BRACE parameter_group_text CLOSE_BRACE { pin=1 } // Be sure to capture the whitespace before and after the actual content as groups are meant to capture // *everything* inside them. -parameter_group_text ::= content* { hooks = [wsBinders="GREEDY_LEFT_BINDER, GREEDY_RIGHT_BINDER"] } +parameter_group_text ::= (parameter_text | COMMA | EQUALS | OPEN_BRACKET | CLOSE_BRACKET)* { hooks = [wsBinders="GREEDY_LEFT_BINDER, GREEDY_RIGHT_BINDER"] } comment ::= COMMENT_TOKEN diff --git a/src/nl/hannahsten/texifyidea/psi/LatexCommandsImplUtil.kt b/src/nl/hannahsten/texifyidea/psi/LatexCommandsImplUtil.kt index 69da280b8..ed4619aec 100644 --- a/src/nl/hannahsten/texifyidea/psi/LatexCommandsImplUtil.kt +++ b/src/nl/hannahsten/texifyidea/psi/LatexCommandsImplUtil.kt @@ -218,9 +218,8 @@ fun keyValContentToString(element: LatexKeyvalKey): String = fun keyValContentToString(list: List): String = list.joinToString(separator = "") { when { - it.keyvalText != null -> it.keyvalText!!.text + it.parameterText != null -> it.parameterText!!.text it.parameterGroup != null -> it.parameterGroup!!.parameterGroupText!!.text - it.commands != null -> it.commands!!.text else -> "" } } diff --git a/src/nl/hannahsten/texifyidea/psi/LatexParameterTextUtil.kt b/src/nl/hannahsten/texifyidea/psi/LatexParameterTextUtil.kt index b198c9fdb..744ee9c25 100644 --- a/src/nl/hannahsten/texifyidea/psi/LatexParameterTextUtil.kt +++ b/src/nl/hannahsten/texifyidea/psi/LatexParameterTextUtil.kt @@ -8,6 +8,7 @@ import nl.hannahsten.texifyidea.reference.LatexLabelParameterReference import nl.hannahsten.texifyidea.util.Magic import nl.hannahsten.texifyidea.util.extractLabelName import nl.hannahsten.texifyidea.util.firstParentOfType +import nl.hannahsten.texifyidea.util.parentOfType /** * If the normal text is the parameter of a \ref-like command, get the references to the label declaration. @@ -52,9 +53,12 @@ fun getNameIdentifier(element: LatexParameterText): PsiElement? { // (think non-ASCII characters in a \section command), we return null here when the element is not an identifier // It is important not to return null for any identifier, otherwise exceptions like "Throwable: null byMemberInplaceRenamer" may occur val name = element.firstParentOfType(LatexCommands::class)?.name + val environmentName = element.firstParentOfType(LatexEnvironment::class)?.environmentName if (!Magic.Command.labelReferenceWithoutCustomCommands.contains(name) && !Magic.Command.labelDefinitionsWithoutCustomCommands.contains(name) && !Magic.Command.bibliographyReference.contains(name) && + !Magic.Command.labelAsParameter.contains(name) && + !Magic.Environment.labelAsParameter.contains(environmentName) && element.firstParentOfType(LatexEndCommand::class) == null && element.firstParentOfType(LatexBeginCommand::class) == null ) { @@ -89,7 +93,15 @@ fun setName(element: LatexParameterText, name: String): PsiElement { ) ) { val helper = LatexPsiHelper(element.project) - helper.setOptionalParameter(command ?: environment!!.beginCommand, "label", name) + + // If the label name is inside a group, keep the group + val value = if (element.parentOfType(LatexParameterGroupText::class) != null) { + "{$name}" + } + else { + name + } + helper.setOptionalParameter(command ?: environment!!.beginCommand, "label", value) } else if (element.firstParentOfType(LatexEndCommand::class) != null || element.firstParentOfType(LatexBeginCommand::class) != null) { // We are renaming an environment, text in \begin or \end diff --git a/src/nl/hannahsten/texifyidea/psi/LatexPsiHelper.kt b/src/nl/hannahsten/texifyidea/psi/LatexPsiHelper.kt index 8164d69ce..be6735d61 100644 --- a/src/nl/hannahsten/texifyidea/psi/LatexPsiHelper.kt +++ b/src/nl/hannahsten/texifyidea/psi/LatexPsiHelper.kt @@ -74,6 +74,13 @@ class LatexPsiHelper(private val project: Project) { return createFromText(commandText).firstChildOfType(LatexRequiredParam::class)!! } + /** + * Set the value of the optional parameter with the givevn key name. If the the parameter already exists, + * its value is changed. If no key with the given name exists yet, a new one is created with the given value. + * + * @param name The name of the parameter to change + * @param value The new parameter value. If the value is null, the parameter will have a key only. + */ fun setOptionalParameter(command: LatexCommandWithParams, name: String, value: String?): PsiElement { val existingParameters = command.optionalParameterMap if (existingParameters.isEmpty()) { diff --git a/src/nl/hannahsten/texifyidea/refactoring/LatexRefactoringSupportProvider.kt b/src/nl/hannahsten/texifyidea/refactoring/LatexRefactoringSupportProvider.kt index 583f10fc9..f6f0f49a5 100644 --- a/src/nl/hannahsten/texifyidea/refactoring/LatexRefactoringSupportProvider.kt +++ b/src/nl/hannahsten/texifyidea/refactoring/LatexRefactoringSupportProvider.kt @@ -2,7 +2,6 @@ package nl.hannahsten.texifyidea.refactoring import com.intellij.lang.refactoring.RefactoringSupportProvider import com.intellij.psi.PsiElement -import nl.hannahsten.texifyidea.psi.LatexKeyvalValue import nl.hannahsten.texifyidea.psi.LatexParameterText /** @@ -13,7 +12,6 @@ class LatexRefactoringSupportProvider : RefactoringSupportProvider() { // Label parameters are LatexParameterText return when (element) { is LatexParameterText -> true - is LatexKeyvalValue -> true else -> false } } diff --git a/src/nl/hannahsten/texifyidea/util/Labels.kt b/src/nl/hannahsten/texifyidea/util/Labels.kt index e5738fb39..cec64d2e6 100644 --- a/src/nl/hannahsten/texifyidea/util/Labels.kt +++ b/src/nl/hannahsten/texifyidea/util/Labels.kt @@ -193,12 +193,19 @@ fun PsiElement.extractLabelName(): String { * Extracts the label element (so the element that should be resolved to) from the PsiElement given that the PsiElement represents a label. */ fun PsiElement.extractLabelElement(): PsiElement? { + fun getLabelParameterText(command: LatexCommandWithParams): LatexParameterText { + val optionalParameters = command.optionalParameterMap + val labelEntry = optionalParameters.filter { pair -> pair.key.toString() == "label" }.first() + val contentList = labelEntry.value.keyvalContentList + return contentList.firstOrNull { c -> c.parameterText != null }?.parameterText + ?: contentList.first { c -> c.parameterGroup != null }.parameterGroup!!.parameterGroupText!!.parameterTextList.first() + } + return when (this) { is BibtexEntry -> firstChildOfType(BibtexId::class) is LatexCommands -> { if (Magic.Command.labelAsParameter.contains(name)) { - val labelEntry = optionalParameterMap.filter { pair -> pair.key.toString() == "label" }.first() - return labelEntry.value + return getLabelParameterText(this) } else { // For now just take the first label name (may be multiple for user defined commands) @@ -212,9 +219,7 @@ fun PsiElement.extractLabelElement(): PsiElement? { } is LatexEnvironment -> { if (Magic.Environment.labelAsParameter.contains(environmentName)) { - val labelEntry = - beginCommand.optionalParameterMap.filter { pair -> pair.key.toString() == "label" }.first() - return labelEntry.value + getLabelParameterText(beginCommand) } else { null diff --git a/test/nl/hannahsten/texifyidea/reference/LabelDefinitionReferenceTest.kt b/test/nl/hannahsten/texifyidea/reference/LabelDefinitionReferenceTest.kt index 7281b9cf9..230b532af 100644 --- a/test/nl/hannahsten/texifyidea/reference/LabelDefinitionReferenceTest.kt +++ b/test/nl/hannahsten/texifyidea/reference/LabelDefinitionReferenceTest.kt @@ -23,7 +23,7 @@ class LabelDefinitionReferenceTest : BasePlatformTestCase() { myFixture.renameElementAtCaret("renamed") myFixture.checkResult( """ - \begin{lstlisting}[label={renamed}] + \begin{lstlisting}[label=renamed] \end{lstlisting} \ref{renamed} """.trimMargin() @@ -42,7 +42,7 @@ class LabelDefinitionReferenceTest : BasePlatformTestCase() { myFixture.renameElementAtCaret("renamed") myFixture.checkResult( """ - \begin{lstlisting}[label={renamed},escapechar=|!\"&] + \begin{lstlisting}[label=renamed,escapechar=|!\"&] \end{lstlisting} \ref{renamed} """.trimMargin() @@ -61,7 +61,7 @@ class LabelDefinitionReferenceTest : BasePlatformTestCase() { myFixture.renameElementAtCaret("renamed") myFixture.checkResult( """ - \lstinputlisting[label={renamed}]{inputfile} + \lstinputlisting[label=renamed]{inputfile} \ref{renamed} """.trimMargin() ) @@ -84,22 +84,4 @@ class LabelDefinitionReferenceTest : BasePlatformTestCase() { """.trimMargin() ) } - - fun `test rename of label in multiple groups`() { - myFixture.configureByText( - LatexFileType, - """ - \lstinputlisting[label={test}{test2}]{inputfile} - \ref{testtest2} - """ - .trimMargin() - ) - myFixture.renameElementAtCaret("renamed") - myFixture.checkResult( - """ - \lstinputlisting[label={renamed}]{inputfile} - \ref{renamed} - """.trimMargin() - ) - } } \ No newline at end of file From 1cd6e0fb543dff29d5b8e7fb35fc4268c1fc7631 Mon Sep 17 00:00:00 2001 From: Felix Berlakovich Date: Sun, 3 Jan 2021 17:34:05 +0100 Subject: [PATCH 19/20] Remove unused utility methods --- .../psi/LatexParameterGroupTextUtil.kt | 39 ------------------- .../texifyidea/psi/LatexPsiImplUtil.java | 12 ------ 2 files changed, 51 deletions(-) delete mode 100644 src/nl/hannahsten/texifyidea/psi/LatexParameterGroupTextUtil.kt diff --git a/src/nl/hannahsten/texifyidea/psi/LatexParameterGroupTextUtil.kt b/src/nl/hannahsten/texifyidea/psi/LatexParameterGroupTextUtil.kt deleted file mode 100644 index d9998c100..000000000 --- a/src/nl/hannahsten/texifyidea/psi/LatexParameterGroupTextUtil.kt +++ /dev/null @@ -1,39 +0,0 @@ -package nl.hannahsten.texifyidea.psi - -import com.intellij.psi.PsiElement -import nl.hannahsten.texifyidea.util.Magic -import nl.hannahsten.texifyidea.util.firstParentOfType - -fun getNameIdentifier(element: LatexKeyvalValue): PsiElement? { - // Because we do not want to trigger the NonAsciiCharactersInspection when the LatexParameterText is not an identifier - // (think non-ASCII characters in a \section command), we return null here when the element is not an identifier - // It is important not to return null for any identifier, otherwise exceptions like "Throwable: null byMemberInplaceRenamer" may occur - val command = element.firstParentOfType(LatexCommands::class) - val environment = element.firstParentOfType(LatexEnvironment::class) - if (Magic.Command.labelAsParameter.contains(command?.name) || - Magic.Environment.labelAsParameter.contains(environment?.environmentName) - ) { - return element - } - return null -} - -fun setName(element: LatexKeyvalValue, name: String): PsiElement { - val command = element.firstParentOfType(LatexCommands::class) - val environment = element.firstParentOfType(LatexEnvironment::class) - if (Magic.Command.labelAsParameter.contains(command?.name) || Magic.Environment.labelAsParameter.contains( - environment?.environmentName - ) - ) { - val helper = LatexPsiHelper(element.project) - val commandWithParams = command ?: environment!!.beginCommand - helper.setOptionalParameter(commandWithParams, "label", "{$name}") - } - - // Else, element is not renamable - return element -} - -fun getName(element: LatexKeyvalValue): String { - return element.toString() -} \ No newline at end of file diff --git a/src/nl/hannahsten/texifyidea/psi/LatexPsiImplUtil.java b/src/nl/hannahsten/texifyidea/psi/LatexPsiImplUtil.java index 68ae5c145..eca8eb4f9 100644 --- a/src/nl/hannahsten/texifyidea/psi/LatexPsiImplUtil.java +++ b/src/nl/hannahsten/texifyidea/psi/LatexPsiImplUtil.java @@ -136,18 +136,6 @@ public static String getName(@NotNull LatexParameterText element) { return LatexParameterTextUtilKt.getName(element); } - public static PsiElement getNameIdentifier(@NotNull LatexKeyvalValue element) { - return LatexParameterGroupTextUtilKt.getNameIdentifier(element); - } - - public static PsiElement setName(@NotNull LatexKeyvalValue element, String name) { - return LatexParameterGroupTextUtilKt.setName(element, name); - } - - public static String getName(@NotNull LatexKeyvalValue element) { - return LatexParameterGroupTextUtilKt.getName(element); - } - /* * LatexParameter */ From 3e26c1f301f22a6d3d5f206e62099fc37adab95e Mon Sep 17 00:00:00 2001 From: Thomas Date: Mon, 4 Jan 2021 17:26:09 +0100 Subject: [PATCH 20/20] Add comment --- src/nl/hannahsten/texifyidea/LatexParserDefinition.kt | 2 +- src/nl/hannahsten/texifyidea/grammar/Latex.bnf | 2 ++ src/nl/hannahsten/texifyidea/util/Magic.kt | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/nl/hannahsten/texifyidea/LatexParserDefinition.kt b/src/nl/hannahsten/texifyidea/LatexParserDefinition.kt index d77a0dc0b..b6dbd34d6 100644 --- a/src/nl/hannahsten/texifyidea/LatexParserDefinition.kt +++ b/src/nl/hannahsten/texifyidea/LatexParserDefinition.kt @@ -50,7 +50,7 @@ class LatexParserDefinition : ParserDefinition { val FILE: IStubFileElementType<*> = object : IStubFileElementType( Language.findInstance(LatexLanguage::class.java) ) { - override fun getStubVersion(): Int = 14 + override fun getStubVersion(): Int = 15 } } diff --git a/src/nl/hannahsten/texifyidea/grammar/Latex.bnf b/src/nl/hannahsten/texifyidea/grammar/Latex.bnf index 9a70b53b4..35aa46863 100644 --- a/src/nl/hannahsten/texifyidea/grammar/Latex.bnf +++ b/src/nl/hannahsten/texifyidea/grammar/Latex.bnf @@ -132,10 +132,12 @@ parameter_text ::= (commands | NORMAL_TEXT_WORD | STAR | AMPERSAND | OPEN_ANGLE_ group ::= OPEN_BRACE content* CLOSE_BRACE { pin=1 } +// Use a separate element for inside parameters, because it has to contain parameter_text as leaf element parameter_group ::= OPEN_BRACE parameter_group_text CLOSE_BRACE { pin=1 } // Be sure to capture the whitespace before and after the actual content as groups are meant to capture // *everything* inside them. +// This element is needed instead of parameter_text in order to avoid parse errors for various other tokens that do not appear in parameter_text because they are not usually part of the reference parameter_group_text ::= (parameter_text | COMMA | EQUALS | OPEN_BRACKET | CLOSE_BRACKET)* { hooks = [wsBinders="GREEDY_LEFT_BINDER, GREEDY_RIGHT_BINDER"] } comment ::= COMMENT_TOKEN diff --git a/src/nl/hannahsten/texifyidea/util/Magic.kt b/src/nl/hannahsten/texifyidea/util/Magic.kt index 1babc18ea..490de3336 100644 --- a/src/nl/hannahsten/texifyidea/util/Magic.kt +++ b/src/nl/hannahsten/texifyidea/util/Magic.kt @@ -343,7 +343,7 @@ object Magic { * Commands that define a label via an optional parameter */ @JvmField - val labelAsParameter = hashSetOf("\\lstinputlisting") + val labelAsParameter = hashSetOf(LSTINPUTLISTING.commandDisplay) /** * All commands that mark some kind of section.