commit b9c25435aed1ee5e24db3e3b198112aaf1bcf987
Author: anon <anon@anon.anon>
Date:   Thu Nov 9 11:04:41 2023 +0100

    init

diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..9eb31f4
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,3 @@
+main:
+	flex -o main.cpp main.l
+	g++ main.cpp
diff --git a/draft.csml b/draft.csml
new file mode 100644
index 0000000..270fbd0
--- /dev/null
+++ b/draft.csml
@@ -0,0 +1,11 @@
+// DOCTYPE HTML
+html {
+	head {
+
+	}
+	body {
+		div {
+
+		}
+	}
+}
diff --git a/main.l b/main.l
new file mode 100644
index 0000000..2a31f24
--- /dev/null
+++ b/main.l
@@ -0,0 +1,98 @@
+%{
+#include <stdio.h>
+#include <stack>
+
+#define ECHOS(s) fwrite(s, strlen(s), 1, yyout)
+
+std::stack<std::string> tag_stack;
+std::string tag_candidate = "";
+
+bool push_tag() {
+	if (tag_candidate == "") {
+		return false;
+	}
+	tag_stack.push(tag_candidate);
+	ECHOS("<" + tag_stack.top() + ">");
+	tag_candidate = "";
+}
+
+bool pop_tag() {
+	ECHOS("</" + tag_stack.top() + ">");
+	tag_stack.pop();
+}
+
+/*
+	q0(.)  -> q1
+	q0(\d) -> q2
+	q1(\d) -> qe
+	q2(\d) -> q2
+	q2(.)  -> qe
+	qe(\d) -> qe
+*/
+%}
+
+%x HEAD STRING COMMENT COMMENT_MULTILINE
+%s BODY
+
+ws			[ \t\r\v\f]
+wsnl		[ \t\r\v\f\n]
+
+%%
+
+<BODY>{
+\/\/	{
+	BEGIN COMMENT;
+	ECHOS("<!--");
+}
+\/\*	{
+	BEGIN COMMENT_MULTILINE;
+	ECHOS("<!--");
+}
+w+	{
+	tag_candidate = yytext;
+}
+\(	{
+	push_tag();
+	BEGIN HEAD;
+}
+\{	{
+	push_tag();
+}
+\}	{
+	pop_tag();
+}
+}
+
+<COMMENT,COMMENT_MULTILINE>{
+.*	{
+	ECHO;
+}
+}
+
+<COMMENT>{
+\n	{
+	ECHOS("-->");
+	BEGIN BODY;
+}
+}
+
+<COMMENT_MULTILINE>{
+\n	{
+	ECHO;
+}
+\*\/	{
+	ECHOS("-->");
+	BEGIN BODY;
+}
+}
+
+<HEAD> {
+.*	{
+	ECHO;
+}
+)[wsnl]{	{
+	BEGIN BODY;
+}
+}
+
+%%