Skip to content

Commit 2e6049e

Browse files
authored
Merge pull request #109 from EatChangmyeong/main
2 parents 0330484 + 52e91f2 commit 2e6049e

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

docs/src/structure/primitive_types.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,8 +219,7 @@ that multiple decimal values are allowed, and are delimited by spaces:
219219

220220
```par
221221
def Bytes1 = <<65 91>> // inferred as `Bytes`
222-
def Bytes2 = << >> // zero-byte sequence
223-
// def Bytes3 = <<>> // This triggers syntax error for now, but we intend to fix it
222+
def Bytes2 = <<>> // zero-byte sequence
224223
```
225224

226225
A `Bytes` can also be broken down to a list of `Byte`s:

src/par/parse.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -850,6 +850,18 @@ fn expr_literal_string(input: &mut Input) -> Result<Expression> {
850850
}
851851

852852
fn expr_literal_bytes(input: &mut Input) -> Result<Expression> {
853+
alt((expr_literal_bytes_empty, expr_literal_bytes_nonempty)).parse_next(input)
854+
}
855+
856+
fn expr_literal_bytes_empty(input: &mut Input) -> Result<Expression> {
857+
commit_after((t(TokenKind::Lt), t(TokenKind::Link)), t(TokenKind::Gt))
858+
.map(|((pre, _), post)| {
859+
Expression::Primitive(pre.span.join(post.span()), Primitive::Bytes(Bytes::new()))
860+
})
861+
.parse_next(input)
862+
}
863+
864+
fn expr_literal_bytes_nonempty(input: &mut Input) -> Result<Expression> {
853865
commit_after(
854866
(t(TokenKind::Lt), t(TokenKind::Lt)),
855867
(literal_bytes_inner, t(TokenKind::Gt), t(TokenKind::Gt)),

0 commit comments

Comments
 (0)