From: NeilBrown Date: Sun, 18 Feb 2018 05:10:12 +0000 (+1100) Subject: scanner: improve text and fix typos. X-Git-Tag: StoneyCreek~12 X-Git-Url: https://ocean-lang.org/code/?p=ocean;a=commitdiff_plain;h=70d7b2363bd206129fc3f2c972ce0114b49eb4f1 scanner: improve text and fix typos. Improve the text about 'marks' to explain the difficulty with comments and '/'. Fix a few typos. Signed-off-by: NeilBrown --- diff --git a/csrc/scanner.mdc b/csrc/scanner.mdc index 14cec4b..4d92241 100644 --- a/csrc/scanner.mdc +++ b/csrc/scanner.mdc @@ -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 -