From 4bee4f99bc7a0ab4dcd635766acdd15e96f29f5f Mon Sep 17 00:00:00 2001 From: NeilBrown Date: Wed, 29 May 2019 21:54:53 +1000 Subject: [PATCH] oceani: allow spaces in numbers. Spaces are now allowed in (decimal) numbers to highlight grouping. Tests are added. Also ensure unknown marks are reported as errors. Signed-off-by: NeilBrown --- csrc/oceani-tests.mdc | 4 ++-- csrc/oceani.mdc | 9 +++++---- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/csrc/oceani-tests.mdc b/csrc/oceani-tests.mdc index d7253b3..c0a9c88 100644 --- a/csrc/oceani-tests.mdc +++ b/csrc/oceani-tests.mdc @@ -154,7 +154,7 @@ Now some contants ###### test: consts const: - pi ::= 3.1415926 + pi ::= 3.141 592 653 four ::= 2 + 2 ; five ::= 10/2 const pie ::= "I like Pie"; cake ::= "The cake is" @@ -356,7 +356,7 @@ Here I break it into two parts, keeping the array code separate. program: size::=55 list:[size]number - list[0] = 1234 + list[0] = 1_234 for i:=1; then i = i + 1; while i < size: n := list[i-1] * list[i-1] list[i] = (n / 100) % 10000 diff --git a/csrc/oceani.mdc b/csrc/oceani.mdc index 342182e..86b3e3c 100644 --- a/csrc/oceani.mdc +++ b/csrc/oceani.mdc @@ -169,8 +169,9 @@ structures can be used. struct parse_context context = { .config = { .ignored = (1 << TK_line_comment) - | (1 << TK_block_comment), - .number_chars = ".,_+-", + | (1 << TK_block_comment) + | (1 << TK_mark), + .number_chars = ".,_+- ", .word_start = "_", .word_cont = "_", }, @@ -4186,7 +4187,7 @@ things which will likely grow as the languages grows. ###### demo: hello const: - pi ::= 3.1415926 + pi ::= 3.141_592_6 four ::= 2 + 2 ; five ::= 10/2 const pie ::= "I like Pie"; cake ::= "The cake is" @@ -4275,7 +4276,7 @@ things which will likely grow as the languages grows. // Dad taught me - the first one I ever heard of. for i:=1; then i = i + 1; while i < size: n := list[i-1] * list[i-1] - list[i] = (n / 100) % 10000 + list[i] = (n / 100) % 10 000 print "Before sort:", for i:=0; then i = i + 1; while i < size: -- 2.43.0