How do I align adjacent tokens in a custom language?
# How do I align adjacent tokens in a custom language?
I'd like to align on multiple tokens on a single line so that the following code:
```
clocking_example c1 ( .s1(),
.s2(),
.default_clk(),
.rst()
);
```
becomes (note aligned on `.` and `(`):
```
clocking_example c1 (.s1 (),
.s2 (),
.default_clk (),
.rst ()
);
```
It's unclear to me how to do this. My project successfully aligns on the `.` but if I create a second `Alignment` token for `(` then nothing seems to happen.
Java somehow does it according to this thread
How do I get a secondary token alignment to work in my language?
I apologize for the bad formatting of this post initially - I long for the day when this page allows markdown (or HTML).
Please sign in to leave a comment.
try to create Alignment with allowBackwardShift property set to true (This will allow to shift tokens to the left in order to satisfy alignment constraints)
Will do! But I'm not sure why any characters in this example need left shifts?
THANK YOU!
It works if I `allowBackwardsShift` on the second `(` `Alignment` object.
Not sure I understand why shifting a Token backward would be needed in this example? If you have a chance can you help me understand why it helps?
/Robert
Actually reading the code in Alignment.java makes me realize that allowBackwardsShift doesn’t mean what I thought it meant. I understand what it does now.
All set!