├── .idea ├── .name ├── .gitignore ├── codeStyles │ └── codeStyleConfig.xml ├── compiler.xml ├── vcs.xml ├── modules.xml ├── intellij-ron.iml ├── gradle.xml ├── misc.xml ├── $CACHE_FILE$ └── jarRepositories.xml ├── settings.gradle ├── .gitignore ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── src └── main │ ├── resources │ ├── flex │ │ ├── jflex-1.7.0-2.jar │ │ └── idea-flex.skeleton │ ├── META-INF │ │ ├── plugin.xml │ │ ├── pluginIcon.svg │ │ └── pluginIcon_dark.svg │ └── icons │ │ └── ronFile.svg │ ├── java │ └── org │ │ └── jonahhenriksson │ │ └── ron │ │ └── language │ │ ├── psi │ │ ├── RONParserUtil.java │ │ ├── RONElementType.java │ │ ├── RONTokenType.java │ │ └── RONFile.java │ │ ├── RONIcons.java │ │ ├── RONLexerAdapter.java │ │ ├── RONLanguage.java │ │ ├── RONFileType.java │ │ ├── RONCreateFile.java │ │ ├── RONParserDefinition.java │ │ ├── RON.bnf │ │ ├── __RONLexer.flex │ │ └── RONSyntaxHighlighter.java │ └── gen │ └── org │ └── jonahhenriksson │ └── ron │ └── language │ ├── psi │ ├── RONBool.java │ ├── RONOption.java │ ├── RONList.java │ ├── RONMap.java │ ├── RONMapEntry.java │ ├── RONNamedField.java │ ├── RONObject.java │ ├── RONValue.java │ ├── impl │ │ ├── RONBoolImpl.java │ │ ├── RONOptionImpl.java │ │ ├── RONListImpl.java │ │ ├── RONMapImpl.java │ │ ├── RONMapEntryImpl.java │ │ ├── RONNamedFieldImpl.java │ │ ├── RONObjectImpl.java │ │ └── RONValueImpl.java │ ├── RONVisitor.java │ └── RONTypes.java │ ├── parser │ └── _RONParser.java │ └── __RONLexer.java ├── LICENSE-MIT ├── README.md ├── gradlew.bat ├── gradlew └── LICENSE-APACHE /.idea/.name: -------------------------------------------------------------------------------- 1 | ron -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'ron' 2 | 3 | -------------------------------------------------------------------------------- /.idea/.gitignore: -------------------------------------------------------------------------------- 1 | # Default ignored files 2 | /shelf/ 3 | /workspace.xml 4 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .gradle 2 | build 3 | src/main/gen/org/jonahhenriksson/ron/language/__RONLexer.java~ 4 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ron-rs/intellij-ron/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /src/main/resources/flex/jflex-1.7.0-2.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ron-rs/intellij-ron/HEAD/src/main/resources/flex/jflex-1.7.0-2.jar -------------------------------------------------------------------------------- /.idea/codeStyles/codeStyleConfig.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | -------------------------------------------------------------------------------- /.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-6.3-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /src/main/java/org/jonahhenriksson/ron/language/psi/RONParserUtil.java: -------------------------------------------------------------------------------- 1 | package org.jonahhenriksson.ron.language.psi; 2 | 3 | import com.intellij.lang.parser.GeneratedParserUtilBase; 4 | 5 | public class RONParserUtil extends GeneratedParserUtilBase { 6 | } 7 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /src/main/java/org/jonahhenriksson/ron/language/RONIcons.java: -------------------------------------------------------------------------------- 1 | package org.jonahhenriksson.ron.language; 2 | 3 | import com.intellij.openapi.util.IconLoader; 4 | 5 | import javax.swing.*; 6 | 7 | public class RONIcons { 8 | public static final Icon FILE = IconLoader.getIcon("/icons/ronFile.svg"); 9 | } 10 | -------------------------------------------------------------------------------- /src/main/java/org/jonahhenriksson/ron/language/RONLexerAdapter.java: -------------------------------------------------------------------------------- 1 | package org.jonahhenriksson.ron.language; 2 | 3 | import com.intellij.lexer.FlexAdapter; 4 | 5 | public class RONLexerAdapter extends FlexAdapter { 6 | public RONLexerAdapter() { 7 | super(new __RONLexer()); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /src/main/java/org/jonahhenriksson/ron/language/RONLanguage.java: -------------------------------------------------------------------------------- 1 | package org.jonahhenriksson.ron.language; 2 | 3 | import com.intellij.lang.Language; 4 | 5 | public class RONLanguage extends Language { 6 | public static final RONLanguage INSTANCE = new RONLanguage(); 7 | 8 | private RONLanguage() { 9 | super("RON"); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/main/gen/org/jonahhenriksson/ron/language/psi/RONBool.java: -------------------------------------------------------------------------------- 1 | // This is a generated file. Not intended for manual editing. 2 | package org.jonahhenriksson.ron.language.psi; 3 | 4 | import java.util.List; 5 | import org.jetbrains.annotations.*; 6 | import com.intellij.psi.PsiElement; 7 | 8 | public interface RONBool extends PsiElement { 9 | 10 | @NotNull 11 | PsiElement getBoolean(); 12 | 13 | } 14 | -------------------------------------------------------------------------------- /src/main/gen/org/jonahhenriksson/ron/language/psi/RONOption.java: -------------------------------------------------------------------------------- 1 | // This is a generated file. Not intended for manual editing. 2 | package org.jonahhenriksson.ron.language.psi; 3 | 4 | import java.util.List; 5 | import org.jetbrains.annotations.*; 6 | import com.intellij.psi.PsiElement; 7 | 8 | public interface RONOption extends PsiElement { 9 | 10 | @NotNull 11 | RONValue getValue(); 12 | 13 | } 14 | -------------------------------------------------------------------------------- /src/main/gen/org/jonahhenriksson/ron/language/psi/RONList.java: -------------------------------------------------------------------------------- 1 | // This is a generated file. Not intended for manual editing. 2 | package org.jonahhenriksson.ron.language.psi; 3 | 4 | import java.util.List; 5 | import org.jetbrains.annotations.*; 6 | import com.intellij.psi.PsiElement; 7 | 8 | public interface RONList extends PsiElement { 9 | 10 | @NotNull 11 | List getValueList(); 12 | 13 | } 14 | -------------------------------------------------------------------------------- /src/main/gen/org/jonahhenriksson/ron/language/psi/RONMap.java: -------------------------------------------------------------------------------- 1 | // This is a generated file. Not intended for manual editing. 2 | package org.jonahhenriksson.ron.language.psi; 3 | 4 | import java.util.List; 5 | import org.jetbrains.annotations.*; 6 | import com.intellij.psi.PsiElement; 7 | 8 | public interface RONMap extends PsiElement { 9 | 10 | @NotNull 11 | List getMapEntryList(); 12 | 13 | } 14 | -------------------------------------------------------------------------------- /src/main/gen/org/jonahhenriksson/ron/language/psi/RONMapEntry.java: -------------------------------------------------------------------------------- 1 | // This is a generated file. Not intended for manual editing. 2 | package org.jonahhenriksson.ron.language.psi; 3 | 4 | import java.util.List; 5 | import org.jetbrains.annotations.*; 6 | import com.intellij.psi.PsiElement; 7 | 8 | public interface RONMapEntry extends PsiElement { 9 | 10 | @NotNull 11 | List getValueList(); 12 | 13 | } 14 | -------------------------------------------------------------------------------- /src/main/gen/org/jonahhenriksson/ron/language/psi/RONNamedField.java: -------------------------------------------------------------------------------- 1 | // This is a generated file. Not intended for manual editing. 2 | package org.jonahhenriksson.ron.language.psi; 3 | 4 | import java.util.List; 5 | import org.jetbrains.annotations.*; 6 | import com.intellij.psi.PsiElement; 7 | 8 | public interface RONNamedField extends PsiElement { 9 | 10 | @NotNull 11 | RONValue getValue(); 12 | 13 | @NotNull 14 | PsiElement getIdent(); 15 | 16 | } 17 | -------------------------------------------------------------------------------- /src/main/gen/org/jonahhenriksson/ron/language/psi/RONObject.java: -------------------------------------------------------------------------------- 1 | // This is a generated file. Not intended for manual editing. 2 | package org.jonahhenriksson.ron.language.psi; 3 | 4 | import java.util.List; 5 | import org.jetbrains.annotations.*; 6 | import com.intellij.psi.PsiElement; 7 | 8 | public interface RONObject extends PsiElement { 9 | 10 | @NotNull 11 | List getValueList(); 12 | 13 | @Nullable 14 | PsiElement getIdent(); 15 | 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/org/jonahhenriksson/ron/language/psi/RONElementType.java: -------------------------------------------------------------------------------- 1 | package org.jonahhenriksson.ron.language.psi; 2 | 3 | import com.intellij.psi.tree.IElementType; 4 | import org.jetbrains.annotations.NonNls; 5 | import org.jetbrains.annotations.NotNull; 6 | import org.jonahhenriksson.ron.language.RONLanguage; 7 | 8 | public class RONElementType extends IElementType { 9 | 10 | public RONElementType(@NotNull @NonNls String debugName) { 11 | super(debugName, RONLanguage.INSTANCE); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /.idea/intellij-ron.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /src/main/java/org/jonahhenriksson/ron/language/psi/RONTokenType.java: -------------------------------------------------------------------------------- 1 | package org.jonahhenriksson.ron.language.psi; 2 | 3 | import com.intellij.psi.tree.IElementType; 4 | import org.jetbrains.annotations.NonNls; 5 | import org.jetbrains.annotations.NotNull; 6 | import org.jonahhenriksson.ron.language.RONLanguage; 7 | 8 | public class RONTokenType extends IElementType { 9 | 10 | public RONTokenType(@NotNull @NonNls String debugName) { 11 | super(debugName, RONLanguage.INSTANCE); 12 | } 13 | 14 | @Override 15 | public String toString() { 16 | return "RONTokenType." + super.toString(); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 16 | 17 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 15 | -------------------------------------------------------------------------------- /src/main/gen/org/jonahhenriksson/ron/language/psi/RONValue.java: -------------------------------------------------------------------------------- 1 | // This is a generated file. Not intended for manual editing. 2 | package org.jonahhenriksson.ron.language.psi; 3 | 4 | import java.util.List; 5 | import org.jetbrains.annotations.*; 6 | import com.intellij.psi.PsiElement; 7 | 8 | public interface RONValue extends PsiElement { 9 | 10 | @Nullable 11 | RONBool getBool(); 12 | 13 | @Nullable 14 | RONList getList(); 15 | 16 | @Nullable 17 | RONMap getMap(); 18 | 19 | @Nullable 20 | RONNamedField getNamedField(); 21 | 22 | @Nullable 23 | RONObject getObject(); 24 | 25 | @Nullable 26 | RONOption getOption(); 27 | 28 | @Nullable 29 | PsiElement getChar(); 30 | 31 | @Nullable 32 | PsiElement getFloat(); 33 | 34 | @Nullable 35 | PsiElement getInteger(); 36 | 37 | @Nullable 38 | PsiElement getString(); 39 | 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/org/jonahhenriksson/ron/language/psi/RONFile.java: -------------------------------------------------------------------------------- 1 | package org.jonahhenriksson.ron.language.psi; 2 | 3 | import com.intellij.extapi.psi.PsiFileBase; 4 | import com.intellij.lang.Language; 5 | import com.intellij.openapi.fileTypes.FileType; 6 | import com.intellij.psi.FileViewProvider; 7 | import org.jetbrains.annotations.NotNull; 8 | import org.jonahhenriksson.ron.language.RONFileType; 9 | import org.jonahhenriksson.ron.language.RONLanguage; 10 | 11 | public class RONFile extends PsiFileBase { 12 | public RONFile(@NotNull FileViewProvider viewProvider) { 13 | super(viewProvider, RONLanguage.INSTANCE); 14 | } 15 | 16 | @Override 17 | public @NotNull FileType getFileType() { 18 | return RONFileType.INSTANCE; 19 | } 20 | 21 | @Override 22 | public String toString() { 23 | return "RON File"; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/org/jonahhenriksson/ron/language/RONFileType.java: -------------------------------------------------------------------------------- 1 | package org.jonahhenriksson.ron.language; 2 | 3 | import com.intellij.openapi.fileTypes.LanguageFileType; 4 | import com.intellij.openapi.util.NlsContexts; 5 | import org.jetbrains.annotations.NotNull; 6 | import org.jetbrains.annotations.Nullable; 7 | 8 | import javax.swing.*; 9 | 10 | public class RONFileType extends LanguageFileType { 11 | public static final RONFileType INSTANCE = new RONFileType(); 12 | 13 | private RONFileType() { 14 | super(RONLanguage.INSTANCE); 15 | } 16 | 17 | @Override 18 | public @NotNull String getName() { 19 | return "RON file"; 20 | } 21 | 22 | @Override 23 | public @NotNull @NlsContexts.Label String getDescription() { 24 | return "Rusty Object Notation file"; 25 | } 26 | 27 | @Override 28 | public @NotNull String getDefaultExtension() { 29 | return "ron"; 30 | } 31 | 32 | @Override 33 | public @Nullable Icon getIcon() { 34 | return RONIcons.FILE; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /LICENSE-MIT: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) [year] [fullname] 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /.idea/$CACHE_FILE$: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | Code styleScala 10 | 11 | 12 | Java 13 | 14 | 15 | Java interop issuesKotlin 16 | 17 | 18 | Kotlin 19 | 20 | 21 | Packaging issuesJava 22 | 23 | 24 | Probable bugsJava 25 | 26 | 27 | Scala 28 | 29 | 30 | Version control 31 | 32 | 33 | 34 | 35 | Ant 36 | 37 | 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /src/main/gen/org/jonahhenriksson/ron/language/psi/impl/RONBoolImpl.java: -------------------------------------------------------------------------------- 1 | // This is a generated file. Not intended for manual editing. 2 | package org.jonahhenriksson.ron.language.psi.impl; 3 | 4 | import java.util.List; 5 | import org.jetbrains.annotations.*; 6 | import com.intellij.lang.ASTNode; 7 | import com.intellij.psi.PsiElement; 8 | import com.intellij.psi.PsiElementVisitor; 9 | import com.intellij.psi.util.PsiTreeUtil; 10 | import static org.jonahhenriksson.ron.language.psi.RONTypes.*; 11 | import com.intellij.extapi.psi.ASTWrapperPsiElement; 12 | import org.jonahhenriksson.ron.language.psi.*; 13 | 14 | public class RONBoolImpl extends ASTWrapperPsiElement implements RONBool { 15 | 16 | public RONBoolImpl(@NotNull ASTNode node) { 17 | super(node); 18 | } 19 | 20 | public void accept(@NotNull RONVisitor visitor) { 21 | visitor.visitBool(this); 22 | } 23 | 24 | public void accept(@NotNull PsiElementVisitor visitor) { 25 | if (visitor instanceof RONVisitor) accept((RONVisitor)visitor); 26 | else super.accept(visitor); 27 | } 28 | 29 | @Override 30 | @NotNull 31 | public PsiElement getBoolean() { 32 | return findNotNullChildByType(BOOLEAN); 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /src/main/gen/org/jonahhenriksson/ron/language/psi/impl/RONOptionImpl.java: -------------------------------------------------------------------------------- 1 | // This is a generated file. Not intended for manual editing. 2 | package org.jonahhenriksson.ron.language.psi.impl; 3 | 4 | import java.util.List; 5 | import org.jetbrains.annotations.*; 6 | import com.intellij.lang.ASTNode; 7 | import com.intellij.psi.PsiElement; 8 | import com.intellij.psi.PsiElementVisitor; 9 | import com.intellij.psi.util.PsiTreeUtil; 10 | import static org.jonahhenriksson.ron.language.psi.RONTypes.*; 11 | import com.intellij.extapi.psi.ASTWrapperPsiElement; 12 | import org.jonahhenriksson.ron.language.psi.*; 13 | 14 | public class RONOptionImpl extends ASTWrapperPsiElement implements RONOption { 15 | 16 | public RONOptionImpl(@NotNull ASTNode node) { 17 | super(node); 18 | } 19 | 20 | public void accept(@NotNull RONVisitor visitor) { 21 | visitor.visitOption(this); 22 | } 23 | 24 | public void accept(@NotNull PsiElementVisitor visitor) { 25 | if (visitor instanceof RONVisitor) accept((RONVisitor)visitor); 26 | else super.accept(visitor); 27 | } 28 | 29 | @Override 30 | @NotNull 31 | public RONValue getValue() { 32 | return findNotNullChildByClass(RONValue.class); 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/org/jonahhenriksson/ron/language/RONCreateFile.java: -------------------------------------------------------------------------------- 1 | package org.jonahhenriksson.ron.language; 2 | 3 | import com.intellij.ide.actions.CreateFileFromTemplateAction; 4 | import com.intellij.ide.actions.CreateFileFromTemplateDialog; 5 | import com.intellij.openapi.project.Project; 6 | import com.intellij.openapi.util.NlsActions; 7 | import com.intellij.openapi.util.NlsContexts; 8 | import com.intellij.psi.PsiDirectory; 9 | import org.jetbrains.annotations.NotNull; 10 | 11 | import javax.swing.*; 12 | 13 | public class RONCreateFile extends CreateFileFromTemplateAction { 14 | 15 | private static final String NAME = "RON File"; 16 | 17 | public RONCreateFile() { 18 | super(NAME, "Create new RON file", RONIcons.FILE); 19 | } 20 | 21 | @Override 22 | protected void buildDialog(@NotNull Project project, @NotNull PsiDirectory directory, CreateFileFromTemplateDialog.@NotNull Builder builder) { 23 | builder.setTitle(NAME).addKind("Empty file", RONIcons.FILE, "RON File"); 24 | } 25 | 26 | @Override 27 | protected @NlsContexts.Command String getActionName(PsiDirectory directory, @NotNull String newName, String templateName) { 28 | return NAME; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/main/gen/org/jonahhenriksson/ron/language/psi/impl/RONListImpl.java: -------------------------------------------------------------------------------- 1 | // This is a generated file. Not intended for manual editing. 2 | package org.jonahhenriksson.ron.language.psi.impl; 3 | 4 | import java.util.List; 5 | import org.jetbrains.annotations.*; 6 | import com.intellij.lang.ASTNode; 7 | import com.intellij.psi.PsiElement; 8 | import com.intellij.psi.PsiElementVisitor; 9 | import com.intellij.psi.util.PsiTreeUtil; 10 | import static org.jonahhenriksson.ron.language.psi.RONTypes.*; 11 | import com.intellij.extapi.psi.ASTWrapperPsiElement; 12 | import org.jonahhenriksson.ron.language.psi.*; 13 | 14 | public class RONListImpl extends ASTWrapperPsiElement implements RONList { 15 | 16 | public RONListImpl(@NotNull ASTNode node) { 17 | super(node); 18 | } 19 | 20 | public void accept(@NotNull RONVisitor visitor) { 21 | visitor.visitList(this); 22 | } 23 | 24 | public void accept(@NotNull PsiElementVisitor visitor) { 25 | if (visitor instanceof RONVisitor) accept((RONVisitor)visitor); 26 | else super.accept(visitor); 27 | } 28 | 29 | @Override 30 | @NotNull 31 | public List getValueList() { 32 | return PsiTreeUtil.getChildrenOfTypeAsList(this, RONValue.class); 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /src/main/gen/org/jonahhenriksson/ron/language/psi/impl/RONMapImpl.java: -------------------------------------------------------------------------------- 1 | // This is a generated file. Not intended for manual editing. 2 | package org.jonahhenriksson.ron.language.psi.impl; 3 | 4 | import java.util.List; 5 | import org.jetbrains.annotations.*; 6 | import com.intellij.lang.ASTNode; 7 | import com.intellij.psi.PsiElement; 8 | import com.intellij.psi.PsiElementVisitor; 9 | import com.intellij.psi.util.PsiTreeUtil; 10 | import static org.jonahhenriksson.ron.language.psi.RONTypes.*; 11 | import com.intellij.extapi.psi.ASTWrapperPsiElement; 12 | import org.jonahhenriksson.ron.language.psi.*; 13 | 14 | public class RONMapImpl extends ASTWrapperPsiElement implements RONMap { 15 | 16 | public RONMapImpl(@NotNull ASTNode node) { 17 | super(node); 18 | } 19 | 20 | public void accept(@NotNull RONVisitor visitor) { 21 | visitor.visitMap(this); 22 | } 23 | 24 | public void accept(@NotNull PsiElementVisitor visitor) { 25 | if (visitor instanceof RONVisitor) accept((RONVisitor)visitor); 26 | else super.accept(visitor); 27 | } 28 | 29 | @Override 30 | @NotNull 31 | public List getMapEntryList() { 32 | return PsiTreeUtil.getChildrenOfTypeAsList(this, RONMapEntry.class); 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /src/main/gen/org/jonahhenriksson/ron/language/psi/RONVisitor.java: -------------------------------------------------------------------------------- 1 | // This is a generated file. Not intended for manual editing. 2 | package org.jonahhenriksson.ron.language.psi; 3 | 4 | import org.jetbrains.annotations.*; 5 | import com.intellij.psi.PsiElementVisitor; 6 | import com.intellij.psi.PsiElement; 7 | 8 | public class RONVisitor extends PsiElementVisitor { 9 | 10 | public void visitBool(@NotNull RONBool o) { 11 | visitPsiElement(o); 12 | } 13 | 14 | public void visitList(@NotNull RONList o) { 15 | visitPsiElement(o); 16 | } 17 | 18 | public void visitMap(@NotNull RONMap o) { 19 | visitPsiElement(o); 20 | } 21 | 22 | public void visitMapEntry(@NotNull RONMapEntry o) { 23 | visitPsiElement(o); 24 | } 25 | 26 | public void visitNamedField(@NotNull RONNamedField o) { 27 | visitPsiElement(o); 28 | } 29 | 30 | public void visitObject(@NotNull RONObject o) { 31 | visitPsiElement(o); 32 | } 33 | 34 | public void visitOption(@NotNull RONOption o) { 35 | visitPsiElement(o); 36 | } 37 | 38 | public void visitValue(@NotNull RONValue o) { 39 | visitPsiElement(o); 40 | } 41 | 42 | public void visitPsiElement(@NotNull PsiElement o) { 43 | visitElement(o); 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /src/main/resources/META-INF/plugin.xml: -------------------------------------------------------------------------------- 1 | 2 | org.jonahhenriksson.ron 3 | RON 4 | Jonah Henriksson 5 | 6 | 9 | 10 | com.intellij.modules.platform 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /src/main/gen/org/jonahhenriksson/ron/language/psi/impl/RONMapEntryImpl.java: -------------------------------------------------------------------------------- 1 | // This is a generated file. Not intended for manual editing. 2 | package org.jonahhenriksson.ron.language.psi.impl; 3 | 4 | import java.util.List; 5 | import org.jetbrains.annotations.*; 6 | import com.intellij.lang.ASTNode; 7 | import com.intellij.psi.PsiElement; 8 | import com.intellij.psi.PsiElementVisitor; 9 | import com.intellij.psi.util.PsiTreeUtil; 10 | import static org.jonahhenriksson.ron.language.psi.RONTypes.*; 11 | import com.intellij.extapi.psi.ASTWrapperPsiElement; 12 | import org.jonahhenriksson.ron.language.psi.*; 13 | 14 | public class RONMapEntryImpl extends ASTWrapperPsiElement implements RONMapEntry { 15 | 16 | public RONMapEntryImpl(@NotNull ASTNode node) { 17 | super(node); 18 | } 19 | 20 | public void accept(@NotNull RONVisitor visitor) { 21 | visitor.visitMapEntry(this); 22 | } 23 | 24 | public void accept(@NotNull PsiElementVisitor visitor) { 25 | if (visitor instanceof RONVisitor) accept((RONVisitor)visitor); 26 | else super.accept(visitor); 27 | } 28 | 29 | @Override 30 | @NotNull 31 | public List getValueList() { 32 | return PsiTreeUtil.getChildrenOfTypeAsList(this, RONValue.class); 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /src/main/gen/org/jonahhenriksson/ron/language/psi/impl/RONNamedFieldImpl.java: -------------------------------------------------------------------------------- 1 | // This is a generated file. Not intended for manual editing. 2 | package org.jonahhenriksson.ron.language.psi.impl; 3 | 4 | import java.util.List; 5 | import org.jetbrains.annotations.*; 6 | import com.intellij.lang.ASTNode; 7 | import com.intellij.psi.PsiElement; 8 | import com.intellij.psi.PsiElementVisitor; 9 | import com.intellij.psi.util.PsiTreeUtil; 10 | import static org.jonahhenriksson.ron.language.psi.RONTypes.*; 11 | import com.intellij.extapi.psi.ASTWrapperPsiElement; 12 | import org.jonahhenriksson.ron.language.psi.*; 13 | 14 | public class RONNamedFieldImpl extends ASTWrapperPsiElement implements RONNamedField { 15 | 16 | public RONNamedFieldImpl(@NotNull ASTNode node) { 17 | super(node); 18 | } 19 | 20 | public void accept(@NotNull RONVisitor visitor) { 21 | visitor.visitNamedField(this); 22 | } 23 | 24 | public void accept(@NotNull PsiElementVisitor visitor) { 25 | if (visitor instanceof RONVisitor) accept((RONVisitor)visitor); 26 | else super.accept(visitor); 27 | } 28 | 29 | @Override 30 | @NotNull 31 | public RONValue getValue() { 32 | return findNotNullChildByClass(RONValue.class); 33 | } 34 | 35 | @Override 36 | @NotNull 37 | public PsiElement getIdent() { 38 | return findNotNullChildByType(IDENT); 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /src/main/gen/org/jonahhenriksson/ron/language/psi/impl/RONObjectImpl.java: -------------------------------------------------------------------------------- 1 | // This is a generated file. Not intended for manual editing. 2 | package org.jonahhenriksson.ron.language.psi.impl; 3 | 4 | import java.util.List; 5 | import org.jetbrains.annotations.*; 6 | import com.intellij.lang.ASTNode; 7 | import com.intellij.psi.PsiElement; 8 | import com.intellij.psi.PsiElementVisitor; 9 | import com.intellij.psi.util.PsiTreeUtil; 10 | import static org.jonahhenriksson.ron.language.psi.RONTypes.*; 11 | import com.intellij.extapi.psi.ASTWrapperPsiElement; 12 | import org.jonahhenriksson.ron.language.psi.*; 13 | 14 | public class RONObjectImpl extends ASTWrapperPsiElement implements RONObject { 15 | 16 | public RONObjectImpl(@NotNull ASTNode node) { 17 | super(node); 18 | } 19 | 20 | public void accept(@NotNull RONVisitor visitor) { 21 | visitor.visitObject(this); 22 | } 23 | 24 | public void accept(@NotNull PsiElementVisitor visitor) { 25 | if (visitor instanceof RONVisitor) accept((RONVisitor)visitor); 26 | else super.accept(visitor); 27 | } 28 | 29 | @Override 30 | @NotNull 31 | public List getValueList() { 32 | return PsiTreeUtil.getChildrenOfTypeAsList(this, RONValue.class); 33 | } 34 | 35 | @Override 36 | @Nullable 37 | public PsiElement getIdent() { 38 | return findChildByType(IDENT); 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # intellij-ron 2 | [![Marketplace](https://img.shields.io/static/v1?label=&message=Marketplace&labelColor=FFF&color=000&logo=intellij-idea&logoColor=000)](https://plugins.jetbrains.com/plugin/14897-ron/) 3 | 4 | A plugin that adds RON (Rusty Object Notation) support to IntelliJ IDEA 5 | 6 | ## Versions 7 | 1.4 - Updated to support 2020.3 edition of Intellij IDEs 8 | 9 | 1.3 - Adds support for block comments and cleaned up some code 10 | 11 | 1.2 - Adds context menu option for creating RON files 12 | 13 | 1.1 - Fixes issues with recognizing types, and allows raw strings to work properly 14 | 15 | 1.0 - Allows underscores in identifiers and extensions, and fixed maps and lists 16 | 17 | 1.0-SNAPSHOT - Initial release, very buggy, but adds basic support for highlighting RON files 18 | 19 | ## Contributing 20 | If there is a specific feature you want to see, or an issue with the plugin, make an issue, and I'll try to get back to it. 21 | If you want to add a feature or resolve an issue, first let me know by replying to a feature request or issue report, and then make a pull request. 22 | 23 | 24 | ## Building 25 | Requires Intellij IDEA, Gradle CLI and the plugins Grammar-Kit, PsiViewer, and Plugin DevKit. 26 | 27 | To build, run the command `gradle buildPlugin`, and the zipped plugin will be generated in build/distributions 28 | 29 | ## License 30 | intellij-ron is dual-licensed under Apache-2 and MIT. -------------------------------------------------------------------------------- /src/main/resources/icons/ronFile.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 11 | 12 | 13 | 14 | 15 | 19 | 20 | 22 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /.idea/jarRepositories.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 9 | 10 | 14 | 15 | 19 | 20 | 24 | 25 | 29 | 30 | 34 | 35 | -------------------------------------------------------------------------------- /src/main/java/org/jonahhenriksson/ron/language/RONParserDefinition.java: -------------------------------------------------------------------------------- 1 | package org.jonahhenriksson.ron.language; 2 | 3 | import com.intellij.lang.ASTNode; 4 | import com.intellij.lang.ParserDefinition; 5 | import com.intellij.lang.PsiParser; 6 | import com.intellij.lexer.Lexer; 7 | import com.intellij.openapi.project.Project; 8 | import com.intellij.psi.FileViewProvider; 9 | import com.intellij.psi.PsiElement; 10 | import com.intellij.psi.PsiFile; 11 | import com.intellij.psi.TokenType; 12 | import com.intellij.psi.tree.IFileElementType; 13 | import com.intellij.psi.tree.TokenSet; 14 | import org.jetbrains.annotations.NotNull; 15 | import org.jonahhenriksson.ron.language.parser._RONParser; 16 | import org.jonahhenriksson.ron.language.psi.RONElementType; 17 | import org.jonahhenriksson.ron.language.psi.RONFile; 18 | import org.jonahhenriksson.ron.language.psi.RONTypes; 19 | 20 | public class RONParserDefinition implements ParserDefinition { 21 | public static final TokenSet COMMENTS = TokenSet.create(RONTypes.COMMENT, RONTypes.BLOCK_COMMENT); 22 | public static final TokenSet STRING_LITERALS = TokenSet.create(RONTypes.STRING); 23 | 24 | public static final IFileElementType FILE = new IFileElementType(RONLanguage.INSTANCE); 25 | 26 | @Override 27 | public @NotNull Lexer createLexer(Project project) { 28 | return new RONLexerAdapter(); 29 | } 30 | 31 | @Override 32 | public PsiParser createParser(Project project) { 33 | return new _RONParser(); 34 | } 35 | 36 | @Override 37 | public IFileElementType getFileNodeType() { 38 | return FILE; 39 | } 40 | 41 | @Override 42 | public @NotNull TokenSet getCommentTokens() { 43 | return COMMENTS; 44 | } 45 | 46 | @Override 47 | public @NotNull TokenSet getStringLiteralElements() { 48 | return STRING_LITERALS; 49 | } 50 | 51 | @Override 52 | public @NotNull PsiElement createElement(ASTNode node) { 53 | return RONTypes.Factory.createElement(node); 54 | } 55 | 56 | @Override 57 | public PsiFile createFile(FileViewProvider viewProvider) { 58 | return new RONFile(viewProvider); 59 | } 60 | 61 | public SpaceRequirements spaceExistenceTypeBetweenTokens(ASTNode left, ASTNode right) { 62 | return SpaceRequirements.MAY; 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /src/main/gen/org/jonahhenriksson/ron/language/psi/impl/RONValueImpl.java: -------------------------------------------------------------------------------- 1 | // This is a generated file. Not intended for manual editing. 2 | package org.jonahhenriksson.ron.language.psi.impl; 3 | 4 | import java.util.List; 5 | import org.jetbrains.annotations.*; 6 | import com.intellij.lang.ASTNode; 7 | import com.intellij.psi.PsiElement; 8 | import com.intellij.psi.PsiElementVisitor; 9 | import com.intellij.psi.util.PsiTreeUtil; 10 | import static org.jonahhenriksson.ron.language.psi.RONTypes.*; 11 | import com.intellij.extapi.psi.ASTWrapperPsiElement; 12 | import org.jonahhenriksson.ron.language.psi.*; 13 | 14 | public class RONValueImpl extends ASTWrapperPsiElement implements RONValue { 15 | 16 | public RONValueImpl(@NotNull ASTNode node) { 17 | super(node); 18 | } 19 | 20 | public void accept(@NotNull RONVisitor visitor) { 21 | visitor.visitValue(this); 22 | } 23 | 24 | public void accept(@NotNull PsiElementVisitor visitor) { 25 | if (visitor instanceof RONVisitor) accept((RONVisitor)visitor); 26 | else super.accept(visitor); 27 | } 28 | 29 | @Override 30 | @Nullable 31 | public RONBool getBool() { 32 | return findChildByClass(RONBool.class); 33 | } 34 | 35 | @Override 36 | @Nullable 37 | public RONList getList() { 38 | return findChildByClass(RONList.class); 39 | } 40 | 41 | @Override 42 | @Nullable 43 | public RONMap getMap() { 44 | return findChildByClass(RONMap.class); 45 | } 46 | 47 | @Override 48 | @Nullable 49 | public RONNamedField getNamedField() { 50 | return findChildByClass(RONNamedField.class); 51 | } 52 | 53 | @Override 54 | @Nullable 55 | public RONObject getObject() { 56 | return findChildByClass(RONObject.class); 57 | } 58 | 59 | @Override 60 | @Nullable 61 | public RONOption getOption() { 62 | return findChildByClass(RONOption.class); 63 | } 64 | 65 | @Override 66 | @Nullable 67 | public PsiElement getChar() { 68 | return findChildByType(CHAR); 69 | } 70 | 71 | @Override 72 | @Nullable 73 | public PsiElement getFloat() { 74 | return findChildByType(FLOAT); 75 | } 76 | 77 | @Override 78 | @Nullable 79 | public PsiElement getInteger() { 80 | return findChildByType(INTEGER); 81 | } 82 | 83 | @Override 84 | @Nullable 85 | public PsiElement getString() { 86 | return findChildByType(STRING); 87 | } 88 | 89 | } 90 | -------------------------------------------------------------------------------- /src/main/java/org/jonahhenriksson/ron/language/RON.bnf: -------------------------------------------------------------------------------- 1 | { 2 | parserClass = "org.jonahhenriksson.ron.language.parser._RONParser" 3 | parserUtilClass = "org.jonahhenriksson.ron.language.psi.RONParserUtil" 4 | 5 | extends = "com.intellij.extapi.psi.ASTWrapperPsiElement" 6 | 7 | psiClassPrefix = "RON" 8 | psiImplClassSuffix = "Impl" 9 | psiPackage = "org.jonahhenriksson.ron.language.psi" 10 | psiImplPackage = "org.jonahhenriksson.ron.language.psi.impl" 11 | 12 | elementTypeHolderClass = "org.jonahhenriksson.ron.language.psi.RONTypes" 13 | elementTypeClass = "org.jonahhenriksson.ron.language.psi.RONElementType" 14 | tokenTypeClass = "org.jonahhenriksson.ron.language.psi.RONTokenType" 15 | 16 | psiImplUtilClass = "org.jonahhenriksson.ron.language.psi.impl.RONPsiImplUtil" 17 | 18 | tokens = [ 19 | COMMENT = "regexp://.*" 20 | BLOCK_COMMENT = "BLOCK COMMENT" 21 | 22 | BOOLEAN = "regexp:true|false" 23 | 24 | IDENT = "regexp:[A-Za-z_]+" 25 | 26 | INTEGER = "regexp:[+-]?((0x[0-9A-Fa-f][0-9A-Fa-f_]*)|((0[bo]?)?[0-9][0-9_]*))" 27 | FLOAT = "regexp:([+-]?[0-9]+\.[0-9]*([Ee][0-9]+)?)|(\.[0-9]+([Ee][0-9]+)?)" 28 | 29 | CHAR = "regexp:'([ -&(-\[\]-~])|(\\')|(\\\\)'" 30 | STRING = "regexp:\"([^\r\n\"]|(\\[\S]))*\"" 31 | RAW_STRING = "RAW STRING" 32 | 33 | EXTENSION = "regexp:#!\[enable\([A-Za-z_]+\)\]" 34 | PARENTHESISL = "(" 35 | PARENTHESISR = ")" 36 | BRACKETL = "[" 37 | BRACKETR = "]" 38 | BRACEL = "{" 39 | BRACER = "}" 40 | COLON = ":" 41 | COMMA = "," 42 | SOME = "Some" 43 | ] 44 | } 45 | 46 | // RON File 47 | RON ::= [extension+] value; 48 | 49 | // Extension 50 | private extension ::= EXTENSION; 51 | 52 | // Values 53 | value ::= bool | integer | float | string | char | option | list | map | named_field | object; 54 | 55 | // Bool 56 | bool ::= BOOLEAN; 57 | 58 | // Integer 59 | private integer ::= INTEGER; 60 | 61 | // Float 62 | private float ::= FLOAT; 63 | 64 | // String 65 | private string ::= STRING | RAW_STRING; 66 | 67 | // Char 68 | private char ::= CHAR; 69 | 70 | // Option 71 | option ::= SOME PARENTHESISL value PARENTHESISR; 72 | 73 | // List 74 | list ::= BRACKETL [value (COMMA value)* [COMMA]] BRACKETR; 75 | 76 | // Map 77 | map ::= BRACEL [map_entry (COMMA map_entry)* [COMMA]] BRACER 78 | map_entry ::= value COLON value; 79 | 80 | // Named Field for Struct 81 | named_field ::= IDENT COLON value; 82 | 83 | // Tuple + Enum Tuple + Tuple Struct + Struct + Unit Struct + Named Enum 84 | object ::= [IDENT] PARENTHESISL [value (COMMA value)* [COMMA]] PARENTHESISR | PARENTHESISL PARENTHESISR | IDENT; -------------------------------------------------------------------------------- /src/main/gen/org/jonahhenriksson/ron/language/psi/RONTypes.java: -------------------------------------------------------------------------------- 1 | // This is a generated file. Not intended for manual editing. 2 | package org.jonahhenriksson.ron.language.psi; 3 | 4 | import com.intellij.psi.tree.IElementType; 5 | import com.intellij.psi.PsiElement; 6 | import com.intellij.lang.ASTNode; 7 | import org.jonahhenriksson.ron.language.psi.impl.*; 8 | 9 | public interface RONTypes { 10 | 11 | IElementType BOOL = new RONElementType("BOOL"); 12 | IElementType LIST = new RONElementType("LIST"); 13 | IElementType MAP = new RONElementType("MAP"); 14 | IElementType MAP_ENTRY = new RONElementType("MAP_ENTRY"); 15 | IElementType NAMED_FIELD = new RONElementType("NAMED_FIELD"); 16 | IElementType OBJECT = new RONElementType("OBJECT"); 17 | IElementType OPTION = new RONElementType("OPTION"); 18 | IElementType VALUE = new RONElementType("VALUE"); 19 | 20 | IElementType BLOCK_COMMENT = new RONTokenType("BLOCK COMMENT"); 21 | IElementType BOOLEAN = new RONTokenType("BOOLEAN"); 22 | IElementType BRACEL = new RONTokenType("{"); 23 | IElementType BRACER = new RONTokenType("}"); 24 | IElementType BRACKETL = new RONTokenType("["); 25 | IElementType BRACKETR = new RONTokenType("]"); 26 | IElementType CHAR = new RONTokenType("CHAR"); 27 | IElementType COLON = new RONTokenType(":"); 28 | IElementType COMMA = new RONTokenType(","); 29 | IElementType COMMENT = new RONTokenType("COMMENT"); 30 | IElementType EXTENSION = new RONTokenType("EXTENSION"); 31 | IElementType FLOAT = new RONTokenType("FLOAT"); 32 | IElementType IDENT = new RONTokenType("IDENT"); 33 | IElementType INTEGER = new RONTokenType("INTEGER"); 34 | IElementType PARENTHESISL = new RONTokenType("("); 35 | IElementType PARENTHESISR = new RONTokenType(")"); 36 | IElementType RAW_STRING = new RONTokenType("RAW STRING"); 37 | IElementType SOME = new RONTokenType("Some"); 38 | IElementType STRING = new RONTokenType("STRING"); 39 | 40 | class Factory { 41 | public static PsiElement createElement(ASTNode node) { 42 | IElementType type = node.getElementType(); 43 | if (type == BOOL) { 44 | return new RONBoolImpl(node); 45 | } 46 | else if (type == LIST) { 47 | return new RONListImpl(node); 48 | } 49 | else if (type == MAP) { 50 | return new RONMapImpl(node); 51 | } 52 | else if (type == MAP_ENTRY) { 53 | return new RONMapEntryImpl(node); 54 | } 55 | else if (type == NAMED_FIELD) { 56 | return new RONNamedFieldImpl(node); 57 | } 58 | else if (type == OBJECT) { 59 | return new RONObjectImpl(node); 60 | } 61 | else if (type == OPTION) { 62 | return new RONOptionImpl(node); 63 | } 64 | else if (type == VALUE) { 65 | return new RONValueImpl(node); 66 | } 67 | throw new AssertionError("Unknown element type: " + type); 68 | } 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /src/main/resources/META-INF/pluginIcon.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/main/resources/META-INF/pluginIcon_dark.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @rem 2 | @rem Copyright 2015 the original author or authors. 3 | @rem 4 | @rem Licensed under the Apache License, Version 2.0 (the "License"); 5 | @rem you may not use this file except in compliance with the License. 6 | @rem You may obtain a copy of the License at 7 | @rem 8 | @rem https://www.apache.org/licenses/LICENSE-2.0 9 | @rem 10 | @rem Unless required by applicable law or agreed to in writing, software 11 | @rem distributed under the License is distributed on an "AS IS" BASIS, 12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | @rem See the License for the specific language governing permissions and 14 | @rem limitations under the License. 15 | @rem 16 | 17 | @if "%DEBUG%" == "" @echo off 18 | @rem ########################################################################## 19 | @rem 20 | @rem Gradle startup script for Windows 21 | @rem 22 | @rem ########################################################################## 23 | 24 | @rem Set local scope for the variables with windows NT shell 25 | if "%OS%"=="Windows_NT" setlocal 26 | 27 | set DIRNAME=%~dp0 28 | if "%DIRNAME%" == "" set DIRNAME=. 29 | set APP_BASE_NAME=%~n0 30 | set APP_HOME=%DIRNAME% 31 | 32 | @rem Resolve any "." and ".." in APP_HOME to make it shorter. 33 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi 34 | 35 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 36 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" 37 | 38 | @rem Find java.exe 39 | if defined JAVA_HOME goto findJavaFromJavaHome 40 | 41 | set JAVA_EXE=java.exe 42 | %JAVA_EXE% -version >NUL 2>&1 43 | if "%ERRORLEVEL%" == "0" goto init 44 | 45 | echo. 46 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 47 | echo. 48 | echo Please set the JAVA_HOME variable in your environment to match the 49 | echo location of your Java installation. 50 | 51 | goto fail 52 | 53 | :findJavaFromJavaHome 54 | set JAVA_HOME=%JAVA_HOME:"=% 55 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 56 | 57 | if exist "%JAVA_EXE%" goto init 58 | 59 | echo. 60 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 61 | echo. 62 | echo Please set the JAVA_HOME variable in your environment to match the 63 | echo location of your Java installation. 64 | 65 | goto fail 66 | 67 | :init 68 | @rem Get command-line arguments, handling Windows variants 69 | 70 | if not "%OS%" == "Windows_NT" goto win9xME_args 71 | 72 | :win9xME_args 73 | @rem Slurp the command line arguments. 74 | set CMD_LINE_ARGS= 75 | set _SKIP=2 76 | 77 | :win9xME_args_slurp 78 | if "x%~1" == "x" goto execute 79 | 80 | set CMD_LINE_ARGS=%* 81 | 82 | :execute 83 | @rem Setup the command line 84 | 85 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 86 | 87 | 88 | @rem Execute Gradle 89 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 90 | 91 | :end 92 | @rem End local scope for the variables with windows NT shell 93 | if "%ERRORLEVEL%"=="0" goto mainEnd 94 | 95 | :fail 96 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 97 | rem the _cmd.exe /c_ return code! 98 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 99 | exit /b 1 100 | 101 | :mainEnd 102 | if "%OS%"=="Windows_NT" endlocal 103 | 104 | :omega 105 | -------------------------------------------------------------------------------- /src/main/java/org/jonahhenriksson/ron/language/__RONLexer.flex: -------------------------------------------------------------------------------- 1 | package org.jonahhenriksson.ron.language; 2 | 3 | import com.intellij.lexer.FlexLexer; 4 | import com.intellij.psi.tree.IElementType; 5 | 6 | import static com.intellij.psi.TokenType.BAD_CHARACTER; 7 | import static com.intellij.psi.TokenType.WHITE_SPACE; 8 | import static org.jonahhenriksson.ron.language.psi.RONTypes.*; 9 | 10 | %% 11 | 12 | %{ 13 | public __RONLexer() { 14 | this((java.io.Reader)null); 15 | } 16 | %} 17 | 18 | %{ 19 | private int zzShaStride = -1; 20 | 21 | private int zzPostponedMarkedPos = -1; 22 | %} 23 | 24 | %{ 25 | IElementType imbueRawLiteral() { 26 | yybegin(YYINITIAL); 27 | 28 | zzStartRead = zzPostponedMarkedPos; 29 | zzShaStride = -1; 30 | zzPostponedMarkedPos = -1; 31 | 32 | return RAW_STRING; 33 | } 34 | 35 | IElementType imbueBlockComment() { 36 | yybegin(YYINITIAL); 37 | 38 | zzStartRead = zzPostponedMarkedPos; 39 | zzPostponedMarkedPos = -1; 40 | 41 | return BLOCK_COMMENT; 42 | } 43 | %} 44 | 45 | %public 46 | %class __RONLexer 47 | %implements FlexLexer 48 | %function advance 49 | %type IElementType 50 | 51 | %s IN_RAW_STRING 52 | %s IN_RAW_STRING_SUFFIX 53 | 54 | %s IN_BLOCK_COMMENT 55 | 56 | %unicode 57 | 58 | EOL=\R 59 | WHITE_SPACE=\s+ 60 | 61 | BOOLEAN=true|false 62 | IDENT=[A-Za-z_]+ 63 | INTEGER=[+-]?((0x[0-9A-Fa-f][0-9A-Fa-f_]*)|((0[bo]?)?[0-9][0-9_]*)) 64 | FLOAT=([+-]?[0-9]+\.[0-9]*([Ee][0-9]+)?)|(\.[0-9]+([Ee][0-9]+)?) 65 | CHAR='([ -&(-\[\]-~])|(\')|(\\\\)' 66 | STRING=\"([^\r\n\"]|(\\[\S]))*\" 67 | EXTENSION=#!\[enable\([A-Za-z_]+\)\] 68 | COMMENT="//".* 69 | 70 | %% 71 | { 72 | "(" { return PARENTHESISL; } 73 | ")" { return PARENTHESISR; } 74 | "[" { return BRACKETL; } 75 | "]" { return BRACKETR; } 76 | "{" { return BRACEL; } 77 | "}" { return BRACER; } 78 | ":" { return COLON; } 79 | "," { return COMMA; } 80 | "Some" { return SOME; } 81 | 82 | "r" #* \" { 83 | yybegin(IN_RAW_STRING); 84 | zzPostponedMarkedPos = zzStartRead; 85 | zzShaStride = yylength() - 2; 86 | } 87 | 88 | {BOOLEAN} { return BOOLEAN; } 89 | {IDENT} { return IDENT; } 90 | {INTEGER} { return INTEGER; } 91 | {FLOAT} { return FLOAT; } 92 | {CHAR} { return CHAR; } 93 | {STRING} { return STRING; } 94 | {EXTENSION} { return EXTENSION; } 95 | {COMMENT} { return COMMENT; } 96 | "/*" { 97 | yybegin(IN_BLOCK_COMMENT); 98 | yypushback(2); 99 | } 100 | 101 | {WHITE_SPACE} { return WHITE_SPACE; } 102 | } 103 | 104 | { 105 | \" #* { int shaExcess = yylength() - 1 - zzShaStride; if (shaExcess >= 0) { yybegin(IN_RAW_STRING_SUFFIX); yypushback(shaExcess); } } 106 | [^] { } 107 | <> { return imbueRawLiteral(); } 108 | } 109 | 110 | { 111 | [^] { yypushback(1); return imbueRawLiteral(); } 112 | <> { return imbueRawLiteral(); } 113 | } 114 | 115 | { 116 | "*/" { return imbueBlockComment(); } 117 | <> { return imbueBlockComment(); } 118 | [^] { } 119 | } 120 | 121 | [^] { return BAD_CHARACTER; } 122 | -------------------------------------------------------------------------------- /src/main/java/org/jonahhenriksson/ron/language/RONSyntaxHighlighter.java: -------------------------------------------------------------------------------- 1 | package org.jonahhenriksson.ron.language; 2 | 3 | import com.intellij.lexer.Lexer; 4 | import com.intellij.openapi.editor.DefaultLanguageHighlighterColors; 5 | import com.intellij.openapi.editor.HighlighterColors; 6 | import com.intellij.openapi.editor.colors.TextAttributesKey; 7 | import com.intellij.openapi.fileTypes.SyntaxHighlighterBase; 8 | import com.intellij.psi.TokenType; 9 | import com.intellij.psi.tree.IElementType; 10 | import org.jetbrains.annotations.NotNull; 11 | import org.jonahhenriksson.ron.language.psi.RONTypes; 12 | 13 | public class RONSyntaxHighlighter extends SyntaxHighlighterBase { 14 | 15 | public static final TextAttributesKey COLON = TextAttributesKey.createTextAttributesKey("RON_COLON", DefaultLanguageHighlighterColors.OPERATION_SIGN); 16 | public static final TextAttributesKey COMMA = TextAttributesKey.createTextAttributesKey("RON_COMMA", DefaultLanguageHighlighterColors.COMMA); 17 | public static final TextAttributesKey PARENTHESES = TextAttributesKey.createTextAttributesKey("RON_PARENTHESES", DefaultLanguageHighlighterColors.PARENTHESES); 18 | public static final TextAttributesKey BRACKETS = TextAttributesKey.createTextAttributesKey("RON_BRACKETS", DefaultLanguageHighlighterColors.BRACKETS); 19 | public static final TextAttributesKey BRACES = TextAttributesKey.createTextAttributesKey("RON_BRACES", DefaultLanguageHighlighterColors.BRACES); 20 | public static final TextAttributesKey BOOLEAN = TextAttributesKey.createTextAttributesKey("RON_BOOLEAN", DefaultLanguageHighlighterColors.KEYWORD); 21 | public static final TextAttributesKey NUMBER = TextAttributesKey.createTextAttributesKey("RON_NUMBER", DefaultLanguageHighlighterColors.NUMBER); 22 | public static final TextAttributesKey STRING = TextAttributesKey.createTextAttributesKey("RON_STRING", DefaultLanguageHighlighterColors.STRING); 23 | public static final TextAttributesKey OPTION = TextAttributesKey.createTextAttributesKey("RON_OPTION", DefaultLanguageHighlighterColors.KEYWORD); 24 | public static final TextAttributesKey EXTENSION = TextAttributesKey.createTextAttributesKey("RON_EXTENSION", DefaultLanguageHighlighterColors.METADATA); 25 | public static final TextAttributesKey IDENT = TextAttributesKey.createTextAttributesKey("RON_IDENT", DefaultLanguageHighlighterColors.IDENTIFIER); 26 | public static final TextAttributesKey COMMENT = TextAttributesKey.createTextAttributesKey("RON_COMMENT", DefaultLanguageHighlighterColors.LINE_COMMENT); 27 | public static final TextAttributesKey BAD_CHAR = TextAttributesKey.createTextAttributesKey("RON_BAD_CHAR", HighlighterColors.BAD_CHARACTER); 28 | 29 | private static final TextAttributesKey[] COLON_KEYS = new TextAttributesKey[]{COLON}; 30 | private static final TextAttributesKey[] COMMA_KEYS = new TextAttributesKey[]{COMMA}; 31 | private static final TextAttributesKey[] PARENTHESES_KEYS = new TextAttributesKey[]{PARENTHESES}; 32 | private static final TextAttributesKey[] BRACKETS_KEYS = new TextAttributesKey[]{BRACKETS}; 33 | private static final TextAttributesKey[] BRACES_KEYS = new TextAttributesKey[]{BRACES}; 34 | private static final TextAttributesKey[] BOOLEAN_KEYS = new TextAttributesKey[]{BOOLEAN}; 35 | private static final TextAttributesKey[] NUMBER_KEYS = new TextAttributesKey[]{NUMBER}; 36 | private static final TextAttributesKey[] STRING_KEYS = new TextAttributesKey[]{STRING}; 37 | private static final TextAttributesKey[] OPTION_KEYS = new TextAttributesKey[]{OPTION}; 38 | private static final TextAttributesKey[] EXTENSION_KEYS = new TextAttributesKey[]{EXTENSION}; 39 | private static final TextAttributesKey[] IDENT_KEYS = new TextAttributesKey[]{IDENT}; 40 | private static final TextAttributesKey[] COMMENT_KEYS = new TextAttributesKey[]{COMMENT}; 41 | private static final TextAttributesKey[] BAD_CHAR_KEYS = new TextAttributesKey[]{BAD_CHAR}; 42 | private static final TextAttributesKey[] EMPTY_KEYS = new TextAttributesKey[0]; 43 | 44 | @Override 45 | public @NotNull Lexer getHighlightingLexer() { 46 | return new RONLexerAdapter(); 47 | } 48 | 49 | @Override 50 | public @NotNull TextAttributesKey[] getTokenHighlights(IElementType tokenType) { 51 | if (tokenType.equals(RONTypes.COLON)) { 52 | return COLON_KEYS; 53 | } 54 | else if (tokenType.equals(RONTypes.COMMA)) { 55 | return COMMA_KEYS; 56 | } 57 | else if (tokenType.equals(RONTypes.PARENTHESISL) || tokenType.equals(RONTypes.PARENTHESISR)) { 58 | return PARENTHESES_KEYS; 59 | } 60 | else if (tokenType.equals(RONTypes.BRACKETL) || tokenType.equals(RONTypes.BRACKETR)) { 61 | return BRACKETS_KEYS; 62 | } 63 | else if (tokenType.equals(RONTypes.BRACEL) || tokenType.equals(RONTypes.BRACER)) { 64 | return BRACES_KEYS; 65 | } 66 | else if (tokenType.equals(RONTypes.BOOLEAN)) { 67 | return BOOLEAN_KEYS; 68 | } 69 | else if (tokenType.equals(RONTypes.INTEGER)|| tokenType.equals(RONTypes.FLOAT)) { 70 | return NUMBER_KEYS; 71 | } 72 | else if (tokenType.equals(RONTypes.STRING) || tokenType.equals(RONTypes.RAW_STRING)) { 73 | return STRING_KEYS; 74 | } 75 | else if (tokenType.equals(RONTypes.SOME)) { 76 | return OPTION_KEYS; 77 | } 78 | else if (tokenType.equals(RONTypes.EXTENSION)) { 79 | return EXTENSION_KEYS; 80 | } 81 | else if (tokenType.equals(RONTypes.IDENT)) { 82 | return IDENT_KEYS; 83 | } 84 | else if (tokenType.equals(RONTypes.COMMENT) || tokenType.equals(RONTypes.BLOCK_COMMENT)) { 85 | return COMMENT_KEYS; 86 | } 87 | else if (tokenType.equals(TokenType.BAD_CHARACTER)) { 88 | return BAD_CHAR_KEYS; 89 | } 90 | else { 91 | return EMPTY_KEYS; 92 | } 93 | } 94 | } 95 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | # 4 | # Copyright 2015 the original author or authors. 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # https://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | # 18 | 19 | ############################################################################## 20 | ## 21 | ## Gradle start up script for UN*X 22 | ## 23 | ############################################################################## 24 | 25 | # Attempt to set APP_HOME 26 | # Resolve links: $0 may be a link 27 | PRG="$0" 28 | # Need this for relative symlinks. 29 | while [ -h "$PRG" ] ; do 30 | ls=`ls -ld "$PRG"` 31 | link=`expr "$ls" : '.*-> \(.*\)$'` 32 | if expr "$link" : '/.*' > /dev/null; then 33 | PRG="$link" 34 | else 35 | PRG=`dirname "$PRG"`"/$link" 36 | fi 37 | done 38 | SAVED="`pwd`" 39 | cd "`dirname \"$PRG\"`/" >/dev/null 40 | APP_HOME="`pwd -P`" 41 | cd "$SAVED" >/dev/null 42 | 43 | APP_NAME="Gradle" 44 | APP_BASE_NAME=`basename "$0"` 45 | 46 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 47 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' 48 | 49 | # Use the maximum available, or set MAX_FD != -1 to use that value. 50 | MAX_FD="maximum" 51 | 52 | warn () { 53 | echo "$*" 54 | } 55 | 56 | die () { 57 | echo 58 | echo "$*" 59 | echo 60 | exit 1 61 | } 62 | 63 | # OS specific support (must be 'true' or 'false'). 64 | cygwin=false 65 | msys=false 66 | darwin=false 67 | nonstop=false 68 | case "`uname`" in 69 | CYGWIN* ) 70 | cygwin=true 71 | ;; 72 | Darwin* ) 73 | darwin=true 74 | ;; 75 | MINGW* ) 76 | msys=true 77 | ;; 78 | NONSTOP* ) 79 | nonstop=true 80 | ;; 81 | esac 82 | 83 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 84 | 85 | 86 | # Determine the Java command to use to start the JVM. 87 | if [ -n "$JAVA_HOME" ] ; then 88 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 89 | # IBM's JDK on AIX uses strange locations for the executables 90 | JAVACMD="$JAVA_HOME/jre/sh/java" 91 | else 92 | JAVACMD="$JAVA_HOME/bin/java" 93 | fi 94 | if [ ! -x "$JAVACMD" ] ; then 95 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 96 | 97 | Please set the JAVA_HOME variable in your environment to match the 98 | location of your Java installation." 99 | fi 100 | else 101 | JAVACMD="java" 102 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 103 | 104 | Please set the JAVA_HOME variable in your environment to match the 105 | location of your Java installation." 106 | fi 107 | 108 | # Increase the maximum file descriptors if we can. 109 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then 110 | MAX_FD_LIMIT=`ulimit -H -n` 111 | if [ $? -eq 0 ] ; then 112 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 113 | MAX_FD="$MAX_FD_LIMIT" 114 | fi 115 | ulimit -n $MAX_FD 116 | if [ $? -ne 0 ] ; then 117 | warn "Could not set maximum file descriptor limit: $MAX_FD" 118 | fi 119 | else 120 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 121 | fi 122 | fi 123 | 124 | # For Darwin, add options to specify how the application appears in the dock 125 | if $darwin; then 126 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 127 | fi 128 | 129 | # For Cygwin or MSYS, switch paths to Windows format before running java 130 | if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then 131 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 132 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 133 | 134 | JAVACMD=`cygpath --unix "$JAVACMD"` 135 | 136 | # We build the pattern for arguments to be converted via cygpath 137 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 138 | SEP="" 139 | for dir in $ROOTDIRSRAW ; do 140 | ROOTDIRS="$ROOTDIRS$SEP$dir" 141 | SEP="|" 142 | done 143 | OURCYGPATTERN="(^($ROOTDIRS))" 144 | # Add a user-defined pattern to the cygpath arguments 145 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 146 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 147 | fi 148 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 149 | i=0 150 | for arg in "$@" ; do 151 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 152 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 153 | 154 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 155 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 156 | else 157 | eval `echo args$i`="\"$arg\"" 158 | fi 159 | i=`expr $i + 1` 160 | done 161 | case $i in 162 | 0) set -- ;; 163 | 1) set -- "$args0" ;; 164 | 2) set -- "$args0" "$args1" ;; 165 | 3) set -- "$args0" "$args1" "$args2" ;; 166 | 4) set -- "$args0" "$args1" "$args2" "$args3" ;; 167 | 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 168 | 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 169 | 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 170 | 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 171 | 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 172 | esac 173 | fi 174 | 175 | # Escape application args 176 | save () { 177 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done 178 | echo " " 179 | } 180 | APP_ARGS=`save "$@"` 181 | 182 | # Collect all arguments for the java command, following the shell quoting and substitution rules 183 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" 184 | 185 | exec "$JAVACMD" "$@" 186 | -------------------------------------------------------------------------------- /src/main/resources/flex/idea-flex.skeleton: -------------------------------------------------------------------------------- 1 | 2 | /** This character denotes the end of file */ 3 | public static final int YYEOF = -1; 4 | 5 | /** initial size of the lookahead buffer */ 6 | --- private static final int ZZ_BUFFERSIZE = ...; 7 | 8 | /** lexical states */ 9 | --- lexical states, charmap 10 | 11 | /* error codes */ 12 | private static final int ZZ_UNKNOWN_ERROR = 0; 13 | private static final int ZZ_NO_MATCH = 1; 14 | private static final int ZZ_PUSHBACK_2BIG = 2; 15 | 16 | /* error messages for the codes above */ 17 | private static final String[] ZZ_ERROR_MSG = { 18 | "Unknown internal scanner error", 19 | "Error: could not match input", 20 | "Error: pushback value was too large" 21 | }; 22 | 23 | --- isFinal list 24 | /** the input device */ 25 | private java.io.Reader zzReader; 26 | 27 | /** the current state of the DFA */ 28 | private int zzState; 29 | 30 | /** the current lexical state */ 31 | private int zzLexicalState = YYINITIAL; 32 | 33 | /** this buffer contains the current text to be matched and is 34 | the source of the yytext() string */ 35 | private CharSequence zzBuffer = ""; 36 | 37 | /** the textposition at the last accepting state */ 38 | private int zzMarkedPos; 39 | 40 | /** the current text position in the buffer */ 41 | private int zzCurrentPos; 42 | 43 | /** startRead marks the beginning of the yytext() string in the buffer */ 44 | private int zzStartRead; 45 | 46 | /** endRead marks the last character in the buffer, that has been read 47 | from input */ 48 | private int zzEndRead; 49 | 50 | /** 51 | * zzAtBOL == true <=> the scanner is currently at the beginning of a line 52 | */ 53 | private boolean zzAtBOL = true; 54 | 55 | /** zzAtEOF == true <=> the scanner is at the EOF */ 56 | private boolean zzAtEOF; 57 | 58 | /** denotes if the user-EOF-code has already been executed */ 59 | private boolean zzEOFDone; 60 | 61 | --- user class code 62 | 63 | --- constructor declaration 64 | 65 | public final int getTokenStart() { 66 | return zzStartRead; 67 | } 68 | 69 | public final int getTokenEnd() { 70 | return getTokenStart() + yylength(); 71 | } 72 | 73 | public void reset(CharSequence buffer, int start, int end, int initialState) { 74 | zzBuffer = buffer; 75 | zzCurrentPos = zzMarkedPos = zzStartRead = start; 76 | zzAtEOF = false; 77 | zzAtBOL = true; 78 | zzEndRead = end; 79 | yybegin(initialState); 80 | } 81 | 82 | /** 83 | * Refills the input buffer. 84 | * 85 | * @return {@code false}, iff there was new input. 86 | * 87 | * @exception java.io.IOException if any I/O-Error occurs 88 | */ 89 | private boolean zzRefill() throws java.io.IOException { 90 | return true; 91 | } 92 | 93 | 94 | /** 95 | * Returns the current lexical state. 96 | */ 97 | public final int yystate() { 98 | return zzLexicalState; 99 | } 100 | 101 | 102 | /** 103 | * Enters a new lexical state 104 | * 105 | * @param newState the new lexical state 106 | */ 107 | public final void yybegin(int newState) { 108 | zzLexicalState = newState; 109 | } 110 | 111 | 112 | /** 113 | * Returns the text matched by the current regular expression. 114 | */ 115 | public final CharSequence yytext() { 116 | return zzBuffer.subSequence(zzStartRead, zzMarkedPos); 117 | } 118 | 119 | 120 | /** 121 | * Returns the character at position {@code pos} from the 122 | * matched text. 123 | * 124 | * It is equivalent to yytext().charAt(pos), but faster 125 | * 126 | * @param pos the position of the character to fetch. 127 | * A value from 0 to yylength()-1. 128 | * 129 | * @return the character at position pos 130 | */ 131 | public final char yycharat(int pos) { 132 | return zzBuffer.charAt(zzStartRead+pos); 133 | } 134 | 135 | 136 | /** 137 | * Returns the length of the matched text region. 138 | */ 139 | public final int yylength() { 140 | return zzMarkedPos-zzStartRead; 141 | } 142 | 143 | 144 | /** 145 | * Reports an error that occurred while scanning. 146 | * 147 | * In a wellformed scanner (no or only correct usage of 148 | * yypushback(int) and a match-all fallback rule) this method 149 | * will only be called with things that "Can't Possibly Happen". 150 | * If this method is called, something is seriously wrong 151 | * (e.g. a JFlex bug producing a faulty scanner etc.). 152 | * 153 | * Usual syntax/scanner level error handling should be done 154 | * in error fallback rules. 155 | * 156 | * @param errorCode the code of the errormessage to display 157 | */ 158 | --- zzScanError declaration 159 | String message; 160 | try { 161 | message = ZZ_ERROR_MSG[errorCode]; 162 | } 163 | catch (ArrayIndexOutOfBoundsException e) { 164 | message = ZZ_ERROR_MSG[ZZ_UNKNOWN_ERROR]; 165 | } 166 | 167 | --- throws clause 168 | } 169 | 170 | 171 | /** 172 | * Pushes the specified amount of characters back into the input stream. 173 | * 174 | * They will be read again by then next call of the scanning method 175 | * 176 | * @param number the number of characters to be read again. 177 | * This number must not be greater than yylength()! 178 | */ 179 | --- yypushback decl (contains zzScanError exception) 180 | if ( number > yylength() ) 181 | zzScanError(ZZ_PUSHBACK_2BIG); 182 | 183 | zzMarkedPos -= number; 184 | } 185 | 186 | 187 | --- zzDoEOF 188 | /** 189 | * Resumes scanning until the next regular expression is matched, 190 | * the end of input is encountered or an I/O-Error occurs. 191 | * 192 | * @return the next token 193 | * @exception java.io.IOException if any I/O-Error occurs 194 | */ 195 | --- yylex declaration 196 | int zzInput; 197 | int zzAction; 198 | 199 | // cached fields: 200 | int zzCurrentPosL; 201 | int zzMarkedPosL; 202 | int zzEndReadL = zzEndRead; 203 | CharSequence zzBufferL = zzBuffer; 204 | 205 | --- local declarations 206 | 207 | while (true) { 208 | zzMarkedPosL = zzMarkedPos; 209 | 210 | --- start admin (line, char, col count) 211 | zzAction = -1; 212 | 213 | zzCurrentPosL = zzCurrentPos = zzStartRead = zzMarkedPosL; 214 | 215 | --- start admin (lexstate etc) 216 | 217 | zzForAction: { 218 | while (true) { 219 | 220 | --- next input, line, col, char count, next transition, isFinal action 221 | zzAction = zzState; 222 | zzMarkedPosL = zzCurrentPosL; 223 | --- line count update 224 | } 225 | 226 | } 227 | } 228 | 229 | // store back cached position 230 | zzMarkedPos = zzMarkedPosL; 231 | --- char count update 232 | 233 | if (zzInput == YYEOF && zzStartRead == zzCurrentPos) { 234 | zzAtEOF = true; 235 | --- eofvalue 236 | } 237 | else { 238 | --- actions 239 | default: 240 | --- no match 241 | } 242 | } 243 | } 244 | } 245 | 246 | --- main 247 | 248 | } 249 | -------------------------------------------------------------------------------- /LICENSE-APACHE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /src/main/gen/org/jonahhenriksson/ron/language/parser/_RONParser.java: -------------------------------------------------------------------------------- 1 | // This is a generated file. Not intended for manual editing. 2 | package org.jonahhenriksson.ron.language.parser; 3 | 4 | import com.intellij.lang.PsiBuilder; 5 | import com.intellij.lang.PsiBuilder.Marker; 6 | import static org.jonahhenriksson.ron.language.psi.RONTypes.*; 7 | import static org.jonahhenriksson.ron.language.psi.RONParserUtil.*; 8 | import com.intellij.psi.tree.IElementType; 9 | import com.intellij.lang.ASTNode; 10 | import com.intellij.psi.tree.TokenSet; 11 | import com.intellij.lang.PsiParser; 12 | import com.intellij.lang.LightPsiParser; 13 | 14 | @SuppressWarnings({"SimplifiableIfStatement", "UnusedAssignment"}) 15 | public class _RONParser implements PsiParser, LightPsiParser { 16 | 17 | public ASTNode parse(IElementType t, PsiBuilder b) { 18 | parseLight(t, b); 19 | return b.getTreeBuilt(); 20 | } 21 | 22 | public void parseLight(IElementType t, PsiBuilder b) { 23 | boolean r; 24 | b = adapt_builder_(t, b, this, null); 25 | Marker m = enter_section_(b, 0, _COLLAPSE_, null); 26 | r = parse_root_(t, b); 27 | exit_section_(b, 0, m, t, r, true, TRUE_CONDITION); 28 | } 29 | 30 | protected boolean parse_root_(IElementType t, PsiBuilder b) { 31 | return parse_root_(t, b, 0); 32 | } 33 | 34 | static boolean parse_root_(IElementType t, PsiBuilder b, int l) { 35 | return RON(b, l + 1); 36 | } 37 | 38 | /* ********************************************************** */ 39 | // [extension+] value 40 | static boolean RON(PsiBuilder b, int l) { 41 | if (!recursion_guard_(b, l, "RON")) return false; 42 | boolean r; 43 | Marker m = enter_section_(b); 44 | r = RON_0(b, l + 1); 45 | r = r && value(b, l + 1); 46 | exit_section_(b, m, null, r); 47 | return r; 48 | } 49 | 50 | // [extension+] 51 | private static boolean RON_0(PsiBuilder b, int l) { 52 | if (!recursion_guard_(b, l, "RON_0")) return false; 53 | RON_0_0(b, l + 1); 54 | return true; 55 | } 56 | 57 | // extension+ 58 | private static boolean RON_0_0(PsiBuilder b, int l) { 59 | if (!recursion_guard_(b, l, "RON_0_0")) return false; 60 | boolean r; 61 | Marker m = enter_section_(b); 62 | r = extension(b, l + 1); 63 | while (r) { 64 | int c = current_position_(b); 65 | if (!extension(b, l + 1)) break; 66 | if (!empty_element_parsed_guard_(b, "RON_0_0", c)) break; 67 | } 68 | exit_section_(b, m, null, r); 69 | return r; 70 | } 71 | 72 | /* ********************************************************** */ 73 | // BOOLEAN 74 | public static boolean bool(PsiBuilder b, int l) { 75 | if (!recursion_guard_(b, l, "bool")) return false; 76 | if (!nextTokenIs(b, BOOLEAN)) return false; 77 | boolean r; 78 | Marker m = enter_section_(b); 79 | r = consumeToken(b, BOOLEAN); 80 | exit_section_(b, m, BOOL, r); 81 | return r; 82 | } 83 | 84 | /* ********************************************************** */ 85 | // CHAR 86 | static boolean char_$(PsiBuilder b, int l) { 87 | return consumeToken(b, CHAR); 88 | } 89 | 90 | /* ********************************************************** */ 91 | // EXTENSION 92 | static boolean extension(PsiBuilder b, int l) { 93 | return consumeToken(b, EXTENSION); 94 | } 95 | 96 | /* ********************************************************** */ 97 | // FLOAT 98 | static boolean float_$(PsiBuilder b, int l) { 99 | return consumeToken(b, FLOAT); 100 | } 101 | 102 | /* ********************************************************** */ 103 | // INTEGER 104 | static boolean integer(PsiBuilder b, int l) { 105 | return consumeToken(b, INTEGER); 106 | } 107 | 108 | /* ********************************************************** */ 109 | // BRACKETL [value (COMMA value)* [COMMA]] BRACKETR 110 | public static boolean list(PsiBuilder b, int l) { 111 | if (!recursion_guard_(b, l, "list")) return false; 112 | if (!nextTokenIs(b, BRACKETL)) return false; 113 | boolean r; 114 | Marker m = enter_section_(b); 115 | r = consumeToken(b, BRACKETL); 116 | r = r && list_1(b, l + 1); 117 | r = r && consumeToken(b, BRACKETR); 118 | exit_section_(b, m, LIST, r); 119 | return r; 120 | } 121 | 122 | // [value (COMMA value)* [COMMA]] 123 | private static boolean list_1(PsiBuilder b, int l) { 124 | if (!recursion_guard_(b, l, "list_1")) return false; 125 | list_1_0(b, l + 1); 126 | return true; 127 | } 128 | 129 | // value (COMMA value)* [COMMA] 130 | private static boolean list_1_0(PsiBuilder b, int l) { 131 | if (!recursion_guard_(b, l, "list_1_0")) return false; 132 | boolean r; 133 | Marker m = enter_section_(b); 134 | r = value(b, l + 1); 135 | r = r && list_1_0_1(b, l + 1); 136 | r = r && list_1_0_2(b, l + 1); 137 | exit_section_(b, m, null, r); 138 | return r; 139 | } 140 | 141 | // (COMMA value)* 142 | private static boolean list_1_0_1(PsiBuilder b, int l) { 143 | if (!recursion_guard_(b, l, "list_1_0_1")) return false; 144 | while (true) { 145 | int c = current_position_(b); 146 | if (!list_1_0_1_0(b, l + 1)) break; 147 | if (!empty_element_parsed_guard_(b, "list_1_0_1", c)) break; 148 | } 149 | return true; 150 | } 151 | 152 | // COMMA value 153 | private static boolean list_1_0_1_0(PsiBuilder b, int l) { 154 | if (!recursion_guard_(b, l, "list_1_0_1_0")) return false; 155 | boolean r; 156 | Marker m = enter_section_(b); 157 | r = consumeToken(b, COMMA); 158 | r = r && value(b, l + 1); 159 | exit_section_(b, m, null, r); 160 | return r; 161 | } 162 | 163 | // [COMMA] 164 | private static boolean list_1_0_2(PsiBuilder b, int l) { 165 | if (!recursion_guard_(b, l, "list_1_0_2")) return false; 166 | consumeToken(b, COMMA); 167 | return true; 168 | } 169 | 170 | /* ********************************************************** */ 171 | // BRACEL [map_entry (COMMA map_entry)* [COMMA]] BRACER 172 | public static boolean map(PsiBuilder b, int l) { 173 | if (!recursion_guard_(b, l, "map")) return false; 174 | if (!nextTokenIs(b, BRACEL)) return false; 175 | boolean r; 176 | Marker m = enter_section_(b); 177 | r = consumeToken(b, BRACEL); 178 | r = r && map_1(b, l + 1); 179 | r = r && consumeToken(b, BRACER); 180 | exit_section_(b, m, MAP, r); 181 | return r; 182 | } 183 | 184 | // [map_entry (COMMA map_entry)* [COMMA]] 185 | private static boolean map_1(PsiBuilder b, int l) { 186 | if (!recursion_guard_(b, l, "map_1")) return false; 187 | map_1_0(b, l + 1); 188 | return true; 189 | } 190 | 191 | // map_entry (COMMA map_entry)* [COMMA] 192 | private static boolean map_1_0(PsiBuilder b, int l) { 193 | if (!recursion_guard_(b, l, "map_1_0")) return false; 194 | boolean r; 195 | Marker m = enter_section_(b); 196 | r = map_entry(b, l + 1); 197 | r = r && map_1_0_1(b, l + 1); 198 | r = r && map_1_0_2(b, l + 1); 199 | exit_section_(b, m, null, r); 200 | return r; 201 | } 202 | 203 | // (COMMA map_entry)* 204 | private static boolean map_1_0_1(PsiBuilder b, int l) { 205 | if (!recursion_guard_(b, l, "map_1_0_1")) return false; 206 | while (true) { 207 | int c = current_position_(b); 208 | if (!map_1_0_1_0(b, l + 1)) break; 209 | if (!empty_element_parsed_guard_(b, "map_1_0_1", c)) break; 210 | } 211 | return true; 212 | } 213 | 214 | // COMMA map_entry 215 | private static boolean map_1_0_1_0(PsiBuilder b, int l) { 216 | if (!recursion_guard_(b, l, "map_1_0_1_0")) return false; 217 | boolean r; 218 | Marker m = enter_section_(b); 219 | r = consumeToken(b, COMMA); 220 | r = r && map_entry(b, l + 1); 221 | exit_section_(b, m, null, r); 222 | return r; 223 | } 224 | 225 | // [COMMA] 226 | private static boolean map_1_0_2(PsiBuilder b, int l) { 227 | if (!recursion_guard_(b, l, "map_1_0_2")) return false; 228 | consumeToken(b, COMMA); 229 | return true; 230 | } 231 | 232 | /* ********************************************************** */ 233 | // value COLON value 234 | public static boolean map_entry(PsiBuilder b, int l) { 235 | if (!recursion_guard_(b, l, "map_entry")) return false; 236 | boolean r; 237 | Marker m = enter_section_(b, l, _NONE_, MAP_ENTRY, ""); 238 | r = value(b, l + 1); 239 | r = r && consumeToken(b, COLON); 240 | r = r && value(b, l + 1); 241 | exit_section_(b, l, m, r, false, null); 242 | return r; 243 | } 244 | 245 | /* ********************************************************** */ 246 | // IDENT COLON value 247 | public static boolean named_field(PsiBuilder b, int l) { 248 | if (!recursion_guard_(b, l, "named_field")) return false; 249 | if (!nextTokenIs(b, IDENT)) return false; 250 | boolean r; 251 | Marker m = enter_section_(b); 252 | r = consumeTokens(b, 0, IDENT, COLON); 253 | r = r && value(b, l + 1); 254 | exit_section_(b, m, NAMED_FIELD, r); 255 | return r; 256 | } 257 | 258 | /* ********************************************************** */ 259 | // [IDENT] PARENTHESISL [value (COMMA value)* [COMMA]] PARENTHESISR | PARENTHESISL PARENTHESISR | IDENT 260 | public static boolean object(PsiBuilder b, int l) { 261 | if (!recursion_guard_(b, l, "object")) return false; 262 | if (!nextTokenIs(b, "", IDENT, PARENTHESISL)) return false; 263 | boolean r; 264 | Marker m = enter_section_(b, l, _NONE_, OBJECT, ""); 265 | r = object_0(b, l + 1); 266 | if (!r) r = parseTokens(b, 0, PARENTHESISL, PARENTHESISR); 267 | if (!r) r = consumeToken(b, IDENT); 268 | exit_section_(b, l, m, r, false, null); 269 | return r; 270 | } 271 | 272 | // [IDENT] PARENTHESISL [value (COMMA value)* [COMMA]] PARENTHESISR 273 | private static boolean object_0(PsiBuilder b, int l) { 274 | if (!recursion_guard_(b, l, "object_0")) return false; 275 | boolean r; 276 | Marker m = enter_section_(b); 277 | r = object_0_0(b, l + 1); 278 | r = r && consumeToken(b, PARENTHESISL); 279 | r = r && object_0_2(b, l + 1); 280 | r = r && consumeToken(b, PARENTHESISR); 281 | exit_section_(b, m, null, r); 282 | return r; 283 | } 284 | 285 | // [IDENT] 286 | private static boolean object_0_0(PsiBuilder b, int l) { 287 | if (!recursion_guard_(b, l, "object_0_0")) return false; 288 | consumeToken(b, IDENT); 289 | return true; 290 | } 291 | 292 | // [value (COMMA value)* [COMMA]] 293 | private static boolean object_0_2(PsiBuilder b, int l) { 294 | if (!recursion_guard_(b, l, "object_0_2")) return false; 295 | object_0_2_0(b, l + 1); 296 | return true; 297 | } 298 | 299 | // value (COMMA value)* [COMMA] 300 | private static boolean object_0_2_0(PsiBuilder b, int l) { 301 | if (!recursion_guard_(b, l, "object_0_2_0")) return false; 302 | boolean r; 303 | Marker m = enter_section_(b); 304 | r = value(b, l + 1); 305 | r = r && object_0_2_0_1(b, l + 1); 306 | r = r && object_0_2_0_2(b, l + 1); 307 | exit_section_(b, m, null, r); 308 | return r; 309 | } 310 | 311 | // (COMMA value)* 312 | private static boolean object_0_2_0_1(PsiBuilder b, int l) { 313 | if (!recursion_guard_(b, l, "object_0_2_0_1")) return false; 314 | while (true) { 315 | int c = current_position_(b); 316 | if (!object_0_2_0_1_0(b, l + 1)) break; 317 | if (!empty_element_parsed_guard_(b, "object_0_2_0_1", c)) break; 318 | } 319 | return true; 320 | } 321 | 322 | // COMMA value 323 | private static boolean object_0_2_0_1_0(PsiBuilder b, int l) { 324 | if (!recursion_guard_(b, l, "object_0_2_0_1_0")) return false; 325 | boolean r; 326 | Marker m = enter_section_(b); 327 | r = consumeToken(b, COMMA); 328 | r = r && value(b, l + 1); 329 | exit_section_(b, m, null, r); 330 | return r; 331 | } 332 | 333 | // [COMMA] 334 | private static boolean object_0_2_0_2(PsiBuilder b, int l) { 335 | if (!recursion_guard_(b, l, "object_0_2_0_2")) return false; 336 | consumeToken(b, COMMA); 337 | return true; 338 | } 339 | 340 | /* ********************************************************** */ 341 | // SOME PARENTHESISL value PARENTHESISR 342 | public static boolean option(PsiBuilder b, int l) { 343 | if (!recursion_guard_(b, l, "option")) return false; 344 | if (!nextTokenIs(b, SOME)) return false; 345 | boolean r; 346 | Marker m = enter_section_(b); 347 | r = consumeTokens(b, 0, SOME, PARENTHESISL); 348 | r = r && value(b, l + 1); 349 | r = r && consumeToken(b, PARENTHESISR); 350 | exit_section_(b, m, OPTION, r); 351 | return r; 352 | } 353 | 354 | /* ********************************************************** */ 355 | // STRING | RAW_STRING 356 | static boolean string(PsiBuilder b, int l) { 357 | if (!recursion_guard_(b, l, "string")) return false; 358 | if (!nextTokenIs(b, "", RAW_STRING, STRING)) return false; 359 | boolean r; 360 | r = consumeToken(b, STRING); 361 | if (!r) r = consumeToken(b, RAW_STRING); 362 | return r; 363 | } 364 | 365 | /* ********************************************************** */ 366 | // bool | integer | float | string | char | option | list | map | named_field | object 367 | public static boolean value(PsiBuilder b, int l) { 368 | if (!recursion_guard_(b, l, "value")) return false; 369 | boolean r; 370 | Marker m = enter_section_(b, l, _NONE_, VALUE, ""); 371 | r = bool(b, l + 1); 372 | if (!r) r = integer(b, l + 1); 373 | if (!r) r = float_$(b, l + 1); 374 | if (!r) r = string(b, l + 1); 375 | if (!r) r = char_$(b, l + 1); 376 | if (!r) r = option(b, l + 1); 377 | if (!r) r = list(b, l + 1); 378 | if (!r) r = map(b, l + 1); 379 | if (!r) r = named_field(b, l + 1); 380 | if (!r) r = object(b, l + 1); 381 | exit_section_(b, l, m, r, false, null); 382 | return r; 383 | } 384 | 385 | } 386 | -------------------------------------------------------------------------------- /src/main/gen/org/jonahhenriksson/ron/language/__RONLexer.java: -------------------------------------------------------------------------------- 1 | /* The following code was generated by JFlex 1.7.0 tweaked for IntelliJ platform */ 2 | 3 | package org.jonahhenriksson.ron.language; 4 | 5 | import com.intellij.lexer.FlexLexer; 6 | import com.intellij.psi.tree.IElementType; 7 | 8 | import static com.intellij.psi.TokenType.BAD_CHARACTER; 9 | import static com.intellij.psi.TokenType.WHITE_SPACE; 10 | import static org.jonahhenriksson.ron.language.psi.RONTypes.*; 11 | 12 | 13 | /** 14 | * This class is a scanner generated by 15 | * JFlex 1.7.0 16 | * from the specification file __RONLexer.flex 17 | */ 18 | public class __RONLexer implements FlexLexer { 19 | 20 | /** This character denotes the end of file */ 21 | public static final int YYEOF = -1; 22 | 23 | /** initial size of the lookahead buffer */ 24 | private static final int ZZ_BUFFERSIZE = 16384; 25 | 26 | /** lexical states */ 27 | public static final int YYINITIAL = 0; 28 | public static final int IN_RAW_STRING = 2; 29 | public static final int IN_RAW_STRING_SUFFIX = 4; 30 | public static final int IN_BLOCK_COMMENT = 6; 31 | 32 | /** 33 | * ZZ_LEXSTATE[l] is the state in the DFA for the lexical state l 34 | * ZZ_LEXSTATE[l+1] is the state in the DFA for the lexical state l 35 | * at the beginning of a line 36 | * l is of the form l = 2*k, k a non negative integer 37 | */ 38 | private static final int ZZ_LEXSTATE[] = { 39 | 0, 0, 1, 1, 2, 2, 3, 3 40 | }; 41 | 42 | /** 43 | * Translates characters to character classes 44 | * Chosen bits are [7, 7, 7] 45 | * Total runtime size is 1928 bytes 46 | */ 47 | public static int ZZ_CMAP(int ch) { 48 | return ZZ_CMAP_A[(ZZ_CMAP_Y[ZZ_CMAP_Z[ch>>14]|((ch>>7)&0x7f)]<<7)|(ch&0x7f)]; 49 | } 50 | 51 | /* The ZZ_CMAP_Z table has 68 entries */ 52 | static final char ZZ_CMAP_Z[] = zzUnpackCMap( 53 | "\1\0\103\200"); 54 | 55 | /* The ZZ_CMAP_Y table has 256 entries */ 56 | static final char ZZ_CMAP_Y[] = zzUnpackCMap( 57 | "\1\0\1\1\53\2\1\3\22\2\1\4\37\2\1\3\237\2"); 58 | 59 | /* The ZZ_CMAP_A table has 640 entries */ 60 | static final char ZZ_CMAP_A[] = zzUnpackCMap( 61 | "\11\0\1\3\1\2\2\1\1\2\22\0\1\31\1\30\1\33\1\34\3\30\1\27\1\37\1\40\1\51\1"+ 62 | "\15\1\46\1\15\1\25\1\42\1\16\11\20\1\45\6\30\4\21\1\26\1\21\14\14\1\47\7\14"+ 63 | "\1\35\1\32\1\41\1\30\1\22\1\30\1\11\1\24\2\21\1\7\1\10\5\14\1\12\1\50\1\36"+ 64 | "\1\23\2\14\1\5\1\13\1\4\1\6\2\14\1\17\2\14\1\43\1\30\1\44\1\30\6\0\1\1\32"+ 65 | "\0\1\3\337\0\1\3\177\0\13\3\35\0\2\1\5\0\1\3\57\0\1\3\40\0"); 66 | 67 | /** 68 | * Translates DFA states to action switch labels. 69 | */ 70 | private static final int [] ZZ_ACTION = zzUnpackAction(); 71 | 72 | private static final String ZZ_ACTION_PACKED_0 = 73 | "\4\0\1\1\1\2\4\3\1\1\2\4\1\1\1\5"+ 74 | "\3\1\1\6\1\7\1\10\1\11\1\1\1\12\1\13"+ 75 | "\1\14\1\15\1\3\1\16\1\17\1\20\1\16\1\3"+ 76 | "\1\21\1\0\1\3\1\0\1\4\1\0\1\22\1\5"+ 77 | "\3\0\1\23\3\0\1\24\1\25\1\3\1\26\2\3"+ 78 | "\1\4\1\0\1\23\1\0\1\3\1\27\1\22\1\0"+ 79 | "\1\30\10\0\1\31\4\0"; 80 | 81 | private static int [] zzUnpackAction() { 82 | int [] result = new int[76]; 83 | int offset = 0; 84 | offset = zzUnpackAction(ZZ_ACTION_PACKED_0, offset, result); 85 | return result; 86 | } 87 | 88 | private static int zzUnpackAction(String packed, int offset, int [] result) { 89 | int i = 0; /* index in packed string */ 90 | int j = offset; /* index in unpacked array */ 91 | int l = packed.length(); 92 | while (i < l) { 93 | int count = packed.charAt(i++); 94 | int value = packed.charAt(i++); 95 | do result[j++] = value; while (--count > 0); 96 | } 97 | return j; 98 | } 99 | 100 | 101 | /** 102 | * Translates a state to a row index in the transition table 103 | */ 104 | private static final int [] ZZ_ROWMAP = zzUnpackRowMap(); 105 | 106 | private static final String ZZ_ROWMAP_PACKED_0 = 107 | "\0\0\0\52\0\124\0\176\0\250\0\322\0\374\0\u0126"+ 108 | "\0\u0150\0\u017a\0\u01a4\0\u01ce\0\u01f8\0\u0222\0\u024c\0\u0276"+ 109 | "\0\u02a0\0\u02ca\0\250\0\250\0\250\0\250\0\u02f4\0\250"+ 110 | "\0\250\0\250\0\250\0\u031e\0\250\0\u0348\0\250\0\u0372"+ 111 | "\0\u039c\0\250\0\u03c6\0\u03f0\0\u041a\0\u0444\0\u046e\0\u0498"+ 112 | "\0\250\0\u04c2\0\u02a0\0\u04ec\0\250\0\u0516\0\u0540\0\u056a"+ 113 | "\0\u0594\0\250\0\u05be\0\250\0\u05e8\0\u0612\0\u063c\0\u0666"+ 114 | "\0\u02a0\0\u0690\0\u06ba\0\u0150\0\u0666\0\u06e4\0\u0150\0\u070e"+ 115 | "\0\u0738\0\u0762\0\u078c\0\u07b6\0\u07e0\0\u080a\0\u0834\0\u0516"+ 116 | "\0\u085e\0\u0888\0\u08b2\0\u08dc"; 117 | 118 | private static int [] zzUnpackRowMap() { 119 | int [] result = new int[76]; 120 | int offset = 0; 121 | offset = zzUnpackRowMap(ZZ_ROWMAP_PACKED_0, offset, result); 122 | return result; 123 | } 124 | 125 | private static int zzUnpackRowMap(String packed, int offset, int [] result) { 126 | int i = 0; /* index in packed string */ 127 | int j = offset; /* index in unpacked array */ 128 | int l = packed.length(); 129 | while (i < l) { 130 | int high = packed.charAt(i++) << 16; 131 | result[j++] = high | packed.charAt(i++); 132 | } 133 | return j; 134 | } 135 | 136 | /** 137 | * The transition table of the DFA 138 | */ 139 | private static final int [] ZZ_TRANS = zzUnpackTrans(); 140 | 141 | private static final String ZZ_TRANS_PACKED_0 = 142 | "\1\5\3\6\1\7\1\10\2\11\1\12\4\11\1\13"+ 143 | "\1\14\1\11\1\15\4\11\1\16\1\11\1\17\1\5"+ 144 | "\1\6\1\20\1\21\1\22\1\23\1\11\1\24\1\25"+ 145 | "\1\26\1\27\1\30\1\31\1\32\1\33\1\34\1\11"+ 146 | "\1\5\33\35\1\36\16\35\52\37\51\35\1\40\53\0"+ 147 | "\3\6\25\0\1\6\24\0\1\11\1\41\7\11\2\0"+ 148 | "\1\11\1\0\4\11\1\0\1\11\7\0\1\11\10\0"+ 149 | "\2\11\5\0\11\11\2\0\1\11\1\0\4\11\1\0"+ 150 | "\1\11\4\0\1\42\1\43\1\0\1\11\10\0\2\11"+ 151 | "\5\0\11\11\2\0\1\11\1\0\4\11\1\0\1\11"+ 152 | "\7\0\1\11\10\0\2\11\5\0\5\11\1\44\3\11"+ 153 | "\2\0\1\11\1\0\4\11\1\0\1\11\7\0\1\11"+ 154 | "\10\0\2\11\17\0\1\14\1\0\1\15\47\0\1\15"+ 155 | "\1\45\1\15\1\0\1\46\2\47\1\50\42\0\1\15"+ 156 | "\1\0\1\15\1\0\1\46\2\0\1\50\42\0\1\50"+ 157 | "\1\0\1\50\35\0\23\51\1\0\2\51\1\0\17\51"+ 158 | "\32\0\1\52\17\0\2\53\1\0\27\53\1\54\1\55"+ 159 | "\16\53\7\56\1\57\25\56\1\60\14\56\42\0\1\61"+ 160 | "\6\0\1\62\4\0\11\11\2\0\1\11\1\0\2\11"+ 161 | "\1\63\1\11\1\0\1\11\7\0\1\11\10\0\2\11"+ 162 | "\35\0\1\36\57\0\1\64\13\0\2\11\1\65\6\11"+ 163 | "\2\0\1\11\1\0\4\11\1\0\1\11\7\0\1\11"+ 164 | "\10\0\2\11\34\0\1\42\1\43\21\0\6\11\1\66"+ 165 | "\2\11\2\0\1\11\1\0\4\11\1\0\1\11\7\0"+ 166 | "\1\11\10\0\2\11\10\0\3\67\4\0\1\67\1\0"+ 167 | "\2\67\2\0\1\67\1\0\1\67\41\0\1\46\1\0"+ 168 | "\1\46\1\0\1\46\45\0\1\46\1\0\1\46\40\0"+ 169 | "\1\70\6\0\1\50\1\0\1\50\5\0\1\70\52\0"+ 170 | "\1\51\22\0\2\53\1\0\27\53\1\54\1\71\16\53"+ 171 | "\7\56\1\57\51\56\1\57\26\56\1\72\65\56\1\61"+ 172 | "\2\0\47\61\4\0\11\11\2\0\1\11\1\0\4\11"+ 173 | "\1\0\1\11\7\0\1\11\10\0\1\11\1\73\5\0"+ 174 | "\3\11\1\74\5\11\2\0\1\11\1\0\4\11\1\0"+ 175 | "\1\11\7\0\1\11\10\0\2\11\5\0\7\11\1\65"+ 176 | "\1\11\2\0\1\11\1\0\4\11\1\0\1\11\7\0"+ 177 | "\1\11\10\0\2\11\10\0\3\67\4\0\1\67\1\0"+ 178 | "\3\67\1\0\1\67\1\0\1\67\41\0\1\75\1\0"+ 179 | "\1\75\31\0\7\56\1\57\1\56\1\76\40\56\4\0"+ 180 | "\3\11\1\77\5\11\2\0\1\11\1\0\4\11\1\0"+ 181 | "\1\11\7\0\1\11\10\0\2\11\1\0\7\56\1\57"+ 182 | "\14\56\1\100\34\56\1\57\2\56\1\101\46\56\1\102"+ 183 | "\51\56\1\57\26\56\1\72\1\103\16\56\3\104\1\105"+ 184 | "\5\104\2\56\1\104\1\56\4\104\1\56\1\104\7\56"+ 185 | "\1\104\10\56\2\104\5\56\3\104\1\105\5\104\2\56"+ 186 | "\1\104\1\56\4\104\1\56\1\104\7\56\1\104\1\56"+ 187 | "\1\106\6\56\2\104\5\56\3\104\1\105\5\104\2\56"+ 188 | "\1\104\1\56\4\104\1\56\1\104\7\56\1\107\1\56"+ 189 | "\1\106\6\56\2\104\10\56\1\57\31\56\1\110\14\56"+ 190 | "\3\104\1\105\1\104\1\111\3\104\2\56\1\104\1\56"+ 191 | "\4\104\1\56\1\104\7\56\1\104\1\56\1\106\6\56"+ 192 | "\2\104\5\56\3\104\1\105\5\104\2\56\1\104\1\56"+ 193 | "\3\104\1\112\1\56\1\104\7\56\1\104\1\56\1\106"+ 194 | "\6\56\2\104\5\56\3\104\1\105\2\104\1\113\2\104"+ 195 | "\2\56\1\104\1\56\4\104\1\56\1\104\7\56\1\104"+ 196 | "\1\56\1\106\6\56\2\104\5\56\3\104\1\114\5\104"+ 197 | "\2\56\1\104\1\56\4\104\1\56\1\104\7\56\1\104"+ 198 | "\1\56\1\106\6\56\2\104\5\56\3\104\1\105\5\104"+ 199 | "\2\56\1\104\1\56\4\104\1\56\1\104\7\56\1\107"+ 200 | "\1\103\1\106\6\56\2\104\1\56"; 201 | 202 | private static int [] zzUnpackTrans() { 203 | int [] result = new int[2310]; 204 | int offset = 0; 205 | offset = zzUnpackTrans(ZZ_TRANS_PACKED_0, offset, result); 206 | return result; 207 | } 208 | 209 | private static int zzUnpackTrans(String packed, int offset, int [] result) { 210 | int i = 0; /* index in packed string */ 211 | int j = offset; /* index in unpacked array */ 212 | int l = packed.length(); 213 | while (i < l) { 214 | int count = packed.charAt(i++); 215 | int value = packed.charAt(i++); 216 | value--; 217 | do result[j++] = value; while (--count > 0); 218 | } 219 | return j; 220 | } 221 | 222 | 223 | /* error codes */ 224 | private static final int ZZ_UNKNOWN_ERROR = 0; 225 | private static final int ZZ_NO_MATCH = 1; 226 | private static final int ZZ_PUSHBACK_2BIG = 2; 227 | 228 | /* error messages for the codes above */ 229 | private static final String[] ZZ_ERROR_MSG = { 230 | "Unknown internal scanner error", 231 | "Error: could not match input", 232 | "Error: pushback value was too large" 233 | }; 234 | 235 | /** 236 | * ZZ_ATTRIBUTE[aState] contains the attributes of state aState 237 | */ 238 | private static final int [] ZZ_ATTRIBUTE = zzUnpackAttribute(); 239 | 240 | private static final String ZZ_ATTRIBUTE_PACKED_0 = 241 | "\4\0\1\11\15\1\4\11\1\1\4\11\1\1\1\11"+ 242 | "\1\1\1\11\2\1\1\11\1\0\1\1\1\0\1\1"+ 243 | "\1\0\1\1\1\11\3\0\1\11\3\0\1\1\1\11"+ 244 | "\1\1\1\11\3\1\1\0\1\1\1\0\3\1\1\0"+ 245 | "\1\1\10\0\1\1\4\0"; 246 | 247 | private static int [] zzUnpackAttribute() { 248 | int [] result = new int[76]; 249 | int offset = 0; 250 | offset = zzUnpackAttribute(ZZ_ATTRIBUTE_PACKED_0, offset, result); 251 | return result; 252 | } 253 | 254 | private static int zzUnpackAttribute(String packed, int offset, int [] result) { 255 | int i = 0; /* index in packed string */ 256 | int j = offset; /* index in unpacked array */ 257 | int l = packed.length(); 258 | while (i < l) { 259 | int count = packed.charAt(i++); 260 | int value = packed.charAt(i++); 261 | do result[j++] = value; while (--count > 0); 262 | } 263 | return j; 264 | } 265 | 266 | /** the input device */ 267 | private java.io.Reader zzReader; 268 | 269 | /** the current state of the DFA */ 270 | private int zzState; 271 | 272 | /** the current lexical state */ 273 | private int zzLexicalState = YYINITIAL; 274 | 275 | /** this buffer contains the current text to be matched and is 276 | the source of the yytext() string */ 277 | private CharSequence zzBuffer = ""; 278 | 279 | /** the textposition at the last accepting state */ 280 | private int zzMarkedPos; 281 | 282 | /** the current text position in the buffer */ 283 | private int zzCurrentPos; 284 | 285 | /** startRead marks the beginning of the yytext() string in the buffer */ 286 | private int zzStartRead; 287 | 288 | /** endRead marks the last character in the buffer, that has been read 289 | from input */ 290 | private int zzEndRead; 291 | 292 | /** 293 | * zzAtBOL == true <=> the scanner is currently at the beginning of a line 294 | */ 295 | private boolean zzAtBOL = true; 296 | 297 | /** zzAtEOF == true <=> the scanner is at the EOF */ 298 | private boolean zzAtEOF; 299 | 300 | /** denotes if the user-EOF-code has already been executed */ 301 | private boolean zzEOFDone; 302 | 303 | /* user code: */ 304 | public __RONLexer() { 305 | this((java.io.Reader)null); 306 | } 307 | private int zzShaStride = -1; 308 | 309 | private int zzPostponedMarkedPos = -1; 310 | IElementType imbueRawLiteral() { 311 | yybegin(YYINITIAL); 312 | 313 | zzStartRead = zzPostponedMarkedPos; 314 | zzShaStride = -1; 315 | zzPostponedMarkedPos = -1; 316 | 317 | return RAW_STRING; 318 | } 319 | 320 | IElementType imbueBlockComment() { 321 | yybegin(YYINITIAL); 322 | 323 | zzStartRead = zzPostponedMarkedPos; 324 | zzPostponedMarkedPos = -1; 325 | 326 | return BLOCK_COMMENT; 327 | } 328 | 329 | 330 | /** 331 | * Creates a new scanner 332 | * 333 | * @param in the java.io.Reader to read input from. 334 | */ 335 | public __RONLexer(java.io.Reader in) { 336 | this.zzReader = in; 337 | } 338 | 339 | 340 | /** 341 | * Unpacks the compressed character translation table. 342 | * 343 | * @param packed the packed character translation table 344 | * @return the unpacked character translation table 345 | */ 346 | private static char [] zzUnpackCMap(String packed) { 347 | int size = 0; 348 | for (int i = 0, length = packed.length(); i < length; i += 2) { 349 | size += packed.charAt(i); 350 | } 351 | char[] map = new char[size]; 352 | int i = 0; /* index in packed string */ 353 | int j = 0; /* index in unpacked array */ 354 | while (i < packed.length()) { 355 | int count = packed.charAt(i++); 356 | char value = packed.charAt(i++); 357 | do map[j++] = value; while (--count > 0); 358 | } 359 | return map; 360 | } 361 | 362 | public final int getTokenStart() { 363 | return zzStartRead; 364 | } 365 | 366 | public final int getTokenEnd() { 367 | return getTokenStart() + yylength(); 368 | } 369 | 370 | public void reset(CharSequence buffer, int start, int end, int initialState) { 371 | zzBuffer = buffer; 372 | zzCurrentPos = zzMarkedPos = zzStartRead = start; 373 | zzAtEOF = false; 374 | zzAtBOL = true; 375 | zzEndRead = end; 376 | yybegin(initialState); 377 | } 378 | 379 | /** 380 | * Refills the input buffer. 381 | * 382 | * @return {@code false}, iff there was new input. 383 | * 384 | * @exception java.io.IOException if any I/O-Error occurs 385 | */ 386 | private boolean zzRefill() throws java.io.IOException { 387 | return true; 388 | } 389 | 390 | 391 | /** 392 | * Returns the current lexical state. 393 | */ 394 | public final int yystate() { 395 | return zzLexicalState; 396 | } 397 | 398 | 399 | /** 400 | * Enters a new lexical state 401 | * 402 | * @param newState the new lexical state 403 | */ 404 | public final void yybegin(int newState) { 405 | zzLexicalState = newState; 406 | } 407 | 408 | 409 | /** 410 | * Returns the text matched by the current regular expression. 411 | */ 412 | public final CharSequence yytext() { 413 | return zzBuffer.subSequence(zzStartRead, zzMarkedPos); 414 | } 415 | 416 | 417 | /** 418 | * Returns the character at position {@code pos} from the 419 | * matched text. 420 | * 421 | * It is equivalent to yytext().charAt(pos), but faster 422 | * 423 | * @param pos the position of the character to fetch. 424 | * A value from 0 to yylength()-1. 425 | * 426 | * @return the character at position pos 427 | */ 428 | public final char yycharat(int pos) { 429 | return zzBuffer.charAt(zzStartRead+pos); 430 | } 431 | 432 | 433 | /** 434 | * Returns the length of the matched text region. 435 | */ 436 | public final int yylength() { 437 | return zzMarkedPos-zzStartRead; 438 | } 439 | 440 | 441 | /** 442 | * Reports an error that occurred while scanning. 443 | * 444 | * In a wellformed scanner (no or only correct usage of 445 | * yypushback(int) and a match-all fallback rule) this method 446 | * will only be called with things that "Can't Possibly Happen". 447 | * If this method is called, something is seriously wrong 448 | * (e.g. a JFlex bug producing a faulty scanner etc.). 449 | * 450 | * Usual syntax/scanner level error handling should be done 451 | * in error fallback rules. 452 | * 453 | * @param errorCode the code of the errormessage to display 454 | */ 455 | private void zzScanError(int errorCode) { 456 | String message; 457 | try { 458 | message = ZZ_ERROR_MSG[errorCode]; 459 | } 460 | catch (ArrayIndexOutOfBoundsException e) { 461 | message = ZZ_ERROR_MSG[ZZ_UNKNOWN_ERROR]; 462 | } 463 | 464 | throw new Error(message); 465 | } 466 | 467 | 468 | /** 469 | * Pushes the specified amount of characters back into the input stream. 470 | * 471 | * They will be read again by then next call of the scanning method 472 | * 473 | * @param number the number of characters to be read again. 474 | * This number must not be greater than yylength()! 475 | */ 476 | public void yypushback(int number) { 477 | if ( number > yylength() ) 478 | zzScanError(ZZ_PUSHBACK_2BIG); 479 | 480 | zzMarkedPos -= number; 481 | } 482 | 483 | 484 | /** 485 | * Resumes scanning until the next regular expression is matched, 486 | * the end of input is encountered or an I/O-Error occurs. 487 | * 488 | * @return the next token 489 | * @exception java.io.IOException if any I/O-Error occurs 490 | */ 491 | public IElementType advance() throws java.io.IOException { 492 | int zzInput; 493 | int zzAction; 494 | 495 | // cached fields: 496 | int zzCurrentPosL; 497 | int zzMarkedPosL; 498 | int zzEndReadL = zzEndRead; 499 | CharSequence zzBufferL = zzBuffer; 500 | 501 | int [] zzTransL = ZZ_TRANS; 502 | int [] zzRowMapL = ZZ_ROWMAP; 503 | int [] zzAttrL = ZZ_ATTRIBUTE; 504 | 505 | while (true) { 506 | zzMarkedPosL = zzMarkedPos; 507 | 508 | zzAction = -1; 509 | 510 | zzCurrentPosL = zzCurrentPos = zzStartRead = zzMarkedPosL; 511 | 512 | zzState = ZZ_LEXSTATE[zzLexicalState]; 513 | 514 | // set up zzAction for empty match case: 515 | int zzAttributes = zzAttrL[zzState]; 516 | if ( (zzAttributes & 1) == 1 ) { 517 | zzAction = zzState; 518 | } 519 | 520 | 521 | zzForAction: { 522 | while (true) { 523 | 524 | if (zzCurrentPosL < zzEndReadL) { 525 | zzInput = Character.codePointAt(zzBufferL, zzCurrentPosL/*, zzEndReadL*/); 526 | zzCurrentPosL += Character.charCount(zzInput); 527 | } 528 | else if (zzAtEOF) { 529 | zzInput = YYEOF; 530 | break zzForAction; 531 | } 532 | else { 533 | // store back cached positions 534 | zzCurrentPos = zzCurrentPosL; 535 | zzMarkedPos = zzMarkedPosL; 536 | boolean eof = zzRefill(); 537 | // get translated positions and possibly new buffer 538 | zzCurrentPosL = zzCurrentPos; 539 | zzMarkedPosL = zzMarkedPos; 540 | zzBufferL = zzBuffer; 541 | zzEndReadL = zzEndRead; 542 | if (eof) { 543 | zzInput = YYEOF; 544 | break zzForAction; 545 | } 546 | else { 547 | zzInput = Character.codePointAt(zzBufferL, zzCurrentPosL/*, zzEndReadL*/); 548 | zzCurrentPosL += Character.charCount(zzInput); 549 | } 550 | } 551 | int zzNext = zzTransL[ zzRowMapL[zzState] + ZZ_CMAP(zzInput) ]; 552 | if (zzNext == -1) break zzForAction; 553 | zzState = zzNext; 554 | 555 | zzAttributes = zzAttrL[zzState]; 556 | if ( (zzAttributes & 1) == 1 ) { 557 | zzAction = zzState; 558 | zzMarkedPosL = zzCurrentPosL; 559 | if ( (zzAttributes & 8) == 8 ) break zzForAction; 560 | } 561 | 562 | } 563 | } 564 | 565 | // store back cached position 566 | zzMarkedPos = zzMarkedPosL; 567 | 568 | if (zzInput == YYEOF && zzStartRead == zzCurrentPos) { 569 | zzAtEOF = true; 570 | switch (zzLexicalState) { 571 | case IN_RAW_STRING: { 572 | return imbueRawLiteral(); 573 | } // fall though 574 | case 77: break; 575 | case IN_RAW_STRING_SUFFIX: { 576 | return imbueRawLiteral(); 577 | } // fall though 578 | case 78: break; 579 | case IN_BLOCK_COMMENT: { 580 | return imbueBlockComment(); 581 | } // fall though 582 | case 79: break; 583 | default: 584 | return null; 585 | } 586 | } 587 | else { 588 | switch (zzAction < 0 ? zzAction : ZZ_ACTION[zzAction]) { 589 | case 1: 590 | { return BAD_CHARACTER; 591 | } 592 | // fall through 593 | case 26: break; 594 | case 2: 595 | { return WHITE_SPACE; 596 | } 597 | // fall through 598 | case 27: break; 599 | case 3: 600 | { return IDENT; 601 | } 602 | // fall through 603 | case 28: break; 604 | case 4: 605 | { return INTEGER; 606 | } 607 | // fall through 608 | case 29: break; 609 | case 5: 610 | { return CHAR; 611 | } 612 | // fall through 613 | case 30: break; 614 | case 6: 615 | { return BRACKETL; 616 | } 617 | // fall through 618 | case 31: break; 619 | case 7: 620 | { return PARENTHESISL; 621 | } 622 | // fall through 623 | case 32: break; 624 | case 8: 625 | { return PARENTHESISR; 626 | } 627 | // fall through 628 | case 33: break; 629 | case 9: 630 | { return BRACKETR; 631 | } 632 | // fall through 633 | case 34: break; 634 | case 10: 635 | { return BRACEL; 636 | } 637 | // fall through 638 | case 35: break; 639 | case 11: 640 | { return BRACER; 641 | } 642 | // fall through 643 | case 36: break; 644 | case 12: 645 | { return COLON; 646 | } 647 | // fall through 648 | case 37: break; 649 | case 13: 650 | { return COMMA; 651 | } 652 | // fall through 653 | case 38: break; 654 | case 14: 655 | { 656 | } 657 | // fall through 658 | case 39: break; 659 | case 15: 660 | { int shaExcess = yylength() - 1 - zzShaStride; if (shaExcess >= 0) { yybegin(IN_RAW_STRING_SUFFIX); yypushback(shaExcess); } 661 | } 662 | // fall through 663 | case 40: break; 664 | case 16: 665 | { yypushback(1); return imbueRawLiteral(); 666 | } 667 | // fall through 668 | case 41: break; 669 | case 17: 670 | { yybegin(IN_RAW_STRING); 671 | zzPostponedMarkedPos = zzStartRead; 672 | zzShaStride = yylength() - 2; 673 | } 674 | // fall through 675 | case 42: break; 676 | case 18: 677 | { return FLOAT; 678 | } 679 | // fall through 680 | case 43: break; 681 | case 19: 682 | { return STRING; 683 | } 684 | // fall through 685 | case 44: break; 686 | case 20: 687 | { return COMMENT; 688 | } 689 | // fall through 690 | case 45: break; 691 | case 21: 692 | { yybegin(IN_BLOCK_COMMENT); 693 | yypushback(2); 694 | } 695 | // fall through 696 | case 46: break; 697 | case 22: 698 | { return imbueBlockComment(); 699 | } 700 | // fall through 701 | case 47: break; 702 | case 23: 703 | { return BOOLEAN; 704 | } 705 | // fall through 706 | case 48: break; 707 | case 24: 708 | { return SOME; 709 | } 710 | // fall through 711 | case 49: break; 712 | case 25: 713 | { return EXTENSION; 714 | } 715 | // fall through 716 | case 50: break; 717 | default: 718 | zzScanError(ZZ_NO_MATCH); 719 | } 720 | } 721 | } 722 | } 723 | 724 | 725 | } 726 | --------------------------------------------------------------------------------