Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

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?

share|improve this question
    
Whitespace / Symbols ^^ –  Paul Aug 7 '12 at 19:49
add comment

2 Answers

up vote 9 down vote accepted

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.

share|improve this answer
1  
An AST is more specific AFAIK - whitespace and comments might be stripped by the tokenizer and the rest may go into a concrete syntax tree first. –  delnan Aug 7 '12 at 20:46
    
@delnan - Thanks for the comment. Integrated into the answer. –  Oded Aug 8 '12 at 8:39
add comment

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.