Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions examples/hello_world.csq
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
include stdio;

void! main() {
printf("Hello, World!\n");
}
3 changes: 2 additions & 1 deletion include/csquare/lexer/lexer.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
T(T_SEMICOLON, "SEMICOLON") \
T(T_AND, "AND") \
T(T_OR, "OR") \
T(T_EXCLAMATION, "EXCLAMATION MARK") \
\
T(T_KW_DO, "DO") \
T(T_KW_IF, "IF") \
Expand Down Expand Up @@ -112,7 +113,7 @@ void add_token(token_list *list, token *tk);

#define isws(c) (c == ' ' || c == '\t' || c == '\n' || c == '\r')
#define isdigit(c) (c >= '0' && c <= '9')
#define isalpha(c) (c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z')
#define isalpha(c) ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'))

#define LEX_FUNC_ARGS const char *p, int *len
token *lex_symbol(LEX_FUNC_ARGS);
Expand Down
4 changes: 3 additions & 1 deletion makefile
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
include config.mk

.PHONY: all clean directories
.PHONY: all clean directories rebuild

# Default target
all: directories $(TARGET)

rebuild: clean all

directories:
@mkdir -p $(BUILDDIR) $(BINDIR) $(shell find $(SRCDIR) -type d | sed 's/$(SRCDIR)/$(BUILDDIR)/')

Expand Down
1 change: 1 addition & 0 deletions src/csquare/opt-common.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ static const opt_map_t opts[] = {{"--info", "-i", OPT_KIND_FUNC,
handle_info}};

static void handle_info(csq_options *opts, const char *_) {
(void)_;
(void)opts;
printf("Csquared - %s (%s)\n", CSQ_VERSION, __DATE__);
printf("Authors: %s\n", CSQ_AUTHORS);
Expand Down
8 changes: 5 additions & 3 deletions src/lexer/lex_symbol.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@ const struct {
{"==", T_EQ}, {"!=", T_NEQ}, {">=", T_GREATER_EQUALS},
{"<=", T_LESS_EQUALS}, {"+=", T_ADD_ASSIGN}, {"-=", T_SUB_ASSIGN},
{"/=", T_DIV_ASSIGN}, {"*=", T_MUL_ASSIGN}, {"&&", T_AND},
{"||", T_OR}, {"=", T_ASSIGN}, {"+", T_ADD},
{"-", T_SUB}, {"/", T_DIV}, {"*", T_MUL},
{">", T_GREATER}, {"<", T_LESS}, {"(", T_OPEN_PAREN},
{"||", T_OR},

{"=", T_ASSIGN}, {"+", T_ADD}, {"-", T_SUB},
{"/", T_DIV}, {"*", T_MUL}, {">", T_GREATER},
{"<", T_LESS}, {"!", T_EXCLAMATION}, {"(", T_OPEN_PAREN},
{")", T_CLOSE_PAREN}, {"{", T_OPEN_BRACE}, {"}", T_CLOSE_BRACE},
{"[", T_OPEN_BRACKET}, {"]", T_CLOSE_BRACKET}, {".", T_PERIOD},
{",", T_COMMA}, {":", T_COLON}, {";", T_SEMICOLON}};
Expand Down
1 change: 1 addition & 0 deletions src/lexer/lexer.c
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ token_list *lex(const char *src) {
add_token(list, tk);
}

add_token(list, new_token(p, 0, T_EOF));
return list;
}

Expand Down
Loading