From bf795f6e85d1458d146d07b4a977c5dc24a05948 Mon Sep 17 00:00:00 2001
From: Illyrius <28700752+illyrius666@users.noreply.github.com>
Date: Thu, 23 Jan 2025 12:01:46 +0100
Subject: [PATCH] some implementing
---
..._com_google_code_findbugs_jsr305_3_0_2.xml | 12 ++++
.../Gradle__org_apache_ant_ant_1_10_13.xml | 12 ++++
...e__org_apache_ant_ant_launcher_1_10_13.xml | 12 ++++
...brains_intellij_deps_jflex_jflex_1_9_2.xml | 10 ++++
.idea/modules/webstorm-vento.main.iml | 5 +-
.idea/modules/webstorm-vento.test.iml | 4 ++
.idea/workspace.xml | 50 ++++++----------
build.gradle.kts | 1 +
src/main/jflex/VentoLexer.flex | 58 +++++++++++++++++++
.../org/js/vento/webstormvento/VentoParser.kt | 9 +--
src/main/resources/META-INF/plugin.xml | 19 +-----
11 files changed, 135 insertions(+), 57 deletions(-)
create mode 100644 .idea/libraries/Gradle__com_google_code_findbugs_jsr305_3_0_2.xml
create mode 100644 .idea/libraries/Gradle__org_apache_ant_ant_1_10_13.xml
create mode 100644 .idea/libraries/Gradle__org_apache_ant_ant_launcher_1_10_13.xml
create mode 100644 .idea/libraries/Gradle__org_jetbrains_intellij_deps_jflex_jflex_1_9_2.xml
create mode 100644 src/main/jflex/VentoLexer.flex
diff --git a/.idea/libraries/Gradle__com_google_code_findbugs_jsr305_3_0_2.xml b/.idea/libraries/Gradle__com_google_code_findbugs_jsr305_3_0_2.xml
new file mode 100644
index 0000000..34b8357
--- /dev/null
+++ b/.idea/libraries/Gradle__com_google_code_findbugs_jsr305_3_0_2.xml
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Gradle__org_apache_ant_ant_1_10_13.xml b/.idea/libraries/Gradle__org_apache_ant_ant_1_10_13.xml
new file mode 100644
index 0000000..906d4d9
--- /dev/null
+++ b/.idea/libraries/Gradle__org_apache_ant_ant_1_10_13.xml
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Gradle__org_apache_ant_ant_launcher_1_10_13.xml b/.idea/libraries/Gradle__org_apache_ant_ant_launcher_1_10_13.xml
new file mode 100644
index 0000000..bd21f04
--- /dev/null
+++ b/.idea/libraries/Gradle__org_apache_ant_ant_launcher_1_10_13.xml
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Gradle__org_jetbrains_intellij_deps_jflex_jflex_1_9_2.xml b/.idea/libraries/Gradle__org_jetbrains_intellij_deps_jflex_jflex_1_9_2.xml
new file mode 100644
index 0000000..4d5546b
--- /dev/null
+++ b/.idea/libraries/Gradle__org_jetbrains_intellij_deps_jflex_jflex_1_9_2.xml
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/modules/webstorm-vento.main.iml b/.idea/modules/webstorm-vento.main.iml
index eadb393..ea07433 100644
--- a/.idea/modules/webstorm-vento.main.iml
+++ b/.idea/modules/webstorm-vento.main.iml
@@ -43,6 +43,7 @@
+
@@ -82,7 +83,9 @@
+
+
-
+
\ No newline at end of file
diff --git a/.idea/modules/webstorm-vento.test.iml b/.idea/modules/webstorm-vento.test.iml
index f8ec7fe..82aa2b0 100644
--- a/.idea/modules/webstorm-vento.test.iml
+++ b/.idea/modules/webstorm-vento.test.iml
@@ -42,6 +42,7 @@
+
@@ -81,7 +82,10 @@
+
+
+
\ No newline at end of file
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 15b8c2c..296e980 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -4,35 +4,14 @@
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
@@ -104,7 +83,7 @@
"nodejs_package_manager_path": "npm",
"rearrange.code.on.save": "true",
"run.code.analysis.last.selected.profile": "pProject Default",
- "settings.editor.selected.configurable": "advanced.settings"
+ "settings.editor.selected.configurable": "preferences.pluginManager"
}
}]]>
@@ -131,7 +110,7 @@
-
+
@@ -165,7 +144,15 @@
1737626073409
-
+
+
+ 1737628436805
+
+
+
+ 1737628436805
+
+
@@ -191,7 +178,8 @@
-
+
+
diff --git a/build.gradle.kts b/build.gradle.kts
index bfca1d2..2ae09f3 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -21,6 +21,7 @@ repositories {
dependencies {
implementation(kotlin("stdlib-jdk8"))
+ implementation("org.jetbrains.intellij.deps.jflex:jflex:1.9.2")
intellijPlatform {
create(providers.gradleProperty("platformType"), providers.gradleProperty("platformVersion"))
bundledPlugins(providers.gradleProperty("platformBundledPlugins").map { it.split(',') })
diff --git a/src/main/jflex/VentoLexer.flex b/src/main/jflex/VentoLexer.flex
new file mode 100644
index 0000000..582611b
--- /dev/null
+++ b/src/main/jflex/VentoLexer.flex
@@ -0,0 +1,58 @@
+/*---------------------------------------------------------------------------*
+ | VentoLexer.flex |
+ | Lexer specification for the Vento language using JFlex |
+ *---------------------------------------------------------------------------*/
+
+%%
+
+%class VentoLexer
+%unicode
+%cup
+%implements java_cup.runtime.Scanner
+%function next_token
+%type java_cup.runtime.Symbol
+
+%{
+ // Imports and additional code can be placed here
+ import com.intellij.psi.tree.IElementType;
+ import org.js.vento.webstormvento.psi.VentoTypes;
+ import org.js.vento.webstormvento.VentoTypes.*;
+ import java_cup.runtime.Symbol;
+%}
+
+IDENTIFIER = [a-zA-Z_][a-zA-Z0-9_]*
+NUMBER = [0-9]+(\.[0-9]+)?
+STRING = \"([^\"\\]|\\.)*\"
+WHITESPACE = [ \t\r\n]+
+COMMENT = \/\*(.|\n)*?\*\/ | \/\/.*
+
+%%
+
+ {
+
+ {WHITESPACE} { /* Skip whitespace */ }
+
+ {COMMENT} { /* Handle comments */ return new Symbol(VentoTypes.COMMENT); }
+
+ "if" { return new Symbol(VentoTypes.IF); }
+ "else" { return new Symbol(VentoTypes.ELSE); }
+ "for" { return new Symbol(VentoTypes.FOR); }
+ "while" { return new Symbol(VentoTypes.WHILE); }
+ "function" { return new Symbol(VentoTypes.FUNCTION); }
+ "return" { return new Symbol(VentoTypes.RETURN); }
+
+ {IDENTIFIER} { return new Symbol(VentoTypes.IDENTIFIER, yytext()); }
+ {NUMBER} { return new Symbol(VentoTypes.NUMBER, yytext()); }
+ {STRING} { return new Symbol(VentoTypes.STRING, yytext()); }
+
+ "=" { return new Symbol(VentoTypes.EQUALS); }
+ "+" { return new Symbol(VentoTypes.PLUS); }
+ "-" { return new Symbol(VentoTypes.MINUS); }
+ "*" { return new Symbol(VentoTypes.MULTIPLY); }
+ "/" { return new Symbol(VentoTypes.DIVIDE); }
+ ";" { return new Symbol(VentoTypes.SEMICOLON); }
+ "{" { return new Symbol(VentoTypes.LBRACE); }
+ "}" { return new Symbol(VentoTypes.RBRACE); }
+
+ . { /* Handle any other character */ return new Symbol(VentoTypes.ERROR, yytext()); }
+}
\ No newline at end of file
diff --git a/src/main/kotlin/org/js/vento/webstormvento/VentoParser.kt b/src/main/kotlin/org/js/vento/webstormvento/VentoParser.kt
index 21b6b17..d6ed693 100644
--- a/src/main/kotlin/org/js/vento/webstormvento/VentoParser.kt
+++ b/src/main/kotlin/org/js/vento/webstormvento/VentoParser.kt
@@ -5,7 +5,6 @@
package org.js.vento.webstormvento
-import com.intellij.lang.ASTNode
import com.intellij.lang.PsiBuilder
import com.intellij.lang.PsiParser
import com.intellij.psi.tree.IElementType
@@ -16,10 +15,6 @@ import com.intellij.psi.tree.IElementType
* that you can later expand to properly handle your Vento grammar.
*/
class VentoParser : PsiParser {
- override fun parse(root: IElementType, builder: PsiBuilder): ASTNode {
- val rootMarker = builder.mark()
- while (!builder.eof()) builder.advanceLexer()
- rootMarker.done(root)
- return builder.treeBuilt
- }
+ override fun parse(root: IElementType, builder: PsiBuilder) =
+ builder.mark().apply { while (!builder.eof()) builder.advanceLexer() }.done(root).run { builder.treeBuilt }
}
\ No newline at end of file
diff --git a/src/main/resources/META-INF/plugin.xml b/src/main/resources/META-INF/plugin.xml
index 90e14be..915fbd5 100644
--- a/src/main/resources/META-INF/plugin.xml
+++ b/src/main/resources/META-INF/plugin.xml
@@ -3,7 +3,6 @@
~ All rights reserved.
-->
-
org.js.vento.webstormvento
@@ -13,28 +12,12 @@
ventojs
-
-
com.intellij.modules.platform
com.intellij.modules.lang
com.intellij.modules.xml
JavaScript
-
-
-
-
-
-
-
-
-
+