Skip to content

Commit f3c1cc5

Browse files
committed
fix(exts/devin-lang): ensure proper indentation of code blocks in parser grammar #101
The DevInParser.bnf file has been modified to fix an issue where code blocks were not being properly indented. This change ensures that code blocks are correctly identified and parsed, regardless of whether they contain language identifiers or not.
1 parent d65daaf commit f3c1cc5

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,6 @@ used ::= (
3535
| VARIABLE_START VARIABLE_ID?
3636
)
3737

38-
code ::= CODE_BLOCK_START LANGUAGE_ID? code_contents CODE_BLOCK_END
38+
code ::= CODE_BLOCK_START LANGUAGE_ID? NEWLINE code_contents CODE_BLOCK_END
3939

4040
code_contents ::= (NEWLINE | CODE_CONTENT)*

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ DevInFile
44
PsiElement(DevInTokenType.NEWLINE)('\n')
55
CodeBlockElement(CODE)
66
PsiElement(DevInTokenType.CODE_BLOCK_START)('```')
7+
PsiElement(DevInTokenType.NEWLINE)('\n')
78
DevInCodeContentsImpl(CODE_CONTENTS)
8-
PsiElement(DevInTokenType.NEWLINE)('\n')
99
PsiElement(DevInTokenType.CODE_CONTENT)('print("Hello, world!")')
1010
PsiElement(DevInTokenType.NEWLINE)('\n')
1111
PsiElement(DevInTokenType.CODE_BLOCK_END)('```')

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ DevInFile
55
CodeBlockElement(CODE)
66
PsiElement(DevInTokenType.CODE_BLOCK_START)('```')
77
PsiElement(DevInTokenType.LANGUAGE_ID)('java')
8+
PsiElement(DevInTokenType.NEWLINE)('\n')
89
DevInCodeContentsImpl(CODE_CONTENTS)
9-
PsiElement(DevInTokenType.NEWLINE)('\n')
1010
PsiElement(DevInTokenType.CODE_CONTENT)('public class Main {')
1111
PsiElement(DevInTokenType.NEWLINE)('\n')
1212
PsiElement(DevInTokenType.CODE_CONTENT)(' public static void main(String[] args) {')

0 commit comments

Comments
 (0)