All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.relogiclabs.json.schema.internal.grammar.SchemaParser.g4 Maven / Gradle / Ivy

Go to download

The New JSON Schema prioritizes simplicity, conciseness, and readability, making it user-friendly and accessible without the need for extensive prior knowledge. It offers efficient read-write facilities, precise JSON document definition through various data types and functions, and extensibility to meet modern web service diverse requirements.

There is a newer version: 1.12.1
Show newest version
parser grammar SchemaParser;

options { tokenVocab = SchemaLexer; }

schema
    : title? version? include* pragma*
            define* schemaBase define* EOF  # AggregateSchema
    | validator EOF                         # CoreSchema
    ;

schemaBase
    : SCHEMA COLON validator
    ;

title
    : TITLE COLON STRING
    ;

version
    : VERSION COLON1 VERSION_NUMBER1;

include
    : INCLUDE COLON IDENTIFIER (COMMA IDENTIFIER)?
    ;

pragma
    : PRAGMA IDENTIFIER COLON primitive
    ;

define
    : DEFINE alias COLON validatorMain
    ;

alias
    : ALIAS
    ;

validatorMain
    : value function* datatype* receiver* OPTIONAL?
    | function+ datatype* receiver* OPTIONAL?
    | datatype+ receiver* OPTIONAL?
    ;

validator
    : validatorMain
    | alias
    ;

value
    : primitive
    | object
    | array
    ;

receiver
    : RECEIVER
    ;

object
    : LBRACE (property (COMMA property)*)? RBRACE
    ;

property
    : STRING COLON validator
    ;

array
    : LBRACKET (validator (COMMA validator)*)? RBRACKET
    ;

datatype
    : DATATYPE STAR? (LPAREN alias RPAREN)?
    ;

function
    : FUNCTION STAR? (LPAREN (argument (COMMA argument)*)? RPAREN)?
    ;

argument
    : value
    | receiver
    ;

primitive
    : TRUE          # PrimitiveTrue
    | FALSE         # PrimitiveFalse
    | STRING        # PrimitiveString
    | INTEGER       # PrimitiveInteger
    | FLOAT         # PrimitiveFloat
    | DOUBLE        # PrimitiveDouble
    | NULL          # PrimitiveNull
    | UNDEFINED     # PrimitiveUndefined
    ;




© 2015 - 2024 Weber Informatics LLC | Privacy Policy