Skip to content

Commit f5c845b

Browse files
committed
Begin implementation, backup
1 parent cee8f80 commit f5c845b

File tree

4 files changed

+541
-0
lines changed

4 files changed

+541
-0
lines changed

.vscode/settings.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"files.associations": {
3+
"*.nwdl": "properties",
4+
"string.h": "c"
5+
}
6+
}

Include/noodle.h

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
#ifndef NOODLE_PARSER_H
2+
#define NOODLE_PARSER_H
3+
4+
#ifndef NOODLE_NO_STDINT
5+
# include <stdint.h>
6+
#endif
7+
8+
#ifndef NOODLE_SIZE
9+
#define NOODLE_SIZE size_t
10+
#endif
11+
12+
#ifndef NOODLE_NO_STDBOOL_H
13+
#include <stdbool.h>
14+
15+
#ifndef NOODLE_BOOL
16+
#define NOODLE_BOOL bool
17+
#endif
18+
19+
#ifndef NOODLE_TRUE
20+
#define NOODLE_TRUE true
21+
#endif
22+
#ifndef NOODLE_FALSE
23+
#define NOODLE_FALSE false
24+
#endif
25+
#endif
26+
27+
#ifndef NOODLE_NO_STDLIB_H
28+
#include <stdlib.h>
29+
30+
#ifndef NOODLE_MALLOC
31+
#define NOODLE_CALLOC(count, type) calloc(count, sizeof(type))
32+
#endif
33+
#ifndef NOODLE_FREE
34+
#define NOODLE_FREE(ptr) free(ptr)
35+
#endif
36+
37+
#ifndef NOODLE_MEMCPY
38+
#define NOODLE_MEMCPY(dest, src, size) memcpy(dest, src, size)
39+
#endif
40+
#endif
41+
42+
#ifndef NOODLE_NO_STRING_H
43+
#include <string.h>
44+
#endif
45+
46+
47+
typedef enum NoodleResult_t
48+
{
49+
NOODLE_SUCCESS,
50+
NOODLE_MEMORY_ALLOC_ERROR,
51+
NOODLE_UNEXPECTED_TOKEN_ERROR,
52+
} NoodleResult_t;
53+
54+
typedef enum NoodleType_t
55+
{
56+
NOODLE_TYPE_GROUP,
57+
NOODLE_TYPE_ARRAY,
58+
NOODLE_TYPE_INTEGER,
59+
NOODLE_TYPE_FLOAT,
60+
NOODLE_TYPE_BOOLEAN,
61+
NOODLE_TYPE_STRING,
62+
} NoodleType_t;
63+
64+
typedef struct Noodle_t Noodle_t;
65+
typedef struct NoodleGroup_t NoodleGroup_t;
66+
typedef struct NoodleValue_t NoodleValue_t;
67+
typedef struct NoodleArray_t NoodleArray_t;
68+
69+
NoodleGroup_t* noodleParse(const char* pContent, size_t contentSize, char* pErrorBuffer, size_t bufferSize);
70+
NoodleGroup_t* noodleGroupFrom(const NoodleGroup_t* group, const char* name);
71+
int noodleIntFrom(const NoodleGroup_t* group, const char* name);
72+
float noodleFloatFrom(const NoodleGroup_t* group, const char* name);
73+
NOODLE_BOOL noodleBoolFrom(const NoodleGroup_t* group, const char* name);
74+
const char* noodleStringFrom(const NoodleGroup_t* group, const char* name);
75+
const NoodleArray_t* noodleArrayFrom(const NoodleGroup_t* group, const char* name);
76+
size_t noodleCount(const Noodle_t* noodle);
77+
int noodleIntAt(const NoodleArray_t* array, size_t index);
78+
float noodleFloatAt(const NoodleArray_t* array, size_t index);
79+
NOODLE_BOOL noodleBoolAt(const NoodleArray_t* array, size_t index);
80+
const char* noodleStringAt(const NoodleArray_t* array, size_t index);
81+
void noodleFree(Noodle_t* noodle);
82+
83+
#endif // NOODLE_PARSER_H

Include/noodle_em.h

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#ifndef NOODLE_SINGLE_
2+
#define NOODLE_SINGLE_H
3+
4+
// This file is completely self contained. It will allocate no memory and only
5+
// uses what you provide. If you are using noodle as a
6+
7+
8+
typedef enum NoodleType_t
9+
{
10+
NOODLE_TYPE_GROUP,
11+
NOODLE_TYPE_ARRAY,
12+
NOODLE_TYPE_INT,
13+
NOODLE_TYPE_FLOAT,
14+
NOODLE_TYPE_BOOLEAN,
15+
NOODLE_TYPE_STRING,
16+
NOODLE_TYPE_INVALID,
17+
} NoodleType_t;
18+
19+
typedef struct NoodleTokenEm_t
20+
{
21+
NoodleTypeEm_t type;
22+
int nameStart;
23+
int nameEnd;
24+
int valueStart;
25+
int valueEnd;
26+
int start;
27+
int end;
28+
int size;
29+
};
30+
31+
#define NOODLE_SINGLE_IMPLEMENTATION
32+
#ifdef NOODLE_SINGLE_IMPLEMENTATION
33+
34+
static inline bool noodleIsIdentifier(char c)
35+
{
36+
37+
}
38+
39+
NoodleTypeEm_t noodleParseNext();
40+
41+
#endif // NOODLE_SINGLE_IMPLEMENTATION
42+
43+
#endif // NOODLE_SINGLE_H

0 commit comments

Comments
 (0)