cambridge-asm 0.15.3

Run pseudoassembly from Cambridge International syllabus 9618
Documentation
// Copyright (c) 2021 Saadi Save
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.

address = { num+ }
label = @{ ( !":" ~ unicode )+ ~ ":" }
op = { alpha+ }
data = { num+ }
immediate = _{ "#" ~ ( num+ | ("b" | "B") ~ bin+ | ("x" | "X") ~ hex+ | ("o" | "O") ~ oct+ ) }
oper = @{ immediate | address | "r" ~ num{1, 2} | !"//" ~ !"#" ~ !"," ~ !"r" ~ unicode+ }
operand = @{ oper ~ ( "," ~ oper )* }

comment = _{ "//" ~ space* ~ ( unicode+ ~ space* )* ~ space* }

instruction = ${ (whitespace* ~ comment ~ whitespace*)* ~ ( address | label )? ~ space* ~ op ~ space* ~ operand? ~ space* ~ comment? ~ NEWLINE }
prog = ${ whitespace* ~ instruction+ ~ whitespace* }

memory_entry = ${ (comment ~ whitespace*)* ~ ( address | label ) ~ space* ~ data? ~ space* ~ comment? ~ NEWLINE }
memory = ${ whitespace* ~ memory_entry+ ~ whitespace* }

space = _{ " " | "\t" }
whitespace = _{ space | NEWLINE }
num = _{ ASCII_DIGIT }
alpha = _{ ASCII_ALPHA }
hex = _{ ASCII_HEX_DIGIT }
bin = _{ ASCII_BIN_DIGIT }
oct = _{ ASCII_OCT_DIGIT }
unicode = _{ !space ~ !NEWLINE ~ ANY }