mirror of
https://github.com/NixOS/nix.git
synced 2025-11-20 17:29:36 +01:00
* Basic grammar and parser for the Fix language. We use libsglr and
friends to do the parsing. The parse table is embedded in the Fix executable using bin2c, which converts an arbitrary file into a C character array.
This commit is contained in:
parent
4d728f6a36
commit
b95a3dc45b
6 changed files with 298 additions and 7 deletions
23
src/fix-ng/bin2c.c
Normal file
23
src/fix-ng/bin2c.c
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
void print(const char *format, ...)
|
||||
{
|
||||
va_list ap;
|
||||
va_start(ap, format);
|
||||
if (vprintf(format, ap) < 0) abort();
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
int main(int argc, char * * argv)
|
||||
{
|
||||
int c;
|
||||
if (argc != 2) abort();
|
||||
print("static unsigned char %s[] = {", argv[1]);
|
||||
while ((c = getchar()) != EOF) {
|
||||
print("0x%02x, ", (unsigned char) c);
|
||||
}
|
||||
print("};\n");
|
||||
return 0;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue