aboutsummaryrefslogtreecommitdiff
path: root/core/io.nom
blob: d9dbdd3bf0f15f712390cc5d91c4d47834223556 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/usr/bin/env nomsu -V4.10.12.7
#
    This file contains basic input/output code
    
use "core/metaprogramming.nom"

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

(say %message) compiles to:
    lua> "\
        ..if \%message.type == "Text" then
            return LuaCode("print(", \(%message as lua expr), ");");
        else
            return LuaCode("print(tostring(", \(%message as lua expr), "));");
        end"

(ask %prompt) compiles to:
    lua> "\
        ..if \%prompt.type == "Text" then
            return LuaCode("(io.write(", \(%prompt as lua expr), ") and io.read())");
        else
            return LuaCode("(io.write(tostring(", \(%prompt as lua expr), ")) and io.read())");
        end"