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

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

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

(say %message inline) compiles to:
    lua> "\
        ..if \%message.type == "Text" then
            return LuaCode("io.write(", \(%message as lua expr), ")");
        else
            return LuaCode("io.write(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"