@openfga/syntax-transformer
Version:
Javascript implementation of ANTLR Grammar for the OpenFGA DSL and parser from and to the OpenFGA JSON Syntax
1,300 lines (1,299 loc) • 119 kB
JavaScript
"use strict";
// Generated from /app/OpenFGAParser.g4 by ANTLR 4.13.1
// noinspection ES6UnusedImports,JSUnusedGlobalSymbols,JSUnusedLocalSymbols
Object.defineProperty(exports, "__esModule", { value: true });
exports.ConditionExpressionContext = exports.Extended_identifierContext = exports.IdentifierContext = exports.MultiLineCommentContext = exports.ParameterTypeContext = exports.ParameterNameContext = exports.ConditionParameterContext = exports.ConditionNameContext = exports.ConditionContext = exports.ConditionsContext = exports.RelationDefTypeRestrictionBaseContext = exports.RelationDefTypeRestrictionContext = exports.RelationDefRewriteContext = exports.RelationDefDirectAssignmentContext = exports.RelationRecurseNoDirectContext = exports.RelationRecurseContext = exports.RelationDefGroupingContext = exports.RelationDefPartialsContext = exports.RelationDefNoDirectContext = exports.RelationDefContext = exports.RelationNameContext = exports.RelationDeclarationContext = exports.TypeDefContext = exports.TypeDefsContext = exports.ModuleHeaderContext = exports.ModelHeaderContext = exports.MainContext = void 0;
const antlr4_1 = require("antlr4");
class OpenFGAParser extends antlr4_1.Parser {
get grammarFileName() { return "OpenFGAParser.g4"; }
get literalNames() { return OpenFGAParser.literalNames; }
get symbolicNames() { return OpenFGAParser.symbolicNames; }
get ruleNames() { return OpenFGAParser.ruleNames; }
get serializedATN() { return OpenFGAParser._serializedATN; }
createFailedPredicateException(predicate, message) {
return new antlr4_1.FailedPredicateException(this, predicate, message);
}
constructor(input) {
super(input);
this._interp = new antlr4_1.ParserATNSimulator(this, OpenFGAParser._ATN, OpenFGAParser.DecisionsToDFA, new antlr4_1.PredictionContextCache());
}
// @RuleVersion(0)
main() {
let localctx = new MainContext(this, this._ctx, this.state);
this.enterRule(localctx, 0, OpenFGAParser.RULE_main);
let _la;
try {
this.enterOuterAlt(localctx, 1);
{
this.state = 55;
this._errHandler.sync(this);
_la = this._input.LA(1);
if (_la === 9) {
{
this.state = 54;
this.match(OpenFGAParser.WHITESPACE);
}
}
this.state = 58;
this._errHandler.sync(this);
_la = this._input.LA(1);
if (_la === 55) {
{
this.state = 57;
this.match(OpenFGAParser.NEWLINE);
}
}
this.state = 62;
this._errHandler.sync(this);
switch (this._interp.adaptivePredict(this._input, 2, this._ctx)) {
case 1:
{
this.state = 60;
this.modelHeader();
}
break;
case 2:
{
this.state = 61;
this.moduleHeader();
}
break;
}
this.state = 65;
this._errHandler.sync(this);
switch (this._interp.adaptivePredict(this._input, 3, this._ctx)) {
case 1:
{
this.state = 64;
this.match(OpenFGAParser.NEWLINE);
}
break;
}
this.state = 67;
this.typeDefs();
this.state = 69;
this._errHandler.sync(this);
switch (this._interp.adaptivePredict(this._input, 4, this._ctx)) {
case 1:
{
this.state = 68;
this.match(OpenFGAParser.NEWLINE);
}
break;
}
this.state = 71;
this.conditions();
this.state = 73;
this._errHandler.sync(this);
_la = this._input.LA(1);
if (_la === 55) {
{
this.state = 72;
this.match(OpenFGAParser.NEWLINE);
}
}
this.state = 75;
this.match(OpenFGAParser.EOF);
}
}
catch (re) {
if (re instanceof antlr4_1.RecognitionException) {
localctx.exception = re;
this._errHandler.reportError(this, re);
this._errHandler.recover(this, re);
}
else {
throw re;
}
}
finally {
this.exitRule();
}
return localctx;
}
// @RuleVersion(0)
modelHeader() {
let localctx = new ModelHeaderContext(this, this._ctx, this.state);
this.enterRule(localctx, 2, OpenFGAParser.RULE_modelHeader);
let _la;
try {
this.enterOuterAlt(localctx, 1);
{
this.state = 80;
this._errHandler.sync(this);
_la = this._input.LA(1);
if (_la === 11) {
{
this.state = 77;
this.multiLineComment();
this.state = 78;
this.match(OpenFGAParser.NEWLINE);
}
}
this.state = 82;
this.match(OpenFGAParser.MODEL);
this.state = 83;
this.match(OpenFGAParser.NEWLINE);
this.state = 84;
this.match(OpenFGAParser.SCHEMA);
this.state = 85;
this.match(OpenFGAParser.WHITESPACE);
this.state = 86;
localctx._schemaVersion = this.match(OpenFGAParser.SCHEMA_VERSION);
this.state = 88;
this._errHandler.sync(this);
_la = this._input.LA(1);
if (_la === 9) {
{
this.state = 87;
this.match(OpenFGAParser.WHITESPACE);
}
}
}
}
catch (re) {
if (re instanceof antlr4_1.RecognitionException) {
localctx.exception = re;
this._errHandler.reportError(this, re);
this._errHandler.recover(this, re);
}
else {
throw re;
}
}
finally {
this.exitRule();
}
return localctx;
}
// @RuleVersion(0)
moduleHeader() {
let localctx = new ModuleHeaderContext(this, this._ctx, this.state);
this.enterRule(localctx, 4, OpenFGAParser.RULE_moduleHeader);
let _la;
try {
this.enterOuterAlt(localctx, 1);
{
this.state = 93;
this._errHandler.sync(this);
_la = this._input.LA(1);
if (_la === 11) {
{
this.state = 90;
this.multiLineComment();
this.state = 91;
this.match(OpenFGAParser.NEWLINE);
}
}
this.state = 95;
this.match(OpenFGAParser.MODULE);
this.state = 96;
this.match(OpenFGAParser.WHITESPACE);
this.state = 97;
localctx._moduleName = this.identifier();
this.state = 99;
this._errHandler.sync(this);
_la = this._input.LA(1);
if (_la === 9) {
{
this.state = 98;
this.match(OpenFGAParser.WHITESPACE);
}
}
}
}
catch (re) {
if (re instanceof antlr4_1.RecognitionException) {
localctx.exception = re;
this._errHandler.reportError(this, re);
this._errHandler.recover(this, re);
}
else {
throw re;
}
}
finally {
this.exitRule();
}
return localctx;
}
// @RuleVersion(0)
typeDefs() {
let localctx = new TypeDefsContext(this, this._ctx, this.state);
this.enterRule(localctx, 6, OpenFGAParser.RULE_typeDefs);
try {
let _alt;
this.enterOuterAlt(localctx, 1);
{
this.state = 104;
this._errHandler.sync(this);
_alt = this._interp.adaptivePredict(this._input, 10, this._ctx);
while (_alt !== 2 && _alt !== antlr4_1.ATN.INVALID_ALT_NUMBER) {
if (_alt === 1) {
{
{
this.state = 101;
this.typeDef();
}
}
}
this.state = 106;
this._errHandler.sync(this);
_alt = this._interp.adaptivePredict(this._input, 10, this._ctx);
}
}
}
catch (re) {
if (re instanceof antlr4_1.RecognitionException) {
localctx.exception = re;
this._errHandler.reportError(this, re);
this._errHandler.recover(this, re);
}
else {
throw re;
}
}
finally {
this.exitRule();
}
return localctx;
}
// @RuleVersion(0)
typeDef() {
let localctx = new TypeDefContext(this, this._ctx, this.state);
this.enterRule(localctx, 8, OpenFGAParser.RULE_typeDef);
let _la;
try {
let _alt;
this.enterOuterAlt(localctx, 1);
{
this.state = 109;
this._errHandler.sync(this);
switch (this._interp.adaptivePredict(this._input, 11, this._ctx)) {
case 1:
{
this.state = 107;
this.match(OpenFGAParser.NEWLINE);
this.state = 108;
this.multiLineComment();
}
break;
}
this.state = 111;
this.match(OpenFGAParser.NEWLINE);
this.state = 114;
this._errHandler.sync(this);
_la = this._input.LA(1);
if (_la === 20) {
{
this.state = 112;
this.match(OpenFGAParser.EXTEND);
this.state = 113;
this.match(OpenFGAParser.WHITESPACE);
}
}
this.state = 116;
this.match(OpenFGAParser.TYPE);
this.state = 117;
this.match(OpenFGAParser.WHITESPACE);
this.state = 118;
localctx._typeName = this.extended_identifier();
this.state = 126;
this._errHandler.sync(this);
switch (this._interp.adaptivePredict(this._input, 14, this._ctx)) {
case 1:
{
this.state = 119;
this.match(OpenFGAParser.NEWLINE);
this.state = 120;
this.match(OpenFGAParser.RELATIONS);
this.state = 122;
this._errHandler.sync(this);
_alt = 1;
do {
switch (_alt) {
case 1:
{
{
this.state = 121;
this.relationDeclaration();
}
}
break;
default:
throw new antlr4_1.NoViableAltException(this);
}
this.state = 124;
this._errHandler.sync(this);
_alt = this._interp.adaptivePredict(this._input, 13, this._ctx);
} while (_alt !== 2 && _alt !== antlr4_1.ATN.INVALID_ALT_NUMBER);
}
break;
}
}
}
catch (re) {
if (re instanceof antlr4_1.RecognitionException) {
localctx.exception = re;
this._errHandler.reportError(this, re);
this._errHandler.recover(this, re);
}
else {
throw re;
}
}
finally {
this.exitRule();
}
return localctx;
}
// @RuleVersion(0)
relationDeclaration() {
let localctx = new RelationDeclarationContext(this, this._ctx, this.state);
this.enterRule(localctx, 10, OpenFGAParser.RULE_relationDeclaration);
let _la;
try {
this.enterOuterAlt(localctx, 1);
{
this.state = 130;
this._errHandler.sync(this);
switch (this._interp.adaptivePredict(this._input, 15, this._ctx)) {
case 1:
{
this.state = 128;
this.match(OpenFGAParser.NEWLINE);
this.state = 129;
this.multiLineComment();
}
break;
}
this.state = 132;
this.match(OpenFGAParser.NEWLINE);
this.state = 133;
this.match(OpenFGAParser.DEFINE);
this.state = 134;
this.match(OpenFGAParser.WHITESPACE);
this.state = 135;
this.relationName();
this.state = 137;
this._errHandler.sync(this);
_la = this._input.LA(1);
if (_la === 9) {
{
this.state = 136;
this.match(OpenFGAParser.WHITESPACE);
}
}
this.state = 139;
this.match(OpenFGAParser.COLON);
this.state = 141;
this._errHandler.sync(this);
_la = this._input.LA(1);
if (_la === 9) {
{
this.state = 140;
this.match(OpenFGAParser.WHITESPACE);
}
}
{
this.state = 143;
this.relationDef();
}
}
}
catch (re) {
if (re instanceof antlr4_1.RecognitionException) {
localctx.exception = re;
this._errHandler.reportError(this, re);
this._errHandler.recover(this, re);
}
else {
throw re;
}
}
finally {
this.exitRule();
}
return localctx;
}
// @RuleVersion(0)
relationName() {
let localctx = new RelationNameContext(this, this._ctx, this.state);
this.enterRule(localctx, 12, OpenFGAParser.RULE_relationName);
try {
this.enterOuterAlt(localctx, 1);
{
this.state = 145;
this.extended_identifier();
}
}
catch (re) {
if (re instanceof antlr4_1.RecognitionException) {
localctx.exception = re;
this._errHandler.reportError(this, re);
this._errHandler.recover(this, re);
}
else {
throw re;
}
}
finally {
this.exitRule();
}
return localctx;
}
// @RuleVersion(0)
relationDef() {
let localctx = new RelationDefContext(this, this._ctx, this.state);
this.enterRule(localctx, 14, OpenFGAParser.RULE_relationDef);
try {
this.enterOuterAlt(localctx, 1);
{
this.state = 150;
this._errHandler.sync(this);
switch (this._input.LA(1)) {
case 5:
{
this.state = 147;
this.relationDefDirectAssignment();
}
break;
case 10:
case 16:
case 17:
case 18:
case 20:
case 21:
case 24:
case 54:
{
this.state = 148;
this.relationDefGrouping();
}
break;
case 7:
{
this.state = 149;
this.relationRecurse();
}
break;
default:
throw new antlr4_1.NoViableAltException(this);
}
this.state = 153;
this._errHandler.sync(this);
switch (this._interp.adaptivePredict(this._input, 19, this._ctx)) {
case 1:
{
this.state = 152;
this.relationDefPartials();
}
break;
}
}
}
catch (re) {
if (re instanceof antlr4_1.RecognitionException) {
localctx.exception = re;
this._errHandler.reportError(this, re);
this._errHandler.recover(this, re);
}
else {
throw re;
}
}
finally {
this.exitRule();
}
return localctx;
}
// @RuleVersion(0)
relationDefNoDirect() {
let localctx = new RelationDefNoDirectContext(this, this._ctx, this.state);
this.enterRule(localctx, 16, OpenFGAParser.RULE_relationDefNoDirect);
try {
this.enterOuterAlt(localctx, 1);
{
this.state = 157;
this._errHandler.sync(this);
switch (this._input.LA(1)) {
case 10:
case 16:
case 17:
case 18:
case 20:
case 21:
case 24:
case 54:
{
this.state = 155;
this.relationDefGrouping();
}
break;
case 7:
{
this.state = 156;
this.relationRecurseNoDirect();
}
break;
default:
throw new antlr4_1.NoViableAltException(this);
}
this.state = 160;
this._errHandler.sync(this);
switch (this._interp.adaptivePredict(this._input, 21, this._ctx)) {
case 1:
{
this.state = 159;
this.relationDefPartials();
}
break;
}
}
}
catch (re) {
if (re instanceof antlr4_1.RecognitionException) {
localctx.exception = re;
this._errHandler.reportError(this, re);
this._errHandler.recover(this, re);
}
else {
throw re;
}
}
finally {
this.exitRule();
}
return localctx;
}
// @RuleVersion(0)
relationDefPartials() {
let localctx = new RelationDefPartialsContext(this, this._ctx, this.state);
this.enterRule(localctx, 18, OpenFGAParser.RULE_relationDefPartials);
try {
let _alt;
this.state = 191;
this._errHandler.sync(this);
switch (this._interp.adaptivePredict(this._input, 27, this._ctx)) {
case 1:
this.enterOuterAlt(localctx, 1);
{
this.state = 169;
this._errHandler.sync(this);
_alt = 1;
do {
switch (_alt) {
case 1:
{
{
this.state = 162;
this.match(OpenFGAParser.WHITESPACE);
this.state = 163;
this.match(OpenFGAParser.OR);
this.state = 164;
this.match(OpenFGAParser.WHITESPACE);
this.state = 167;
this._errHandler.sync(this);
switch (this._input.LA(1)) {
case 10:
case 16:
case 17:
case 18:
case 20:
case 21:
case 24:
case 54:
{
this.state = 165;
this.relationDefGrouping();
}
break;
case 7:
{
this.state = 166;
this.relationRecurseNoDirect();
}
break;
default:
throw new antlr4_1.NoViableAltException(this);
}
}
}
break;
default:
throw new antlr4_1.NoViableAltException(this);
}
this.state = 171;
this._errHandler.sync(this);
_alt = this._interp.adaptivePredict(this._input, 23, this._ctx);
} while (_alt !== 2 && _alt !== antlr4_1.ATN.INVALID_ALT_NUMBER);
}
break;
case 2:
this.enterOuterAlt(localctx, 2);
{
this.state = 180;
this._errHandler.sync(this);
_alt = 1;
do {
switch (_alt) {
case 1:
{
{
this.state = 173;
this.match(OpenFGAParser.WHITESPACE);
this.state = 174;
this.match(OpenFGAParser.AND);
this.state = 175;
this.match(OpenFGAParser.WHITESPACE);
this.state = 178;
this._errHandler.sync(this);
switch (this._input.LA(1)) {
case 10:
case 16:
case 17:
case 18:
case 20:
case 21:
case 24:
case 54:
{
this.state = 176;
this.relationDefGrouping();
}
break;
case 7:
{
this.state = 177;
this.relationRecurseNoDirect();
}
break;
default:
throw new antlr4_1.NoViableAltException(this);
}
}
}
break;
default:
throw new antlr4_1.NoViableAltException(this);
}
this.state = 182;
this._errHandler.sync(this);
_alt = this._interp.adaptivePredict(this._input, 25, this._ctx);
} while (_alt !== 2 && _alt !== antlr4_1.ATN.INVALID_ALT_NUMBER);
}
break;
case 3:
this.enterOuterAlt(localctx, 3);
{
{
this.state = 184;
this.match(OpenFGAParser.WHITESPACE);
this.state = 185;
this.match(OpenFGAParser.BUT_NOT);
this.state = 186;
this.match(OpenFGAParser.WHITESPACE);
this.state = 189;
this._errHandler.sync(this);
switch (this._input.LA(1)) {
case 10:
case 16:
case 17:
case 18:
case 20:
case 21:
case 24:
case 54:
{
this.state = 187;
this.relationDefGrouping();
}
break;
case 7:
{
this.state = 188;
this.relationRecurseNoDirect();
}
break;
default:
throw new antlr4_1.NoViableAltException(this);
}
}
}
break;
}
}
catch (re) {
if (re instanceof antlr4_1.RecognitionException) {
localctx.exception = re;
this._errHandler.reportError(this, re);
this._errHandler.recover(this, re);
}
else {
throw re;
}
}
finally {
this.exitRule();
}
return localctx;
}
// @RuleVersion(0)
relationDefGrouping() {
let localctx = new RelationDefGroupingContext(this, this._ctx, this.state);
this.enterRule(localctx, 20, OpenFGAParser.RULE_relationDefGrouping);
try {
this.enterOuterAlt(localctx, 1);
{
this.state = 193;
this.relationDefRewrite();
}
}
catch (re) {
if (re instanceof antlr4_1.RecognitionException) {
localctx.exception = re;
this._errHandler.reportError(this, re);
this._errHandler.recover(this, re);
}
else {
throw re;
}
}
finally {
this.exitRule();
}
return localctx;
}
// @RuleVersion(0)
relationRecurse() {
let localctx = new RelationRecurseContext(this, this._ctx, this.state);
this.enterRule(localctx, 22, OpenFGAParser.RULE_relationRecurse);
let _la;
try {
this.enterOuterAlt(localctx, 1);
{
this.state = 195;
this.match(OpenFGAParser.LPAREN);
this.state = 199;
this._errHandler.sync(this);
_la = this._input.LA(1);
while (_la === 9) {
{
{
this.state = 196;
this.match(OpenFGAParser.WHITESPACE);
}
}
this.state = 201;
this._errHandler.sync(this);
_la = this._input.LA(1);
}
this.state = 204;
this._errHandler.sync(this);
switch (this._interp.adaptivePredict(this._input, 29, this._ctx)) {
case 1:
{
this.state = 202;
this.relationDef();
}
break;
case 2:
{
this.state = 203;
this.relationRecurseNoDirect();
}
break;
}
this.state = 209;
this._errHandler.sync(this);
_la = this._input.LA(1);
while (_la === 9) {
{
{
this.state = 206;
this.match(OpenFGAParser.WHITESPACE);
}
}
this.state = 211;
this._errHandler.sync(this);
_la = this._input.LA(1);
}
this.state = 212;
this.match(OpenFGAParser.RPAREN);
}
}
catch (re) {
if (re instanceof antlr4_1.RecognitionException) {
localctx.exception = re;
this._errHandler.reportError(this, re);
this._errHandler.recover(this, re);
}
else {
throw re;
}
}
finally {
this.exitRule();
}
return localctx;
}
// @RuleVersion(0)
relationRecurseNoDirect() {
let localctx = new RelationRecurseNoDirectContext(this, this._ctx, this.state);
this.enterRule(localctx, 24, OpenFGAParser.RULE_relationRecurseNoDirect);
let _la;
try {
this.enterOuterAlt(localctx, 1);
{
this.state = 214;
this.match(OpenFGAParser.LPAREN);
this.state = 218;
this._errHandler.sync(this);
_la = this._input.LA(1);
while (_la === 9) {
{
{
this.state = 215;
this.match(OpenFGAParser.WHITESPACE);
}
}
this.state = 220;
this._errHandler.sync(this);
_la = this._input.LA(1);
}
this.state = 223;
this._errHandler.sync(this);
switch (this._interp.adaptivePredict(this._input, 32, this._ctx)) {
case 1:
{
this.state = 221;
this.relationDefNoDirect();
}
break;
case 2:
{
this.state = 222;
this.relationRecurseNoDirect();
}
break;
}
this.state = 228;
this._errHandler.sync(this);
_la = this._input.LA(1);
while (_la === 9) {
{
{
this.state = 225;
this.match(OpenFGAParser.WHITESPACE);
}
}
this.state = 230;
this._errHandler.sync(this);
_la = this._input.LA(1);
}
this.state = 231;
this.match(OpenFGAParser.RPAREN);
}
}
catch (re) {
if (re instanceof antlr4_1.RecognitionException) {
localctx.exception = re;
this._errHandler.reportError(this, re);
this._errHandler.recover(this, re);
}
else {
throw re;
}
}
finally {
this.exitRule();
}
return localctx;
}
// @RuleVersion(0)
relationDefDirectAssignment() {
let localctx = new RelationDefDirectAssignmentContext(this, this._ctx, this.state);
this.enterRule(localctx, 26, OpenFGAParser.RULE_relationDefDirectAssignment);
let _la;
try {
this.enterOuterAlt(localctx, 1);
{
this.state = 233;
this.match(OpenFGAParser.LBRACKET);
this.state = 235;
this._errHandler.sync(this);
_la = this._input.LA(1);
if (_la === 9) {
{
this.state = 234;
this.match(OpenFGAParser.WHITESPACE);
}
}
this.state = 237;
this.relationDefTypeRestriction();
this.state = 239;
this._errHandler.sync(this);
_la = this._input.LA(1);
if (_la === 9) {
{
this.state = 238;
this.match(OpenFGAParser.WHITESPACE);
}
}
this.state = 251;
this._errHandler.sync(this);
_la = this._input.LA(1);
while (_la === 2) {
{
{
this.state = 241;
this.match(OpenFGAParser.COMMA);
this.state = 243;
this._errHandler.sync(this);
_la = this._input.LA(1);
if (_la === 9) {
{
this.state = 242;
this.match(OpenFGAParser.WHITESPACE);
}
}
this.state = 245;
this.relationDefTypeRestriction();
this.state = 247;
this._errHandler.sync(this);
_la = this._input.LA(1);
if (_la === 9) {
{
this.state = 246;
this.match(OpenFGAParser.WHITESPACE);
}
}
}
}
this.state = 253;
this._errHandler.sync(this);
_la = this._input.LA(1);
}
this.state = 254;
this.match(OpenFGAParser.RPRACKET);
}
}
catch (re) {
if (re instanceof antlr4_1.RecognitionException) {
localctx.exception = re;
this._errHandler.reportError(this, re);
this._errHandler.recover(this, re);
}
else {
throw re;
}
}
finally {
this.exitRule();
}
return localctx;
}
// @RuleVersion(0)
relationDefRewrite() {
let localctx = new RelationDefRewriteContext(this, this._ctx, this.state);
this.enterRule(localctx, 28, OpenFGAParser.RULE_relationDefRewrite);
try {
this.enterOuterAlt(localctx, 1);
{
this.state = 256;
localctx._rewriteComputedusersetName = this.extended_identifier();
this.state = 261;
this._errHandler.sync(this);
switch (this._interp.adaptivePredict(this._input, 39, this._ctx)) {
case 1:
{
this.state = 257;
this.match(OpenFGAParser.WHITESPACE);
this.state = 258;
this.match(OpenFGAParser.FROM);
this.state = 259;
this.match(OpenFGAParser.WHITESPACE);
this.state = 260;
localctx._rewriteTuplesetName = this.extended_identifier();
}
break;
}
}
}
catch (re) {
if (re instanceof antlr4_1.RecognitionException) {
localctx.exception = re;
this._errHandler.reportError(this, re);
this._errHandler.recover(this, re);
}
else {
throw re;
}
}
finally {
this.exitRule();
}
return localctx;
}
// @RuleVersion(0)
relationDefTypeRestriction() {
let localctx = new RelationDefTypeRestrictionContext(this, this._ctx, this.state);
this.enterRule(localctx, 30, OpenFGAParser.RULE_relationDefTypeRestriction);
let _la;
try {
this.enterOuterAlt(localctx, 1);
{
this.state = 264;
this._errHandler.sync(this);
_la = this._input.LA(1);
if (_la === 55) {
{
this.state = 263;
this.match(OpenFGAParser.NEWLINE);
}
}
this.state = 273;
this._errHandler.sync(this);
switch (this._interp.adaptivePredict(this._input, 41, this._ctx)) {
case 1:
{
this.state = 266;
this.relationDefTypeRestrictionBase();
}
break;
case 2:
{
{
this.state = 267;
this.relationDefTypeRestrictionBase();
this.state = 268;
this.match(OpenFGAParser.WHITESPACE);
this.state = 269;
this.match(OpenFGAParser.KEYWORD_WITH);
this.state = 270;
this.match(OpenFGAParser.WHITESPACE);
this.state = 271;
this.conditionName();
}
}
break;
}
this.state = 276;
this._errHandler.sync(this);
_la = this._input.LA(1);
if (_la === 55) {
{
this.state = 275;
this.match(OpenFGAParser.NEWLINE);
}
}
}
}
catch (re) {
if (re instanceof antlr4_1.RecognitionException) {
localctx.exception = re;
this._errHandler.reportError(this, re);
this._errHandler.recover(this, re);
}
else {
throw re;
}
}
finally {
this.exitRule();
}
return localctx;
}
// @RuleVersion(0)
relationDefTypeRestrictionBase() {
let localctx = new RelationDefTypeRestrictionBaseContext(this, this._ctx, this.state);
this.enterRule(localctx, 32, OpenFGAParser.RULE_relationDefTypeRestrictionBase);
try {
this.enterOuterAlt(localctx, 1);
{
this.state = 278;
localctx._relationDefTypeRestrictionType = this.extended_identifier();
this.state = 283;
this._errHandler.sync(this);
switch (this._input.LA(1)) {
case 1:
{
{
this.state = 279;
this.match(OpenFGAParser.COLON);
this.state = 280;
localctx._relationDefTypeRestrictionWildcard = this.match(OpenFGAParser.STAR);
}
}
break;
case 11:
{
{
this.state = 281;
this.match(OpenFGAParser.HASH);
this.state = 282;
localctx._relationDefTypeRestrictionRelation = this.extended_identifier();
}
}
break;
case 2:
case 9:
case 34:
case 55:
break;
default:
break;
}
}
}
catch (re) {
if (re instanceof antlr4_1.RecognitionException) {
localctx.exception = re;
this._errHandler.reportError(this, re);
this._errHandler.recover(this, re);
}
else {
throw re;
}
}
finally {
this.exitRule();
}
return localctx;
}
// @RuleVersion(0)
conditions() {
let localctx = new ConditionsContext(this, this._ctx, this.state);
this.enterRule(localctx, 34, OpenFGAParser.RULE_conditions);
try {
let _alt;
this.enterOuterAlt(localctx, 1);
{
this.state = 288;
this._errHandler.sync(this);
_alt = this._interp.adaptivePredict(this._input, 44, this._ctx);
while (_alt !== 2 && _alt !== antlr4_1.ATN.INVALID_ALT_NUMBER) {
if (_alt === 1) {
{
{
this.state = 285;
this.condition();
}
}
}
this.state = 290;
this._errHandler.sync(this);
_alt = this._interp.adaptivePredict(this._input, 44, this._ctx);
}
}
}
catch (re) {
if (re instanceof antlr4_1.RecognitionException) {
localctx.exception = re;
this._errHandler.reportError(this, re);
this._errHandler.recover(this, re);
}
else {
throw re;
}
}
finally {
this.exitRule();
}
return localctx;
}
// @RuleVersion(0)
condition() {
let localctx = new ConditionContext(this, this._ctx, this.state);
this.enterRule(localctx, 36, OpenFGAParser.RULE_condition);
let _la;
try {
this.enterOuterAlt(localctx, 1);
{
this.state = 293;
this._errHandler.sync(this);
switch (this._interp.adaptivePredict(this._input, 45, this._ctx)) {
case 1:
{
this.state = 291;
this.match(OpenFGAParser.NEWLINE);
this.state = 292;
this.multiLineComment();
}
break;
}
this.state = 295;
this.match(OpenFGAParser.NEWLINE);
this.state = 296;
this.match(OpenFGAParser.CONDITION);
this.state = 297;
this.match(OpenFGAParser.WHITESPACE);
this.state = 298;
this.conditionName();
this.state = 300;
this._errHandler.sync(this);
_la = this._input.LA(1);
if (_la === 9) {
{
this.state = 299;
this.match(OpenFGAParser.WHITESPACE);
}
}
this.state = 302;
this.match(OpenFGAParser.LPAREN);
this.state = 304;
this._errHandler.sync(this);
_la = this._input.LA(1);
if (_la === 9) {
{
this.state = 303;
this.match(OpenFGAParser.WHITESPACE);
}
}
this.state = 306;
this.conditionParameter();
this.state = 308;
this._errHandler.sync(this);
_la = this._input.LA(1);
if (_la === 9) {
{
this.state = 307;
this.match(OpenFGAParser.WHITESPACE);
}
}
this.state = 320;
this._errHandler.sync(this);
_la = this._input.LA(1);
while (_la === 2) {
{
{
this.state = 310;
this.match(OpenFGAParser.COMMA);
this.state = 312;
this._errHandler.sync(this);
_la = this._input.LA(1);
if (_la === 9) {
{
this.state = 311;
this.match(OpenFGAParser.WHITESPACE);
}
}
this.state = 314;
this.conditionParameter();
this.state = 316;
this._errHandler.sync(this);
_la = this._input.LA(1);
if (_la === 9) {
{
this.state = 315;
this.match(OpenFGAParser.WHITESPACE);
}
}
}
}
this.state = 322;
this._errHandler.sync(this);
_la = this._input.LA(1);
}
this.state = 324;
this._errHandler.sync(this);