Skip to content

Improve C litmus grammar #887

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 16, 2025
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
4 changes: 2 additions & 2 deletions dartagnan/src/main/antlr4/C11Lexer.g4
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ C11AtomicStore : 'atomic_store';
C11AtomicXchgExplicit : 'atomic_exchange_explicit';
C11AtomicXchg : 'atomic_exchange';
C11AtomicSCASExplicit : 'atomic_compare_exchange_strong_explicit';
C11AtomicSCAS : 'atomic_compare_exchange_strong';
C11AtomicSCAS : 'atomic_compare_exchange_strong' | 'SCAS';
C11AtomicWCASExplicit : 'atomic_compare_exchange_weak_explicit';
C11AtomicWCAS : 'atomic_compare_exchange_weak';
C11AtomicWCAS : 'atomic_compare_exchange_weak' | 'WCAS';
C11AtomicFence : 'atomic_thread_fence';
C11AtomicAddExplicit : 'atomic_fetch_add_explicit';
C11AtomicAdd : 'atomic_fetch_add';
Expand Down
5 changes: 4 additions & 1 deletion dartagnan/src/main/antlr4/LitmusC.g4
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ main
;

variableDeclaratorList
: LBrace (globalDeclarator Semi comment?)* RBrace (Semi)?
: LBrace (globalDeclarator Semi comment?)* (globalDeclarator comment?)? RBrace Semi?
;

globalDeclarator
Expand Down Expand Up @@ -193,6 +193,7 @@ nre locals [IntBinaryOp op, String mo, String name]
| C11AtomicStore LPar address = re Comma value = re RPar # nreC11Store

| Ast? varName Equals re # nreAssignment
| re # reAsNre
| typeSpecifier varName (Equals re)? # nreRegDeclaration

| SpinLock LPar address = re RPar # nreSpinLock
Expand Down Expand Up @@ -247,6 +248,8 @@ opCompare returns [IntCmpOp op]
opArith returns [IntBinaryOp op]
: Plus {$op = IntBinaryOp.ADD;}
| Minus {$op = IntBinaryOp.SUB;}
| Ast {$op = IntBinaryOp.MUL;}
| Slash {$op = IntBinaryOp.DIV;}
| Amp {$op = IntBinaryOp.AND;}
| Bar {$op = IntBinaryOp.OR;}
| Circ {$op = IntBinaryOp.XOR;}
Expand Down