feat(lang): numbers float - a module whose decimal literals are float
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
e6f565a6c4
commit
3ac0d8d5cb
5 changed files with 36 additions and 0 deletions
|
|
@ -11,6 +11,18 @@ var g_game_name: pointer # the `program` name
|
|||
# build tools parse. While parsing, the location is the current token's; while
|
||||
# lowering, it is the statement being emitted (emit_stmt records it).
|
||||
var g_parse_file: pointer = "" # the file whose tokens are being parsed
|
||||
# `numbers float`: files whose bare decimal literals are float, not fixed. A file that says
|
||||
# so is listed, and so is every non-runtime file it imports (a barrel passes it on).
|
||||
var g_float_files: []pointer = new []pointer
|
||||
function is_float_file(f: pointer) -> bool {
|
||||
if (f == null) { return false }
|
||||
var i = 0
|
||||
while i < len(g_float_files) {
|
||||
if (g_float_files[i] == f) { return true }
|
||||
i += 1
|
||||
}
|
||||
return false
|
||||
}
|
||||
var g_parsing: bool = true # false once lowering starts
|
||||
var g_err_file: pointer = "" # the statement being lowered
|
||||
var g_err_line: int = 0
|
||||
|
|
@ -816,6 +828,11 @@ function parse_one_decl() -> void {
|
|||
}
|
||||
skipnl()
|
||||
}
|
||||
if is_id("numbers") and (toks[pi + 1].text == "float") {
|
||||
pi += 2
|
||||
if not is_float_file(g_parse_file) { push(g_float_files, g_parse_file) }
|
||||
return
|
||||
}
|
||||
if is_id("import") { pi += 1
|
||||
let t = toks[pi]
|
||||
if t.kind != TK_STR { perr("expected \"path\" after import") }
|
||||
|
|
@ -1004,6 +1021,7 @@ function do_import(rel: pointer) -> void {
|
|||
}
|
||||
if already_loaded(full) { return }
|
||||
push(loaded_paths, full)
|
||||
if is_float_file(g_parse_file) and not is_runtime_path(rel) and not is_float_file(full) { push(g_float_files, full) }
|
||||
if (src == null) { perr(`cannot open import {full}`) }
|
||||
# the audio runtime can arrive through atlas.ludic's own import or the Assets
|
||||
# splice, not only through an Audio.* call in the game; a windowed build must
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue