Skip to content

Commit 1589eb1

Browse files
committed
fix(devin-language): update syntax #101
1 parent 1e4507a commit 1589eb1

File tree

3 files changed

+25
-9
lines changed

3 files changed

+25
-9
lines changed

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

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,14 @@ import com.intellij.psi.TokenType;
2222
%eof{ return;
2323
%eof}
2424

25-
%s CONTEXT_BLOCK
2625
%s AGENT_BLOCK
2726
%s VARIABLE_BLOCK
27+
%s COMMAND_BLOCK
2828

29-
IDENTIFIER=[a-zA-Z0-9]([_\-a-zA-Z0-9]*)
30-
VARIABLE_ID=[a-zA-Z0-9]([_\-a-zA-Z0-9]*)
29+
IDENTIFIER=[a-zA-Z0-9][_\-a-zA-Z0-9]*
30+
VARIABLE_ID=[a-zA-Z0-9][_\-a-zA-Z0-9]*
31+
AGENT_ID=[a-zA-Z0-9][_\-a-zA-Z0-9]*
32+
COMMAND_ID=[a-zA-Z0-9][_\-a-zA-Z0-9]*
3133
REF_BLOCK=([$/@] {IDENTIFIER} )
3234
TEXT_SEGMENT=[^$/@]+
3335
NEWLINE=\n|\r\n
@@ -45,7 +47,7 @@ NEWLINE=\n|\r\n
4547
%%
4648
<YYINITIAL> {
4749
"@" { yybegin(AGENT_BLOCK); return AGENT_START; }
48-
"/" { yybegin(AGENT_BLOCK); return COMMAND_START; }
50+
"/" { yybegin(COMMAND_BLOCK); return COMMAND_START; }
4951
"$" { yybegin(VARIABLE_BLOCK); return VARIABLE_START; }
5052

5153
{TEXT_SEGMENT} { return TEXT_SEGMENT; }
@@ -54,7 +56,12 @@ NEWLINE=\n|\r\n
5456
}
5557

5658
<AGENT_BLOCK> {
57-
{IDENTIFIER} { yybegin(YYINITIAL); return IDENTIFIER; }
59+
{IDENTIFIER} { yybegin(YYINITIAL); return AGENT_ID; }
60+
[^] { return TokenType.BAD_CHARACTER; }
61+
}
62+
63+
<COMMAND_BLOCK> {
64+
{COMMAND_ID} { yybegin(YYINITIAL); return COMMAND_ID; }
5865
[^] { return TokenType.BAD_CHARACTER; }
5966
}
6067

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1-
你好 @hello-world sm
1+
你好 @hello-world sm
2+
解释一下代码 $selection
3+
/agent dothign somet

exts/devin-lang/src/test/testData/parser/BasicTest.txt

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@ DevInFile
22
PsiElement(DevInTokenType.TEXT_SEGMENT)('你好 ')
33
DevInUsedImpl(USED)
44
PsiElement(DevInTokenType.AGENT_START)('@')
5-
DevInAgentIdImpl(AGENT_ID)
6-
PsiElement(DevInTokenType.IDENTIFIER)('hello-world')
7-
PsiElement(DevInTokenType.TEXT_SEGMENT)(' sm')
5+
PsiElement(DevInTokenType.AGENT_ID)('hello-world')
6+
PsiElement(DevInTokenType.TEXT_SEGMENT)(' sm\n解释一下代码 ')
7+
DevInUsedImpl(USED)
8+
PsiElement(DevInTokenType.VARIABLE_START)('$')
9+
PsiElement(DevInTokenType.VARIABLE_ID)('selection')
10+
PsiElement(DevInTokenType.TEXT_SEGMENT)('\n')
11+
DevInUsedImpl(USED)
12+
PsiElement(DevInTokenType.COMMAND_START)('/')
13+
PsiElement(DevInTokenType.COMMAND_ID)('agent')
14+
PsiElement(DevInTokenType.TEXT_SEGMENT)(' dothign somet')

0 commit comments

Comments
 (0)