MCPcopy Create free account
hub / github.com/WheretIB/nullc / Lexify

Method Lexify

NULLC/Lexer.cpp:11–378  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

9}
10
11void Lexer::Lexify(const char* code)
12{
13 LexemeType lType = lex_none;
14 int lLength = 1;
15
16 while(*code)
17 {
18 switch(*code)
19 {
20 case ' ':
21 case '\r':
22 case '\n':
23 case '\t':
24 code++;
25 while((unsigned char)(code[0] - 1) < ' ')
26 code++;
27 continue;
28 case '\"':
29 lType = lex_quotedstring;
30 {
31 const char *pos = code;
32 pos++;
33 while(*pos && *pos != '\"')
34 pos += (pos[0] == '\\' && pos[1]) ? 2 : 1;
35 if(*pos)
36 pos++;
37 lLength = (int)(pos - code);
38 }
39 break;
40 case '\'':
41 lType = lex_semiquotedchar;
42 {
43 const char *pos = code;
44 pos++;
45 while(*pos && *pos != '\'')
46 pos += (pos[0] == '\\' && pos[1]) ? 2 : 1;
47 if(*pos)
48 pos++;
49 lLength = (int)(pos - code);
50 }
51 break;
52 case '.':
53 lType = lex_point;
54 break;
55 case ',':
56 lType = lex_comma;
57 break;
58 case '+':
59 lType = lex_add;
60 if(code[1] == '=')
61 {
62 lType = lex_addset;
63 lLength = 2;
64 }else if(code[1] == '+'){
65 lType = lex_inc;
66 lLength = 2;
67 }
68 break;

Callers 1

CompileMethod · 0.80

Calls 2

isDigitFunction · 0.70
push_backMethod · 0.45

Tested by

no test coverage detected