]> ocean-lang.org Git - ocean/commitdiff
scanner: improve text and fix typos.
authorNeilBrown <neil@brown.name>
Sun, 18 Feb 2018 05:10:12 +0000 (16:10 +1100)
committerNeilBrown <neil@brown.name>
Sun, 18 Feb 2018 05:10:12 +0000 (16:10 +1100)
Improve the text about 'marks' to explain the difficulty
with comments and '/'.
Fix a few typos.

Signed-off-by: NeilBrown <neil@brown.name>
csrc/scanner.mdc

index 14cec4b89ef7b885a48422fa0a8cb2c7af59843d..4d922415018e67a2f9aa87dba9a0f28b60fb6485 100644 (file)
@@ -106,7 +106,7 @@ token numbers from `TK_reserved` upwards.
 ### Numbers
 
 Numbers are the messiest tokens to parse, primarily because they can
-contain characters that also have meaning outside of number and,
+contain characters that also have meaning outside of numbers and,
 particularly, immediately after numbers.
 
 The obvious example is the '`-`' sign.  It can come inside a number for
@@ -260,7 +260,7 @@ and the length of the list must be given (`known_count`).
 Tokens matching these known words are reported as the index of the
 list added to `TK_reserved`.
 
-If identifiers are ignored, then any work which is not listed as a
+If identifiers are ignored, then any word which is not listed as a
 known word results in an error.
 
 ###### token config parameters
@@ -324,10 +324,17 @@ below before giving up and assuming an unknown mark.
 
 If an unknown mark contains a quote character or a comment marker, and
 that token is not being ignored, then we terminate the unknown mark
-before that quote or comment.  This ensure that an unknown mark
+before that quote or comment.  This ensures that an unknown mark
 immediately before a string is handled correctly.
 
-If `TK_mark` is ignored, then unknown marks as returned as an error.
+If the first character of a comment marker (i.e. '/') is a known mark,
+the above rules would suggest that the start of a comment would be
+parsed as that mark, which is not what is wanted.  So the introductory
+sequences for a comment ("//" and "/*") are treated as
+partially-known.  They prevent the leading "/" from being a mark by
+itself, but do not actually constitute a stand-alone mark.
+
+If `TK_mark` is ignored, then unknown marks are returned as errors.
 
 ###### token types
        TK_mark,
@@ -407,7 +414,7 @@ and continue until a matching character on the same line.  Any of
 these characters can be included in the list of known marks and then
 they will not be used for identifying strings.
 
-Immediately following the close quote one or two ASCII letters may
+Immediately following the close quote, one or two ASCII letters may
 appear.  These are somewhat like the arbitrary letters allowed in
 "Numbers" above.  They can be used by the language in various ways.
 
@@ -2022,4 +2029,3 @@ the tokens one per line.
                        libmdcode.o libnumber.o libstring.o -licuuc -lgmp
        scanner.o : scanner.c
                $(CC) $(CFLAGS) -c scanner.c
-