grammar GTS;

id: (ID '.')* ID;
property: id EQUALS value;

port: 'port {' property* '}' ;

atomic: ATOMICTYPE '{' (property | port)* '}' ;

COMPOSITE_DEFINITION: 'type';

composite: COMPOSITE_DEFINITION? ID '{' element* '}' ;

element:  property | composite | atomic | port | adjacency ;

adjacency: 'adjacency' portName ',' portName;

portName: (hostId '.')? portId;

hostId: ID;
portId: ID;

ATOMICTYPE: 'host' | 'link' | 'ofx' | 'ExternalDomain';

ID: [a-zA-Z][a-zA-Z0-9_]+;

value
   : STRING
   | '-'? IntegerLiteral
   | '-'? FloatingPointLiteral
   | 'true'
   | 'false'
   | 'null'
   ;

STRING     : '"' ('\\"' | ~'"')* '"';

PORT: 'port';
EQUALS: '=';
BR_OPEN: '{';
BR_CLOSE: '}';

WS
   : [ \t\n\r] + -> skip
   ;


IntegerLiteral   :  (DecimalNumeral | HexNumeral) ('L' | 'l')?;
FloatingPointLiteral
                 :  Digit+ '.' Digit+ ExponentPart? FloatType?
                 |  '.' Digit+ ExponentPart? FloatType?
                 |  Digit ExponentPart FloatType?
                 |  Digit+ ExponentPart? FloatType;

fragment DecimalNumeral   :  '0' | NonZeroDigit Digit*;
fragment HexNumeral       :  '0' 'x' HexDigit HexDigit+;
fragment Digit            :  '0' | NonZeroDigit;
fragment NonZeroDigit     :  '1' .. '9';
fragment HexDigit         :  '0' .. '9'  |  'A' .. 'Z'  |  'a' .. 'z' ;
fragment ExponentPart     :  ('E' | 'e') ('+' | '-')? Digit+;
fragment FloatType        :  'F' | 'f' | 'D' | 'd';