Remove expr/stmt (#5857)

This commit is contained in:
Arne Döring 2017-07-25 09:28:23 +02:00 • committed by Andreas Rumpf
commit 000b8afd26
168 changed files with 497 additions and 529 deletions

View file

@ -10,10 +10,10 @@ var
cpp {.compileTime.} = ""
token {.compileTime.} = ""
proc log (msg: string) {.compileTime.} =
proc log(msg: string) {.compileTime.} =
echo msg
proc asmx64 () {.compileTime} =
proc asmx64() {.compileTime} =
#log "code = $1" % code
@ -36,7 +36,7 @@ proc asmx64 () {.compileTime} =
const end_or_symbol_or_comment_or_passthrough = symbolStart + end_or_comment + passthrough_start
proc abortAsmParse (err:string) =
proc abortAsmParse(err:string) =
discard
let codeLen = code.len
@ -49,17 +49,17 @@ proc asmx64 () {.compileTime} =
var state:asmParseState = leading
proc checkEnd (err:string) =
let ch = code [start]
if int (ch) == 0:
abortAsmParse (err)
proc checkEnd(err:string) =
let ch = code[start]
if int(ch) == 0:
abortAsmParse(err)
proc get_passthrough () =
proc get_passthrough() =
inc start
let prev_start = start
let prev_token = token
start += code.parseUntil (token, passthrough_end, start)
checkEnd ("Failed to find passthrough end delimiter from offset $1 for:$2\n$3" % [$prev_start, $(code [prev_start-prev_token.len..prev_start]), token[1..token.len-1]])
start += code.parseUntil(token, passthrough_end, start)
checkEnd("Failed to find passthrough end delimiter from offset $1 for:$2\n$3" % [$prev_start, $(code[prev_start-prev_token.len..prev_start]), token[1..token.len-1]])
inc start
cpp.add "`"
cpp.add token
@ -67,27 +67,27 @@ proc asmx64 () {.compileTime} =
var inparse = true
proc checkCmdEnd () =
proc checkCmdEnd() =
if codeLen == start:
state = endCmd
inparse = false
while inparse:
checkCmdEnd ()
checkCmdEnd()
log ("state=$1 start=$2" % [$state, $start])
log("state=$1 start=$2" % [$state, $start])
case state:
of leading:
echo "b100 ", start
start += code.skipWhile (leadingWhiteSpace, start)
start += code.skipWhile(leadingWhiteSpace, start)
echo "b200 ", start
let ch = code [start]
let ch = code[start]
if ch in endOfLine:
inc (line)
inc(line)
#echo "c100 ", start, ' ', code
start += code.skipWhile (endOfline, start)
start += code.skipWhile(endOfline, start)
#echo "c200 ", start, ' ', code
continue
elif ch in symbolStart:
@ -95,20 +95,20 @@ proc asmx64 () {.compileTime} =
elif ch in eolComment:
state = skipToEndOfLine
elif ch in passthrough_start:
get_passthrough ()
get_passthrough()
echo "d100 ", start
start += code.parseUntil (token, end_or_symbol_or_comment_or_passthrough, start)
start += code.parseUntil(token, end_or_symbol_or_comment_or_passthrough, start)
echo "d200 ", start
cpp.add token
state = mnemonic
elif int (ch) == 0:
elif int(ch) == 0:
break
else:
abortAsmParse ("after '$3' illegal character at offset $1: $2" % [$start, $(int (ch)), token])
abortAsmParse("after '$3' illegal character at offset $1: $2" % [$start, $(int(ch)), token])
of mnemonic:
echo "e100 ", start
start += code.parseWhile (token, symbol, start)
start += code.parseWhile(token, symbol, start)
echo "e200 ", start
cpp.add xp
cpp.add token
@ -118,29 +118,29 @@ proc asmx64 () {.compileTime} =
of betweenArguments:
let tmp = start
let rcode = code
start += rcode.parseUntil (token, end_or_symbol_or_comment_or_passthrough, tmp)
start += rcode.parseUntil(token, end_or_symbol_or_comment_or_passthrough, tmp)
cpp.add token
if codeLen <= start:
state = endCmd
continue
let ch = code [start]
let ch = code[start]
if ch in passthrough_start:
get_passthrough ()
get_passthrough()
continue
if (ch in {'x', 'X'}) and ('0' == code [start-1]):
token = $(code [start])
if(ch in {'x', 'X'}) and('0' == code[start-1]):
token = $(code[start])
cpp.add token
inc start
continue
state = arguments
of arguments:
if code [start] in end_or_comment:
if code[start] in end_or_comment:
state = endCmd
continue
start += code.parseWhile (token, symbol, start)
start += code.parseWhile(token, symbol, start)
cpp.add xp
cpp.add token
state = betweenArguments
@ -151,21 +151,21 @@ proc asmx64 () {.compileTime} =
of skipToEndOfLine:
echo "a100 ", start
start += code.skipUntil (endOfLine, start)
start += code.skipUntil(endOfLine, start)
echo "a200 ", start
start += code.skipWhile (endOfline, start)
start += code.skipWhile(endOfline, start)
echo "a300 ", start
inc line
state = leading
cpp.add asmx64post
echo ($cpp)
echo($cpp)
macro asmx64x (code_in:expr) : stmt =
macro asmx64x(code_in:untyped) : typed =
code = $code_in
echo ("code.len = $1, code = >>>$2<<<" % [$code.len, code])
asmx64 ()
echo("code.len = $1, code = >>>$2<<<" % [$code.len, code])
asmx64()
discard result
asmx64x """