Compare commits
3 Commits
31d2f7336b
...
d3066748b2
| Author | SHA1 | Date | |
|---|---|---|---|
| d3066748b2 | |||
| f17b2c1087 | |||
| fa71f23bbf |
21
compile.phi
21
compile.phi
@ -1,10 +1,4 @@
|
||||
|
||||
(fn dbg (msg) (do
|
||||
(if is_phi_compiler (do
|
||||
(call println "dbg: %" msg)
|
||||
))
|
||||
))
|
||||
|
||||
(fn Emitter (ast filename) (do
|
||||
(let output ())
|
||||
|
||||
@ -41,12 +35,6 @@
|
||||
(call define_builtin ident builtin_id)
|
||||
))
|
||||
|
||||
(let is_phi_compiler_sym_id (call define_let "is_phi_compiler" 0))
|
||||
(call emit (call format
|
||||
"let _is_phi_compiler% = { type: \"bool\", value: true };\n"
|
||||
is_phi_compiler_sym_id
|
||||
))
|
||||
|
||||
(call discover_syms ast)
|
||||
(call emit_exprs ast)
|
||||
(return (call strings_join output))
|
||||
@ -99,7 +87,6 @@
|
||||
|
||||
(let sym (call get_sym value))
|
||||
(if (== sym null) (do
|
||||
(call print_syms)
|
||||
(call panic "undefined symbol '%' on line %" value line)
|
||||
))
|
||||
|
||||
@ -242,6 +229,8 @@
|
||||
))
|
||||
|
||||
(call emit "))")
|
||||
) (if (== id "list") (do
|
||||
(call emit_list_literal (call slice s 1))
|
||||
) (if (== id "=") (do
|
||||
(call emit_assign_expr s line "=")
|
||||
) (if (== id "+=") (do
|
||||
@ -287,7 +276,7 @@
|
||||
(call emit ")")
|
||||
) (do
|
||||
(call emit_list_literal s)
|
||||
))))))))))))))))))))))))
|
||||
)))))))))))))))))))))))))
|
||||
))
|
||||
|
||||
(fn emit_list_literal (s) (do
|
||||
@ -805,8 +794,8 @@
|
||||
(let (emit) emitter)
|
||||
(let js_code (call emit))
|
||||
|
||||
// (call println "=== js ===")
|
||||
// (call println js_code)
|
||||
(call println "=== js ===")
|
||||
(call println js_code)
|
||||
|
||||
(if (not silent) (call println "writing file '%'..." output_filename))
|
||||
(call write_text_file output_filename js_code)
|
||||
|
||||
@ -1,7 +0,0 @@
|
||||
(fn hello () (do
|
||||
(call println "hello world")
|
||||
(call println "hello world")
|
||||
(return null)
|
||||
))
|
||||
|
||||
(call hello)
|
||||
Loading…
x
Reference in New Issue
Block a user