README.md (1754B)
1 # stac 2 ------ 3 4 stac is a simple programming language which can be used to generate static, 5 but also dynamic content - it reads a file with embedded C code onto input 6 and writes out compilable C code to output. Finally good alternative to PHP, 7 node.js and other bloatware! 8 9 Slightly inspired by node.c created by Tsoding: 10 (https://github.com/tsoding/node.c). 11 12 ## Usage 13 -------- 14 Use `stac` script - just give input (.stac) file and you are ready to go! 15 you can also add optional arguments: 16 * `[-o OUTPUT]` - give an output file, without that option stac will 17 produce content to stdout 18 * `[-t TEMPLATE]` - template file; usable for building more advanced 19 websites 20 * `[-CC CC]` - compiler to use (by default gcc) 21 * `[-CFLAGS FLAGS]` - additional flags for the compiler 22 23 For example: 24 ``` 25 % ./stac in/index.stac 26 <prints compiled in/index.stac> 27 % ./stac -t templates/basic.stac in/index.stac 28 <prints compiled in/index.stac inside template templates/basic.stac> 29 ``` 30 31 You can also use a `compile` script to just generate C code - syntax is 32 just like in `stac` script, but without `[-CFLAGS]` and `[-CC]` options. 33 34 ## Introduction 35 --------------- 36 stac code is just data. In that data you can embed C code - you must 37 surround it by percent signs. Example: 38 ``` 39 <html> 40 <body> 41 <p>% echo("Welcome from C-mode!"); %</p> 42 </body> 43 </html> 44 ``` 45 46 You can also embed plain data inside C code - of course, just by 47 surrounding the data by percent signs - for example write: 48 ``` 49 <html> 50 <body> 51 % for (int i = 0; i < 32; ++i) { 52 % Hello from <b>data-mode</b>! % 53 } % 54 </body> 55 </html> 56 ``` 57 and you have loop which will produce data 32 times! Awesome! 58 59 Technically, the data-mode chunk is statement, more precisely - 60 `write()` function, so it will print text to a file.