src/compiler/lexer.c
SkipWhitespaceResult skip_whitespace()
{
	while (1)
	{
		char c = peek();
		switch (c)
		{
			case '\0':
				return WHITESPACE_FOUND_EOF;
			case '\n':
				// If we are currently parsing docs, then end of line is considered meaningful.
				if (lexer.lexer_state == LEXER_STATE_DOCS_PARSE_DIRECTIVE) return WHITESPACE_FOUND_DOCS_EOL;
			case ' ':
			case '\t':
			case '\r':
			case '\f':
				next();
				break;
			case '/':
				if (peek_next() == '/')
				{
					while (!reached_end() && peek() != '\n') next();
					break;
				}
				if (peek_next() == '*')
				{
					// Enter docs parsing on /**
					if (lookahead(2) == '*' && lexer.lexer_state == LEXER_STATE_NORMAL)
					{
						return WHITESPACE_FOUND_DOCS_START;
					}
					while (1)
					{
						next();
						if (reached_end()) return WHITESPACE_COMMENT_REACHED_EOF;
						if (peek() == '*' && peek_next() == '/')
						{
							lexer.current += 2;
							break;
						}
					}
					break;
				}
				if (peek_next() == '+')
				{
					int nesting_depth = 1;
					while (1)
					{
						next();
						if (reached_end()) return WHITESPACE_COMMENT_REACHED_EOF;
						if (peek() == '/' && peek_next() == '+')
						{
							lexer.current += 2;
							nesting_depth++;
							continue;
						}
						if (peek() == '+' && peek_next() == '/')
						{
							lexer.current += 2;
							if (--nesting_depth == 0) break;
						}
					}
					break;
				}
				return WHITESPACE_SKIPPED_OK;
			default:
				return WHITESPACE_SKIPPED_OK;
		}
	}
}
/**
 * Skip regular comments.
 *
 * @return the result of the skip (did we enter docs? did we have any errors?)
 */
Skip regular comments.
@return the result of the skip (did we enter docs. did we have any errors?)
Skip regular comments . @return the result of the skip ( did we enter docs . did we have any errors? )
SkipWhitespaceResult skip_whitespace()
{
	while (1)
	{
		char c = peek();
		switch (c)
		{
			case '\0':
				return WHITESPACE_FOUND_EOF;
			case '\n':
				if (lexer.lexer_state == LEXER_STATE_DOCS_PARSE_DIRECTIVE) return WHITESPACE_FOUND_DOCS_EOL;
			case ' ':
			case '\t':
			case '\r':
			case '\f':
				next();
				break;
			case '/':
				if (peek_next() == '/')
				{
					while (!reached_end() && peek() != '\n') next();
					break;
				}
				if (peek_next() == '*')
				{
					if (lookahead(2) == '*' && lexer.lexer_state == LEXER_STATE_NORMAL)
					{
						return WHITESPACE_FOUND_DOCS_START;
					}
					while (1)
					{
						next();
						if (reached_end()) return WHITESPACE_COMMENT_REACHED_EOF;
						if (peek() == '*' && peek_next() == '/')
						{
							lexer.current += 2;
							break;
						}
					}
					break;
				}
				if (peek_next() == '+')
				{
					int nesting_depth = 1;
					while (1)
					{
						next();
						if (reached_end()) return WHITESPACE_COMMENT_REACHED_EOF;
						if (peek() == '/' && peek_next() == '+')
						{
							lexer.current += 2;
							nesting_depth++;
							continue;
						}
						if (peek() == '+' && peek_next() == '/')
						{
							lexer.current += 2;
							if (--nesting_depth == 0) break;
						}
					}
					break;
				}
				return WHITESPACE_SKIPPED_OK;
			default:
				return WHITESPACE_SKIPPED_OK;
		}
	}
}
SkipWhitespaceResult skip_whitespace ( ) { while ( 1 ) { char c = peek ( ) ; switch ( c ) { case ' \0 ' : return WHITESPACE_FOUND_EOF ; case ' \n ' : if ( lexer . lexer_state == LEXER_STATE_DOCS_PARSE_DIRECTIVE ) return WHITESPACE_FOUND_DOCS_EOL ; case ' ' : case ' \t ' : case ' \r ' : case ' \f ' : next ( ) ; break ; case ' ' : if ( peek_next ( ) == ' ' ) { while ( ! reached_end ( ) && peek ( ) != ' \n ' ) next ( ) ; break ; } if ( peek_next ( ) == ' ' ) { if ( lookahead ( 2 ) == ' ' && lexer . lexer_state == LEXER_STATE_NORMAL ) { return WHITESPACE_FOUND_DOCS_START ; } while ( 1 ) { next ( ) ; if ( reached_end ( ) ) return WHITESPACE_COMMENT_REACHED_EOF ; if ( peek ( ) == ' ' && peek_next ( ) == ' ' ) { lexer . current += 2 ; break ; } } break ; } if ( peek_next ( ) == ' ' ) { int nesting_depth = 1 ; while ( 1 ) { next ( ) ; if ( reached_end ( ) ) return WHITESPACE_COMMENT_REACHED_EOF ; if ( peek ( ) == ' ' && peek_next ( ) == ' ' ) { lexer . current += 2 ; nesting_depth ++ ; continue ; } if ( peek ( ) == ' ' && peek_next ( ) == ' ' ) { lexer . current += 2 ; if ( -- nesting_depth == 0 ) break ; } } break ; } return WHITESPACE_SKIPPED_OK ; default : return WHITESPACE_SKIPPED_OK ; } } }
Skip regular comments.
Skip regular comments .
// If we are currently parsing docs, then end of line is considered meaningful. // Enter docs parsing on /**