Skip to content

Commit fd3d3f2

Browse files
committed
Continueing to implement the parser
1 parent f5c845b commit fd3d3f2

File tree

9 files changed

+421
-47
lines changed

9 files changed

+421
-47
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
build

.vscode/launch.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
// Use IntelliSense to learn about possible attributes.
3+
// Hover to view descriptions of existing attributes.
4+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5+
"version": "0.2.0",
6+
"configurations": [
7+
{
8+
"name": "(Windows) Launch",
9+
"type": "cppvsdbg",
10+
"request": "launch",
11+
"program": "${workspaceFolder}/build/Examples/Sandbox/Debug/Sandbox.exe",
12+
"args": [],
13+
"stopAtEntry": false,
14+
"cwd": "${fileDirname}",
15+
"environment": [],
16+
"console": "externalTerminal"
17+
}
18+
19+
]
20+
}

.vscode/tasks.json

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"tasks": [
3+
{
4+
"type": "cppbuild",
5+
"label": "C/C++: cl.exe build active file",
6+
"command": "cl.exe",
7+
"args": [
8+
"/Zi",
9+
"/EHsc",
10+
"/nologo",
11+
"/Fe${fileDirname}\\${fileBasenameNoExtension}.exe",
12+
"${file}"
13+
],
14+
"options": {
15+
"cwd": "${fileDirname}"
16+
},
17+
"problemMatcher": [
18+
"$msCompile"
19+
],
20+
"group": {
21+
"kind": "build",
22+
"isDefault": true
23+
},
24+
"detail": "Task generated by Debugger."
25+
}
26+
],
27+
"version": "2.0.0"
28+
}

CMakeLists.txt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
cmake_minimum_required(VERSION 3.12)
2+
project(noodlec)
3+
4+
option(NOODLEC_EXAMPLES "Enables building of examples" ON)
5+
6+
add_library(noodlec STATIC "Source/noodle.c")
7+
target_include_directories(noodlec PUBLIC "Include")
8+
9+
10+
if (NOODLEC_EXAMPLES)
11+
add_subdirectory("Examples")
12+
endif()

Examples/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
add_subdirectory("Sandbox")

Examples/Sandbox/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
add_executable(Sandbox "main.c")
2+
target_link_libraries(Sandbox noodlec)

Examples/Sandbox/main.c

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
2+
#include "noodle.h"
3+
4+
const char* pContent =
5+
"audio = { \
6+
weapons = [ \"sword\", \"bow\", \"staff\" ], \
7+
music = { \
8+
enabled = true, \
9+
volume = 0.400000, \
10+
} \
11+
soundEffects = { \
12+
enabled = true, \
13+
volume = 0.600000, \
14+
} \
15+
volume = 0.800000, \
16+
} \
17+
player = { \
18+
inventory = { \
19+
potions = { \
20+
health = 5, \
21+
mana = 3, \
22+
} \
23+
} \
24+
level = 10, \
25+
name = \"John Doe\", \
26+
} \
27+
render = { \
28+
physicalDevice = 2, \
29+
resolution = { \
30+
height = 1080, \
31+
width = 1920, \
32+
} \
33+
shadowsEnabled = true, \
34+
textureQuality = \"high\", \
35+
} \
36+
window = { \
37+
fullscreen = true, \
38+
height = 1600, \
39+
monitor = 1, \
40+
someValue = [ 20, 40, 60, 80 ], \
41+
title = \"My Game Window\", \
42+
width = 1580, \
43+
}";
44+
45+
int main(int argc, const char* argv[])
46+
{
47+
char pErrorBuffer[256] = {0};
48+
49+
noodleParse(pContent, pErrorBuffer, sizeof(pErrorBuffer) / sizeof(pErrorBuffer[0]));
50+
51+
}

Include/noodle.h

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,7 @@
11
#ifndef NOODLE_PARSER_H
22
#define NOODLE_PARSER_H
33

4-
#ifndef NOODLE_NO_STDINT
5-
# include <stdint.h>
6-
#endif
7-
8-
#ifndef NOODLE_SIZE
9-
#define NOODLE_SIZE size_t
10-
#endif
4+
#include <stdint.h>
115

126
#ifndef NOODLE_NO_STDBOOL_H
137
#include <stdbool.h>
@@ -28,7 +22,7 @@
2822
#include <stdlib.h>
2923

3024
#ifndef NOODLE_MALLOC
31-
#define NOODLE_CALLOC(count, type) calloc(count, sizeof(type))
25+
#define NOODLE_MALLOC(size) malloc(size)
3226
#endif
3327
#ifndef NOODLE_FREE
3428
#define NOODLE_FREE(ptr) free(ptr)
@@ -63,10 +57,11 @@ typedef enum NoodleType_t
6357

6458
typedef struct Noodle_t Noodle_t;
6559
typedef struct NoodleGroup_t NoodleGroup_t;
66-
typedef struct NoodleValue_t NoodleValue_t;
6760
typedef struct NoodleArray_t NoodleArray_t;
61+
typedef struct NoodleValue_t NoodleValue_t;
6862

69-
NoodleGroup_t* noodleParse(const char* pContent, size_t contentSize, char* pErrorBuffer, size_t bufferSize);
63+
NoodleGroup_t* noodleParse(const char* pContent, char* pErrorBuffer, size_t bufferSize);
64+
NoodleGroup_t* noodleParseFromFile(const char* pPath, char* pErrorBuffer, size_t bufferSize);
7065
NoodleGroup_t* noodleGroupFrom(const NoodleGroup_t* group, const char* name);
7166
int noodleIntFrom(const NoodleGroup_t* group, const char* name);
7267
float noodleFloatFrom(const NoodleGroup_t* group, const char* name);

0 commit comments

Comments
 (0)