segment: Distinguish snippets from full files.
authorBen Pfaff <blp@cs.stanford.edu>
Sun, 4 Jul 2021 05:00:47 +0000 (22:00 -0700)
committerBen Pfaff <blp@cs.stanford.edu>
Sun, 4 Jul 2021 05:15:21 +0000 (22:15 -0700)
commitdc25c013a7ce573b87fd27cbefddc732733c837f
treec7024d7d238549355e91905a2e8f9ca7d89d1c2a
parentddf2365f2c3b8924f37cb0c96b2093cceaa64cb9
segment: Distinguish snippets from full files.

The comment on segmenter_init() explains what this means:

If IS_SNIPPET is false, then the segmenter will parse as if it's being
given a whole file.  This means, for example, that it will interpret -
or + at the beginning of the syntax as a separator between commands
(since - or + at the beginning of a line has this meaning).

If IS_SNIPPET is true, then the segmenter will parse as if it's being
given an isolated piece of syntax.  This means that, for example, that
it will interpret - or + at the beginning of the syntax as an operator
token or (if followed by a digit) as part of a number.
src/language/control/repeat.c
src/language/lexer/lexer.c
src/language/lexer/scan.c
src/language/lexer/scan.h
src/language/lexer/segment.c
src/language/lexer/segment.h
tests/language/lexer/scan-test.c
tests/language/lexer/segment-test.c