0

I have a question regarding the notation of a UCB Logo grammar that I found was generated for ANTLR4. There are some notations can't make out and thought about asking. If anyone is willing to clarify, I will be grateful. Here are the notations I don't quite understand:

WORD
: {listDepth > 0}?  ~[ \t\r\n\[\];] ( ~[ \t\r\n\];~] | LINE_CONTINUATION | '\\' ( [ \t\[\]();~] | LINE_BREAK ) )*
| {arrayDepth > 0}? ~[ \t\r\n{};]   ( ~[ \t\r\n};~]  | LINE_CONTINUATION | '\\' ( [ \t{}();~]   | LINE_BREAK ) )*;

array
: '{' ( ~( '{' | '}' ) | array )* '}';

NAME
: ~[-+*/=<> \t\r\n\[\]()":{}] ( ~[-+*/=<> \t\r\n\[\](){}] | LINE_CONTINUATION | '\\' [-+*/=<> \t\r\n\[\]();~{}] )*;

I guess the array means that it can start with { and have an arbitrary number of levels, but has to end with }. I take it that the others are some form of regular expressions? Too my knowledge, regex is different for different programming languages.

Did I get that right?

Marin
  • 861
  • 1
  • 11
  • 27

1 Answers1

1

Antlr does not do regular expressions. It does implement some of the same operators, but that is where the similarity largely ends.

The first sub-terms ( {listDepth > 0}?) in the WORD rule are predicates - no relation to anything in the regular expression world. They are defined in the Antlr documentation and explained in detail in the TDAR.

Your understanding of the array rule is essentially correct.

GRosenberg
  • 5,843
  • 2
  • 19
  • 23