diff options
-rw-r--r-- | README.md | 16 | ||||
-rw-r--r-- | test/parser.c | 11 | ||||
-rw-r--r-- | test/tree.c | 28 |
3 files changed, 44 insertions, 11 deletions
@@ -12,7 +12,8 @@ If you wish to remove all HALK-related items from your life, you can try $ sudo make uninstall ``` -As of `82e7599`, HALK has been tested on both Linux and MacOS. +`test` and `dbg` targets also exist. +HALK should build properly on unix-like systems with gcc installed. # Usage @@ -22,9 +23,9 @@ One must simply $ halk examples/simple.halk ``` -. This will print out the token and AST representations of the given text. Running HALK -without an argument allows one to pass in text through stdin. An example session is transcribed -below: +. This will print out the token and AST representations of the given text. +Running HALK without an argument allows one to pass in text through stdin. An +example session is transcribed below: ``` $ halk @@ -75,9 +76,10 @@ nxt: # About -HALK is a **dubiously-typed**, **vaguely-functional**, **interpreted** programming language, -with syntax designed to be as **minimal** and **consistent** as possible. Note that all syntax -described is liable to sudden and violent change. +HALK is a **dubiously-typed**, **vaguely-functional**, **interpreted** +programming language, with syntax designed to be as **minimal** and +**consistent** as possible. Note that all syntax described is liable to sudden +and violent change. Example programs can be found in the examples directory. diff --git a/test/parser.c b/test/parser.c index fb1c0b2..06a305e 100644 --- a/test/parser.c +++ b/test/parser.c @@ -45,10 +45,17 @@ int main(int argc, char** argv) { treep_11->data.block.nxt = NULL; tree_0->data.block.nxt = NULL; + /* + + [block] + + + */ + char src_0[] = "" \ ":int:f = {" \ - " a.b;" \ - " c.d;" \ + "a.b;" \ + "c.d" "}"; pp = pp_init(src_0); diff --git a/test/tree.c b/test/tree.c index 4c32746..b4c6ed8 100644 --- a/test/tree.c +++ b/test/tree.c @@ -29,8 +29,6 @@ int main(int argc, char** argv) { tree_lstr_1 = tree_init(TREE_TYPE_LSTR); tree_tag_0 = tree_init(TREE_TYPE_TAG); tree_tag_1 = tree_init(TREE_TYPE_TAG); - tree_def_0 = tree_init(TREE_TYPE_DEF); - tree_def_1 = tree_init(TREE_TYPE_DEF); tree_call_0 = tree_init(TREE_TYPE_CALL); tree_call_1 = tree_init(TREE_TYPE_CALL); @@ -49,6 +47,32 @@ int main(int argc, char** argv) { ASSERT(tree_cmp(tree_lint_0, tree_lint_0) == 1); ASSERT(tree_cmp(tree_lint_0, tree_lint_1) == 0); + /* Test lstrs. */ + tree_lstr_0->data.lstr.val = "foo"; + tree_lstr_0->data.lstr.len = 3; + tree_lstr_1->data.lstr.val = "bar"; + tree_lstr_1->data.lstr.len = 3; + ASSERT(tree_cmp(tree_lstr_0, tree_lstr_0) == 1); + ASSERT(tree_cmp(tree_lstr_0, tree_lstr_1) == 0); + + /* Test tags. */ + tree_tag_0->data.tag.val = "int"; + tree_tag_0->data.tag.nxt = NULL; + tree_tag_1->data.tag.val = "str"; + tree_tag_1->data.tag.nxt = NULL; + ASSERT(tree_cmp(tree_tag_0, tree_tag_0) == 1); + ASSERT(tree_cmp(tree_tag_0, tree_tag_1) == 0); + tree_tag_1->data.tag.nxt = tree_tag_0; + ASSERT(tree_cmp(tree_tag_0, tree_tag_1) == 0); + + /* Test calls. */ + tree_call_0->data.call.arg = NULL; + tree_call_0->data.call.target = "foo"; + tree_call_1->data.call.arg = NULL; + tree_call_1->data.call.target = "bar"; + ASSERT(tree_cmp(tree_call_0, tree_call_0) == 1); + ASSERT(tree_cmp(tree_call_0, tree_call_1) == 0); + TEST_REPORT; return 0; } |