1
2
3
4
5
6 #include <gendoc/html/LexerFileSourceLineParser.hpp>
7 #include <gendoc/html/LexerFileTokenLexerTokens.hpp>
8 #include <gendoc/html/LexerFileTokenLexer.hpp>
9
10 void ParseLexerFileSourceLine(const std::u32string& sourceLine, sngcpp::ast::SourceCodeWriter& sourceCodeWriter)
11 {
12
13
14 std::u32string line(sourceLine);
15 line.append(U"\n");
16 LexerFileTokenLexer lexer(line, "", 0);
17 lexer.SetSeparatorChar('\n');
18 ++lexer;
19 int i = 0;
20 while (*lexer != END)
21 {
22 switch (*lexer)
23 {
24 case WS: { soulng::lexer::Token token = lexer.GetToken(i); sourceCodeWriter.WriteSpaces(token.match.ToString()); break; }
25 case LINECOMMENT: { soulng::lexer::Token token = lexer.GetToken(i); sourceCodeWriter.WriteLineComment(token.match.ToString()); return; }
26 case BLOCKCOMMENT: { soulng::lexer::Token token = lexer.GetToken(i); sourceCodeWriter.WriteBlockComment(token.match.ToString()); break; }
27 case KEYWORD: { soulng::lexer::Token token = lexer.GetToken(i); sourceCodeWriter.WriteKeyword(token.match.ToString()); break; }
28 case ID: { soulng::lexer::Token token = lexer.GetToken(i); sourceCodeWriter.WriteIdentifier(token.match.ToString()); break; }
29 case CHARLIT: { soulng::lexer::Token token = lexer.GetToken(i); sourceCodeWriter.WriteChar(token.match.ToString()); break; }
30 case STRINGLIT: { soulng::lexer::Token token = lexer.GetToken(i); sourceCodeWriter.WriteString(token.match.ToString()); break; }
31 case NUMBER: { soulng::lexer::Token token = lexer.GetToken(i); sourceCodeWriter.WriteNumber(token.match.ToString()); break; }
32 case PP: { soulng::lexer::Token token = lexer.GetToken(i); sourceCodeWriter.WritePP(token.match.ToString()); break; }
33 case OTHER: { soulng::lexer::Token token = lexer.GetToken(i); sourceCodeWriter.WriteOther(token.match.ToString()); break; }
34 }
35 ++lexer;
36 ++i;
37 }
38 }