Skip to content

Commit

Permalink
Parse lines which contain only identifiers
Browse files Browse the repository at this point in the history
This is needed, so the `animation` block is correctly parsed.
  • Loading branch information
dirkgroot committed Mar 31, 2023
1 parent db76d07 commit c01d377
Show file tree
Hide file tree
Showing 9 changed files with 152 additions and 2 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions src/main/gen/nl/dirkgroot/structurizr/dsl/psi/SDTypes.java

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions src/main/gen/nl/dirkgroot/structurizr/dsl/psi/SDVisitor.java

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion src/main/grammar/StructurizrDSL.bnf
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@

structurizrDSLFile ::= statement*

private statement ::= elementDefinition | scriptBlock | explicitRelationship | implicitRelationship
private statement ::= elementDefinition | scriptBlock | explicitRelationship | implicitRelationship | identifierReferences

private elementDefinition ::= singleLineStatement | blockStatement | propertyBlockStatement | CRLF

Expand All @@ -123,6 +123,8 @@ scriptContents ::= SCRIPT_TEXT+
explicitRelationship ::= identifierName '->' identifierName argument*
implicitRelationship ::= '->' identifierName argument*

identifierReferences ::= identifierName+ lf_eof

private keywordWithArguments ::= keyword argument*

keyword ::= '!adrs' | 'animation' | 'autoLayout' | 'background' | 'border' | 'color' | 'colour' | 'component' |
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package nl.dirkgroot.structurizr.dsl.parser

import nl.dirkgroot.structurizr.dsl.support.StructurizrDSLParserTest
import org.junit.jupiter.api.Test

class LineWithIdentifierReferencesTest : StructurizrDSLParserTest() {
@Test
fun `single identifier reference on one line`() {
assertPsiTree(
"""
someIdentifier
""".trimIndent(),
"""
IdentifierReferences
IdentifierName someIdentifier
""".trimIndent()
)
}

@Test
fun `multiple identifier references on one line`() {
assertPsiTree(
"""
someIdentifier1 someIdentifier2
""".trimIndent(),
"""
IdentifierReferences
IdentifierName someIdentifier1
IdentifierName someIdentifier2
""".trimIndent()
)
}

@Test
fun `multiple lines with identifier references`() {
assertPsiTree(
"""
someIdentifier1 someIdentifier2
someIdentifier3
someIdentifier4
""".trimIndent(),
"""
IdentifierReferences
IdentifierName someIdentifier1
IdentifierName someIdentifier2
IdentifierReferences
IdentifierName someIdentifier3
IdentifierReferences
IdentifierName someIdentifier4
""".trimIndent()
)
}
}

0 comments on commit c01d377

Please sign in to comment.