aboutsummaryrefslogtreecommitdiff
path: root/src/parser.cpp
diff options
context:
space:
mode:
authorAndrew Kelley <superjoe30@gmail.com>2017-02-04 22:33:58 -0500
committerAndrew Kelley <superjoe30@gmail.com>2017-02-04 22:33:58 -0500
commit64a0510205b4d224413de52fd87632fbe6bfe083 (patch)
treec673e98af23f82d939ec0513bfbf8f757704a9a6 /src/parser.cpp
parentb840184bb09b9d5e4272f848dcaa7c4973dfdcd5 (diff)
downloadzig-64a0510205b4d224413de52fd87632fbe6bfe083.tar.gz
zig-64a0510205b4d224413de52fd87632fbe6bfe083.zip
inline assembly supports `%=` syntax
it outputs a number that is unique to each instance of the asm statement in the entire compilation. useful when creating local labels and referring to them multiple times in a single template that generates multiple assembler instructions
Diffstat (limited to 'src/parser.cpp')
-rw-r--r--src/parser.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/parser.cpp b/src/parser.cpp
index aa0d7ddff3..68ccd6aff4 100644
--- a/src/parser.cpp
+++ b/src/parser.cpp
@@ -136,6 +136,10 @@ static void parse_asm_template(ParseContext *pc, AstNode *node) {
} else if (c == '[') {
cur_tok->id = AsmTokenIdVar;
state = StateVar;
+ } else if (c == '=') {
+ cur_tok->id = AsmTokenIdUniqueId;
+ cur_tok->end = i;
+ state = StateStart;
} else {
ast_asm_error(pc, node, i, "expected a '%%' or '['");
}