aboutsummaryrefslogtreecommitdiff
path: root/examples/preprocessor.halk
blob: e755ca29c30dacd9849b3f1b0ec9a875cf6ec9ff (plain) (blame)
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
32
33
`
   Preprocessor directive types:
      
      #FOO#                Call a macro or function.
      #=BAR#               A string that can be stored by a macro. 

   #def# #ID# [#=VALUE#]   Set a macro.
   #fed# #ID#              Unset a macro.

   #dex# #ID?# ... #xed#   If macro ID is defined, expand to ... (Defined EXpand).
   #uex# #ID?# ... #xeu#   If macro ID is undefined, expand to ... (Undefined EXpand).

   #inc# #FILE#            Include a file; first searches cwd, then some kind of $HALKPATH.

   #ID#                    Call a macro.
`

` Example usage: `

` Simple header guard. `
#uex# #TEST#
#def# #TEST#

#inc# #io#
#inc# #packet.hlk#

#def# #VERSION# #= 3.14.1 #
#def# #ERR# #= {io!print."Error D:"; die;} #

:packet_t:p = packet!get;
?.(~=.p!version,#VERSION#),#ERR#;   ` Throw error if versions do not match. `

#xeu#