In languages like c/c++ spacing and comments are ignored and only actual code gets into compiler.
I’m interested if there is accepted way of naming these two things?
- comments & spacing
- everything else (actual code)
Referring to comments & spacing as “comments & spacing” is quite annoying.
Any ideas?
1
When whitespace and comments are discarded during parsing, you are left with the Abstract Syntax Tree (AST).
This is a structure representing the rest of the code and you can simply refer to that “thing” as the AST.
I don’t believe there is a specific name for “comments & spacing” except for – comments & whitespace (I guess they don’t really have a specific name because they are discarded during parsing to the AST).
As @delnan commented, whitespace and comments are discarded by the tokenizer and the rest is built into the parse tree, which is a pre-cursor to the AST, so you could effectively also use “parse tree” as a name.
2
Usually I don’t refer to them at all in the parser, because the lexer discards them. Inside the lexer, there’s never a need to refer to them as a group. In conversation, I think most people just consider comments to be implicitly included when you say “whitespace,” unless you are specifically distinguishing between comments and whitespace at the time, which doesn’t come up that often.