MOVE
This commit is contained in:
parent
c1593c551c
commit
85d5641e54
|
@ -0,0 +1 @@
|
||||||
|
// glsl?
|
|
@ -0,0 +1,48 @@
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <yaml.h>
|
||||||
|
|
||||||
|
int main(void) {
|
||||||
|
char yamlfile[2048] = {0};
|
||||||
|
printf("YAML file?");
|
||||||
|
scanf("%s", yamlfile);
|
||||||
|
FILE *fh = fopen(yamlfile, "r");
|
||||||
|
yaml_parser_t parser;
|
||||||
|
yaml_token_t token;
|
||||||
|
|
||||||
|
if (!yaml_parser_initialize(&parser)) {
|
||||||
|
fputs("Failed to initialize parser!\n", stderr);
|
||||||
|
}
|
||||||
|
if (fh == NULL) {
|
||||||
|
fputs("Failed to open file!\n", stderr);
|
||||||
|
}
|
||||||
|
|
||||||
|
yaml_parser_set_input_file(&parser, fh);
|
||||||
|
|
||||||
|
|
||||||
|
do {
|
||||||
|
yaml_parser_scan(&parser, &token);
|
||||||
|
switch(token.type) {
|
||||||
|
case YAML_KEY_TOKEN:
|
||||||
|
printf("Key: ");
|
||||||
|
break;
|
||||||
|
case YAML_VALUE_TOKEN:
|
||||||
|
printf("Value: ");
|
||||||
|
break;
|
||||||
|
case YAML_SCALAR_TOKEN:
|
||||||
|
printf("%s\n", token.data.scalar.value);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if(token.type != YAML_STREAM_END_TOKEN)
|
||||||
|
yaml_token_delete(&token);
|
||||||
|
} while(token.type != YAML_STREAM_END_TOKEN);
|
||||||
|
yaml_token_delete(&token);
|
||||||
|
|
||||||
|
|
||||||
|
yaml_parser_delete(&parser);
|
||||||
|
fclose(fh);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
|
@ -0,0 +1,2 @@
|
||||||
|
name: John Doe
|
||||||
|
age: 30
|
|
@ -0,0 +1,32 @@
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <lua.h>
|
||||||
|
#include <lualib.h>
|
||||||
|
#include <lauxlib.h>
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
int val = 5;
|
||||||
|
printf("Original value: %d\n", val);
|
||||||
|
|
||||||
|
lua_State *L = luaL_newstate();
|
||||||
|
luaL_openlibs(L);
|
||||||
|
|
||||||
|
|
||||||
|
if (luaL_dofile(L, "ex1.lua") != LUA_OK) {
|
||||||
|
fprintf(stderr, "Could not load script: %s\n", lua_tostring(L, -1));
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
lua_getglobal(L, "value");
|
||||||
|
if (lua_isnumber(L, -1)) {
|
||||||
|
val = (int)lua_tonumber(L, -1);
|
||||||
|
} else {
|
||||||
|
fprintf(stderr, "Expected a number\n");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("Modified value: %d\n", val);
|
||||||
|
|
||||||
|
lua_close(L);
|
||||||
|
return 0;
|
||||||
|
}
|
|
@ -0,0 +1 @@
|
||||||
|
value = 10
|
Loading…
Reference in New Issue