Skip to content

Commit eda58cd

Browse files
committed
fix(devin-lang): update parser and lexer tokens and rules for improved grammar and tokenization. #101
1 parent b7e6106 commit eda58cd

File tree

4 files changed

+11
-16
lines changed

4 files changed

+11
-16
lines changed

exts/devin-lang/src/grammar/DevInLexer.flex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import com.intellij.psi.TokenType;
2727

2828
IDENTIFIER=[a-zA-Z0-9]([_\-a-zA-Z0-9]*)
2929
REF_BLOCK=("@" {IDENTIFIER} )
30-
TEXT_SEGMENT=.*
30+
TEXT_SEGMENT=[^$/@]+
3131
NEWLINE=\n|\r\n
3232

3333
%{

exts/devin-lang/src/grammar/DevInParser.bnf

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@
1313
elementTypeHolderClass="cc.unitmesh.language.psi.DevInTypes"
1414
elementTypeClass="cc.unitmesh.language.psi.DevInElementType"
1515
tokenTypeClass="cc.unitmesh.language.lexer.DevInTokenType"
16+
17+
tokens=[
18+
]
1619
}
1720

18-
DevInFile ::= (REF_BLOCK | TEXT_SEGMENT | NEWLINE)*
21+
DevInFile ::= (REF_BLOCK | TEXT_SEGMENT | CODE_FENCE | NEWLINE)*
22+
23+
//used ::= (AGENT | COMMAND | VARIABLE) IDENTIFIER
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
FILE
2-
PsiElement(DevInTokenType.TEXT_SEGMENT)('你好 @hello-world sm')
2+
PsiElement(DevInTokenType.TEXT_SEGMENT)('你好 ')
3+
PsiElement(DevInTokenType.REF_BLOCK)('@hello-world')
4+
PsiElement(DevInTokenType.TEXT_SEGMENT)(' sm')
Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,2 @@
11
FILE
2-
PsiElement(DevInTokenType.TEXT_SEGMENT)('```java')
3-
PsiElement(DevInTokenType.NEWLINE)('\n')
4-
PsiElement(DevInTokenType.TEXT_SEGMENT)('public class Main {')
5-
PsiElement(DevInTokenType.NEWLINE)('\n')
6-
PsiElement(DevInTokenType.TEXT_SEGMENT)(' public static void main(String[] args) {')
7-
PsiElement(DevInTokenType.NEWLINE)('\n')
8-
PsiElement(DevInTokenType.TEXT_SEGMENT)(' System.out.println("Hello, world!");')
9-
PsiElement(DevInTokenType.NEWLINE)('\n')
10-
PsiElement(DevInTokenType.TEXT_SEGMENT)(' }')
11-
PsiElement(DevInTokenType.NEWLINE)('\n')
12-
PsiElement(DevInTokenType.TEXT_SEGMENT)('}')
13-
PsiElement(DevInTokenType.NEWLINE)('\n')
14-
PsiElement(DevInTokenType.TEXT_SEGMENT)('```')
2+
PsiElement(DevInTokenType.TEXT_SEGMENT)('```java\npublic class Main {\n public static void main(String[] args) {\n System.out.println("Hello, world!");\n }\n}\n```')

0 commit comments

Comments
 (0)