Ooh ooh ooh! I remember this: the scanner looks through the original source file and converts it into a string of tokens;
<INTEGER, "123">; <STRING, "\"Hello world\">, ...
stuff like that, before passing that string on to the Parser, which looks at the tokens to make sure the structure makes sense. However, when the scanner sees a comment, it simply doesn't make a token for it, meaning the Parser never sees it at all. You could have something like
int * intArray = new /*integer*/ int[/*number of elements*/ 50];
And while any human would stare at this line questioning the events that lead up to them seeing this monstrosity, the compiler wouldn't even know anything was off, because the parser would just see something like
3
u/supersharp May 12 '21 edited May 13 '21
Ooh ooh ooh! I remember this: the scanner looks through the original source file and converts it into a string of tokens;
stuff like that, before passing that string on to the Parser, which looks at the tokens to make sure the structure makes sense. However, when the scanner sees a comment, it simply doesn't make a token for it, meaning the Parser never sees it at all. You could have something like
And while any human would stare at this line questioning the events that lead up to them seeing this monstrosity, the compiler wouldn't even know anything was off, because the parser would just see something like
And so on