diff options
-rw-r--r-- | README.md | 38 | ||||
-rw-r--r-- | src/lexer.c | 5 |
2 files changed, 5 insertions, 38 deletions
@@ -30,43 +30,7 @@ One can only hope this feature will be added in the future. *HALK* is a **dubiously-typed**, **procedural**, **interpreted** programming language. Note that all syntax described is liable to sudden and violent change. -```HALK -[comments in square brackets] - -[preprocessor directives] -#INCLUDE 'math.halk'; [looks for a 'math.halk' file in the cwd, then ~/halk/include] -#INCLUDE 'io' AS ''; [bring everything in 'io' into global scope] - - -let.hello -> 'hello, '; [variables must be given a value at declaration] - -let.PI => math/PI; [namespaces are accessed with a '/'] - [constants are denoted with a '=>'] - -fn.greeting,to -> { [functions defined with: `fn.<name>,<argument>,..., -> {<body>};`] - let.message -> strcat.hello,to; [functions are right-associative] - - stdo.message; [since 'io' was brought into global scope, we - do not prefix it with a namespace/] -}; - -fn.sum_all._ -> { [variadic functions are possible with the reserved '_' argument, - which is treated as an array] - return.foldl.+,0,_; -}; - -fn.fibonacci.n -> { - if.or.(num=?.n, 0), (num=?.n, 1) -> { [functions ending in '?' should be predicates] - return.1; - }; - return.+.(fibonacci. -.n, 1), (fibonacci. -.n, 2); [parens can be used to group function application] -}; - -fn.main -> { [where our code will begin executing] - greeting.[comments can be placed *anywhere*]"world."; - exit.0; [exit with code 0 for success] -}; -``` +Examples can be found [here](examples/). ***HALK*** **progress:** 20% diff --git a/src/lexer.c b/src/lexer.c index d8534c2..345d5c5 100644 --- a/src/lexer.c +++ b/src/lexer.c @@ -159,6 +159,7 @@ token_t* lexer_get_string(lexer_t* lexer) { token_t* lexer_get_comment(lexer_t* lexer) { lexer_next(lexer); + char* comment_so_far = calloc(1, sizeof(char)); while (lexer->c != ']') { @@ -220,10 +221,12 @@ token_t* lexer_get_directive(lexer_t* lexer) { } token_t* lexer_get_keyword(lexer_t* lexer) { + lexer_next(lexer); + char* str_so_far = calloc(1, sizeof(char)); str_so_far[0] = '\0'; - while (isalnum(lexer->c) || (lexer->c != '.' && lexer->c != ',')) { + while (isalnum(lexer->c)) { char* current = lexer_get_c_as_string(lexer); str_so_far = realloc(str_so_far, (strlen(str_so_far) + strlen(current) * sizeof(char))); strcat(str_so_far, current); |