File tree Expand file tree Collapse file tree 3 files changed +25
-9
lines changed Expand file tree Collapse file tree 3 files changed +25
-9
lines changed Original file line number Diff line number Diff line change @@ -22,12 +22,14 @@ import com.intellij.psi.TokenType;
22
22
%eof{ return ;
23
23
%eof}
24
24
25
- %s CONTEXT_BLOCK
26
25
%s AGENT_BLOCK
27
26
%s VARIABLE_BLOCK
27
+ %s COMMAND_BLOCK
28
28
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] *
31
33
REF_BLOCK =( [ $/@] {IDENTIFIER} )
32
34
TEXT_SEGMENT = [^ $/@] +
33
35
NEWLINE =\n|\r\n
@@ -45,7 +47,7 @@ NEWLINE=\n|\r\n
45
47
%%
46
48
<YYINITIAL> {
47
49
"@" { yybegin(AGENT_BLOCK ); return AGENT_START ; }
48
- "/" { yybegin(AGENT_BLOCK ); return COMMAND_START ; }
50
+ "/" { yybegin(COMMAND_BLOCK ); return COMMAND_START ; }
49
51
"$" { yybegin(VARIABLE_BLOCK ); return VARIABLE_START ; }
50
52
51
53
{TEXT_SEGMENT} { return TEXT_SEGMENT ; }
@@ -54,7 +56,12 @@ NEWLINE=\n|\r\n
54
56
}
55
57
56
58
<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 ; }
58
65
[^] { return TokenType . BAD_CHARACTER ; }
59
66
}
60
67
Original file line number Diff line number Diff line change 1
- 你好 @hello-world sm
1
+ 你好 @hello-world sm
2
+ 解释一下代码 $selection
3
+ /agent dothign somet
Original file line number Diff line number Diff line change @@ -2,6 +2,13 @@ DevInFile
2
2
PsiElement(DevInTokenType.TEXT_SEGMENT)('你好 ')
3
3
DevInUsedImpl(USED)
4
4
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')
You can’t perform that action at this time.
0 commit comments