comparison lexer/Lexer.d @ 176:dc9bf56b7ace

Can now use & as a unary operator and take an AddressOf
author Anders Johnsen <skabet@gmail.com>
date Thu, 24 Jul 2008 23:03:18 +0200
parents 0ea5d2f3e96b
children e1e170c2cd44
comparison
equal deleted inserted replaced
175:c8e26556c24d 176:dc9bf56b7ace
35 charTable[c] = CharType.Letter; 35 charTable[c] = CharType.Letter;
36 36
37 foreach (c; "0123456789") 37 foreach (c; "0123456789")
38 charTable[c] = CharType.Number; 38 charTable[c] = CharType.Number;
39 39
40 foreach (c; "(){}[];:.,=!<>+-*/%\"`") 40 foreach (c; "(){}[];:.,=!<>+-*/%&\"`")
41 charTable[c] = CharType.Symbol; 41 charTable[c] = CharType.Symbol;
42 42
43 foreach (c; " \n") 43 foreach (c; " \n")
44 charTable[c] = CharType.Whitespace; 44 charTable[c] = CharType.Whitespace;
45 45
65 symbolFunctions['+'] = &plus; 65 symbolFunctions['+'] = &plus;
66 symbolFunctions['-'] = &minus; 66 symbolFunctions['-'] = &minus;
67 symbolFunctions['*'] = &star; 67 symbolFunctions['*'] = &star;
68 symbolFunctions['/'] = &slash; 68 symbolFunctions['/'] = &slash;
69 symbolFunctions['%'] = &percent; 69 symbolFunctions['%'] = &percent;
70 symbolFunctions['&'] = &and;
70 symbolFunctions['"'] = &string; 71 symbolFunctions['"'] = &string;
71 symbolFunctions['`'] = &string; 72 symbolFunctions['`'] = &string;
72 } 73 }
73 74
74 /** 75 /**
280 281
281 default: 282 default:
282 return Token(Tok.Slash, Loc(position - 1), 1); 283 return Token(Tok.Slash, Loc(position - 1), 1);
283 } 284 }
284 } 285 }
285 286 Token and()
287 {
288 return Token(Tok.And, Loc(position - 1), 1);
289 }
286 Token percent() 290 Token percent()
287 { 291 {
288 if(source[position] == '=') 292 if(source[position] == '=')
289 return Token(Tok.PercentAssign, Loc(position++ - 1), 2); 293 return Token(Tok.PercentAssign, Loc(position++ - 1), 2);
290 return Token(Tok.Percent, Loc(position - 1), 1); 294 return Token(Tok.Percent, Loc(position - 1), 1);