pgschema 0.2.9

Prototype for PG-SChema with property constraints
Pg:
    Statements ;

Statements: Statement+ ;

Statement:
    Edge
  | Node ;

Node: "(" NodeId LabelsRecord ")" ;

Edge:
//     directed
    // | undirected
//    ;
// directed:
    "(" source=IDENTIFIER ")" "-" "(" EdgeId? LabelsRecord ")" "->" "(" target=IDENTIFIER ")" ;

NodeId:
    Id ;

EdgeId:
    Id ;

Id:
    IDENTIFIER {shift};

LabelsRecord:
    Labels? Record? ;

Labels:
    OPEN_CURLY identifier+[COMMA] CLOSE_CURLY;


Record:
    OPENSQUAREBRACKET Properties CLOSESQUAREBRACKET ;

Properties: Property+[COMMA];

Property:
    key ":" Values  ;

key:
    identifier ;

Values: SingleValue
      | OPENSQUAREBRACKET ListValues CLOSESQUAREBRACKET {ListValue}
      ;

ListValues: SingleValue*[COMMA] ;

SingleValue:
      QUOTED_STRING {StringValue}
    | NUMBER {NumberValue}
    | DATE QUOTED_STRING {DateValue}
    | BOOL {BooleanValue}
    ;

BOOL:
    TRUE | FALSE ;

identifier:
    IDENTIFIER
    | QUOTED_STRING
    ;

// Productions for comments
Layout: LayoutItem*;
LayoutItem: WS | Comment;
Comment: '/*' Corncs '*/' | CommentLine;
Corncs: Cornc*;
Cornc: Comment | NotComment | WS;


terminals

// Terminals for comments
WS: /\s+/;
CommentLine: /\/\/.*/;
NotComment: /((\*[^\/])|[^\s*\/]|\/[^\*])+/;
START_COMMENT: '/*';
END_COMMENT: '*/';

QUOTED_STRING: /"((\\")|[^"])*"/ ;

IDENTIFIER:
    /\w+/ ;

SEMICOLON:
    ";" ;

CREATE:
    "CREATE" ;

NODE:
    "NODE" ;

EDGE:
    "EDGE" ;

GRAPH:
    "GRAPH" ;

TYPE:
    "TYPE" ;

OPEN_PAREN:
    "(" ;

CLOSE_PAREN:
    ")" ;

OPEN_ARROW:
    "-[" ;

CLOSE_ARROW:
    "]->" ;

OPEN_CURLY:
    "{" ;

CLOSE_CURLY:
    "}" ;

COLON:
    ":" ;

COMMA:
    "," ;

BAR:
    "|" ;

PLUS:
    "+" ;

STAR:
    "*" ;

QUESTION:
    "?" ;

INTEGER_NAME:
    "INTEGER" ;

STRING_NAME:
    "STRING" ;

DATE_NAME:
    "DATE" ;

NUMBER:
    /\d+/ ;

OPTIONAL:
    "OPTIONAL" ;

QUOTE:
    '\"' ;

AMPERSAND:
    "&" ;

OPENSQUAREBRACKET:
    "[" ;

CLOSESQUAREBRACKET:
    "]" ;

START_ARROW:
    "-" ;

END_ARROW:
    "->" ;

TRUE:
    "TRUE" ;

FALSE:
    "FALSE" ;

DATE:
    "DATE" ;