Skip to content

Commit 17b9133

Browse files
En3ThoForNeVeR
authored andcommitted
Allow nls before pipe operator
1 parent 3af1625 commit 17b9133

File tree

4 files changed

+72
-1
lines changed

4 files changed

+72
-1
lines changed

src/main/resources/PowerShell.bnf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ cast_expression ::= type_literal_expression unary_expression
381381

382382
//private attributed_expression ::= type_literal variable
383383

384-
left pipeline_tail ::= ( PIPE nls? command_call_expression )+
384+
left pipeline_tail ::= ( nls? PIPE nls? command_call_expression )+
385385
{elementType=pipeline}
386386

387387
command_call_expression ::= command_invocation_operator ( (command_module command_name_expr command_element* ) | command_name_expr command_element* ) | command_name_expression command_element*

src/test/kotlin/com/intellij/plugin/powershell/lang/PowerShellParserTest.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,5 @@ class PowerShellParserTest : ParsingTestCase("parser", "ps1", PowerShellParserDe
4040
fun testEnumDeclaration() { doTest(true) }
4141
fun testParamBlock() { doTest(true) }
4242
fun testComment() { doTest(true) }
43+
fun testNewLineThenPipeOperator() { doTest(true) }
4344
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
1, 2, 3
2+
| Foreach-Object { $_ }
3+
4+
1, 2, 3
5+
6+
| Foreach-Object { $_ }
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
FILE(0,65)
2+
PowerShellPipelineTailImplGen(PIPELINE)(0,31)
3+
PowerShellArrayLiteralExpressionImplGen(ARRAY_LITERAL_EXPRESSION)(0,7)
4+
PowerShellIntegerLiteralExpressionImplGen(INTEGER_LITERAL_EXPRESSION)(0,1)
5+
PsiElement(DEC_INTEGER)('1')(0,1)
6+
PsiElement(,)(',')(1,2)
7+
PsiWhiteSpace(' ')(2,3)
8+
PowerShellIntegerLiteralExpressionImplGen(INTEGER_LITERAL_EXPRESSION)(3,4)
9+
PsiElement(DEC_INTEGER)('2')(3,4)
10+
PsiElement(,)(',')(4,5)
11+
PsiWhiteSpace(' ')(5,6)
12+
PowerShellIntegerLiteralExpressionImplGen(INTEGER_LITERAL_EXPRESSION)(6,7)
13+
PsiElement(DEC_INTEGER)('3')(6,7)
14+
PsiElement(NLS)('\n')(7,8)
15+
PsiElement(|)('|')(8,9)
16+
PsiWhiteSpace(' ')(9,10)
17+
PowerShellCommandCallExpressionImplGen(COMMAND_CALL_EXPRESSION)(10,31)
18+
PowerShellCommandNameImplGen(COMMAND_NAME)(10,24)
19+
PowerShellIdentifierImplGen(IDENTIFIER)(10,24)
20+
PsiElement(GENERIC_ID_PART)('Foreach-Object')(10,24)
21+
PsiWhiteSpace(' ')(24,25)
22+
PowerShellCommandArgumentImplGen(COMMAND_ARGUMENT)(25,31)
23+
PowerShellScriptBlockExpressionImplGen(SCRIPT_BLOCK_EXPRESSION)(25,31)
24+
PsiElement({)('{')(25,26)
25+
PsiWhiteSpace(' ')(26,27)
26+
PowerShellBlockBodyImplGen(BLOCK_BODY)(27,29)
27+
PowerShellTargetVariableExpressionImplGen(TARGET_VARIABLE_EXPRESSION)(27,29)
28+
PsiElement($)('$')(27,28)
29+
PowerShellIdentifierImplGen(IDENTIFIER)(28,29)
30+
PsiElement(SIMPLE_ID)('_')(28,29)
31+
PsiWhiteSpace(' ')(29,30)
32+
PsiElement(})('}')(30,31)
33+
PsiElement(NLS)('\n\n')(31,33)
34+
PowerShellPipelineTailImplGen(PIPELINE)(33,65)
35+
PowerShellArrayLiteralExpressionImplGen(ARRAY_LITERAL_EXPRESSION)(33,40)
36+
PowerShellIntegerLiteralExpressionImplGen(INTEGER_LITERAL_EXPRESSION)(33,34)
37+
PsiElement(DEC_INTEGER)('1')(33,34)
38+
PsiElement(,)(',')(34,35)
39+
PsiWhiteSpace(' ')(35,36)
40+
PowerShellIntegerLiteralExpressionImplGen(INTEGER_LITERAL_EXPRESSION)(36,37)
41+
PsiElement(DEC_INTEGER)('2')(36,37)
42+
PsiElement(,)(',')(37,38)
43+
PsiWhiteSpace(' ')(38,39)
44+
PowerShellIntegerLiteralExpressionImplGen(INTEGER_LITERAL_EXPRESSION)(39,40)
45+
PsiElement(DEC_INTEGER)('3')(39,40)
46+
PsiElement(NLS)('\n\n')(40,42)
47+
PsiElement(|)('|')(42,43)
48+
PsiWhiteSpace(' ')(43,44)
49+
PowerShellCommandCallExpressionImplGen(COMMAND_CALL_EXPRESSION)(44,65)
50+
PowerShellCommandNameImplGen(COMMAND_NAME)(44,58)
51+
PowerShellIdentifierImplGen(IDENTIFIER)(44,58)
52+
PsiElement(GENERIC_ID_PART)('Foreach-Object')(44,58)
53+
PsiWhiteSpace(' ')(58,59)
54+
PowerShellCommandArgumentImplGen(COMMAND_ARGUMENT)(59,65)
55+
PowerShellScriptBlockExpressionImplGen(SCRIPT_BLOCK_EXPRESSION)(59,65)
56+
PsiElement({)('{')(59,60)
57+
PsiWhiteSpace(' ')(60,61)
58+
PowerShellBlockBodyImplGen(BLOCK_BODY)(61,63)
59+
PowerShellTargetVariableExpressionImplGen(TARGET_VARIABLE_EXPRESSION)(61,63)
60+
PsiElement($)('$')(61,62)
61+
PowerShellIdentifierImplGen(IDENTIFIER)(62,63)
62+
PsiElement(SIMPLE_ID)('_')(62,63)
63+
PsiWhiteSpace(' ')(63,64)
64+
PsiElement(})('}')(64,65)

0 commit comments

Comments
 (0)