Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
asinha94 committed Apr 23, 2023
1 parent 43afbd2 commit 7795fde
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 0 deletions.
26 changes: 26 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@

PREFIX = $(shell pwd)

CPP := clang++
WARNINGS := -Wall -Wextra -pedantic -Wshadow -Wpointer-arith -Wcast-align \
-Wwrite-strings -Wcast-qual -Wconversion -Wno-long-long \
-Wredundant-decls -Winline -Wno-sign-conversion -Wno-conversion\

CPPFLAGS := -g $(WARNINGS) -std=c++17 -fno-exceptions $(INCLUDES)


CPP_SRC := $(shell find $(PREFIX)/ -name *.cpp)
CPP_OBJS := $(CPP_SRC:%.cpp=%.o)
BIN := asqlite

.PHONY: clean
.SUFFIXES: .o .cpp

%.o: %.cpp
$(CPP) $(CPPFLAGS) -c $< -o $@ $(CPPFLAGS)

build: $(CPP_OBJS)
$(CPP) $(CPPFLAGS) $(CPP_OBJS) -o $(BIN)

clean:
@rm -rf $(BIN) $(CPP_OBJS)
44 changes: 44 additions & 0 deletions asqlite.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#include <cstdio>
#include <vector>
#include <string>

const char * sql = "SELECT * from table;";


void parse(const char * str)
{
while (char c = *str++) {

// Parse out the spaces
while (true) {
if (!isspace(c)) break;
c = *str++;
}

std::string s;

if (isalpha(c) || ispunct(c)) {
do
s += c;
while (isalnum(c = *str++) || ispunct(c));
printf("String: %s\n", s.c_str());
}

if (isdigit(c)) {
do
s += c;
while (isdigit(c = *str++));
printf("Int: %s\n", s.c_str());
}

if (c == '\0')
return;
}
}


int main()
{
parse(sql);
return 0;
}

0 comments on commit 7795fde

Please sign in to comment.