WarsmashModEngine/fdfparser/antlr-src/FDF.g4

152 lines
3.6 KiB
Plaintext
Raw Normal View History

2020-05-18 05:57:07 +02:00
/**
* Define a grammar called FDF
*/
grammar FDF;
@header {
package com.etheller.warsmash.fdfparser;
}
program :
(statement)*
;
statement:
STRING_LIST OPEN_CURLY (ID STRING_LITERAL COMMA)*? CLOSE_CURLY # StringListStatement
|
INCLUDE_FILE STRING_LITERAL COMMA # IncludeStatement
|
frame # FrameStatement
2020-05-20 07:39:41 +02:00
;
2020-05-18 05:57:07 +02:00
frame:
frame_type_qualifier OPEN_CURLY frame_element* CLOSE_CURLY # AnonymousCompDefinition
|
frame_type_qualifier INHERITS STRING_LITERAL OPEN_CURLY frame_element* CLOSE_CURLY # AnonymousCompSubTypeDefinition
|
frame_type_qualifier INHERITS WITHCHILDREN STRING_LITERAL OPEN_CURLY frame_element* CLOSE_CURLY # AnonymousCompSubTypeDefinitionWithChildren
|
2020-05-20 07:39:41 +02:00
frame_type_qualifier STRING_LITERAL OPEN_CURLY frame_element* CLOSE_CURLY # CompDefinition
|
frame_type_qualifier STRING_LITERAL INHERITS STRING_LITERAL OPEN_CURLY frame_element* CLOSE_CURLY # CompSubTypeDefinition
|
frame_type_qualifier STRING_LITERAL INHERITS WITHCHILDREN STRING_LITERAL OPEN_CURLY frame_element* CLOSE_CURLY # CompSubTypeDefinitionWithChildren
2020-05-18 05:57:07 +02:00
|
2020-05-20 07:39:41 +02:00
FRAME STRING_LITERAL STRING_LITERAL OPEN_CURLY frame_element* CLOSE_CURLY # FrameDefinition
2020-05-18 05:57:07 +02:00
|
2020-05-20 07:39:41 +02:00
FRAME STRING_LITERAL STRING_LITERAL INHERITS STRING_LITERAL OPEN_CURLY frame_element* CLOSE_CURLY # FrameSubTypeDefinition
|
FRAME STRING_LITERAL STRING_LITERAL INHERITS WITHCHILDREN STRING_LITERAL OPEN_CURLY frame_element* CLOSE_CURLY # FrameSubTypeDefinitionWithChildren
2020-05-18 05:57:07 +02:00
;
frame_element:
frame # FrameFrameElement
|
ID FLOAT COMMA # FloatElement
2020-05-18 05:57:07 +02:00
|
ID STRING_LITERAL COMMA # StringElement
2020-05-18 05:57:07 +02:00
|
ID STRING_LITERAL STRING_LITERAL COMMA # StringPairElement
2020-05-18 05:57:07 +02:00
|
ID FLOAT FLOAT COMMA # Vector2Element
2020-05-18 05:57:07 +02:00
|
ID COMMA # FlagElement
2020-05-18 05:57:07 +02:00
|
ID FLOAT FLOAT FLOAT FLOAT COMMA # Vector4Element
2020-05-18 05:57:07 +02:00
|
ID FLOAT COMMA FLOAT COMMA FLOAT COMMA FLOAT COMMA # Vector4CommaElement
2020-05-18 05:57:07 +02:00
|
SETPOINT frame_point COMMA STRING_LITERAL COMMA frame_point COMMA FLOAT COMMA FLOAT COMMA # SetPointElement
|
ANCHOR frame_point COMMA FLOAT COMMA FLOAT COMMA # AnchorElement
2020-05-18 05:57:07 +02:00
|
ID STRING_LITERAL COMMA FLOAT COMMA STRING_LITERAL COMMA # FontElement
2020-05-18 05:57:07 +02:00
|
ID FLOAT FLOAT FLOAT COMMA # Vector3Element
2020-05-18 05:57:07 +02:00
|
ID text_justify COMMA # TextJustifyElement
2020-05-18 05:57:07 +02:00
|
ID STRING_LITERAL COMMA FLOAT COMMA # SimpleFontElement
2020-05-18 05:57:07 +02:00
;
text_justify:
JUSTIFYTOP | JUSTIFYMIDDLE | JUSTIFYBOTTOM | JUSTIFYLEFT | JUSTIFYCENTER | JUSTIFYRIGHT;
frame_point:
FRAMEPOINT_TOPLEFT
| FRAMEPOINT_TOP
| FRAMEPOINT_TOPRIGHT
| FRAMEPOINT_LEFT
| FRAMEPOINT_CENTER
| FRAMEPOINT_RIGHT
| FRAMEPOINT_BOTTOMLEFT
| FRAMEPOINT_BOTTOM
| FRAMEPOINT_BOTTOMRIGHT;
color:
FLOAT FLOAT FLOAT
|
FLOAT FLOAT FLOAT FLOAT
;
2020-05-20 07:39:41 +02:00
frame_type_qualifier:
STRING
|
TEXTURE
|
LAYER
;
2020-05-18 05:57:07 +02:00
OPEN_CURLY : '{';
CLOSE_CURLY : '}';
STRING_LIST : 'StringList' ;
INCLUDE_FILE : 'IncludeFile' ;
FRAME : 'Frame' ;
2020-05-20 07:39:41 +02:00
STRING : 'String' ;
TEXTURE : 'Texture' ;
LAYER : 'Layer' ;
2020-05-18 05:57:07 +02:00
INHERITS : 'INHERITS' ;
WITHCHILDREN : 'WITHCHILDREN' ;
SETPOINT : 'SetPoint';
ANCHOR : 'Anchor';
2020-05-18 05:57:07 +02:00
JUSTIFYTOP : 'JUSTIFYTOP';
JUSTIFYMIDDLE : 'JUSTIFYMIDDLE';
JUSTIFYBOTTOM : 'JUSTIFYBOTTOM';
JUSTIFYLEFT : 'JUSTIFYLEFT';
JUSTIFYCENTER : 'JUSTIFYCENTER';
JUSTIFYRIGHT : 'JUSTIFYRIGHT';
FRAMEPOINT_TOPLEFT : 'TOPLEFT';
FRAMEPOINT_TOP : 'TOP';
FRAMEPOINT_TOPRIGHT : 'TOPRIGHT';
FRAMEPOINT_LEFT : 'LEFT';
FRAMEPOINT_CENTER : 'CENTER';
FRAMEPOINT_RIGHT : 'RIGHT';
FRAMEPOINT_BOTTOMLEFT : 'BOTTOMLEFT';
FRAMEPOINT_BOTTOM : 'BOTTOM';
FRAMEPOINT_BOTTOMRIGHT : 'BOTTOMRIGHT';
ID : ([a-zA-Z_][a-zA-Z_0-9]*) ;
COMMA : ',';
STRING_LITERAL : ('"'.*?'"');
WS : [ \t\r\n]+ -> skip ;
FLOAT : '-'?([0]|([1-9][0-9]*))('.'([0-9]*)?)?'f'? ;
MULTI_LINE_COMMENT : '/*'.*?'*/' -> skip ;
COMMENT : '//'.*?'\n' -> skip ;