Skip to content

Commit

Permalink
feat: init basic bnfgst
Browse files Browse the repository at this point in the history
  • Loading branch information
phodal committed Apr 15, 2023
1 parent db0c8c4 commit 0f96930
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/main/grammars/DevtiParser.bnf
@@ -0,0 +1,22 @@
{
parserClass="DevtiParser"
extends="com.intellij.extapi.psi.ASTWrapperPsiElement"
psiClassPrefix="DevtiStory"
psiImplClassSuffix="Impl"
psiPackage="com.example.devtistory.psi"
psiImplPackage="com.example.devtistory.psi.impl"
}

root ::= devtiUrl

devtiUrl ::= 'devti://' storyPath

storyPath ::= 'story' '/' storyId '/' acValues?

storyId ::= integer

// Matches a comma-separated list of AC values enclosed in curly braces
acValues ::= '{' acValue (',' acValue)* '}'

// Define the rules for integer and ac_value
acValue ::= ('AC' INTEGER_LITERAL) {pin=2}
39 changes: 39 additions & 0 deletions src/main/grammars/_DevtiLexer.flex
@@ -0,0 +1,39 @@
package ;

import com.intellij.lexer.FlexLexer;
import com.intellij.psi.tree.IElementType;

import static com.intellij.psi.TokenType.BAD_CHARACTER;
import static com.intellij.psi.TokenType.WHITE_SPACE;
import static generated.GeneratedTypes.*;

%%

%{
public _DevtiLexer() {
this((java.io.Reader)null);
}
%}

%public
%class _DevtiLexer
%implements FlexLexer
%function advance
%type IElementType
%unicode

EOL=\R
WHITE_SPACE=\s+


%%
<YYINITIAL> {
{WHITE_SPACE} { return WHITE_SPACE; }

"integer" { return INTEGER; }
"INTEGER_LITERAL" { return INTEGER_LITERAL; }


}

[^] { return BAD_CHARACTER; }

0 comments on commit 0f96930

Please sign in to comment.