Skip to content

Commit

Permalink
some implementing
Browse files Browse the repository at this point in the history
  • Loading branch information
illyrius666 committed Jan 23, 2025
1 parent 017b0b1 commit bf795f6
Show file tree
Hide file tree
Showing 11 changed files with 135 additions and 57 deletions.
12 changes: 12 additions & 0 deletions .idea/libraries/Gradle__com_google_code_findbugs_jsr305_3_0_2.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions .idea/libraries/Gradle__org_apache_ant_ant_1_10_13.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions .idea/libraries/Gradle__org_apache_ant_ant_launcher_1_10_13.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion .idea/modules/webstorm-vento.main.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions .idea/modules/webstorm-vento.test.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

50 changes: 19 additions & 31 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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(',') })
Expand Down
58 changes: 58 additions & 0 deletions src/main/jflex/VentoLexer.flex
Original file line number Diff line number Diff line change
@@ -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)*?\*\/ | \/\/.*

%%

<YYINITIAL> {

{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()); }
}
9 changes: 2 additions & 7 deletions src/main/kotlin/org/js/vento/webstormvento/VentoParser.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 }
}
19 changes: 1 addition & 18 deletions src/main/resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
~ All rights reserved.
-->

<!-- Plugin Configuration File. Read more: https://plugins.jetbrains.com/docs/intellij/plugin-configuration-file.html -->
<idea-plugin>
<id>org.js.vento.webstormvento</id>

Expand All @@ -13,28 +12,12 @@
ventojs
</vendor>

<!-- Product and plugin compatibility requirements -->
<!-- https://www.jetbrains.org/intellij/sdk/docs/basics/getting_started/plugin_compatibility.html -->
<depends>com.intellij.modules.platform</depends>
<depends>com.intellij.modules.lang</depends>
<depends>com.intellij.modules.xml</depends>
<depends>JavaScript</depends>

<extensions defaultExtensionNs="com.intellij">
<!-- com.jetbrains.php.blade.psi.BladePsiLanguageInjectionHost -->
<multiHostInjector implementation="org.js.vento.webstormvento.VentoJavaScriptAttributeValueInjector"/>
<xml.attributeDescriptorsProvider implementation="org.js.vento.webstormvento.AttributesProvider"/>
<xml.xmlExtension implementation="org.js.vento.webstormvento.XmlExtension"/>
<typedHandler implementation="org.js.vento.webstormvento.AutoPopupHandler"/>
<completion.contributor language="HTML"
implementationClass="org.js.vento.webstormvento.VentoCompletionContributor"
id="VentoCompletionContributor"/>
<codeInsight.lineMarkerProvider language="HTML"
implementationClass="org.js.vento.webstormvento.VentoLineMarkerProvider"/>
<applicationService serviceImplementation="org.js.vento.webstormvento.VentoSettingsState"/>
<applicationConfigurable parentId="Settings.JavaScript"
instance="org.js.vento.webstormvento.VentoSettingsConfigurable"
id="org.js.vento.webstormvento.VentoSettingsConfigurable"
displayName="Vento.js"/>
<parserDefinition implementation="org.js.vento.webstormvento.VentoParserDefinition"/>
</extensions>
</idea-plugin>

0 comments on commit bf795f6

Please sign in to comment.