Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion changes/01-feature/1375-literal-arrays.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
- Byte arrays can occur as literal values as string constants (`"abcd"`) or as
a sequence of expressions (e.g., `{ 1, 2, 3 }`)
([PR 1375](https://github.com/jasmin-lang/jasmin/pull/1375)).
([PR 1375](https://github.com/jasmin-lang/jasmin/pull/1375),
[PR 1376](https://github.com/jasmin-lang/jasmin/pull/1376)).
2 changes: 1 addition & 1 deletion compiler/src/dune
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
(modules lexer))

(menhir
(flags "--table" "--explain" "--inspection")
(flags "--table" "--explain" "--inspection" "--strict")
(modules parser))

(rule
Expand Down
1 change: 1 addition & 0 deletions compiler/src/functionAnnotations.ml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ and pattri_to_simple_attribute (pattri: Syntax.psimple_attribute) : Annotations.
| PEVar id -> Aid (L.unloc id)
| PEInt ir -> Aint (Syntax.parse_int ir)
| PEOp1 (`Neg None, {L.pl_desc = PEInt ir}) -> Aint (Z.neg (Syntax.parse_int ir))
| PEstring s -> Astring s
| _ ->
hierror ~kind:"syntax" ~loc:(Lone (L.loc e))
"complex expressions not allowed in annotations"
Expand Down
30 changes: 17 additions & 13 deletions compiler/src/parser.mly
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,7 @@ annotationlabel:
| s=loc(STRING) { s }

simple_attribute:
| e=pexpr { PAexpr e}
| s=STRING { PAstring s }
| e=pexpr_noarr { PAexpr e}
| s=keyword { PAstring s }
| ws=utype { PAws (fst ws) }

Expand Down Expand Up @@ -267,7 +266,7 @@ arr_access:
let s = if s = None then Warray_.AAscale else Warray_.AAdirect in
s, i }

pexpr_r:
pexpr_noarr_r(parent):
| v=var
{ PEVar v }

Expand All @@ -286,34 +285,39 @@ pexpr_r:
| ma=mem_access
{ PEFetch ma }

| ct=parens(svsize) LBRACKET es=rtuple1(pexpr) RBRACKET
| ct=parens(svsize) LBRACKET es=rtuple1(parent) RBRACKET
{ PEpack(ct,es) }

| e = STRING { PEstring e }

| LBRACE es = rtuple1(pexpr) RBRACE { PEarray es }

| ct=parens(cast) e=pexpr %prec BANG
| ct=parens(cast) e=parent %prec BANG
{ PEOp1 (`Cast(ct), e) }

| o=peop1 e=pexpr
| o=peop1 e=parent
{ PEOp1 (o, e) }

| e1=pexpr o=peop2 e2=pexpr
| e1=parent o=peop2 e2=parent
{ PEOp2 (o, (e1, e2)) }

| e=parens(pexpr)
| e=parens(parent)
{ PEParens e }

| f=var args=parens_tuple(pexpr)
| f=var args=parens_tuple(parent)
{ PECall (f, args) }

| f=prim args=parens_tuple(pexpr)
| f=prim args=parens_tuple(parent)
{ PEPrim (f, args) }

| e1=pexpr QUESTIONMARK e2=pexpr COLON e3=pexpr
| e1=parent QUESTIONMARK e2=parent COLON e3=parent
{ PEIf(e1, e2, e3) }

pexpr_noarr:
| e=loc(pexpr_noarr_r(pexpr_noarr)) { e }

pexpr_r:
| e = pexpr_noarr_r(pexpr) { e }
| LBRACE es = rtuple1(pexpr) RBRACE { PEarray es }

pexpr:
| e=loc(pexpr_r) { e }

Expand Down
1 change: 1 addition & 0 deletions compiler/tests/exec/dune
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
vpsxldq.jazz ../success/x86-64/vpsxldq.jazz
sem_unit.jazz
../success/x86-64/test_global_string_literal.jazz
../success/common/literal-arrays.jazz
wide_rotation.jazz
)
(names
Expand Down
3 changes: 3 additions & 0 deletions compiler/tests/success/common/annotations.jazz
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,6 @@ multiline
annotation with tabs and \" special {| |} characters
"]
export fn noop() {}

#[array = {a, b}, struct = {y = 0, z}, other_struct = { p, q = 1}]
export fn dummy() {}