@@ -13,72 +13,108 @@ constexpr std::string_view DEFAULT_MULTI_LINE_COMMENT_END = "*/";
1313constexpr std::string_view DEFAULT_STRING_START = " \" " ;
1414constexpr std::string_view DEFAULT_STRING_END = " \" " ;
1515extern const std::unordered_map<char , char > DEFAULT_ESCAPE_SEQUENCES;
16+ extern const std::unordered_map<char , char > NO_ESCAPE_SEQUENCES;
1617
1718/* *
18- * If a char is a newline character
19- * @param c The char
20- * @return The char is a newline character
19+ * If a char is a newline character.
20+ * @param c The char.
21+ * @return The char is a newline character.
2122 */
2223[[nodiscard]] bool isNewLine (char c);
2324
2425/* *
25- * If a char is a whitespace character
26- * @param c The char
27- * @return The char is a whitespace character
26+ * If a char is a whitespace character.
27+ * @param c The char.
28+ * @return The char is a whitespace character.
2829 */
2930[[nodiscard]] bool isWhitespace (char c);
3031
3132/* *
32- * If a char is a numerical character (0-9)
33- * @param c The char
34- * @return The char is a numerical character
33+ * If a char is a numerical character (0-9).
34+ * @param c The char.
35+ * @return The char is a numerical character.
3536 */
3637[[nodiscard]] bool isNumber (char c);
3738
3839/* *
39- * If a single line comment is detected, eat its contents
40- * @param stream The BufferStream to modify
40+ * Eat all whitespace after the current stream position.
41+ * @param stream The BufferStream to modify.
42+ */
43+ void eatWhitespace (BufferStream& stream);
44+
45+ /* *
46+ * If a single line comment is detected, eat its contents.
47+ * This function does not handle the detection of single line comments!
48+ * @param stream The BufferStream to modify.
4149 */
4250void eatSingleLineComment (BufferStream& stream);
4351
4452/* *
45- * If a multi line comment is detected, eat its contents
46- * @param stream The BufferStream to modify
47- * @param multiLineCommentEnd The multi line comment ending to search for
53+ * If a multi line comment is detected, eat its contents.
54+ * This function does not handle the detection of multi line comments!
55+ * @param stream The BufferStream to modify.
56+ * @param multiLineCommentEnd The multi line comment ending to search for.
4857 */
4958void eatMultiLineComment (BufferStream& stream, std::string_view multiLineCommentEnd = DEFAULT_MULTI_LINE_COMMENT_END);
5059
5160/* *
52- * Eat all whitespace and single line comments after the current stream position
53- * @param stream The BufferStream to modify
54- * @param singleLineCommentStart The single line comment start sequence. Leave empty to skip checking for single line comments
61+ * Eat all whitespace and single line comments after the current stream position.
62+ * @param stream The BufferStream to modify.
63+ * @param singleLineCommentStart The single line comment start sequence. Leave empty to skip checking for single line comments.
5564 */
5665void eatWhitespaceAndSingleLineComments (BufferStream& stream, std::string_view singleLineCommentStart = DEFAULT_SINGLE_LINE_COMMENT_START);
5766
5867/* *
59- * Eat all whitespace and multi line comments after the current stream position
60- * @param stream The BufferStream to modify
61- * @param multiLineCommentStart The multi line comment start sequence. Leave empty to skip checking for multi line comments
68+ * Eat all whitespace and multi line comments after the current stream position.
69+ * @param stream The BufferStream to modify.
70+ * @param multiLineCommentStart The multi line comment start sequence. Leave empty to skip checking for multi line comments.
6271 */
6372void eatWhitespaceAndMultiLineComments (BufferStream& stream, std::string_view multiLineCommentStart = DEFAULT_MULTI_LINE_COMMENT_START);
6473
6574/* *
66- * Eat all whitespace and comments after the current stream position
67- * @param stream The BufferStream to modify
68- * @param singleLineCommentStart The single line comment start sequence. Leave empty to skip checking for single line comments
69- * @param multiLineCommentStart The multi line comment start sequence. Leave empty to skip checking for multi line comments
75+ * Eat all whitespace and comments after the current stream position.
76+ * @param stream The BufferStream to modify.
77+ * @param singleLineCommentStart The single line comment start sequence. Leave empty to skip checking for single line comments.
78+ * @param multiLineCommentStart The multi line comment start sequence. Leave empty to skip checking for multi line comments.
7079 */
7180void eatWhitespaceAndComments (BufferStream& stream, std::string_view singleLineCommentStart = DEFAULT_SINGLE_LINE_COMMENT_START, std::string_view multiLineCommentStart = DEFAULT_MULTI_LINE_COMMENT_START);
7281
7382/* *
74- * Read a string starting at the current stream position
83+ * If the given char exists at the current position, skip over it
7584 * @param stream The BufferStream to modify
76- * @param backing The BufferStream to store the string data in
77- * @param start The starting string chars. If any char matches this, the string will be treated as "quoted" and will include spaces
78- * @param end The ending string chars. If any char matches this, and a starting char is detected, the string will terminate
79- * @param escapeSequences Characters that will be escaped if a backslash is present before them. To disable escapes, pass an empty map
80- * @return A view over the string written to the backing stream
85+ * @param c The char to compare
86+ * @return If the char exists at the current position
87+ */
88+ [[nodiscard]] bool tryToEatChar (BufferStream& stream, char c);
89+
90+ /* *
91+ * Read a string starting at the current stream position.
92+ * @param stream The BufferStream to modify.
93+ * @param backing The BufferStream to store the string data in.
94+ * @param start The starting string chars. If any processed char is in this string, the string will be treated as "quoted" and will include spaces.
95+ * @param end The ending string chars. If any processed char is in this string, and a starting char is detected, the string will terminate.
96+ * @param escapeSequences Characters that will be escaped if a backslash is present before them. To disable escapes, pass an empty map.
97+ * @return A view over the string written to the backing stream.
8198 */
8299[[nodiscard]] std::string_view readStringToBuffer (BufferStream& stream, BufferStream& backing, std::string_view start = DEFAULT_STRING_START, std::string_view end = DEFAULT_STRING_END, const std::unordered_map<char , char >& escapeSequences = DEFAULT_ESCAPE_SEQUENCES);
83100
101+ /* *
102+ * Read a string starting at the current stream position.
103+ * @param stream The BufferStream to modify.
104+ * @param backing The BufferStream to store the string data in.
105+ * @param escapeSequences Characters that will be escaped if a backslash is present before them. To disable escapes, pass an empty map.
106+ * @return A view over the string written to the backing stream.
107+ */
108+ [[nodiscard]] std::string_view readUnquotedStringToBuffer (BufferStream& stream, BufferStream& backing, const std::unordered_map<char , char >& escapeSequences = DEFAULT_ESCAPE_SEQUENCES);
109+
110+ /* *
111+ * Read a string starting at the current stream position.
112+ * @param stream The BufferStream to modify.
113+ * @param backing The BufferStream to store the string data in.
114+ * @param end The ending string chars. If any processed char is in this string, the string will terminate.
115+ * @param escapeSequences Characters that will be escaped if a backslash is present before them. To disable escapes, pass an empty map.
116+ * @return A view over the string written to the backing stream.
117+ */
118+ [[nodiscard]] std::string_view readUnquotedStringToBuffer (BufferStream& stream, BufferStream& backing, std::string_view end, const std::unordered_map<char , char >& escapeSequences = DEFAULT_ESCAPE_SEQUENCES);
119+
84120} // namespace sourcepp::parser::text
0 commit comments