3.1 Syntactic Analysis

The first thing VHDL Mode does when indenting a line of code, is to analyze the line, determining the syntactic component list of the construct on that line. A syntactic component consists of a pair of information (in lisp parlance, a cons cell), where the first part is a syntactic symbol, and the second part is a relative buffer position. Syntactic symbols describe elements of VHDL code, e.g., statement, comment, block-open, block-close, etc. See Syntactic Symbols, for a complete list of currently recognized syntactic symbols and their semantics. Also, the variable vhdl-offsets-alist contains the list of currently supported syntactic symbols.

Conceptually, a line of VHDL code is always indented relative to the indentation of some line higher up in the buffer. This is represented by the relative buffer position in the syntactic component.

It might help to see an example. Suppose we had the following code as the only thing in a VHDL Mode buffer 1:


  1: inverter : process
  2: begin
  3:   q <= not d;
  4:   wait on d;
  5: end inverter;

We can use the command C-c C-x (vhdl-show-syntactic-information) to simply report what the syntactic analysis is for the current line. Running this command on line 4 of example 1, we’d see in the echo area:


((statement . 28))

This tells us that the line is a statement and it is indented relative to buffer position 28, which happens to be the ‘q’ on line 3. If you were to move point to line 3 and hit C-c C-x, you would see:


((statement-block-intro . 20))

This indicates that line 3 is the first statement in a block, and is indented relative to buffer position 20, which is the ‘b’ in the begin keyword on line 2.

Syntactic component lists can contain more than one component, and individual syntactic components need not have relative buffer positions. The most common example of this is a line that contains a comment only line.


%%% TBD %%%

Hitting C-c C-x on line 3 of the example gives us:


((comment-intro) (block-intro . 46))

so you can see that the syntactic component list contains two syntactic components. Also notice that the first component, ‘(comment-intro)’ has no relative buffer position.


Footnotes

(1)

The line numbers in this and future examples don’t actually appear in the buffer.