| 1 |
# This file should expose all possible meson syntaxes |
| 2 |
# and ensure the AstInterpreter and RawPrinter are able |
| 3 |
|
| 4 |
# to parse and write a file identical to the original. |
| 5 |
|
| 6 |
project ( # project comment 1 |
| 7 |
# project comment 2 |
| 8 |
'rewrite' , # argument comment |
| 9 |
# project comment 3 |
| 10 |
'cpp', |
| 11 |
'c', |
| 12 |
default_options: [ |
| 13 |
'unity=on', |
| 14 |
'unity_size=50', # number of cpp / unity. default is 4... |
| 15 |
'warning_level=2', # eqv to /W3 |
| 16 |
'werror=true', # treat warnings as errors |
| 17 |
'b_ndebug=if-release', # disable assert in Release |
| 18 |
'cpp_eh=a', # /EHa exception handling |
| 19 |
'cpp_std=c++17', |
| 20 |
'cpp_winlibs=' + ','.join([ # array comment |
| 21 |
# in array |
| 22 |
# comment |
| 23 |
'kernel32.lib', |
| 24 |
'user32.lib', |
| 25 |
'gdi32.lib', |
| 26 |
'winspool.lib', |
| 27 |
'comdlg32.lib', |
| 28 |
'advapi32.lib', |
| 29 |
'shell32.lib' |
| 30 |
# before comma comment |
| 31 |
, |
| 32 |
# after comma comment |
| 33 |
'ole32.lib', |
| 34 |
'oleaut32.lib', |
| 35 |
'uuid.lib', |
| 36 |
'odbc32.lib', |
| 37 |
'odbccp32.lib', |
| 38 |
'Delayimp.lib', # For delay loaded dll |
| 39 |
'OLDNAMES.lib', |
| 40 |
'dbghelp.lib', |
| 41 |
'psapi.lib', |
| 42 |
]), |
| 43 |
], |
| 44 |
meson_version: '>=1.2', |
| 45 |
version: '1.0.0', |
| 46 |
) # project comment 4 |
| 47 |
|
| 48 |
cppcoro_dep = dependency('andreasbuhr-cppcoro-cppcoro') |
| 49 |
cppcoro = declare_dependency( |
| 50 |
dependencies: [cppcoro_dep.partial_dependency( |
| 51 |
includes: true, |
| 52 |
link_args: true, |
| 53 |
links: true, |
| 54 |
sources: true, |
| 55 |
)], |
| 56 |
# '/await:strict' allows to use <coroutine> rather than <experimental/coroutine> with C++17. |
| 57 |
# We can remove '/await:strict' once we update to C++20. |
| 58 |
compile_args: ['/await:strict'], |
| 59 |
# includes:true doesn't work for now in partial_dependency() |
| 60 |
# This line could be removed once https://github.com/mesonbuild/meson/pull/10122 is released. |
| 61 |
include_directories: cppcoro_dep.get_variable('includedir1'), |
| 62 |
) |
| 63 |
|
| 64 |
|
| 65 |
cpp_compiler = meson.get_compiler('cpp') |
| 66 |
if get_option('unicode') #if comment |
| 67 |
#if comment 2 |
| 68 |
mfc=cpp_compiler.find_library(get_option('debug')?'mfc140ud':'mfc140u') |
| 69 |
# if comment 3 |
| 70 |
else#elsecommentnowhitespaces |
| 71 |
# else comment 1 |
| 72 |
mfc = cpp_compiler.find_library( get_option( 'debug' ) ? 'mfc140d' : 'mfc140') |
| 73 |
# else comment 2 |
| 74 |
endif #endif comment |
| 75 |
|
| 76 |
|
| 77 |
assert(1 in [1, 2], '''1 should be in [1, 2]''') |
| 78 |
assert(3 not in [1, 2], '''3 shouldn't be in [1, 2]''') |
| 79 |
assert(not (3 in [1, 2]), '''3 shouldn't be in [1, 2]''') |
| 80 |
|
| 81 |
assert('b' in ['a', 'b'], ''''b' should be in ['a', 'b']''') |
| 82 |
assert('c' not in ['a', 'b'], ''''c' shouldn't be in ['a', 'b']''') |
| 83 |
|
| 84 |
exe1 = 'exe1' |
| 85 |
exe2 = 'exe2' |
| 86 |
exe3 = 'exe3' |
| 87 |
|
| 88 |
assert(exe1 in [exe1, exe2], ''''exe1 should be in [exe1, exe2]''') |
| 89 |
assert(exe3 not in [exe1, exe2], ''''exe3 shouldn't be in [exe1, exe2]''') |
| 90 |
|
| 91 |
assert('a' in {'a': 'b'}, '''1 should be in {'a': 'b'}''') |
| 92 |
assert('b'not in{'a':'b'}, '''1 should be in {'a': 'b'}''') |
| 93 |
|
| 94 |
assert('a'in'abc') |
| 95 |
assert('b' not in 'def') |
| 96 |
|
| 97 |
|
| 98 |
w = 'world' |
| 99 |
d = {'a': 1, 'b': 0b10101010, 'c': 'pi', 'd': '''a |
| 100 |
b |
| 101 |
c''', 'e': f'hello @w@', 'f': f'''triple |
| 102 |
formatted |
| 103 |
string # this is not a comment |
| 104 |
hello @w@ |
| 105 |
''', 'g': [1, 2, 3], |
| 106 |
|
| 107 |
'h' # comment a |
| 108 |
: # comment b |
| 109 |
0xDEADBEEF # comment c |
| 110 |
, # comment d |
| 111 |
'hh': 0xfeedc0de, # lowercase hexa |
| 112 |
'hhh': 0XaBcD0123, # mixed case hexa |
| 113 |
'oo': 0O123456, # upper O octa |
| 114 |
'bb': 0B1111, # upper B binary |
| 115 |
'i': {'aa': 11, # this is a comment |
| 116 |
'bb': 22}, # a comment inside a dict |
| 117 |
'o': 0o754, |
| 118 |
'm': -12, # minus number |
| 119 |
'eq': 1 + 3 - 3 % 4 + -( 7 * 8 ), |
| 120 |
} # end of dict comment |
| 121 |
|
| 122 |
hw = d['e'] |
| 123 |
one = d['g'][0] |
| 124 |
w += '!' |
| 125 |
|
| 126 |
|
| 127 |
components = { |
| 128 |
'foo': ['foo.c'], |
| 129 |
'bar': ['bar.c'], |
| 130 |
'baz': ['baz.c'], # this line is indented with a tab! |
| 131 |
} |
| 132 |
|
| 133 |
# compute a configuration based on system dependencies, custom logic |
| 134 |
conf = configuration_data() |
| 135 |
conf.set('USE_FOO', 1) |
| 136 |
|
| 137 |
# Determine the sources to compile |
| 138 |
sources_to_compile = [] |
| 139 |
foreach name, sources : components |
| 140 |
if conf.get('USE_@0@'.format(name.to_upper()), 0) == 1 |
| 141 |
sources_to_compile += sources |
| 142 |
endif |
| 143 |
endforeach |
| 144 |
|
| 145 |
|
| 146 |
items = ['a', 'continue', 'b', 'break', 'c'] |
| 147 |
result = [] |
| 148 |
foreach i : items |
| 149 |
if i == 'continue' |
| 150 |
continue |
| 151 |
elif i == 'break' |
| 152 |
break |
| 153 |
endif |
| 154 |
result += i |
| 155 |
endforeach |
| 156 |
# result is ['a', 'b'] |
| 157 |
|
| 158 |
|
| 159 |
|
| 160 |
if a and b |
| 161 |
# do something |
| 162 |
endif |
| 163 |
if c or d |
| 164 |
# do something |
| 165 |
endif |
| 166 |
if not e |
| 167 |
# do something |
| 168 |
endif |
| 169 |
if not (f or g) |
| 170 |
# do something |
| 171 |
endif |
| 172 |
|
| 173 |
single_quote = 'contains a \' character' |
| 174 |
string_escapes = '\\\'\a\b\f\n\r\t\v\046\x26\u2D4d\U00002d4d\N{GREEK CAPITAL LETTER DELTA}' |
| 175 |
no_string_escapes = '''\\\'\a\b\f\n\r\t\v\046\x26\u2D4d\U00002d4d\N{GREEK CAPITAL LETTER DELTA}''' |
| 176 |
|
| 177 |
# FIXME: is it supposed to work? (cont_eol inside string) |
| 178 |
# cont_string = 'blablabla\ |
| 179 |
# blablabla' |
| 180 |
|
| 181 |
# cont_eol with whitespace and comments after |
| 182 |
if a \ # comment in cont 1 |
| 183 |
and b \ # comment in cont 2 |
| 184 |
or c # comment in cont 3 |
| 185 |
message('ok') |
| 186 |
endif |
| 187 |
|
| 188 |
if a \ |
| 189 |
or b |
| 190 |
debug('help!') |
| 191 |
endif |
| 192 |
|
| 193 |
if false |
| 194 |
# Should produce a warning, but should not crash |
| 195 |
foo = not_defined |
| 196 |
message(not_defined) |
| 197 |
endif |
| 198 |
|
| 199 |
|
| 200 |
# End of file comment with no linebreak |