Browse Source

initial

master
tki 6 years ago
commit
7cfadc190c
  1. 4
      .gitignore
  2. 23
      rmlp/.editorconfig
  3. 1
      rmlp/.env.example
  4. 14
      rmlp/Makefile
  5. 5
      rmlp/README.md
  6. 5
      rmlp/examples/example.html
  7. 13
      rmlp/src/dom.c
  8. 14
      rmlp/src/include/macros.h
  9. 8
      rmlp/src/include/nodes_t.h
  10. 10
      rmlp/src/include/tokenizer.h
  11. 9
      rmlp/src/main.c
  12. 6
      rmlp/src/tokenizer.c

4
.gitignore

@ -0,0 +1,4 @@
*.out
*.o
.#*
.env

23
rmlp/.editorconfig

@ -0,0 +1,23 @@
root = true
[*]
end_of_line = lf
insert_final_newline = true
charset = utf-8
indent_size = 2
indent_style = space
[*.py]
indent_style = space
indent_size = 4
[*.imba]
indent_style = tab
indent_size = 4
[Makefile]
indent_style = tab
[*.c]
indent_style = tab
indent_size = 4

1
rmlp/.env.example

@ -0,0 +1 @@
export RML_DEBUG:=0

14
rmlp/Makefile

@ -0,0 +1,14 @@
include .env
CC=gcc
CFLAGS=-Wall -C -I. -Isrc/include
DEPS = dom.h tokenizer.h nodes_t.h
%.o: %.c $(DEPS)
(CC) -c -o $@ $< $(CFLAGS) -D DEBUG=$(RML_DEBUG)
rmlp: src/main.o src/dom.o src/tokenizer.o
$(CC) -o rmlp.out src/main.o src/dom.o src/tokenizer.o
clean:
rm src/*.o

5
rmlp/README.md

@ -0,0 +1,5 @@
Reduced Markup Language Parser
#### NAME
*rmlp* --- It slurps reduced html and barfs out DOM tree.

5
rmlp/examples/example.html

@ -0,0 +1,5 @@
<!-- should produce colorful text with random skewing -->
<div class="_rainbow">
<div class="_random-skew">This is colorful</div>
</div>
<a href="imba.io">Imba language</a>

13
rmlp/src/dom.c

@ -0,0 +1,13 @@
#include "nodes_t.h"
node current_node(void) {
return NULL;
}
tree add_child(node *child) {
return NULL;
}
tree add_sibling(node *sibling) {
return NULL;
}

14
rmlp/src/include/macros.h

@ -0,0 +1,14 @@
#ifndef __MACROS__
#define __MACROS__
#if DEBUG == 0
#define DEBUG_MODE 0
#else
#define DEBUG_MODE 1
#endif /*debug*/
#define log(fmt, ...) \
do { if (DEBUG_MODE) fprintf(stderr, "%s:%d:%s(): " fmt, __FILE__, \
__LINE__, __func__, __VA_ARGS__); } while (0)
#endif //macros

8
rmlp/src/include/nodes_t.h

@ -0,0 +1,8 @@
#ifndef __NODES_T__
#define __NODES_T__
typedef struct node {
char *element;
} node;
#endif //nodes

10
rmlp/src/include/tokenizer.h

@ -0,0 +1,10 @@
#ifndef __TOKENIZER__
#define __TOKENIZER__
typedef struct node {
char *element;
} node;
node slurp_whitespace(char*);
#endif //tokenizer

9
rmlp/src/main.c

@ -0,0 +1,9 @@
#include <stdio.h>
#include "macros.h"
#include "tokenizer.h"
int main(int argc, char **argv) {
char *input = argv[1];
log("Got: %s\n", input);
return 0;
}

6
rmlp/src/tokenizer.c

@ -0,0 +1,6 @@
#include "nodes_t.h"
#include "tokenizer.h"
node slurp_whitespace(char* input_line) {
return NULL;
}
Loading…
Cancel
Save