mirror of
https://github.com/chancehudson/circom-stark.git
synced 2026-01-10 06:17:54 -05:00
refactor: use ; as comment token
This commit is contained in:
@@ -6,7 +6,7 @@ A lightweight turing-incomplete assembly language for STARK proofs. Designed to
|
||||
|
||||
Each line of a circuitvm `asm` file should contain an opcode, followed by registers to operate on. Each argument should be separated by exactly 1 space. Numbers may be prefixed by `0x` for hex, or written normally for decimal.
|
||||
|
||||
Lines starting with `#` or containing only whitespace are ignored.
|
||||
Lines starting with `;` or containing only whitespace are ignored.
|
||||
|
||||
## Opcodes
|
||||
|
||||
|
||||
@@ -104,14 +104,15 @@ export function compile(asm) {
|
||||
const steps = asm
|
||||
.split('\n')
|
||||
.filter(line => {
|
||||
if (line.startsWith('#')) return false
|
||||
if (line.trim().startsWith(';')) return false
|
||||
if (line.trim().length === 0) return false
|
||||
return true
|
||||
})
|
||||
.map(line => line.trim())
|
||||
.map(line => line.split(' '))
|
||||
.map((operation, i) => {
|
||||
const [ op, ...args ] = operation
|
||||
const commentIndex = operation.indexOf(';')
|
||||
const [ op, ...args ] = commentIndex >= 0 ? operation.slice(0, commentIndex) : operation
|
||||
if (!validOperations[op]) {
|
||||
throw new Error(`Invalid op "${op}"`)
|
||||
}
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
# a simple repeated squaring program
|
||||
; a simple repeated squaring program
|
||||
set 0x0 100
|
||||
# calculate 100^4
|
||||
; calculate 100^4
|
||||
mul 0x1 0x0 0x0
|
||||
mul 0x1 0x0 0x1
|
||||
mul 0x1 0x0 0x1
|
||||
# make a public signal and assert its expected value
|
||||
; make a public signal and assert its expected value
|
||||
out 0x1 100000000
|
||||
# now calculate 200^4
|
||||
; now calculate 200^4
|
||||
set 0x0 200
|
||||
mul 0x1 0x0 0x0
|
||||
mul 0x1 0x0 0x1
|
||||
mul 0x1 0x0 0x1
|
||||
# and output
|
||||
; and output
|
||||
out 0x1 1600000000
|
||||
# registers can be reused after an output is marked
|
||||
; registers can be reused after an output is marked
|
||||
|
||||
Reference in New Issue
Block a user