1
2
3
4
5
6 #include <sngcm/cmlexer/CmajorLexerApi.hpp>
7 #include <sngcm/cmlexer/TokenValueParsers.hpp>
8
9 classmap ContainerFileClassMap;
10
11 prefix "sngcm/cmlexer";
12
13 tokens ContainerFileTokens
14 {
15 (PROJECT, "'project'"), (SOLUTION, "'solution'"), (REFERENCE, "'reference'"), (SOURCE, "'source'"), (RESOURCE, "'resource'"), (TEXT, "'text'"), (TARGET, "'target'"),
16 (PROGRAM, "'program'"), (WINGUIAPP, "'winguiapp'"), (WINAPP, "'winapp'"), (LIBRARY, "'library'"), (WINLIB, "'winlib'"), (UNITTEST, "'unitTest'"), (ACTIVEPROJECT, "'activeProject'"),
17 (ID, "identifier"), (FILEPATH, "file path"), (ASSIGN, "'='"), (SEMICOLON, "';'"), (DOT, "'.'")
18 }
19
20 keywords ContainerFileKeywords
21 {
22 ("project", PROJECT), ("solution", SOLUTION), ("reference", REFERENCE), ("source", SOURCE), ("resource", RESOURCE), ("text", TEXT), ("target", TARGET),
23 ("program", PROGRAM), ("winguiapp", WINGUIAPP), ("winapp", WINAPP), ("library", LIBRARY), ("winlib", WINLIB), ("unitTest", UNITTEST),
24 ("activeProject", ACTIVEPROJECT)
25 }
26
27 expressions
28 {
29 ws = "[\n\r\t ]";
30 newline = "\r\n|\n|\r";
31 linecomment = "//[^\n\r]*{newline}";
32 blockcomment = "/\*([^*]|\*[^/])*\*/";
33 comment = "{linecomment}|{blockcomment}";
34 separators = "({ws}|{comment})+";
35 id = "{idstart}{idcont}*";
36 filepath = "<[^>]*>";
37 }
38
39 lexer api(SNGCM_LEXER_API) ContainerFileLexer
40 {
41 "{separators}" {}
42 "{id}" { int kw = GetKeywordToken(token.match); if (kw == INVALID_TOKEN) return ID; else return kw; }
43 "{filepath}" { filePath = MakeFilePath(token.match); return FILEPATH; }
44 "=" { return ASSIGN; }
45 ";" { return SEMICOLON; }
46 "\." { return DOT; }
47
48 variables
49 {
50 std::string filePath;
51 }
52 }