Skip to content

Commit 836ff0e

Browse files
authored
Merge pull request #91 from dmarcotte/distinguish-open-close-delims
Fix trailing comment lexing issues
2 parents 979f22b + 8b70dde commit 836ff0e

File tree

14 files changed

+227
-186
lines changed

14 files changed

+227
-186
lines changed

src/commonMain/kotlin/org/kson/parser/ElementType.kt

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,24 +33,28 @@ enum class TokenType : ElementType {
3333
// lines starting with `#`
3434
COMMENT,
3535
/**
36-
* Either `%%` or `$$`, see [EMBED_DELIM_CHAR] and [EMBED_DELIM_ALT_CHAR]
36+
* Opening delimiter for an embed block, either `%%` or `$$`, see [EMBED_DELIM_CHAR] and [EMBED_DELIM_ALT_CHAR]
3737
*/
38-
EMBED_DELIM,
38+
EMBED_OPEN_DELIM,
3939
/**
40-
* A single `%` or `$` where an [EMBED_DELIM] should be. Used to give helpful errors to the user.
40+
* Closing delimiter for an embed block, matches the [EMBED_OPEN_DELIM] for the block it closes
41+
*/
42+
EMBED_CLOSE_DELIM,
43+
/**
44+
* A single `%` or `$` where an [EMBED_OPEN_DELIM] should be. Used to give helpful errors to the user.
4145
*/
4246
EMBED_DELIM_PARTIAL,
4347
/**
44-
* The line of text starting at an embed block's opening [EMBED_DELIM], "tagging" that embedded content
48+
* The line of text starting at an embed block's [EMBED_OPEN_DELIM], "tagging" that embedded content
4549
*/
4650
EMBED_TAG,
4751
/**
48-
* The newline that ends the "preamble" of an embed block (i.e. the [EMBED_DELIM] and possibly an [EMBED_TAG])
52+
* The newline that ends the "preamble" of an embed block (i.e. the [EMBED_OPEN_DELIM] and possibly an [EMBED_TAG])
4953
* [EMBED_CONTENT] begins on the line immediately after the [EMBED_PREAMBLE_NEWLINE]
5054
*/
5155
EMBED_PREAMBLE_NEWLINE,
5256
/**
53-
* The content of an [EMBED_DELIM] delimited embed block
57+
* The content of an [EMBED_OPEN_DELIM]/[EMBED_CLOSE_DELIM] delimited embed block
5458
*/
5559
EMBED_CONTENT,
5660
// false
@@ -73,10 +77,12 @@ enum class TokenType : ElementType {
7377
* A number, to be parsed by [NumberParser]
7478
*/
7579
NUMBER,
76-
// " or '
77-
STRING_QUOTE,
80+
// " or ' opening a string
81+
STRING_OPEN_QUOTE,
82+
// " or ' closing a string
83+
STRING_CLOSE_QUOTE,
7884
/**
79-
* A [STRING_QUOTE] delimited chunk of text, i.e. "This is a string"
85+
* A [STRING_OPEN_QUOTE]/[STRING_CLOSE_QUOTE] delimited chunk of text, i.e. "This is a string"
8086
*/
8187
STRING,
8288
/**

src/commonMain/kotlin/org/kson/parser/KsonBuilder.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,8 @@ class KsonBuilder(private val tokens: List<Token>) :
134134
COLON,
135135
COMMA,
136136
COMMENT,
137-
EMBED_DELIM,
137+
EMBED_OPEN_DELIM,
138+
EMBED_CLOSE_DELIM,
138139
EMBED_TAG,
139140
EMBED_CONTENT,
140141
ILLEGAL_CHAR,

0 commit comments

Comments
 (0)