]> ocean-lang.org Git - ocean/commitdiff
oceani: allow spaces in numbers.
authorNeilBrown <neil@brown.name>
Wed, 29 May 2019 11:54:53 +0000 (21:54 +1000)
committerNeilBrown <neil@brown.name>
Fri, 31 May 2019 08:25:55 +0000 (18:25 +1000)
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 <neil@brown.name>
csrc/oceani-tests.mdc
csrc/oceani.mdc

index d7253b354e079c433ad5289bd3ce7ee18b9c7840..c0a9c88b6c344a973d13a4b643d6471aea50c887 100644 (file)
@@ -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
index 342182ee3ae6804f08950595bd3d6a3361eb95f5..86b3e3cb844ddd5fde3ffe8c9243bb21e962a735 100644 (file)
@@ -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: