From 4c5c8364c0fba06e878572dc9b3b1c4d5dae8e85 Mon Sep 17 00:00:00 2001 From: FHIR Team Date: Thu, 28 Mar 2024 15:49:48 -0700 Subject: [PATCH] Automated Code Change PiperOrigin-RevId: 620080105 --- bazel/go_dependencies.bzl | 6 + cc/google/fhir/fhir_path/BUILD | 8 +- examples/bulkdata/BUILD | 3 +- examples/profiles/BUILD | 6 +- go/fhirpath/BUILD | 15 + go/fhirpath/gen/BUILD | 23 + go/fhirpath/gen/doc.go | 16 + go/fhirpath/gen/fhirpath_base_listener.go | 267 + go/fhirpath/gen/fhirpath_base_visitor.go | 172 + go/fhirpath/gen/fhirpath_lexer.go | 410 ++ go/fhirpath/gen/fhirpath_listener.go | 255 + go/fhirpath/gen/fhirpath_parser.go | 4483 +++++++++++++++++ go/fhirpath/gen/fhirpath_visitor.go | 132 + go/fhirpath/visitor.go | 70 + go/go.mod | 3 +- go/go.sum | 6 +- go/jsonformat/internal/accessor/BUILD | 2 +- go/jsonformat/internal/protopath/BUILD | 2 +- .../internal/protopath/proto_path.go | 35 +- .../internal/protopath/proto_path_test.go | 81 + testdata/r4/profiles/split/BUILD | 2 +- 21 files changed, 5970 insertions(+), 27 deletions(-) create mode 100644 go/fhirpath/BUILD create mode 100644 go/fhirpath/gen/BUILD create mode 100644 go/fhirpath/gen/doc.go create mode 100755 go/fhirpath/gen/fhirpath_base_listener.go create mode 100755 go/fhirpath/gen/fhirpath_base_visitor.go create mode 100755 go/fhirpath/gen/fhirpath_lexer.go create mode 100755 go/fhirpath/gen/fhirpath_listener.go create mode 100755 go/fhirpath/gen/fhirpath_parser.go create mode 100755 go/fhirpath/gen/fhirpath_visitor.go create mode 100644 go/fhirpath/visitor.go diff --git a/bazel/go_dependencies.bzl b/bazel/go_dependencies.bzl index af690d6d8..b4a74b118 100644 --- a/bazel/go_dependencies.bzl +++ b/bazel/go_dependencies.bzl @@ -208,3 +208,9 @@ def fhir_go_dependencies(): sum = "h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=", version = "v0.0.0-20191204190536-9bdfabe68543", ) + go_repository( + name = "com_github_antrl4_go_antlr", + importpath = "github.com/antlr4-go/antlr/v4", + sum = "h1:lxCg3LAv+EUK6t1i0y1V6/SLeUi0eKEKdhQAlS8TVTI=", + version = "v4.13.0", + ) diff --git a/cc/google/fhir/fhir_path/BUILD b/cc/google/fhir/fhir_path/BUILD index badf6ce95..1ca830798 100644 --- a/cc/google/fhir/fhir_path/BUILD +++ b/cc/google/fhir/fhir_path/BUILD @@ -120,9 +120,7 @@ cc_library( "fhir_path_types.h", ], strip_include_prefix = "//cc/", - visibility = [ - "//visibility:private", # Only private by automation, not intent. Owner may accept CLs adding visibility. See go/scheuklappen#explicit-private. - ], + visibility = ["//visibility:private"], deps = [ "//cc/google/fhir:annotations", "//cc/google/fhir:fhir_types", @@ -143,9 +141,7 @@ cc_library( "utils.h", ], strip_include_prefix = "//cc/", - visibility = [ - "//visibility:private", # Only private by automation, not intent. Owner may accept CLs adding visibility. See go/scheuklappen#explicit-private. - ], + visibility = ["//visibility:private"], deps = [ "//cc/google/fhir:annotations", "//cc/google/fhir:references", diff --git a/examples/bulkdata/BUILD b/examples/bulkdata/BUILD index 43929d1ea..84254cd25 100644 --- a/examples/bulkdata/BUILD +++ b/examples/bulkdata/BUILD @@ -1,9 +1,10 @@ +load("@fhir_bazel_pip_dependencies//:requirements.bzl", "requirement") + # Simple client to download data from FHIR server (using bulk data protocol) load( "@rules_python//python:python.bzl", "py_binary", ) -load("@fhir_bazel_pip_dependencies//:requirements.bzl", "requirement") licenses(["notice"]) diff --git a/examples/profiles/BUILD b/examples/profiles/BUILD index 929c22066..7ea6c01d2 100644 --- a/examples/profiles/BUILD +++ b/examples/profiles/BUILD @@ -1,10 +1,10 @@ +load("//bazel:proto.bzl", "fhir_proto_library") +load("//bazel:protogen.bzl", "gen_fhir_definitions_and_protos") + package(default_visibility = ["//visibility:public"]) licenses(["notice"]) -load("//bazel:protogen.bzl", "gen_fhir_definitions_and_protos") -load("//bazel:proto.bzl", "fhir_proto_library") - gen_fhir_definitions_and_protos( name = "demo", additional_proto_imports = [ diff --git a/go/fhirpath/BUILD b/go/fhirpath/BUILD new file mode 100644 index 000000000..924ff8383 --- /dev/null +++ b/go/fhirpath/BUILD @@ -0,0 +1,15 @@ +load("@io_bazel_rules_go//go:def.bzl", "go_library") + +licenses(["notice"]) + +package(default_visibility = ["//visibility:public"]) + +go_library( + name = "fhirpath", + srcs = ["visitor.go"], + importpath = "github.com/google/fhir/go/fhirpath", + deps = [ + "//go/fhirpath/gen", + "@com_github_antrl4_go_antlr//:go_default_library", + ], +) diff --git a/go/fhirpath/gen/BUILD b/go/fhirpath/gen/BUILD new file mode 100644 index 000000000..2b5bb0ae9 --- /dev/null +++ b/go/fhirpath/gen/BUILD @@ -0,0 +1,23 @@ +load("@io_bazel_rules_go//go:def.bzl", "go_library") + +licenses(["notice"]) + +package(default_visibility = ["//visibility:public"]) + +go_library( + name = "gen", + srcs = [ + "doc.go", + "fhirpath_base_listener.go", + "fhirpath_base_visitor.go", + "fhirpath_lexer.go", + "fhirpath_listener.go", + "fhirpath_parser.go", + "fhirpath_visitor.go", + ], + importpath = "github.com/google/fhir/go/fhirpath/gen", + visibility = [ + "//go/fhirpath:__subpackages__", + ], + deps = ["@com_github_antrl4_go_antlr//:go_default_library"], +) diff --git a/go/fhirpath/gen/doc.go b/go/fhirpath/gen/doc.go new file mode 100644 index 000000000..0112985ef --- /dev/null +++ b/go/fhirpath/gen/doc.go @@ -0,0 +1,16 @@ +// Copyright 2024 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Package gen is a FHIRPath parser and lexer generated by Antlr. Do not modify the code in this package +package gen diff --git a/go/fhirpath/gen/fhirpath_base_listener.go b/go/fhirpath/gen/fhirpath_base_listener.go new file mode 100755 index 000000000..b722d990b --- /dev/null +++ b/go/fhirpath/gen/fhirpath_base_listener.go @@ -0,0 +1,267 @@ +// Code generated from FhirPath.g4 by ANTLR 4.13.1. DO NOT EDIT. + +package gen // FhirPath +import "github.com/antlr4-go/antlr/v4" + +// BaseFhirPathListener is a complete listener for a parse tree produced by FhirPathParser. +type BaseFhirPathListener struct{} + +var _ FhirPathListener = &BaseFhirPathListener{} + +// VisitTerminal is called when a terminal node is visited. +func (s *BaseFhirPathListener) VisitTerminal(node antlr.TerminalNode) {} + +// VisitErrorNode is called when an error node is visited. +func (s *BaseFhirPathListener) VisitErrorNode(node antlr.ErrorNode) {} + +// EnterEveryRule is called when any rule is entered. +func (s *BaseFhirPathListener) EnterEveryRule(ctx antlr.ParserRuleContext) {} + +// ExitEveryRule is called when any rule is exited. +func (s *BaseFhirPathListener) ExitEveryRule(ctx antlr.ParserRuleContext) {} + +// EnterIndexerExpression is called when production indexerExpression is entered. +func (s *BaseFhirPathListener) EnterIndexerExpression(ctx *IndexerExpressionContext) {} + +// ExitIndexerExpression is called when production indexerExpression is exited. +func (s *BaseFhirPathListener) ExitIndexerExpression(ctx *IndexerExpressionContext) {} + +// EnterPolarityExpression is called when production polarityExpression is entered. +func (s *BaseFhirPathListener) EnterPolarityExpression(ctx *PolarityExpressionContext) {} + +// ExitPolarityExpression is called when production polarityExpression is exited. +func (s *BaseFhirPathListener) ExitPolarityExpression(ctx *PolarityExpressionContext) {} + +// EnterAdditiveExpression is called when production additiveExpression is entered. +func (s *BaseFhirPathListener) EnterAdditiveExpression(ctx *AdditiveExpressionContext) {} + +// ExitAdditiveExpression is called when production additiveExpression is exited. +func (s *BaseFhirPathListener) ExitAdditiveExpression(ctx *AdditiveExpressionContext) {} + +// EnterMultiplicativeExpression is called when production multiplicativeExpression is entered. +func (s *BaseFhirPathListener) EnterMultiplicativeExpression(ctx *MultiplicativeExpressionContext) {} + +// ExitMultiplicativeExpression is called when production multiplicativeExpression is exited. +func (s *BaseFhirPathListener) ExitMultiplicativeExpression(ctx *MultiplicativeExpressionContext) {} + +// EnterUnionExpression is called when production unionExpression is entered. +func (s *BaseFhirPathListener) EnterUnionExpression(ctx *UnionExpressionContext) {} + +// ExitUnionExpression is called when production unionExpression is exited. +func (s *BaseFhirPathListener) ExitUnionExpression(ctx *UnionExpressionContext) {} + +// EnterOrExpression is called when production orExpression is entered. +func (s *BaseFhirPathListener) EnterOrExpression(ctx *OrExpressionContext) {} + +// ExitOrExpression is called when production orExpression is exited. +func (s *BaseFhirPathListener) ExitOrExpression(ctx *OrExpressionContext) {} + +// EnterAndExpression is called when production andExpression is entered. +func (s *BaseFhirPathListener) EnterAndExpression(ctx *AndExpressionContext) {} + +// ExitAndExpression is called when production andExpression is exited. +func (s *BaseFhirPathListener) ExitAndExpression(ctx *AndExpressionContext) {} + +// EnterMembershipExpression is called when production membershipExpression is entered. +func (s *BaseFhirPathListener) EnterMembershipExpression(ctx *MembershipExpressionContext) {} + +// ExitMembershipExpression is called when production membershipExpression is exited. +func (s *BaseFhirPathListener) ExitMembershipExpression(ctx *MembershipExpressionContext) {} + +// EnterInequalityExpression is called when production inequalityExpression is entered. +func (s *BaseFhirPathListener) EnterInequalityExpression(ctx *InequalityExpressionContext) {} + +// ExitInequalityExpression is called when production inequalityExpression is exited. +func (s *BaseFhirPathListener) ExitInequalityExpression(ctx *InequalityExpressionContext) {} + +// EnterInvocationExpression is called when production invocationExpression is entered. +func (s *BaseFhirPathListener) EnterInvocationExpression(ctx *InvocationExpressionContext) {} + +// ExitInvocationExpression is called when production invocationExpression is exited. +func (s *BaseFhirPathListener) ExitInvocationExpression(ctx *InvocationExpressionContext) {} + +// EnterEqualityExpression is called when production equalityExpression is entered. +func (s *BaseFhirPathListener) EnterEqualityExpression(ctx *EqualityExpressionContext) {} + +// ExitEqualityExpression is called when production equalityExpression is exited. +func (s *BaseFhirPathListener) ExitEqualityExpression(ctx *EqualityExpressionContext) {} + +// EnterImpliesExpression is called when production impliesExpression is entered. +func (s *BaseFhirPathListener) EnterImpliesExpression(ctx *ImpliesExpressionContext) {} + +// ExitImpliesExpression is called when production impliesExpression is exited. +func (s *BaseFhirPathListener) ExitImpliesExpression(ctx *ImpliesExpressionContext) {} + +// EnterTermExpression is called when production termExpression is entered. +func (s *BaseFhirPathListener) EnterTermExpression(ctx *TermExpressionContext) {} + +// ExitTermExpression is called when production termExpression is exited. +func (s *BaseFhirPathListener) ExitTermExpression(ctx *TermExpressionContext) {} + +// EnterTypeExpression is called when production typeExpression is entered. +func (s *BaseFhirPathListener) EnterTypeExpression(ctx *TypeExpressionContext) {} + +// ExitTypeExpression is called when production typeExpression is exited. +func (s *BaseFhirPathListener) ExitTypeExpression(ctx *TypeExpressionContext) {} + +// EnterInvocationTerm is called when production invocationTerm is entered. +func (s *BaseFhirPathListener) EnterInvocationTerm(ctx *InvocationTermContext) {} + +// ExitInvocationTerm is called when production invocationTerm is exited. +func (s *BaseFhirPathListener) ExitInvocationTerm(ctx *InvocationTermContext) {} + +// EnterLiteralTerm is called when production literalTerm is entered. +func (s *BaseFhirPathListener) EnterLiteralTerm(ctx *LiteralTermContext) {} + +// ExitLiteralTerm is called when production literalTerm is exited. +func (s *BaseFhirPathListener) ExitLiteralTerm(ctx *LiteralTermContext) {} + +// EnterExternalConstantTerm is called when production externalConstantTerm is entered. +func (s *BaseFhirPathListener) EnterExternalConstantTerm(ctx *ExternalConstantTermContext) {} + +// ExitExternalConstantTerm is called when production externalConstantTerm is exited. +func (s *BaseFhirPathListener) ExitExternalConstantTerm(ctx *ExternalConstantTermContext) {} + +// EnterParenthesizedTerm is called when production parenthesizedTerm is entered. +func (s *BaseFhirPathListener) EnterParenthesizedTerm(ctx *ParenthesizedTermContext) {} + +// ExitParenthesizedTerm is called when production parenthesizedTerm is exited. +func (s *BaseFhirPathListener) ExitParenthesizedTerm(ctx *ParenthesizedTermContext) {} + +// EnterNullLiteral is called when production nullLiteral is entered. +func (s *BaseFhirPathListener) EnterNullLiteral(ctx *NullLiteralContext) {} + +// ExitNullLiteral is called when production nullLiteral is exited. +func (s *BaseFhirPathListener) ExitNullLiteral(ctx *NullLiteralContext) {} + +// EnterBooleanLiteral is called when production booleanLiteral is entered. +func (s *BaseFhirPathListener) EnterBooleanLiteral(ctx *BooleanLiteralContext) {} + +// ExitBooleanLiteral is called when production booleanLiteral is exited. +func (s *BaseFhirPathListener) ExitBooleanLiteral(ctx *BooleanLiteralContext) {} + +// EnterStringLiteral is called when production stringLiteral is entered. +func (s *BaseFhirPathListener) EnterStringLiteral(ctx *StringLiteralContext) {} + +// ExitStringLiteral is called when production stringLiteral is exited. +func (s *BaseFhirPathListener) ExitStringLiteral(ctx *StringLiteralContext) {} + +// EnterNumberLiteral is called when production numberLiteral is entered. +func (s *BaseFhirPathListener) EnterNumberLiteral(ctx *NumberLiteralContext) {} + +// ExitNumberLiteral is called when production numberLiteral is exited. +func (s *BaseFhirPathListener) ExitNumberLiteral(ctx *NumberLiteralContext) {} + +// EnterDateLiteral is called when production dateLiteral is entered. +func (s *BaseFhirPathListener) EnterDateLiteral(ctx *DateLiteralContext) {} + +// ExitDateLiteral is called when production dateLiteral is exited. +func (s *BaseFhirPathListener) ExitDateLiteral(ctx *DateLiteralContext) {} + +// EnterDateTimeLiteral is called when production dateTimeLiteral is entered. +func (s *BaseFhirPathListener) EnterDateTimeLiteral(ctx *DateTimeLiteralContext) {} + +// ExitDateTimeLiteral is called when production dateTimeLiteral is exited. +func (s *BaseFhirPathListener) ExitDateTimeLiteral(ctx *DateTimeLiteralContext) {} + +// EnterTimeLiteral is called when production timeLiteral is entered. +func (s *BaseFhirPathListener) EnterTimeLiteral(ctx *TimeLiteralContext) {} + +// ExitTimeLiteral is called when production timeLiteral is exited. +func (s *BaseFhirPathListener) ExitTimeLiteral(ctx *TimeLiteralContext) {} + +// EnterQuantityLiteral is called when production quantityLiteral is entered. +func (s *BaseFhirPathListener) EnterQuantityLiteral(ctx *QuantityLiteralContext) {} + +// ExitQuantityLiteral is called when production quantityLiteral is exited. +func (s *BaseFhirPathListener) ExitQuantityLiteral(ctx *QuantityLiteralContext) {} + +// EnterExternalConstant is called when production externalConstant is entered. +func (s *BaseFhirPathListener) EnterExternalConstant(ctx *ExternalConstantContext) {} + +// ExitExternalConstant is called when production externalConstant is exited. +func (s *BaseFhirPathListener) ExitExternalConstant(ctx *ExternalConstantContext) {} + +// EnterMemberInvocation is called when production memberInvocation is entered. +func (s *BaseFhirPathListener) EnterMemberInvocation(ctx *MemberInvocationContext) {} + +// ExitMemberInvocation is called when production memberInvocation is exited. +func (s *BaseFhirPathListener) ExitMemberInvocation(ctx *MemberInvocationContext) {} + +// EnterFunctionInvocation is called when production functionInvocation is entered. +func (s *BaseFhirPathListener) EnterFunctionInvocation(ctx *FunctionInvocationContext) {} + +// ExitFunctionInvocation is called when production functionInvocation is exited. +func (s *BaseFhirPathListener) ExitFunctionInvocation(ctx *FunctionInvocationContext) {} + +// EnterThisInvocation is called when production thisInvocation is entered. +func (s *BaseFhirPathListener) EnterThisInvocation(ctx *ThisInvocationContext) {} + +// ExitThisInvocation is called when production thisInvocation is exited. +func (s *BaseFhirPathListener) ExitThisInvocation(ctx *ThisInvocationContext) {} + +// EnterIndexInvocation is called when production indexInvocation is entered. +func (s *BaseFhirPathListener) EnterIndexInvocation(ctx *IndexInvocationContext) {} + +// ExitIndexInvocation is called when production indexInvocation is exited. +func (s *BaseFhirPathListener) ExitIndexInvocation(ctx *IndexInvocationContext) {} + +// EnterTotalInvocation is called when production totalInvocation is entered. +func (s *BaseFhirPathListener) EnterTotalInvocation(ctx *TotalInvocationContext) {} + +// ExitTotalInvocation is called when production totalInvocation is exited. +func (s *BaseFhirPathListener) ExitTotalInvocation(ctx *TotalInvocationContext) {} + +// EnterFunction is called when production function is entered. +func (s *BaseFhirPathListener) EnterFunction(ctx *FunctionContext) {} + +// ExitFunction is called when production function is exited. +func (s *BaseFhirPathListener) ExitFunction(ctx *FunctionContext) {} + +// EnterParamList is called when production paramList is entered. +func (s *BaseFhirPathListener) EnterParamList(ctx *ParamListContext) {} + +// ExitParamList is called when production paramList is exited. +func (s *BaseFhirPathListener) ExitParamList(ctx *ParamListContext) {} + +// EnterQuantity is called when production quantity is entered. +func (s *BaseFhirPathListener) EnterQuantity(ctx *QuantityContext) {} + +// ExitQuantity is called when production quantity is exited. +func (s *BaseFhirPathListener) ExitQuantity(ctx *QuantityContext) {} + +// EnterUnit is called when production unit is entered. +func (s *BaseFhirPathListener) EnterUnit(ctx *UnitContext) {} + +// ExitUnit is called when production unit is exited. +func (s *BaseFhirPathListener) ExitUnit(ctx *UnitContext) {} + +// EnterDateTimePrecision is called when production dateTimePrecision is entered. +func (s *BaseFhirPathListener) EnterDateTimePrecision(ctx *DateTimePrecisionContext) {} + +// ExitDateTimePrecision is called when production dateTimePrecision is exited. +func (s *BaseFhirPathListener) ExitDateTimePrecision(ctx *DateTimePrecisionContext) {} + +// EnterPluralDateTimePrecision is called when production pluralDateTimePrecision is entered. +func (s *BaseFhirPathListener) EnterPluralDateTimePrecision(ctx *PluralDateTimePrecisionContext) {} + +// ExitPluralDateTimePrecision is called when production pluralDateTimePrecision is exited. +func (s *BaseFhirPathListener) ExitPluralDateTimePrecision(ctx *PluralDateTimePrecisionContext) {} + +// EnterTypeSpecifier is called when production typeSpecifier is entered. +func (s *BaseFhirPathListener) EnterTypeSpecifier(ctx *TypeSpecifierContext) {} + +// ExitTypeSpecifier is called when production typeSpecifier is exited. +func (s *BaseFhirPathListener) ExitTypeSpecifier(ctx *TypeSpecifierContext) {} + +// EnterQualifiedIdentifier is called when production qualifiedIdentifier is entered. +func (s *BaseFhirPathListener) EnterQualifiedIdentifier(ctx *QualifiedIdentifierContext) {} + +// ExitQualifiedIdentifier is called when production qualifiedIdentifier is exited. +func (s *BaseFhirPathListener) ExitQualifiedIdentifier(ctx *QualifiedIdentifierContext) {} + +// EnterIdentifier is called when production identifier is entered. +func (s *BaseFhirPathListener) EnterIdentifier(ctx *IdentifierContext) {} + +// ExitIdentifier is called when production identifier is exited. +func (s *BaseFhirPathListener) ExitIdentifier(ctx *IdentifierContext) {} diff --git a/go/fhirpath/gen/fhirpath_base_visitor.go b/go/fhirpath/gen/fhirpath_base_visitor.go new file mode 100755 index 000000000..0fff0d93b --- /dev/null +++ b/go/fhirpath/gen/fhirpath_base_visitor.go @@ -0,0 +1,172 @@ +// Code generated from FhirPath.g4 by ANTLR 4.13.1. DO NOT EDIT. + +package gen // FhirPath +import "github.com/antlr4-go/antlr/v4" + +type BaseFhirPathVisitor struct { + *antlr.BaseParseTreeVisitor +} + +func (v *BaseFhirPathVisitor) VisitIndexerExpression(ctx *IndexerExpressionContext) interface{} { + return v.VisitChildren(ctx) +} + +func (v *BaseFhirPathVisitor) VisitPolarityExpression(ctx *PolarityExpressionContext) interface{} { + return v.VisitChildren(ctx) +} + +func (v *BaseFhirPathVisitor) VisitAdditiveExpression(ctx *AdditiveExpressionContext) interface{} { + return v.VisitChildren(ctx) +} + +func (v *BaseFhirPathVisitor) VisitMultiplicativeExpression(ctx *MultiplicativeExpressionContext) interface{} { + return v.VisitChildren(ctx) +} + +func (v *BaseFhirPathVisitor) VisitUnionExpression(ctx *UnionExpressionContext) interface{} { + return v.VisitChildren(ctx) +} + +func (v *BaseFhirPathVisitor) VisitOrExpression(ctx *OrExpressionContext) interface{} { + return v.VisitChildren(ctx) +} + +func (v *BaseFhirPathVisitor) VisitAndExpression(ctx *AndExpressionContext) interface{} { + return v.VisitChildren(ctx) +} + +func (v *BaseFhirPathVisitor) VisitMembershipExpression(ctx *MembershipExpressionContext) interface{} { + return v.VisitChildren(ctx) +} + +func (v *BaseFhirPathVisitor) VisitInequalityExpression(ctx *InequalityExpressionContext) interface{} { + return v.VisitChildren(ctx) +} + +func (v *BaseFhirPathVisitor) VisitInvocationExpression(ctx *InvocationExpressionContext) interface{} { + return v.VisitChildren(ctx) +} + +func (v *BaseFhirPathVisitor) VisitEqualityExpression(ctx *EqualityExpressionContext) interface{} { + return v.VisitChildren(ctx) +} + +func (v *BaseFhirPathVisitor) VisitImpliesExpression(ctx *ImpliesExpressionContext) interface{} { + return v.VisitChildren(ctx) +} + +func (v *BaseFhirPathVisitor) VisitTermExpression(ctx *TermExpressionContext) interface{} { + return v.VisitChildren(ctx) +} + +func (v *BaseFhirPathVisitor) VisitTypeExpression(ctx *TypeExpressionContext) interface{} { + return v.VisitChildren(ctx) +} + +func (v *BaseFhirPathVisitor) VisitInvocationTerm(ctx *InvocationTermContext) interface{} { + return v.VisitChildren(ctx) +} + +func (v *BaseFhirPathVisitor) VisitLiteralTerm(ctx *LiteralTermContext) interface{} { + return v.VisitChildren(ctx) +} + +func (v *BaseFhirPathVisitor) VisitExternalConstantTerm(ctx *ExternalConstantTermContext) interface{} { + return v.VisitChildren(ctx) +} + +func (v *BaseFhirPathVisitor) VisitParenthesizedTerm(ctx *ParenthesizedTermContext) interface{} { + return v.VisitChildren(ctx) +} + +func (v *BaseFhirPathVisitor) VisitNullLiteral(ctx *NullLiteralContext) interface{} { + return v.VisitChildren(ctx) +} + +func (v *BaseFhirPathVisitor) VisitBooleanLiteral(ctx *BooleanLiteralContext) interface{} { + return v.VisitChildren(ctx) +} + +func (v *BaseFhirPathVisitor) VisitStringLiteral(ctx *StringLiteralContext) interface{} { + return v.VisitChildren(ctx) +} + +func (v *BaseFhirPathVisitor) VisitNumberLiteral(ctx *NumberLiteralContext) interface{} { + return v.VisitChildren(ctx) +} + +func (v *BaseFhirPathVisitor) VisitDateLiteral(ctx *DateLiteralContext) interface{} { + return v.VisitChildren(ctx) +} + +func (v *BaseFhirPathVisitor) VisitDateTimeLiteral(ctx *DateTimeLiteralContext) interface{} { + return v.VisitChildren(ctx) +} + +func (v *BaseFhirPathVisitor) VisitTimeLiteral(ctx *TimeLiteralContext) interface{} { + return v.VisitChildren(ctx) +} + +func (v *BaseFhirPathVisitor) VisitQuantityLiteral(ctx *QuantityLiteralContext) interface{} { + return v.VisitChildren(ctx) +} + +func (v *BaseFhirPathVisitor) VisitExternalConstant(ctx *ExternalConstantContext) interface{} { + return v.VisitChildren(ctx) +} + +func (v *BaseFhirPathVisitor) VisitMemberInvocation(ctx *MemberInvocationContext) interface{} { + return v.VisitChildren(ctx) +} + +func (v *BaseFhirPathVisitor) VisitFunctionInvocation(ctx *FunctionInvocationContext) interface{} { + return v.VisitChildren(ctx) +} + +func (v *BaseFhirPathVisitor) VisitThisInvocation(ctx *ThisInvocationContext) interface{} { + return v.VisitChildren(ctx) +} + +func (v *BaseFhirPathVisitor) VisitIndexInvocation(ctx *IndexInvocationContext) interface{} { + return v.VisitChildren(ctx) +} + +func (v *BaseFhirPathVisitor) VisitTotalInvocation(ctx *TotalInvocationContext) interface{} { + return v.VisitChildren(ctx) +} + +func (v *BaseFhirPathVisitor) VisitFunction(ctx *FunctionContext) interface{} { + return v.VisitChildren(ctx) +} + +func (v *BaseFhirPathVisitor) VisitParamList(ctx *ParamListContext) interface{} { + return v.VisitChildren(ctx) +} + +func (v *BaseFhirPathVisitor) VisitQuantity(ctx *QuantityContext) interface{} { + return v.VisitChildren(ctx) +} + +func (v *BaseFhirPathVisitor) VisitUnit(ctx *UnitContext) interface{} { + return v.VisitChildren(ctx) +} + +func (v *BaseFhirPathVisitor) VisitDateTimePrecision(ctx *DateTimePrecisionContext) interface{} { + return v.VisitChildren(ctx) +} + +func (v *BaseFhirPathVisitor) VisitPluralDateTimePrecision(ctx *PluralDateTimePrecisionContext) interface{} { + return v.VisitChildren(ctx) +} + +func (v *BaseFhirPathVisitor) VisitTypeSpecifier(ctx *TypeSpecifierContext) interface{} { + return v.VisitChildren(ctx) +} + +func (v *BaseFhirPathVisitor) VisitQualifiedIdentifier(ctx *QualifiedIdentifierContext) interface{} { + return v.VisitChildren(ctx) +} + +func (v *BaseFhirPathVisitor) VisitIdentifier(ctx *IdentifierContext) interface{} { + return v.VisitChildren(ctx) +} diff --git a/go/fhirpath/gen/fhirpath_lexer.go b/go/fhirpath/gen/fhirpath_lexer.go new file mode 100755 index 000000000..b6c9c447d --- /dev/null +++ b/go/fhirpath/gen/fhirpath_lexer.go @@ -0,0 +1,410 @@ +// Code generated from FhirPath.g4 by ANTLR 4.13.1. DO NOT EDIT. + +package gen + +import ( + "fmt" + "github.com/antlr4-go/antlr/v4" + "sync" + "unicode" +) + +// Suppress unused import error +var _ = fmt.Printf +var _ = sync.Once{} +var _ = unicode.IsLetter + +type FhirPathLexer struct { + *antlr.BaseLexer + channelNames []string + modeNames []string + // TODO: EOF string +} + +var FhirPathLexerLexerStaticData struct { + once sync.Once + serializedATN []int32 + ChannelNames []string + ModeNames []string + LiteralNames []string + SymbolicNames []string + RuleNames []string + PredictionContextCache *antlr.PredictionContextCache + atn *antlr.ATN + decisionToDFA []*antlr.DFA +} + +func fhirpathlexerLexerInit() { + staticData := &FhirPathLexerLexerStaticData + staticData.ChannelNames = []string{ + "DEFAULT_TOKEN_CHANNEL", "HIDDEN", + } + staticData.ModeNames = []string{ + "DEFAULT_MODE", + } + staticData.LiteralNames = []string{ + "", "'.'", "'['", "']'", "'+'", "'-'", "'*'", "'/'", "'div'", "'mod'", + "'&'", "'is'", "'as'", "'|'", "'<='", "'<'", "'>'", "'>='", "'='", "'~'", + "'!='", "'!~'", "'in'", "'contains'", "'and'", "'or'", "'xor'", "'implies'", + "'('", "')'", "'{'", "'}'", "'true'", "'false'", "'%'", "'$this'", "'$index'", + "'$total'", "','", "'year'", "'month'", "'week'", "'day'", "'hour'", + "'minute'", "'second'", "'millisecond'", "'years'", "'months'", "'weeks'", + "'days'", "'hours'", "'minutes'", "'seconds'", "'milliseconds'", + } + staticData.SymbolicNames = []string{ + "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", + "", "", "", "", "DATE", "DATETIME", "TIME", "IDENTIFIER", "DELIMITEDIDENTIFIER", + "STRING", "NUMBER", "WS", "COMMENT", "LINE_COMMENT", + } + staticData.RuleNames = []string{ + "T__0", "T__1", "T__2", "T__3", "T__4", "T__5", "T__6", "T__7", "T__8", + "T__9", "T__10", "T__11", "T__12", "T__13", "T__14", "T__15", "T__16", + "T__17", "T__18", "T__19", "T__20", "T__21", "T__22", "T__23", "T__24", + "T__25", "T__26", "T__27", "T__28", "T__29", "T__30", "T__31", "T__32", + "T__33", "T__34", "T__35", "T__36", "T__37", "T__38", "T__39", "T__40", + "T__41", "T__42", "T__43", "T__44", "T__45", "T__46", "T__47", "T__48", + "T__49", "T__50", "T__51", "T__52", "T__53", "DATE", "DATETIME", "TIME", + "DATEFORMAT", "TIMEFORMAT", "TIMEZONEOFFSETFORMAT", "IDENTIFIER", "DELIMITEDIDENTIFIER", + "STRING", "NUMBER", "WS", "COMMENT", "LINE_COMMENT", "ESC", "UNICODE", + "HEX", + } + staticData.PredictionContextCache = antlr.NewPredictionContextCache() + staticData.serializedATN = []int32{ + 4, 0, 64, 523, 6, -1, 2, 0, 7, 0, 2, 1, 7, 1, 2, 2, 7, 2, 2, 3, 7, 3, 2, + 4, 7, 4, 2, 5, 7, 5, 2, 6, 7, 6, 2, 7, 7, 7, 2, 8, 7, 8, 2, 9, 7, 9, 2, + 10, 7, 10, 2, 11, 7, 11, 2, 12, 7, 12, 2, 13, 7, 13, 2, 14, 7, 14, 2, 15, + 7, 15, 2, 16, 7, 16, 2, 17, 7, 17, 2, 18, 7, 18, 2, 19, 7, 19, 2, 20, 7, + 20, 2, 21, 7, 21, 2, 22, 7, 22, 2, 23, 7, 23, 2, 24, 7, 24, 2, 25, 7, 25, + 2, 26, 7, 26, 2, 27, 7, 27, 2, 28, 7, 28, 2, 29, 7, 29, 2, 30, 7, 30, 2, + 31, 7, 31, 2, 32, 7, 32, 2, 33, 7, 33, 2, 34, 7, 34, 2, 35, 7, 35, 2, 36, + 7, 36, 2, 37, 7, 37, 2, 38, 7, 38, 2, 39, 7, 39, 2, 40, 7, 40, 2, 41, 7, + 41, 2, 42, 7, 42, 2, 43, 7, 43, 2, 44, 7, 44, 2, 45, 7, 45, 2, 46, 7, 46, + 2, 47, 7, 47, 2, 48, 7, 48, 2, 49, 7, 49, 2, 50, 7, 50, 2, 51, 7, 51, 2, + 52, 7, 52, 2, 53, 7, 53, 2, 54, 7, 54, 2, 55, 7, 55, 2, 56, 7, 56, 2, 57, + 7, 57, 2, 58, 7, 58, 2, 59, 7, 59, 2, 60, 7, 60, 2, 61, 7, 61, 2, 62, 7, + 62, 2, 63, 7, 63, 2, 64, 7, 64, 2, 65, 7, 65, 2, 66, 7, 66, 2, 67, 7, 67, + 2, 68, 7, 68, 2, 69, 7, 69, 1, 0, 1, 0, 1, 1, 1, 1, 1, 2, 1, 2, 1, 3, 1, + 3, 1, 4, 1, 4, 1, 5, 1, 5, 1, 6, 1, 6, 1, 7, 1, 7, 1, 7, 1, 7, 1, 8, 1, + 8, 1, 8, 1, 8, 1, 9, 1, 9, 1, 10, 1, 10, 1, 10, 1, 11, 1, 11, 1, 11, 1, + 12, 1, 12, 1, 13, 1, 13, 1, 13, 1, 14, 1, 14, 1, 15, 1, 15, 1, 16, 1, 16, + 1, 16, 1, 17, 1, 17, 1, 18, 1, 18, 1, 19, 1, 19, 1, 19, 1, 20, 1, 20, 1, + 20, 1, 21, 1, 21, 1, 21, 1, 22, 1, 22, 1, 22, 1, 22, 1, 22, 1, 22, 1, 22, + 1, 22, 1, 22, 1, 23, 1, 23, 1, 23, 1, 23, 1, 24, 1, 24, 1, 24, 1, 25, 1, + 25, 1, 25, 1, 25, 1, 26, 1, 26, 1, 26, 1, 26, 1, 26, 1, 26, 1, 26, 1, 26, + 1, 27, 1, 27, 1, 28, 1, 28, 1, 29, 1, 29, 1, 30, 1, 30, 1, 31, 1, 31, 1, + 31, 1, 31, 1, 31, 1, 32, 1, 32, 1, 32, 1, 32, 1, 32, 1, 32, 1, 33, 1, 33, + 1, 34, 1, 34, 1, 34, 1, 34, 1, 34, 1, 34, 1, 35, 1, 35, 1, 35, 1, 35, 1, + 35, 1, 35, 1, 35, 1, 36, 1, 36, 1, 36, 1, 36, 1, 36, 1, 36, 1, 36, 1, 37, + 1, 37, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 39, 1, 39, 1, 39, 1, 39, 1, + 39, 1, 39, 1, 40, 1, 40, 1, 40, 1, 40, 1, 40, 1, 41, 1, 41, 1, 41, 1, 41, + 1, 42, 1, 42, 1, 42, 1, 42, 1, 42, 1, 43, 1, 43, 1, 43, 1, 43, 1, 43, 1, + 43, 1, 43, 1, 44, 1, 44, 1, 44, 1, 44, 1, 44, 1, 44, 1, 44, 1, 45, 1, 45, + 1, 45, 1, 45, 1, 45, 1, 45, 1, 45, 1, 45, 1, 45, 1, 45, 1, 45, 1, 45, 1, + 46, 1, 46, 1, 46, 1, 46, 1, 46, 1, 46, 1, 47, 1, 47, 1, 47, 1, 47, 1, 47, + 1, 47, 1, 47, 1, 48, 1, 48, 1, 48, 1, 48, 1, 48, 1, 48, 1, 49, 1, 49, 1, + 49, 1, 49, 1, 49, 1, 50, 1, 50, 1, 50, 1, 50, 1, 50, 1, 50, 1, 51, 1, 51, + 1, 51, 1, 51, 1, 51, 1, 51, 1, 51, 1, 51, 1, 52, 1, 52, 1, 52, 1, 52, 1, + 52, 1, 52, 1, 52, 1, 52, 1, 53, 1, 53, 1, 53, 1, 53, 1, 53, 1, 53, 1, 53, + 1, 53, 1, 53, 1, 53, 1, 53, 1, 53, 1, 53, 1, 54, 1, 54, 1, 54, 1, 55, 1, + 55, 1, 55, 1, 55, 1, 55, 3, 55, 386, 8, 55, 3, 55, 388, 8, 55, 1, 56, 1, + 56, 1, 56, 1, 56, 1, 57, 1, 57, 1, 57, 1, 57, 1, 57, 1, 57, 1, 57, 1, 57, + 1, 57, 1, 57, 3, 57, 404, 8, 57, 3, 57, 406, 8, 57, 1, 58, 1, 58, 1, 58, + 1, 58, 1, 58, 1, 58, 1, 58, 1, 58, 1, 58, 1, 58, 4, 58, 418, 8, 58, 11, + 58, 12, 58, 419, 3, 58, 422, 8, 58, 3, 58, 424, 8, 58, 3, 58, 426, 8, 58, + 1, 59, 1, 59, 1, 59, 1, 59, 1, 59, 1, 59, 1, 59, 3, 59, 435, 8, 59, 1, + 60, 3, 60, 438, 8, 60, 1, 60, 5, 60, 441, 8, 60, 10, 60, 12, 60, 444, 9, + 60, 1, 61, 1, 61, 1, 61, 5, 61, 449, 8, 61, 10, 61, 12, 61, 452, 9, 61, + 1, 61, 1, 61, 1, 62, 1, 62, 1, 62, 5, 62, 459, 8, 62, 10, 62, 12, 62, 462, + 9, 62, 1, 62, 1, 62, 1, 63, 4, 63, 467, 8, 63, 11, 63, 12, 63, 468, 1, + 63, 1, 63, 4, 63, 473, 8, 63, 11, 63, 12, 63, 474, 3, 63, 477, 8, 63, 1, + 64, 4, 64, 480, 8, 64, 11, 64, 12, 64, 481, 1, 64, 1, 64, 1, 65, 1, 65, + 1, 65, 1, 65, 5, 65, 490, 8, 65, 10, 65, 12, 65, 493, 9, 65, 1, 65, 1, + 65, 1, 65, 1, 65, 1, 65, 1, 66, 1, 66, 1, 66, 1, 66, 5, 66, 504, 8, 66, + 10, 66, 12, 66, 507, 9, 66, 1, 66, 1, 66, 1, 67, 1, 67, 1, 67, 3, 67, 514, + 8, 67, 1, 68, 1, 68, 1, 68, 1, 68, 1, 68, 1, 68, 1, 69, 1, 69, 3, 450, + 460, 491, 0, 70, 1, 1, 3, 2, 5, 3, 7, 4, 9, 5, 11, 6, 13, 7, 15, 8, 17, + 9, 19, 10, 21, 11, 23, 12, 25, 13, 27, 14, 29, 15, 31, 16, 33, 17, 35, + 18, 37, 19, 39, 20, 41, 21, 43, 22, 45, 23, 47, 24, 49, 25, 51, 26, 53, + 27, 55, 28, 57, 29, 59, 30, 61, 31, 63, 32, 65, 33, 67, 34, 69, 35, 71, + 36, 73, 37, 75, 38, 77, 39, 79, 40, 81, 41, 83, 42, 85, 43, 87, 44, 89, + 45, 91, 46, 93, 47, 95, 48, 97, 49, 99, 50, 101, 51, 103, 52, 105, 53, + 107, 54, 109, 55, 111, 56, 113, 57, 115, 0, 117, 0, 119, 0, 121, 58, 123, + 59, 125, 60, 127, 61, 129, 62, 131, 63, 133, 64, 135, 0, 137, 0, 139, 0, + 1, 0, 8, 1, 0, 48, 57, 2, 0, 43, 43, 45, 45, 3, 0, 65, 90, 95, 95, 97, + 122, 4, 0, 48, 57, 65, 90, 95, 95, 97, 122, 3, 0, 9, 10, 13, 13, 32, 32, + 2, 0, 10, 10, 13, 13, 8, 0, 39, 39, 47, 47, 92, 92, 96, 96, 102, 102, 110, + 110, 114, 114, 116, 116, 3, 0, 48, 57, 65, 70, 97, 102, 537, 0, 1, 1, 0, + 0, 0, 0, 3, 1, 0, 0, 0, 0, 5, 1, 0, 0, 0, 0, 7, 1, 0, 0, 0, 0, 9, 1, 0, + 0, 0, 0, 11, 1, 0, 0, 0, 0, 13, 1, 0, 0, 0, 0, 15, 1, 0, 0, 0, 0, 17, 1, + 0, 0, 0, 0, 19, 1, 0, 0, 0, 0, 21, 1, 0, 0, 0, 0, 23, 1, 0, 0, 0, 0, 25, + 1, 0, 0, 0, 0, 27, 1, 0, 0, 0, 0, 29, 1, 0, 0, 0, 0, 31, 1, 0, 0, 0, 0, + 33, 1, 0, 0, 0, 0, 35, 1, 0, 0, 0, 0, 37, 1, 0, 0, 0, 0, 39, 1, 0, 0, 0, + 0, 41, 1, 0, 0, 0, 0, 43, 1, 0, 0, 0, 0, 45, 1, 0, 0, 0, 0, 47, 1, 0, 0, + 0, 0, 49, 1, 0, 0, 0, 0, 51, 1, 0, 0, 0, 0, 53, 1, 0, 0, 0, 0, 55, 1, 0, + 0, 0, 0, 57, 1, 0, 0, 0, 0, 59, 1, 0, 0, 0, 0, 61, 1, 0, 0, 0, 0, 63, 1, + 0, 0, 0, 0, 65, 1, 0, 0, 0, 0, 67, 1, 0, 0, 0, 0, 69, 1, 0, 0, 0, 0, 71, + 1, 0, 0, 0, 0, 73, 1, 0, 0, 0, 0, 75, 1, 0, 0, 0, 0, 77, 1, 0, 0, 0, 0, + 79, 1, 0, 0, 0, 0, 81, 1, 0, 0, 0, 0, 83, 1, 0, 0, 0, 0, 85, 1, 0, 0, 0, + 0, 87, 1, 0, 0, 0, 0, 89, 1, 0, 0, 0, 0, 91, 1, 0, 0, 0, 0, 93, 1, 0, 0, + 0, 0, 95, 1, 0, 0, 0, 0, 97, 1, 0, 0, 0, 0, 99, 1, 0, 0, 0, 0, 101, 1, + 0, 0, 0, 0, 103, 1, 0, 0, 0, 0, 105, 1, 0, 0, 0, 0, 107, 1, 0, 0, 0, 0, + 109, 1, 0, 0, 0, 0, 111, 1, 0, 0, 0, 0, 113, 1, 0, 0, 0, 0, 121, 1, 0, + 0, 0, 0, 123, 1, 0, 0, 0, 0, 125, 1, 0, 0, 0, 0, 127, 1, 0, 0, 0, 0, 129, + 1, 0, 0, 0, 0, 131, 1, 0, 0, 0, 0, 133, 1, 0, 0, 0, 1, 141, 1, 0, 0, 0, + 3, 143, 1, 0, 0, 0, 5, 145, 1, 0, 0, 0, 7, 147, 1, 0, 0, 0, 9, 149, 1, + 0, 0, 0, 11, 151, 1, 0, 0, 0, 13, 153, 1, 0, 0, 0, 15, 155, 1, 0, 0, 0, + 17, 159, 1, 0, 0, 0, 19, 163, 1, 0, 0, 0, 21, 165, 1, 0, 0, 0, 23, 168, + 1, 0, 0, 0, 25, 171, 1, 0, 0, 0, 27, 173, 1, 0, 0, 0, 29, 176, 1, 0, 0, + 0, 31, 178, 1, 0, 0, 0, 33, 180, 1, 0, 0, 0, 35, 183, 1, 0, 0, 0, 37, 185, + 1, 0, 0, 0, 39, 187, 1, 0, 0, 0, 41, 190, 1, 0, 0, 0, 43, 193, 1, 0, 0, + 0, 45, 196, 1, 0, 0, 0, 47, 205, 1, 0, 0, 0, 49, 209, 1, 0, 0, 0, 51, 212, + 1, 0, 0, 0, 53, 216, 1, 0, 0, 0, 55, 224, 1, 0, 0, 0, 57, 226, 1, 0, 0, + 0, 59, 228, 1, 0, 0, 0, 61, 230, 1, 0, 0, 0, 63, 232, 1, 0, 0, 0, 65, 237, + 1, 0, 0, 0, 67, 243, 1, 0, 0, 0, 69, 245, 1, 0, 0, 0, 71, 251, 1, 0, 0, + 0, 73, 258, 1, 0, 0, 0, 75, 265, 1, 0, 0, 0, 77, 267, 1, 0, 0, 0, 79, 272, + 1, 0, 0, 0, 81, 278, 1, 0, 0, 0, 83, 283, 1, 0, 0, 0, 85, 287, 1, 0, 0, + 0, 87, 292, 1, 0, 0, 0, 89, 299, 1, 0, 0, 0, 91, 306, 1, 0, 0, 0, 93, 318, + 1, 0, 0, 0, 95, 324, 1, 0, 0, 0, 97, 331, 1, 0, 0, 0, 99, 337, 1, 0, 0, + 0, 101, 342, 1, 0, 0, 0, 103, 348, 1, 0, 0, 0, 105, 356, 1, 0, 0, 0, 107, + 364, 1, 0, 0, 0, 109, 377, 1, 0, 0, 0, 111, 380, 1, 0, 0, 0, 113, 389, + 1, 0, 0, 0, 115, 393, 1, 0, 0, 0, 117, 407, 1, 0, 0, 0, 119, 434, 1, 0, + 0, 0, 121, 437, 1, 0, 0, 0, 123, 445, 1, 0, 0, 0, 125, 455, 1, 0, 0, 0, + 127, 466, 1, 0, 0, 0, 129, 479, 1, 0, 0, 0, 131, 485, 1, 0, 0, 0, 133, + 499, 1, 0, 0, 0, 135, 510, 1, 0, 0, 0, 137, 515, 1, 0, 0, 0, 139, 521, + 1, 0, 0, 0, 141, 142, 5, 46, 0, 0, 142, 2, 1, 0, 0, 0, 143, 144, 5, 91, + 0, 0, 144, 4, 1, 0, 0, 0, 145, 146, 5, 93, 0, 0, 146, 6, 1, 0, 0, 0, 147, + 148, 5, 43, 0, 0, 148, 8, 1, 0, 0, 0, 149, 150, 5, 45, 0, 0, 150, 10, 1, + 0, 0, 0, 151, 152, 5, 42, 0, 0, 152, 12, 1, 0, 0, 0, 153, 154, 5, 47, 0, + 0, 154, 14, 1, 0, 0, 0, 155, 156, 5, 100, 0, 0, 156, 157, 5, 105, 0, 0, + 157, 158, 5, 118, 0, 0, 158, 16, 1, 0, 0, 0, 159, 160, 5, 109, 0, 0, 160, + 161, 5, 111, 0, 0, 161, 162, 5, 100, 0, 0, 162, 18, 1, 0, 0, 0, 163, 164, + 5, 38, 0, 0, 164, 20, 1, 0, 0, 0, 165, 166, 5, 105, 0, 0, 166, 167, 5, + 115, 0, 0, 167, 22, 1, 0, 0, 0, 168, 169, 5, 97, 0, 0, 169, 170, 5, 115, + 0, 0, 170, 24, 1, 0, 0, 0, 171, 172, 5, 124, 0, 0, 172, 26, 1, 0, 0, 0, + 173, 174, 5, 60, 0, 0, 174, 175, 5, 61, 0, 0, 175, 28, 1, 0, 0, 0, 176, + 177, 5, 60, 0, 0, 177, 30, 1, 0, 0, 0, 178, 179, 5, 62, 0, 0, 179, 32, + 1, 0, 0, 0, 180, 181, 5, 62, 0, 0, 181, 182, 5, 61, 0, 0, 182, 34, 1, 0, + 0, 0, 183, 184, 5, 61, 0, 0, 184, 36, 1, 0, 0, 0, 185, 186, 5, 126, 0, + 0, 186, 38, 1, 0, 0, 0, 187, 188, 5, 33, 0, 0, 188, 189, 5, 61, 0, 0, 189, + 40, 1, 0, 0, 0, 190, 191, 5, 33, 0, 0, 191, 192, 5, 126, 0, 0, 192, 42, + 1, 0, 0, 0, 193, 194, 5, 105, 0, 0, 194, 195, 5, 110, 0, 0, 195, 44, 1, + 0, 0, 0, 196, 197, 5, 99, 0, 0, 197, 198, 5, 111, 0, 0, 198, 199, 5, 110, + 0, 0, 199, 200, 5, 116, 0, 0, 200, 201, 5, 97, 0, 0, 201, 202, 5, 105, + 0, 0, 202, 203, 5, 110, 0, 0, 203, 204, 5, 115, 0, 0, 204, 46, 1, 0, 0, + 0, 205, 206, 5, 97, 0, 0, 206, 207, 5, 110, 0, 0, 207, 208, 5, 100, 0, + 0, 208, 48, 1, 0, 0, 0, 209, 210, 5, 111, 0, 0, 210, 211, 5, 114, 0, 0, + 211, 50, 1, 0, 0, 0, 212, 213, 5, 120, 0, 0, 213, 214, 5, 111, 0, 0, 214, + 215, 5, 114, 0, 0, 215, 52, 1, 0, 0, 0, 216, 217, 5, 105, 0, 0, 217, 218, + 5, 109, 0, 0, 218, 219, 5, 112, 0, 0, 219, 220, 5, 108, 0, 0, 220, 221, + 5, 105, 0, 0, 221, 222, 5, 101, 0, 0, 222, 223, 5, 115, 0, 0, 223, 54, + 1, 0, 0, 0, 224, 225, 5, 40, 0, 0, 225, 56, 1, 0, 0, 0, 226, 227, 5, 41, + 0, 0, 227, 58, 1, 0, 0, 0, 228, 229, 5, 123, 0, 0, 229, 60, 1, 0, 0, 0, + 230, 231, 5, 125, 0, 0, 231, 62, 1, 0, 0, 0, 232, 233, 5, 116, 0, 0, 233, + 234, 5, 114, 0, 0, 234, 235, 5, 117, 0, 0, 235, 236, 5, 101, 0, 0, 236, + 64, 1, 0, 0, 0, 237, 238, 5, 102, 0, 0, 238, 239, 5, 97, 0, 0, 239, 240, + 5, 108, 0, 0, 240, 241, 5, 115, 0, 0, 241, 242, 5, 101, 0, 0, 242, 66, + 1, 0, 0, 0, 243, 244, 5, 37, 0, 0, 244, 68, 1, 0, 0, 0, 245, 246, 5, 36, + 0, 0, 246, 247, 5, 116, 0, 0, 247, 248, 5, 104, 0, 0, 248, 249, 5, 105, + 0, 0, 249, 250, 5, 115, 0, 0, 250, 70, 1, 0, 0, 0, 251, 252, 5, 36, 0, + 0, 252, 253, 5, 105, 0, 0, 253, 254, 5, 110, 0, 0, 254, 255, 5, 100, 0, + 0, 255, 256, 5, 101, 0, 0, 256, 257, 5, 120, 0, 0, 257, 72, 1, 0, 0, 0, + 258, 259, 5, 36, 0, 0, 259, 260, 5, 116, 0, 0, 260, 261, 5, 111, 0, 0, + 261, 262, 5, 116, 0, 0, 262, 263, 5, 97, 0, 0, 263, 264, 5, 108, 0, 0, + 264, 74, 1, 0, 0, 0, 265, 266, 5, 44, 0, 0, 266, 76, 1, 0, 0, 0, 267, 268, + 5, 121, 0, 0, 268, 269, 5, 101, 0, 0, 269, 270, 5, 97, 0, 0, 270, 271, + 5, 114, 0, 0, 271, 78, 1, 0, 0, 0, 272, 273, 5, 109, 0, 0, 273, 274, 5, + 111, 0, 0, 274, 275, 5, 110, 0, 0, 275, 276, 5, 116, 0, 0, 276, 277, 5, + 104, 0, 0, 277, 80, 1, 0, 0, 0, 278, 279, 5, 119, 0, 0, 279, 280, 5, 101, + 0, 0, 280, 281, 5, 101, 0, 0, 281, 282, 5, 107, 0, 0, 282, 82, 1, 0, 0, + 0, 283, 284, 5, 100, 0, 0, 284, 285, 5, 97, 0, 0, 285, 286, 5, 121, 0, + 0, 286, 84, 1, 0, 0, 0, 287, 288, 5, 104, 0, 0, 288, 289, 5, 111, 0, 0, + 289, 290, 5, 117, 0, 0, 290, 291, 5, 114, 0, 0, 291, 86, 1, 0, 0, 0, 292, + 293, 5, 109, 0, 0, 293, 294, 5, 105, 0, 0, 294, 295, 5, 110, 0, 0, 295, + 296, 5, 117, 0, 0, 296, 297, 5, 116, 0, 0, 297, 298, 5, 101, 0, 0, 298, + 88, 1, 0, 0, 0, 299, 300, 5, 115, 0, 0, 300, 301, 5, 101, 0, 0, 301, 302, + 5, 99, 0, 0, 302, 303, 5, 111, 0, 0, 303, 304, 5, 110, 0, 0, 304, 305, + 5, 100, 0, 0, 305, 90, 1, 0, 0, 0, 306, 307, 5, 109, 0, 0, 307, 308, 5, + 105, 0, 0, 308, 309, 5, 108, 0, 0, 309, 310, 5, 108, 0, 0, 310, 311, 5, + 105, 0, 0, 311, 312, 5, 115, 0, 0, 312, 313, 5, 101, 0, 0, 313, 314, 5, + 99, 0, 0, 314, 315, 5, 111, 0, 0, 315, 316, 5, 110, 0, 0, 316, 317, 5, + 100, 0, 0, 317, 92, 1, 0, 0, 0, 318, 319, 5, 121, 0, 0, 319, 320, 5, 101, + 0, 0, 320, 321, 5, 97, 0, 0, 321, 322, 5, 114, 0, 0, 322, 323, 5, 115, + 0, 0, 323, 94, 1, 0, 0, 0, 324, 325, 5, 109, 0, 0, 325, 326, 5, 111, 0, + 0, 326, 327, 5, 110, 0, 0, 327, 328, 5, 116, 0, 0, 328, 329, 5, 104, 0, + 0, 329, 330, 5, 115, 0, 0, 330, 96, 1, 0, 0, 0, 331, 332, 5, 119, 0, 0, + 332, 333, 5, 101, 0, 0, 333, 334, 5, 101, 0, 0, 334, 335, 5, 107, 0, 0, + 335, 336, 5, 115, 0, 0, 336, 98, 1, 0, 0, 0, 337, 338, 5, 100, 0, 0, 338, + 339, 5, 97, 0, 0, 339, 340, 5, 121, 0, 0, 340, 341, 5, 115, 0, 0, 341, + 100, 1, 0, 0, 0, 342, 343, 5, 104, 0, 0, 343, 344, 5, 111, 0, 0, 344, 345, + 5, 117, 0, 0, 345, 346, 5, 114, 0, 0, 346, 347, 5, 115, 0, 0, 347, 102, + 1, 0, 0, 0, 348, 349, 5, 109, 0, 0, 349, 350, 5, 105, 0, 0, 350, 351, 5, + 110, 0, 0, 351, 352, 5, 117, 0, 0, 352, 353, 5, 116, 0, 0, 353, 354, 5, + 101, 0, 0, 354, 355, 5, 115, 0, 0, 355, 104, 1, 0, 0, 0, 356, 357, 5, 115, + 0, 0, 357, 358, 5, 101, 0, 0, 358, 359, 5, 99, 0, 0, 359, 360, 5, 111, + 0, 0, 360, 361, 5, 110, 0, 0, 361, 362, 5, 100, 0, 0, 362, 363, 5, 115, + 0, 0, 363, 106, 1, 0, 0, 0, 364, 365, 5, 109, 0, 0, 365, 366, 5, 105, 0, + 0, 366, 367, 5, 108, 0, 0, 367, 368, 5, 108, 0, 0, 368, 369, 5, 105, 0, + 0, 369, 370, 5, 115, 0, 0, 370, 371, 5, 101, 0, 0, 371, 372, 5, 99, 0, + 0, 372, 373, 5, 111, 0, 0, 373, 374, 5, 110, 0, 0, 374, 375, 5, 100, 0, + 0, 375, 376, 5, 115, 0, 0, 376, 108, 1, 0, 0, 0, 377, 378, 5, 64, 0, 0, + 378, 379, 3, 115, 57, 0, 379, 110, 1, 0, 0, 0, 380, 381, 5, 64, 0, 0, 381, + 382, 3, 115, 57, 0, 382, 387, 5, 84, 0, 0, 383, 385, 3, 117, 58, 0, 384, + 386, 3, 119, 59, 0, 385, 384, 1, 0, 0, 0, 385, 386, 1, 0, 0, 0, 386, 388, + 1, 0, 0, 0, 387, 383, 1, 0, 0, 0, 387, 388, 1, 0, 0, 0, 388, 112, 1, 0, + 0, 0, 389, 390, 5, 64, 0, 0, 390, 391, 5, 84, 0, 0, 391, 392, 3, 117, 58, + 0, 392, 114, 1, 0, 0, 0, 393, 394, 7, 0, 0, 0, 394, 395, 7, 0, 0, 0, 395, + 396, 7, 0, 0, 0, 396, 405, 7, 0, 0, 0, 397, 398, 5, 45, 0, 0, 398, 399, + 7, 0, 0, 0, 399, 403, 7, 0, 0, 0, 400, 401, 5, 45, 0, 0, 401, 402, 7, 0, + 0, 0, 402, 404, 7, 0, 0, 0, 403, 400, 1, 0, 0, 0, 403, 404, 1, 0, 0, 0, + 404, 406, 1, 0, 0, 0, 405, 397, 1, 0, 0, 0, 405, 406, 1, 0, 0, 0, 406, + 116, 1, 0, 0, 0, 407, 408, 7, 0, 0, 0, 408, 425, 7, 0, 0, 0, 409, 410, + 5, 58, 0, 0, 410, 411, 7, 0, 0, 0, 411, 423, 7, 0, 0, 0, 412, 413, 5, 58, + 0, 0, 413, 414, 7, 0, 0, 0, 414, 421, 7, 0, 0, 0, 415, 417, 5, 46, 0, 0, + 416, 418, 7, 0, 0, 0, 417, 416, 1, 0, 0, 0, 418, 419, 1, 0, 0, 0, 419, + 417, 1, 0, 0, 0, 419, 420, 1, 0, 0, 0, 420, 422, 1, 0, 0, 0, 421, 415, + 1, 0, 0, 0, 421, 422, 1, 0, 0, 0, 422, 424, 1, 0, 0, 0, 423, 412, 1, 0, + 0, 0, 423, 424, 1, 0, 0, 0, 424, 426, 1, 0, 0, 0, 425, 409, 1, 0, 0, 0, + 425, 426, 1, 0, 0, 0, 426, 118, 1, 0, 0, 0, 427, 435, 5, 90, 0, 0, 428, + 429, 7, 1, 0, 0, 429, 430, 7, 0, 0, 0, 430, 431, 7, 0, 0, 0, 431, 432, + 5, 58, 0, 0, 432, 433, 7, 0, 0, 0, 433, 435, 7, 0, 0, 0, 434, 427, 1, 0, + 0, 0, 434, 428, 1, 0, 0, 0, 435, 120, 1, 0, 0, 0, 436, 438, 7, 2, 0, 0, + 437, 436, 1, 0, 0, 0, 438, 442, 1, 0, 0, 0, 439, 441, 7, 3, 0, 0, 440, + 439, 1, 0, 0, 0, 441, 444, 1, 0, 0, 0, 442, 440, 1, 0, 0, 0, 442, 443, + 1, 0, 0, 0, 443, 122, 1, 0, 0, 0, 444, 442, 1, 0, 0, 0, 445, 450, 5, 96, + 0, 0, 446, 449, 3, 135, 67, 0, 447, 449, 9, 0, 0, 0, 448, 446, 1, 0, 0, + 0, 448, 447, 1, 0, 0, 0, 449, 452, 1, 0, 0, 0, 450, 451, 1, 0, 0, 0, 450, + 448, 1, 0, 0, 0, 451, 453, 1, 0, 0, 0, 452, 450, 1, 0, 0, 0, 453, 454, + 5, 96, 0, 0, 454, 124, 1, 0, 0, 0, 455, 460, 5, 39, 0, 0, 456, 459, 3, + 135, 67, 0, 457, 459, 9, 0, 0, 0, 458, 456, 1, 0, 0, 0, 458, 457, 1, 0, + 0, 0, 459, 462, 1, 0, 0, 0, 460, 461, 1, 0, 0, 0, 460, 458, 1, 0, 0, 0, + 461, 463, 1, 0, 0, 0, 462, 460, 1, 0, 0, 0, 463, 464, 5, 39, 0, 0, 464, + 126, 1, 0, 0, 0, 465, 467, 7, 0, 0, 0, 466, 465, 1, 0, 0, 0, 467, 468, + 1, 0, 0, 0, 468, 466, 1, 0, 0, 0, 468, 469, 1, 0, 0, 0, 469, 476, 1, 0, + 0, 0, 470, 472, 5, 46, 0, 0, 471, 473, 7, 0, 0, 0, 472, 471, 1, 0, 0, 0, + 473, 474, 1, 0, 0, 0, 474, 472, 1, 0, 0, 0, 474, 475, 1, 0, 0, 0, 475, + 477, 1, 0, 0, 0, 476, 470, 1, 0, 0, 0, 476, 477, 1, 0, 0, 0, 477, 128, + 1, 0, 0, 0, 478, 480, 7, 4, 0, 0, 479, 478, 1, 0, 0, 0, 480, 481, 1, 0, + 0, 0, 481, 479, 1, 0, 0, 0, 481, 482, 1, 0, 0, 0, 482, 483, 1, 0, 0, 0, + 483, 484, 6, 64, 0, 0, 484, 130, 1, 0, 0, 0, 485, 486, 5, 47, 0, 0, 486, + 487, 5, 42, 0, 0, 487, 491, 1, 0, 0, 0, 488, 490, 9, 0, 0, 0, 489, 488, + 1, 0, 0, 0, 490, 493, 1, 0, 0, 0, 491, 492, 1, 0, 0, 0, 491, 489, 1, 0, + 0, 0, 492, 494, 1, 0, 0, 0, 493, 491, 1, 0, 0, 0, 494, 495, 5, 42, 0, 0, + 495, 496, 5, 47, 0, 0, 496, 497, 1, 0, 0, 0, 497, 498, 6, 65, 0, 0, 498, + 132, 1, 0, 0, 0, 499, 500, 5, 47, 0, 0, 500, 501, 5, 47, 0, 0, 501, 505, + 1, 0, 0, 0, 502, 504, 8, 5, 0, 0, 503, 502, 1, 0, 0, 0, 504, 507, 1, 0, + 0, 0, 505, 503, 1, 0, 0, 0, 505, 506, 1, 0, 0, 0, 506, 508, 1, 0, 0, 0, + 507, 505, 1, 0, 0, 0, 508, 509, 6, 66, 0, 0, 509, 134, 1, 0, 0, 0, 510, + 513, 5, 92, 0, 0, 511, 514, 7, 6, 0, 0, 512, 514, 3, 137, 68, 0, 513, 511, + 1, 0, 0, 0, 513, 512, 1, 0, 0, 0, 514, 136, 1, 0, 0, 0, 515, 516, 5, 117, + 0, 0, 516, 517, 3, 139, 69, 0, 517, 518, 3, 139, 69, 0, 518, 519, 3, 139, + 69, 0, 519, 520, 3, 139, 69, 0, 520, 138, 1, 0, 0, 0, 521, 522, 7, 7, 0, + 0, 522, 140, 1, 0, 0, 0, 24, 0, 385, 387, 403, 405, 419, 421, 423, 425, + 434, 437, 440, 442, 448, 450, 458, 460, 468, 474, 476, 481, 491, 505, 513, + 1, 0, 1, 0, + } + deserializer := antlr.NewATNDeserializer(nil) + staticData.atn = deserializer.Deserialize(staticData.serializedATN) + atn := staticData.atn + staticData.decisionToDFA = make([]*antlr.DFA, len(atn.DecisionToState)) + decisionToDFA := staticData.decisionToDFA + for index, state := range atn.DecisionToState { + decisionToDFA[index] = antlr.NewDFA(state, index) + } +} + +// FhirPathLexerInit initializes any static state used to implement FhirPathLexer. By default the +// static state used to implement the lexer is lazily initialized during the first call to +// NewFhirPathLexer(). You can call this function if you wish to initialize the static state ahead +// of time. +func FhirPathLexerInit() { + staticData := &FhirPathLexerLexerStaticData + staticData.once.Do(fhirpathlexerLexerInit) +} + +// NewFhirPathLexer produces a new lexer instance for the optional input antlr.CharStream. +func NewFhirPathLexer(input antlr.CharStream) *FhirPathLexer { + FhirPathLexerInit() + l := new(FhirPathLexer) + l.BaseLexer = antlr.NewBaseLexer(input) + staticData := &FhirPathLexerLexerStaticData + l.Interpreter = antlr.NewLexerATNSimulator(l, staticData.atn, staticData.decisionToDFA, staticData.PredictionContextCache) + l.channelNames = staticData.ChannelNames + l.modeNames = staticData.ModeNames + l.RuleNames = staticData.RuleNames + l.LiteralNames = staticData.LiteralNames + l.SymbolicNames = staticData.SymbolicNames + l.GrammarFileName = "FhirPath.g4" + // TODO: l.EOF = antlr.TokenEOF + + return l +} + +// FhirPathLexer tokens. +const ( + FhirPathLexerT__0 = 1 + FhirPathLexerT__1 = 2 + FhirPathLexerT__2 = 3 + FhirPathLexerT__3 = 4 + FhirPathLexerT__4 = 5 + FhirPathLexerT__5 = 6 + FhirPathLexerT__6 = 7 + FhirPathLexerT__7 = 8 + FhirPathLexerT__8 = 9 + FhirPathLexerT__9 = 10 + FhirPathLexerT__10 = 11 + FhirPathLexerT__11 = 12 + FhirPathLexerT__12 = 13 + FhirPathLexerT__13 = 14 + FhirPathLexerT__14 = 15 + FhirPathLexerT__15 = 16 + FhirPathLexerT__16 = 17 + FhirPathLexerT__17 = 18 + FhirPathLexerT__18 = 19 + FhirPathLexerT__19 = 20 + FhirPathLexerT__20 = 21 + FhirPathLexerT__21 = 22 + FhirPathLexerT__22 = 23 + FhirPathLexerT__23 = 24 + FhirPathLexerT__24 = 25 + FhirPathLexerT__25 = 26 + FhirPathLexerT__26 = 27 + FhirPathLexerT__27 = 28 + FhirPathLexerT__28 = 29 + FhirPathLexerT__29 = 30 + FhirPathLexerT__30 = 31 + FhirPathLexerT__31 = 32 + FhirPathLexerT__32 = 33 + FhirPathLexerT__33 = 34 + FhirPathLexerT__34 = 35 + FhirPathLexerT__35 = 36 + FhirPathLexerT__36 = 37 + FhirPathLexerT__37 = 38 + FhirPathLexerT__38 = 39 + FhirPathLexerT__39 = 40 + FhirPathLexerT__40 = 41 + FhirPathLexerT__41 = 42 + FhirPathLexerT__42 = 43 + FhirPathLexerT__43 = 44 + FhirPathLexerT__44 = 45 + FhirPathLexerT__45 = 46 + FhirPathLexerT__46 = 47 + FhirPathLexerT__47 = 48 + FhirPathLexerT__48 = 49 + FhirPathLexerT__49 = 50 + FhirPathLexerT__50 = 51 + FhirPathLexerT__51 = 52 + FhirPathLexerT__52 = 53 + FhirPathLexerT__53 = 54 + FhirPathLexerDATE = 55 + FhirPathLexerDATETIME = 56 + FhirPathLexerTIME = 57 + FhirPathLexerIDENTIFIER = 58 + FhirPathLexerDELIMITEDIDENTIFIER = 59 + FhirPathLexerSTRING = 60 + FhirPathLexerNUMBER = 61 + FhirPathLexerWS = 62 + FhirPathLexerCOMMENT = 63 + FhirPathLexerLINE_COMMENT = 64 +) diff --git a/go/fhirpath/gen/fhirpath_listener.go b/go/fhirpath/gen/fhirpath_listener.go new file mode 100755 index 000000000..2d6311724 --- /dev/null +++ b/go/fhirpath/gen/fhirpath_listener.go @@ -0,0 +1,255 @@ +// Code generated from FhirPath.g4 by ANTLR 4.13.1. DO NOT EDIT. + +package gen // FhirPath +import "github.com/antlr4-go/antlr/v4" + +// FhirPathListener is a complete listener for a parse tree produced by FhirPathParser. +type FhirPathListener interface { + antlr.ParseTreeListener + + // EnterIndexerExpression is called when entering the indexerExpression production. + EnterIndexerExpression(c *IndexerExpressionContext) + + // EnterPolarityExpression is called when entering the polarityExpression production. + EnterPolarityExpression(c *PolarityExpressionContext) + + // EnterAdditiveExpression is called when entering the additiveExpression production. + EnterAdditiveExpression(c *AdditiveExpressionContext) + + // EnterMultiplicativeExpression is called when entering the multiplicativeExpression production. + EnterMultiplicativeExpression(c *MultiplicativeExpressionContext) + + // EnterUnionExpression is called when entering the unionExpression production. + EnterUnionExpression(c *UnionExpressionContext) + + // EnterOrExpression is called when entering the orExpression production. + EnterOrExpression(c *OrExpressionContext) + + // EnterAndExpression is called when entering the andExpression production. + EnterAndExpression(c *AndExpressionContext) + + // EnterMembershipExpression is called when entering the membershipExpression production. + EnterMembershipExpression(c *MembershipExpressionContext) + + // EnterInequalityExpression is called when entering the inequalityExpression production. + EnterInequalityExpression(c *InequalityExpressionContext) + + // EnterInvocationExpression is called when entering the invocationExpression production. + EnterInvocationExpression(c *InvocationExpressionContext) + + // EnterEqualityExpression is called when entering the equalityExpression production. + EnterEqualityExpression(c *EqualityExpressionContext) + + // EnterImpliesExpression is called when entering the impliesExpression production. + EnterImpliesExpression(c *ImpliesExpressionContext) + + // EnterTermExpression is called when entering the termExpression production. + EnterTermExpression(c *TermExpressionContext) + + // EnterTypeExpression is called when entering the typeExpression production. + EnterTypeExpression(c *TypeExpressionContext) + + // EnterInvocationTerm is called when entering the invocationTerm production. + EnterInvocationTerm(c *InvocationTermContext) + + // EnterLiteralTerm is called when entering the literalTerm production. + EnterLiteralTerm(c *LiteralTermContext) + + // EnterExternalConstantTerm is called when entering the externalConstantTerm production. + EnterExternalConstantTerm(c *ExternalConstantTermContext) + + // EnterParenthesizedTerm is called when entering the parenthesizedTerm production. + EnterParenthesizedTerm(c *ParenthesizedTermContext) + + // EnterNullLiteral is called when entering the nullLiteral production. + EnterNullLiteral(c *NullLiteralContext) + + // EnterBooleanLiteral is called when entering the booleanLiteral production. + EnterBooleanLiteral(c *BooleanLiteralContext) + + // EnterStringLiteral is called when entering the stringLiteral production. + EnterStringLiteral(c *StringLiteralContext) + + // EnterNumberLiteral is called when entering the numberLiteral production. + EnterNumberLiteral(c *NumberLiteralContext) + + // EnterDateLiteral is called when entering the dateLiteral production. + EnterDateLiteral(c *DateLiteralContext) + + // EnterDateTimeLiteral is called when entering the dateTimeLiteral production. + EnterDateTimeLiteral(c *DateTimeLiteralContext) + + // EnterTimeLiteral is called when entering the timeLiteral production. + EnterTimeLiteral(c *TimeLiteralContext) + + // EnterQuantityLiteral is called when entering the quantityLiteral production. + EnterQuantityLiteral(c *QuantityLiteralContext) + + // EnterExternalConstant is called when entering the externalConstant production. + EnterExternalConstant(c *ExternalConstantContext) + + // EnterMemberInvocation is called when entering the memberInvocation production. + EnterMemberInvocation(c *MemberInvocationContext) + + // EnterFunctionInvocation is called when entering the functionInvocation production. + EnterFunctionInvocation(c *FunctionInvocationContext) + + // EnterThisInvocation is called when entering the thisInvocation production. + EnterThisInvocation(c *ThisInvocationContext) + + // EnterIndexInvocation is called when entering the indexInvocation production. + EnterIndexInvocation(c *IndexInvocationContext) + + // EnterTotalInvocation is called when entering the totalInvocation production. + EnterTotalInvocation(c *TotalInvocationContext) + + // EnterFunction is called when entering the function production. + EnterFunction(c *FunctionContext) + + // EnterParamList is called when entering the paramList production. + EnterParamList(c *ParamListContext) + + // EnterQuantity is called when entering the quantity production. + EnterQuantity(c *QuantityContext) + + // EnterUnit is called when entering the unit production. + EnterUnit(c *UnitContext) + + // EnterDateTimePrecision is called when entering the dateTimePrecision production. + EnterDateTimePrecision(c *DateTimePrecisionContext) + + // EnterPluralDateTimePrecision is called when entering the pluralDateTimePrecision production. + EnterPluralDateTimePrecision(c *PluralDateTimePrecisionContext) + + // EnterTypeSpecifier is called when entering the typeSpecifier production. + EnterTypeSpecifier(c *TypeSpecifierContext) + + // EnterQualifiedIdentifier is called when entering the qualifiedIdentifier production. + EnterQualifiedIdentifier(c *QualifiedIdentifierContext) + + // EnterIdentifier is called when entering the identifier production. + EnterIdentifier(c *IdentifierContext) + + // ExitIndexerExpression is called when exiting the indexerExpression production. + ExitIndexerExpression(c *IndexerExpressionContext) + + // ExitPolarityExpression is called when exiting the polarityExpression production. + ExitPolarityExpression(c *PolarityExpressionContext) + + // ExitAdditiveExpression is called when exiting the additiveExpression production. + ExitAdditiveExpression(c *AdditiveExpressionContext) + + // ExitMultiplicativeExpression is called when exiting the multiplicativeExpression production. + ExitMultiplicativeExpression(c *MultiplicativeExpressionContext) + + // ExitUnionExpression is called when exiting the unionExpression production. + ExitUnionExpression(c *UnionExpressionContext) + + // ExitOrExpression is called when exiting the orExpression production. + ExitOrExpression(c *OrExpressionContext) + + // ExitAndExpression is called when exiting the andExpression production. + ExitAndExpression(c *AndExpressionContext) + + // ExitMembershipExpression is called when exiting the membershipExpression production. + ExitMembershipExpression(c *MembershipExpressionContext) + + // ExitInequalityExpression is called when exiting the inequalityExpression production. + ExitInequalityExpression(c *InequalityExpressionContext) + + // ExitInvocationExpression is called when exiting the invocationExpression production. + ExitInvocationExpression(c *InvocationExpressionContext) + + // ExitEqualityExpression is called when exiting the equalityExpression production. + ExitEqualityExpression(c *EqualityExpressionContext) + + // ExitImpliesExpression is called when exiting the impliesExpression production. + ExitImpliesExpression(c *ImpliesExpressionContext) + + // ExitTermExpression is called when exiting the termExpression production. + ExitTermExpression(c *TermExpressionContext) + + // ExitTypeExpression is called when exiting the typeExpression production. + ExitTypeExpression(c *TypeExpressionContext) + + // ExitInvocationTerm is called when exiting the invocationTerm production. + ExitInvocationTerm(c *InvocationTermContext) + + // ExitLiteralTerm is called when exiting the literalTerm production. + ExitLiteralTerm(c *LiteralTermContext) + + // ExitExternalConstantTerm is called when exiting the externalConstantTerm production. + ExitExternalConstantTerm(c *ExternalConstantTermContext) + + // ExitParenthesizedTerm is called when exiting the parenthesizedTerm production. + ExitParenthesizedTerm(c *ParenthesizedTermContext) + + // ExitNullLiteral is called when exiting the nullLiteral production. + ExitNullLiteral(c *NullLiteralContext) + + // ExitBooleanLiteral is called when exiting the booleanLiteral production. + ExitBooleanLiteral(c *BooleanLiteralContext) + + // ExitStringLiteral is called when exiting the stringLiteral production. + ExitStringLiteral(c *StringLiteralContext) + + // ExitNumberLiteral is called when exiting the numberLiteral production. + ExitNumberLiteral(c *NumberLiteralContext) + + // ExitDateLiteral is called when exiting the dateLiteral production. + ExitDateLiteral(c *DateLiteralContext) + + // ExitDateTimeLiteral is called when exiting the dateTimeLiteral production. + ExitDateTimeLiteral(c *DateTimeLiteralContext) + + // ExitTimeLiteral is called when exiting the timeLiteral production. + ExitTimeLiteral(c *TimeLiteralContext) + + // ExitQuantityLiteral is called when exiting the quantityLiteral production. + ExitQuantityLiteral(c *QuantityLiteralContext) + + // ExitExternalConstant is called when exiting the externalConstant production. + ExitExternalConstant(c *ExternalConstantContext) + + // ExitMemberInvocation is called when exiting the memberInvocation production. + ExitMemberInvocation(c *MemberInvocationContext) + + // ExitFunctionInvocation is called when exiting the functionInvocation production. + ExitFunctionInvocation(c *FunctionInvocationContext) + + // ExitThisInvocation is called when exiting the thisInvocation production. + ExitThisInvocation(c *ThisInvocationContext) + + // ExitIndexInvocation is called when exiting the indexInvocation production. + ExitIndexInvocation(c *IndexInvocationContext) + + // ExitTotalInvocation is called when exiting the totalInvocation production. + ExitTotalInvocation(c *TotalInvocationContext) + + // ExitFunction is called when exiting the function production. + ExitFunction(c *FunctionContext) + + // ExitParamList is called when exiting the paramList production. + ExitParamList(c *ParamListContext) + + // ExitQuantity is called when exiting the quantity production. + ExitQuantity(c *QuantityContext) + + // ExitUnit is called when exiting the unit production. + ExitUnit(c *UnitContext) + + // ExitDateTimePrecision is called when exiting the dateTimePrecision production. + ExitDateTimePrecision(c *DateTimePrecisionContext) + + // ExitPluralDateTimePrecision is called when exiting the pluralDateTimePrecision production. + ExitPluralDateTimePrecision(c *PluralDateTimePrecisionContext) + + // ExitTypeSpecifier is called when exiting the typeSpecifier production. + ExitTypeSpecifier(c *TypeSpecifierContext) + + // ExitQualifiedIdentifier is called when exiting the qualifiedIdentifier production. + ExitQualifiedIdentifier(c *QualifiedIdentifierContext) + + // ExitIdentifier is called when exiting the identifier production. + ExitIdentifier(c *IdentifierContext) +} diff --git a/go/fhirpath/gen/fhirpath_parser.go b/go/fhirpath/gen/fhirpath_parser.go new file mode 100755 index 000000000..9302b1a53 --- /dev/null +++ b/go/fhirpath/gen/fhirpath_parser.go @@ -0,0 +1,4483 @@ +// Code generated from FhirPath.g4 by ANTLR 4.13.1. DO NOT EDIT. + +package gen // FhirPath +import ( + "fmt" + "strconv" + "sync" + + "github.com/antlr4-go/antlr/v4" +) + +// Suppress unused import errors +var _ = fmt.Printf +var _ = strconv.Itoa +var _ = sync.Once{} + +type FhirPathParser struct { + *antlr.BaseParser +} + +var FhirPathParserStaticData struct { + once sync.Once + serializedATN []int32 + LiteralNames []string + SymbolicNames []string + RuleNames []string + PredictionContextCache *antlr.PredictionContextCache + atn *antlr.ATN + decisionToDFA []*antlr.DFA +} + +func fhirpathParserInit() { + staticData := &FhirPathParserStaticData + staticData.LiteralNames = []string{ + "", "'.'", "'['", "']'", "'+'", "'-'", "'*'", "'/'", "'div'", "'mod'", + "'&'", "'is'", "'as'", "'|'", "'<='", "'<'", "'>'", "'>='", "'='", "'~'", + "'!='", "'!~'", "'in'", "'contains'", "'and'", "'or'", "'xor'", "'implies'", + "'('", "')'", "'{'", "'}'", "'true'", "'false'", "'%'", "'$this'", "'$index'", + "'$total'", "','", "'year'", "'month'", "'week'", "'day'", "'hour'", + "'minute'", "'second'", "'millisecond'", "'years'", "'months'", "'weeks'", + "'days'", "'hours'", "'minutes'", "'seconds'", "'milliseconds'", + } + staticData.SymbolicNames = []string{ + "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", + "", "", "", "", "DATE", "DATETIME", "TIME", "IDENTIFIER", "DELIMITEDIDENTIFIER", + "STRING", "NUMBER", "WS", "COMMENT", "LINE_COMMENT", + } + staticData.RuleNames = []string{ + "expression", "term", "literal", "externalConstant", "invocation", "function", + "paramList", "quantity", "unit", "dateTimePrecision", "pluralDateTimePrecision", + "typeSpecifier", "qualifiedIdentifier", "identifier", + } + staticData.PredictionContextCache = antlr.NewPredictionContextCache() + staticData.serializedATN = []int32{ + 4, 1, 64, 150, 2, 0, 7, 0, 2, 1, 7, 1, 2, 2, 7, 2, 2, 3, 7, 3, 2, 4, 7, + 4, 2, 5, 7, 5, 2, 6, 7, 6, 2, 7, 7, 7, 2, 8, 7, 8, 2, 9, 7, 9, 2, 10, 7, + 10, 2, 11, 7, 11, 2, 12, 7, 12, 2, 13, 7, 13, 1, 0, 1, 0, 1, 0, 1, 0, 3, + 0, 33, 8, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, + 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, + 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, + 1, 0, 1, 0, 1, 0, 1, 0, 5, 0, 73, 8, 0, 10, 0, 12, 0, 76, 9, 0, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 1, 85, 8, 1, 1, 2, 1, 2, 1, 2, 1, 2, + 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 3, 2, 96, 8, 2, 1, 3, 1, 3, 1, 3, 3, 3, 101, + 8, 3, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 3, 4, 108, 8, 4, 1, 5, 1, 5, 1, 5, + 3, 5, 113, 8, 5, 1, 5, 1, 5, 1, 6, 1, 6, 1, 6, 5, 6, 120, 8, 6, 10, 6, + 12, 6, 123, 9, 6, 1, 7, 1, 7, 3, 7, 127, 8, 7, 1, 8, 1, 8, 1, 8, 3, 8, + 132, 8, 8, 1, 9, 1, 9, 1, 10, 1, 10, 1, 11, 1, 11, 1, 12, 1, 12, 1, 12, + 5, 12, 143, 8, 12, 10, 12, 12, 12, 146, 9, 12, 1, 13, 1, 13, 1, 13, 0, + 1, 0, 14, 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 0, 12, 1, + 0, 4, 5, 1, 0, 6, 9, 2, 0, 4, 5, 10, 10, 1, 0, 14, 17, 1, 0, 18, 21, 1, + 0, 22, 23, 1, 0, 25, 26, 1, 0, 11, 12, 1, 0, 32, 33, 1, 0, 39, 46, 1, 0, + 47, 54, 3, 0, 11, 12, 22, 23, 58, 59, 169, 0, 32, 1, 0, 0, 0, 2, 84, 1, + 0, 0, 0, 4, 95, 1, 0, 0, 0, 6, 97, 1, 0, 0, 0, 8, 107, 1, 0, 0, 0, 10, + 109, 1, 0, 0, 0, 12, 116, 1, 0, 0, 0, 14, 124, 1, 0, 0, 0, 16, 131, 1, + 0, 0, 0, 18, 133, 1, 0, 0, 0, 20, 135, 1, 0, 0, 0, 22, 137, 1, 0, 0, 0, + 24, 139, 1, 0, 0, 0, 26, 147, 1, 0, 0, 0, 28, 29, 6, 0, -1, 0, 29, 33, + 3, 2, 1, 0, 30, 31, 7, 0, 0, 0, 31, 33, 3, 0, 0, 11, 32, 28, 1, 0, 0, 0, + 32, 30, 1, 0, 0, 0, 33, 74, 1, 0, 0, 0, 34, 35, 10, 10, 0, 0, 35, 36, 7, + 1, 0, 0, 36, 73, 3, 0, 0, 11, 37, 38, 10, 9, 0, 0, 38, 39, 7, 2, 0, 0, + 39, 73, 3, 0, 0, 10, 40, 41, 10, 7, 0, 0, 41, 42, 5, 13, 0, 0, 42, 73, + 3, 0, 0, 8, 43, 44, 10, 6, 0, 0, 44, 45, 7, 3, 0, 0, 45, 73, 3, 0, 0, 7, + 46, 47, 10, 5, 0, 0, 47, 48, 7, 4, 0, 0, 48, 73, 3, 0, 0, 6, 49, 50, 10, + 4, 0, 0, 50, 51, 7, 5, 0, 0, 51, 73, 3, 0, 0, 5, 52, 53, 10, 3, 0, 0, 53, + 54, 5, 24, 0, 0, 54, 73, 3, 0, 0, 4, 55, 56, 10, 2, 0, 0, 56, 57, 7, 6, + 0, 0, 57, 73, 3, 0, 0, 3, 58, 59, 10, 1, 0, 0, 59, 60, 5, 27, 0, 0, 60, + 73, 3, 0, 0, 2, 61, 62, 10, 13, 0, 0, 62, 63, 5, 1, 0, 0, 63, 73, 3, 8, + 4, 0, 64, 65, 10, 12, 0, 0, 65, 66, 5, 2, 0, 0, 66, 67, 3, 0, 0, 0, 67, + 68, 5, 3, 0, 0, 68, 73, 1, 0, 0, 0, 69, 70, 10, 8, 0, 0, 70, 71, 7, 7, + 0, 0, 71, 73, 3, 22, 11, 0, 72, 34, 1, 0, 0, 0, 72, 37, 1, 0, 0, 0, 72, + 40, 1, 0, 0, 0, 72, 43, 1, 0, 0, 0, 72, 46, 1, 0, 0, 0, 72, 49, 1, 0, 0, + 0, 72, 52, 1, 0, 0, 0, 72, 55, 1, 0, 0, 0, 72, 58, 1, 0, 0, 0, 72, 61, + 1, 0, 0, 0, 72, 64, 1, 0, 0, 0, 72, 69, 1, 0, 0, 0, 73, 76, 1, 0, 0, 0, + 74, 72, 1, 0, 0, 0, 74, 75, 1, 0, 0, 0, 75, 1, 1, 0, 0, 0, 76, 74, 1, 0, + 0, 0, 77, 85, 3, 8, 4, 0, 78, 85, 3, 4, 2, 0, 79, 85, 3, 6, 3, 0, 80, 81, + 5, 28, 0, 0, 81, 82, 3, 0, 0, 0, 82, 83, 5, 29, 0, 0, 83, 85, 1, 0, 0, + 0, 84, 77, 1, 0, 0, 0, 84, 78, 1, 0, 0, 0, 84, 79, 1, 0, 0, 0, 84, 80, + 1, 0, 0, 0, 85, 3, 1, 0, 0, 0, 86, 87, 5, 30, 0, 0, 87, 96, 5, 31, 0, 0, + 88, 96, 7, 8, 0, 0, 89, 96, 5, 60, 0, 0, 90, 96, 5, 61, 0, 0, 91, 96, 5, + 55, 0, 0, 92, 96, 5, 56, 0, 0, 93, 96, 5, 57, 0, 0, 94, 96, 3, 14, 7, 0, + 95, 86, 1, 0, 0, 0, 95, 88, 1, 0, 0, 0, 95, 89, 1, 0, 0, 0, 95, 90, 1, + 0, 0, 0, 95, 91, 1, 0, 0, 0, 95, 92, 1, 0, 0, 0, 95, 93, 1, 0, 0, 0, 95, + 94, 1, 0, 0, 0, 96, 5, 1, 0, 0, 0, 97, 100, 5, 34, 0, 0, 98, 101, 3, 26, + 13, 0, 99, 101, 5, 60, 0, 0, 100, 98, 1, 0, 0, 0, 100, 99, 1, 0, 0, 0, + 101, 7, 1, 0, 0, 0, 102, 108, 3, 26, 13, 0, 103, 108, 3, 10, 5, 0, 104, + 108, 5, 35, 0, 0, 105, 108, 5, 36, 0, 0, 106, 108, 5, 37, 0, 0, 107, 102, + 1, 0, 0, 0, 107, 103, 1, 0, 0, 0, 107, 104, 1, 0, 0, 0, 107, 105, 1, 0, + 0, 0, 107, 106, 1, 0, 0, 0, 108, 9, 1, 0, 0, 0, 109, 110, 3, 26, 13, 0, + 110, 112, 5, 28, 0, 0, 111, 113, 3, 12, 6, 0, 112, 111, 1, 0, 0, 0, 112, + 113, 1, 0, 0, 0, 113, 114, 1, 0, 0, 0, 114, 115, 5, 29, 0, 0, 115, 11, + 1, 0, 0, 0, 116, 121, 3, 0, 0, 0, 117, 118, 5, 38, 0, 0, 118, 120, 3, 0, + 0, 0, 119, 117, 1, 0, 0, 0, 120, 123, 1, 0, 0, 0, 121, 119, 1, 0, 0, 0, + 121, 122, 1, 0, 0, 0, 122, 13, 1, 0, 0, 0, 123, 121, 1, 0, 0, 0, 124, 126, + 5, 61, 0, 0, 125, 127, 3, 16, 8, 0, 126, 125, 1, 0, 0, 0, 126, 127, 1, + 0, 0, 0, 127, 15, 1, 0, 0, 0, 128, 132, 3, 18, 9, 0, 129, 132, 3, 20, 10, + 0, 130, 132, 5, 60, 0, 0, 131, 128, 1, 0, 0, 0, 131, 129, 1, 0, 0, 0, 131, + 130, 1, 0, 0, 0, 132, 17, 1, 0, 0, 0, 133, 134, 7, 9, 0, 0, 134, 19, 1, + 0, 0, 0, 135, 136, 7, 10, 0, 0, 136, 21, 1, 0, 0, 0, 137, 138, 3, 24, 12, + 0, 138, 23, 1, 0, 0, 0, 139, 144, 3, 26, 13, 0, 140, 141, 5, 1, 0, 0, 141, + 143, 3, 26, 13, 0, 142, 140, 1, 0, 0, 0, 143, 146, 1, 0, 0, 0, 144, 142, + 1, 0, 0, 0, 144, 145, 1, 0, 0, 0, 145, 25, 1, 0, 0, 0, 146, 144, 1, 0, + 0, 0, 147, 148, 7, 11, 0, 0, 148, 27, 1, 0, 0, 0, 12, 32, 72, 74, 84, 95, + 100, 107, 112, 121, 126, 131, 144, + } + deserializer := antlr.NewATNDeserializer(nil) + staticData.atn = deserializer.Deserialize(staticData.serializedATN) + atn := staticData.atn + staticData.decisionToDFA = make([]*antlr.DFA, len(atn.DecisionToState)) + decisionToDFA := staticData.decisionToDFA + for index, state := range atn.DecisionToState { + decisionToDFA[index] = antlr.NewDFA(state, index) + } +} + +// FhirPathParserInit initializes any static state used to implement FhirPathParser. By default the +// static state used to implement the parser is lazily initialized during the first call to +// NewFhirPathParser(). You can call this function if you wish to initialize the static state ahead +// of time. +func FhirPathParserInit() { + staticData := &FhirPathParserStaticData + staticData.once.Do(fhirpathParserInit) +} + +// NewFhirPathParser produces a new parser instance for the optional input antlr.TokenStream. +func NewFhirPathParser(input antlr.TokenStream) *FhirPathParser { + FhirPathParserInit() + this := new(FhirPathParser) + this.BaseParser = antlr.NewBaseParser(input) + staticData := &FhirPathParserStaticData + this.Interpreter = antlr.NewParserATNSimulator(this, staticData.atn, staticData.decisionToDFA, staticData.PredictionContextCache) + this.RuleNames = staticData.RuleNames + this.LiteralNames = staticData.LiteralNames + this.SymbolicNames = staticData.SymbolicNames + this.GrammarFileName = "FhirPath.g4" + + return this +} + +// FhirPathParser tokens. +const ( + FhirPathParserEOF = antlr.TokenEOF + FhirPathParserT__0 = 1 + FhirPathParserT__1 = 2 + FhirPathParserT__2 = 3 + FhirPathParserT__3 = 4 + FhirPathParserT__4 = 5 + FhirPathParserT__5 = 6 + FhirPathParserT__6 = 7 + FhirPathParserT__7 = 8 + FhirPathParserT__8 = 9 + FhirPathParserT__9 = 10 + FhirPathParserT__10 = 11 + FhirPathParserT__11 = 12 + FhirPathParserT__12 = 13 + FhirPathParserT__13 = 14 + FhirPathParserT__14 = 15 + FhirPathParserT__15 = 16 + FhirPathParserT__16 = 17 + FhirPathParserT__17 = 18 + FhirPathParserT__18 = 19 + FhirPathParserT__19 = 20 + FhirPathParserT__20 = 21 + FhirPathParserT__21 = 22 + FhirPathParserT__22 = 23 + FhirPathParserT__23 = 24 + FhirPathParserT__24 = 25 + FhirPathParserT__25 = 26 + FhirPathParserT__26 = 27 + FhirPathParserT__27 = 28 + FhirPathParserT__28 = 29 + FhirPathParserT__29 = 30 + FhirPathParserT__30 = 31 + FhirPathParserT__31 = 32 + FhirPathParserT__32 = 33 + FhirPathParserT__33 = 34 + FhirPathParserT__34 = 35 + FhirPathParserT__35 = 36 + FhirPathParserT__36 = 37 + FhirPathParserT__37 = 38 + FhirPathParserT__38 = 39 + FhirPathParserT__39 = 40 + FhirPathParserT__40 = 41 + FhirPathParserT__41 = 42 + FhirPathParserT__42 = 43 + FhirPathParserT__43 = 44 + FhirPathParserT__44 = 45 + FhirPathParserT__45 = 46 + FhirPathParserT__46 = 47 + FhirPathParserT__47 = 48 + FhirPathParserT__48 = 49 + FhirPathParserT__49 = 50 + FhirPathParserT__50 = 51 + FhirPathParserT__51 = 52 + FhirPathParserT__52 = 53 + FhirPathParserT__53 = 54 + FhirPathParserDATE = 55 + FhirPathParserDATETIME = 56 + FhirPathParserTIME = 57 + FhirPathParserIDENTIFIER = 58 + FhirPathParserDELIMITEDIDENTIFIER = 59 + FhirPathParserSTRING = 60 + FhirPathParserNUMBER = 61 + FhirPathParserWS = 62 + FhirPathParserCOMMENT = 63 + FhirPathParserLINE_COMMENT = 64 +) + +// FhirPathParser rules. +const ( + FhirPathParserRULE_expression = 0 + FhirPathParserRULE_term = 1 + FhirPathParserRULE_literal = 2 + FhirPathParserRULE_externalConstant = 3 + FhirPathParserRULE_invocation = 4 + FhirPathParserRULE_function = 5 + FhirPathParserRULE_paramList = 6 + FhirPathParserRULE_quantity = 7 + FhirPathParserRULE_unit = 8 + FhirPathParserRULE_dateTimePrecision = 9 + FhirPathParserRULE_pluralDateTimePrecision = 10 + FhirPathParserRULE_typeSpecifier = 11 + FhirPathParserRULE_qualifiedIdentifier = 12 + FhirPathParserRULE_identifier = 13 +) + +// IExpressionContext is an interface to support dynamic dispatch. +type IExpressionContext interface { + antlr.ParserRuleContext + + // GetParser returns the parser. + GetParser() antlr.Parser + // IsExpressionContext differentiates from other interfaces. + IsExpressionContext() +} + +type ExpressionContext struct { + antlr.BaseParserRuleContext + parser antlr.Parser +} + +func NewEmptyExpressionContext() *ExpressionContext { + var p = new(ExpressionContext) + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) + p.RuleIndex = FhirPathParserRULE_expression + return p +} + +func InitEmptyExpressionContext(p *ExpressionContext) { + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) + p.RuleIndex = FhirPathParserRULE_expression +} + +func (*ExpressionContext) IsExpressionContext() {} + +func NewExpressionContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *ExpressionContext { + var p = new(ExpressionContext) + + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, parent, invokingState) + + p.parser = parser + p.RuleIndex = FhirPathParserRULE_expression + + return p +} + +func (s *ExpressionContext) GetParser() antlr.Parser { return s.parser } + +func (s *ExpressionContext) CopyAll(ctx *ExpressionContext) { + s.CopyFrom(&ctx.BaseParserRuleContext) +} + +func (s *ExpressionContext) GetRuleContext() antlr.RuleContext { + return s +} + +func (s *ExpressionContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string { + return antlr.TreesStringTree(s, ruleNames, recog) +} + +type IndexerExpressionContext struct { + ExpressionContext +} + +func NewIndexerExpressionContext(parser antlr.Parser, ctx antlr.ParserRuleContext) *IndexerExpressionContext { + var p = new(IndexerExpressionContext) + + InitEmptyExpressionContext(&p.ExpressionContext) + p.parser = parser + p.CopyAll(ctx.(*ExpressionContext)) + + return p +} + +func (s *IndexerExpressionContext) GetRuleContext() antlr.RuleContext { + return s +} + +func (s *IndexerExpressionContext) AllExpression() []IExpressionContext { + children := s.GetChildren() + len := 0 + for _, ctx := range children { + if _, ok := ctx.(IExpressionContext); ok { + len++ + } + } + + tst := make([]IExpressionContext, len) + i := 0 + for _, ctx := range children { + if t, ok := ctx.(IExpressionContext); ok { + tst[i] = t.(IExpressionContext) + i++ + } + } + + return tst +} + +func (s *IndexerExpressionContext) Expression(i int) IExpressionContext { + var t antlr.RuleContext + j := 0 + for _, ctx := range s.GetChildren() { + if _, ok := ctx.(IExpressionContext); ok { + if j == i { + t = ctx.(antlr.RuleContext) + break + } + j++ + } + } + + if t == nil { + return nil + } + + return t.(IExpressionContext) +} + +func (s *IndexerExpressionContext) EnterRule(listener antlr.ParseTreeListener) { + if listenerT, ok := listener.(FhirPathListener); ok { + listenerT.EnterIndexerExpression(s) + } +} + +func (s *IndexerExpressionContext) ExitRule(listener antlr.ParseTreeListener) { + if listenerT, ok := listener.(FhirPathListener); ok { + listenerT.ExitIndexerExpression(s) + } +} + +func (s *IndexerExpressionContext) Accept(visitor antlr.ParseTreeVisitor) interface{} { + switch t := visitor.(type) { + case FhirPathVisitor: + return t.VisitIndexerExpression(s) + + default: + return t.VisitChildren(s) + } +} + +type PolarityExpressionContext struct { + ExpressionContext +} + +func NewPolarityExpressionContext(parser antlr.Parser, ctx antlr.ParserRuleContext) *PolarityExpressionContext { + var p = new(PolarityExpressionContext) + + InitEmptyExpressionContext(&p.ExpressionContext) + p.parser = parser + p.CopyAll(ctx.(*ExpressionContext)) + + return p +} + +func (s *PolarityExpressionContext) GetRuleContext() antlr.RuleContext { + return s +} + +func (s *PolarityExpressionContext) Expression() IExpressionContext { + var t antlr.RuleContext + for _, ctx := range s.GetChildren() { + if _, ok := ctx.(IExpressionContext); ok { + t = ctx.(antlr.RuleContext) + break + } + } + + if t == nil { + return nil + } + + return t.(IExpressionContext) +} + +func (s *PolarityExpressionContext) EnterRule(listener antlr.ParseTreeListener) { + if listenerT, ok := listener.(FhirPathListener); ok { + listenerT.EnterPolarityExpression(s) + } +} + +func (s *PolarityExpressionContext) ExitRule(listener antlr.ParseTreeListener) { + if listenerT, ok := listener.(FhirPathListener); ok { + listenerT.ExitPolarityExpression(s) + } +} + +func (s *PolarityExpressionContext) Accept(visitor antlr.ParseTreeVisitor) interface{} { + switch t := visitor.(type) { + case FhirPathVisitor: + return t.VisitPolarityExpression(s) + + default: + return t.VisitChildren(s) + } +} + +type AdditiveExpressionContext struct { + ExpressionContext +} + +func NewAdditiveExpressionContext(parser antlr.Parser, ctx antlr.ParserRuleContext) *AdditiveExpressionContext { + var p = new(AdditiveExpressionContext) + + InitEmptyExpressionContext(&p.ExpressionContext) + p.parser = parser + p.CopyAll(ctx.(*ExpressionContext)) + + return p +} + +func (s *AdditiveExpressionContext) GetRuleContext() antlr.RuleContext { + return s +} + +func (s *AdditiveExpressionContext) AllExpression() []IExpressionContext { + children := s.GetChildren() + len := 0 + for _, ctx := range children { + if _, ok := ctx.(IExpressionContext); ok { + len++ + } + } + + tst := make([]IExpressionContext, len) + i := 0 + for _, ctx := range children { + if t, ok := ctx.(IExpressionContext); ok { + tst[i] = t.(IExpressionContext) + i++ + } + } + + return tst +} + +func (s *AdditiveExpressionContext) Expression(i int) IExpressionContext { + var t antlr.RuleContext + j := 0 + for _, ctx := range s.GetChildren() { + if _, ok := ctx.(IExpressionContext); ok { + if j == i { + t = ctx.(antlr.RuleContext) + break + } + j++ + } + } + + if t == nil { + return nil + } + + return t.(IExpressionContext) +} + +func (s *AdditiveExpressionContext) EnterRule(listener antlr.ParseTreeListener) { + if listenerT, ok := listener.(FhirPathListener); ok { + listenerT.EnterAdditiveExpression(s) + } +} + +func (s *AdditiveExpressionContext) ExitRule(listener antlr.ParseTreeListener) { + if listenerT, ok := listener.(FhirPathListener); ok { + listenerT.ExitAdditiveExpression(s) + } +} + +func (s *AdditiveExpressionContext) Accept(visitor antlr.ParseTreeVisitor) interface{} { + switch t := visitor.(type) { + case FhirPathVisitor: + return t.VisitAdditiveExpression(s) + + default: + return t.VisitChildren(s) + } +} + +type MultiplicativeExpressionContext struct { + ExpressionContext +} + +func NewMultiplicativeExpressionContext(parser antlr.Parser, ctx antlr.ParserRuleContext) *MultiplicativeExpressionContext { + var p = new(MultiplicativeExpressionContext) + + InitEmptyExpressionContext(&p.ExpressionContext) + p.parser = parser + p.CopyAll(ctx.(*ExpressionContext)) + + return p +} + +func (s *MultiplicativeExpressionContext) GetRuleContext() antlr.RuleContext { + return s +} + +func (s *MultiplicativeExpressionContext) AllExpression() []IExpressionContext { + children := s.GetChildren() + len := 0 + for _, ctx := range children { + if _, ok := ctx.(IExpressionContext); ok { + len++ + } + } + + tst := make([]IExpressionContext, len) + i := 0 + for _, ctx := range children { + if t, ok := ctx.(IExpressionContext); ok { + tst[i] = t.(IExpressionContext) + i++ + } + } + + return tst +} + +func (s *MultiplicativeExpressionContext) Expression(i int) IExpressionContext { + var t antlr.RuleContext + j := 0 + for _, ctx := range s.GetChildren() { + if _, ok := ctx.(IExpressionContext); ok { + if j == i { + t = ctx.(antlr.RuleContext) + break + } + j++ + } + } + + if t == nil { + return nil + } + + return t.(IExpressionContext) +} + +func (s *MultiplicativeExpressionContext) EnterRule(listener antlr.ParseTreeListener) { + if listenerT, ok := listener.(FhirPathListener); ok { + listenerT.EnterMultiplicativeExpression(s) + } +} + +func (s *MultiplicativeExpressionContext) ExitRule(listener antlr.ParseTreeListener) { + if listenerT, ok := listener.(FhirPathListener); ok { + listenerT.ExitMultiplicativeExpression(s) + } +} + +func (s *MultiplicativeExpressionContext) Accept(visitor antlr.ParseTreeVisitor) interface{} { + switch t := visitor.(type) { + case FhirPathVisitor: + return t.VisitMultiplicativeExpression(s) + + default: + return t.VisitChildren(s) + } +} + +type UnionExpressionContext struct { + ExpressionContext +} + +func NewUnionExpressionContext(parser antlr.Parser, ctx antlr.ParserRuleContext) *UnionExpressionContext { + var p = new(UnionExpressionContext) + + InitEmptyExpressionContext(&p.ExpressionContext) + p.parser = parser + p.CopyAll(ctx.(*ExpressionContext)) + + return p +} + +func (s *UnionExpressionContext) GetRuleContext() antlr.RuleContext { + return s +} + +func (s *UnionExpressionContext) AllExpression() []IExpressionContext { + children := s.GetChildren() + len := 0 + for _, ctx := range children { + if _, ok := ctx.(IExpressionContext); ok { + len++ + } + } + + tst := make([]IExpressionContext, len) + i := 0 + for _, ctx := range children { + if t, ok := ctx.(IExpressionContext); ok { + tst[i] = t.(IExpressionContext) + i++ + } + } + + return tst +} + +func (s *UnionExpressionContext) Expression(i int) IExpressionContext { + var t antlr.RuleContext + j := 0 + for _, ctx := range s.GetChildren() { + if _, ok := ctx.(IExpressionContext); ok { + if j == i { + t = ctx.(antlr.RuleContext) + break + } + j++ + } + } + + if t == nil { + return nil + } + + return t.(IExpressionContext) +} + +func (s *UnionExpressionContext) EnterRule(listener antlr.ParseTreeListener) { + if listenerT, ok := listener.(FhirPathListener); ok { + listenerT.EnterUnionExpression(s) + } +} + +func (s *UnionExpressionContext) ExitRule(listener antlr.ParseTreeListener) { + if listenerT, ok := listener.(FhirPathListener); ok { + listenerT.ExitUnionExpression(s) + } +} + +func (s *UnionExpressionContext) Accept(visitor antlr.ParseTreeVisitor) interface{} { + switch t := visitor.(type) { + case FhirPathVisitor: + return t.VisitUnionExpression(s) + + default: + return t.VisitChildren(s) + } +} + +type OrExpressionContext struct { + ExpressionContext +} + +func NewOrExpressionContext(parser antlr.Parser, ctx antlr.ParserRuleContext) *OrExpressionContext { + var p = new(OrExpressionContext) + + InitEmptyExpressionContext(&p.ExpressionContext) + p.parser = parser + p.CopyAll(ctx.(*ExpressionContext)) + + return p +} + +func (s *OrExpressionContext) GetRuleContext() antlr.RuleContext { + return s +} + +func (s *OrExpressionContext) AllExpression() []IExpressionContext { + children := s.GetChildren() + len := 0 + for _, ctx := range children { + if _, ok := ctx.(IExpressionContext); ok { + len++ + } + } + + tst := make([]IExpressionContext, len) + i := 0 + for _, ctx := range children { + if t, ok := ctx.(IExpressionContext); ok { + tst[i] = t.(IExpressionContext) + i++ + } + } + + return tst +} + +func (s *OrExpressionContext) Expression(i int) IExpressionContext { + var t antlr.RuleContext + j := 0 + for _, ctx := range s.GetChildren() { + if _, ok := ctx.(IExpressionContext); ok { + if j == i { + t = ctx.(antlr.RuleContext) + break + } + j++ + } + } + + if t == nil { + return nil + } + + return t.(IExpressionContext) +} + +func (s *OrExpressionContext) EnterRule(listener antlr.ParseTreeListener) { + if listenerT, ok := listener.(FhirPathListener); ok { + listenerT.EnterOrExpression(s) + } +} + +func (s *OrExpressionContext) ExitRule(listener antlr.ParseTreeListener) { + if listenerT, ok := listener.(FhirPathListener); ok { + listenerT.ExitOrExpression(s) + } +} + +func (s *OrExpressionContext) Accept(visitor antlr.ParseTreeVisitor) interface{} { + switch t := visitor.(type) { + case FhirPathVisitor: + return t.VisitOrExpression(s) + + default: + return t.VisitChildren(s) + } +} + +type AndExpressionContext struct { + ExpressionContext +} + +func NewAndExpressionContext(parser antlr.Parser, ctx antlr.ParserRuleContext) *AndExpressionContext { + var p = new(AndExpressionContext) + + InitEmptyExpressionContext(&p.ExpressionContext) + p.parser = parser + p.CopyAll(ctx.(*ExpressionContext)) + + return p +} + +func (s *AndExpressionContext) GetRuleContext() antlr.RuleContext { + return s +} + +func (s *AndExpressionContext) AllExpression() []IExpressionContext { + children := s.GetChildren() + len := 0 + for _, ctx := range children { + if _, ok := ctx.(IExpressionContext); ok { + len++ + } + } + + tst := make([]IExpressionContext, len) + i := 0 + for _, ctx := range children { + if t, ok := ctx.(IExpressionContext); ok { + tst[i] = t.(IExpressionContext) + i++ + } + } + + return tst +} + +func (s *AndExpressionContext) Expression(i int) IExpressionContext { + var t antlr.RuleContext + j := 0 + for _, ctx := range s.GetChildren() { + if _, ok := ctx.(IExpressionContext); ok { + if j == i { + t = ctx.(antlr.RuleContext) + break + } + j++ + } + } + + if t == nil { + return nil + } + + return t.(IExpressionContext) +} + +func (s *AndExpressionContext) EnterRule(listener antlr.ParseTreeListener) { + if listenerT, ok := listener.(FhirPathListener); ok { + listenerT.EnterAndExpression(s) + } +} + +func (s *AndExpressionContext) ExitRule(listener antlr.ParseTreeListener) { + if listenerT, ok := listener.(FhirPathListener); ok { + listenerT.ExitAndExpression(s) + } +} + +func (s *AndExpressionContext) Accept(visitor antlr.ParseTreeVisitor) interface{} { + switch t := visitor.(type) { + case FhirPathVisitor: + return t.VisitAndExpression(s) + + default: + return t.VisitChildren(s) + } +} + +type MembershipExpressionContext struct { + ExpressionContext +} + +func NewMembershipExpressionContext(parser antlr.Parser, ctx antlr.ParserRuleContext) *MembershipExpressionContext { + var p = new(MembershipExpressionContext) + + InitEmptyExpressionContext(&p.ExpressionContext) + p.parser = parser + p.CopyAll(ctx.(*ExpressionContext)) + + return p +} + +func (s *MembershipExpressionContext) GetRuleContext() antlr.RuleContext { + return s +} + +func (s *MembershipExpressionContext) AllExpression() []IExpressionContext { + children := s.GetChildren() + len := 0 + for _, ctx := range children { + if _, ok := ctx.(IExpressionContext); ok { + len++ + } + } + + tst := make([]IExpressionContext, len) + i := 0 + for _, ctx := range children { + if t, ok := ctx.(IExpressionContext); ok { + tst[i] = t.(IExpressionContext) + i++ + } + } + + return tst +} + +func (s *MembershipExpressionContext) Expression(i int) IExpressionContext { + var t antlr.RuleContext + j := 0 + for _, ctx := range s.GetChildren() { + if _, ok := ctx.(IExpressionContext); ok { + if j == i { + t = ctx.(antlr.RuleContext) + break + } + j++ + } + } + + if t == nil { + return nil + } + + return t.(IExpressionContext) +} + +func (s *MembershipExpressionContext) EnterRule(listener antlr.ParseTreeListener) { + if listenerT, ok := listener.(FhirPathListener); ok { + listenerT.EnterMembershipExpression(s) + } +} + +func (s *MembershipExpressionContext) ExitRule(listener antlr.ParseTreeListener) { + if listenerT, ok := listener.(FhirPathListener); ok { + listenerT.ExitMembershipExpression(s) + } +} + +func (s *MembershipExpressionContext) Accept(visitor antlr.ParseTreeVisitor) interface{} { + switch t := visitor.(type) { + case FhirPathVisitor: + return t.VisitMembershipExpression(s) + + default: + return t.VisitChildren(s) + } +} + +type InequalityExpressionContext struct { + ExpressionContext +} + +func NewInequalityExpressionContext(parser antlr.Parser, ctx antlr.ParserRuleContext) *InequalityExpressionContext { + var p = new(InequalityExpressionContext) + + InitEmptyExpressionContext(&p.ExpressionContext) + p.parser = parser + p.CopyAll(ctx.(*ExpressionContext)) + + return p +} + +func (s *InequalityExpressionContext) GetRuleContext() antlr.RuleContext { + return s +} + +func (s *InequalityExpressionContext) AllExpression() []IExpressionContext { + children := s.GetChildren() + len := 0 + for _, ctx := range children { + if _, ok := ctx.(IExpressionContext); ok { + len++ + } + } + + tst := make([]IExpressionContext, len) + i := 0 + for _, ctx := range children { + if t, ok := ctx.(IExpressionContext); ok { + tst[i] = t.(IExpressionContext) + i++ + } + } + + return tst +} + +func (s *InequalityExpressionContext) Expression(i int) IExpressionContext { + var t antlr.RuleContext + j := 0 + for _, ctx := range s.GetChildren() { + if _, ok := ctx.(IExpressionContext); ok { + if j == i { + t = ctx.(antlr.RuleContext) + break + } + j++ + } + } + + if t == nil { + return nil + } + + return t.(IExpressionContext) +} + +func (s *InequalityExpressionContext) EnterRule(listener antlr.ParseTreeListener) { + if listenerT, ok := listener.(FhirPathListener); ok { + listenerT.EnterInequalityExpression(s) + } +} + +func (s *InequalityExpressionContext) ExitRule(listener antlr.ParseTreeListener) { + if listenerT, ok := listener.(FhirPathListener); ok { + listenerT.ExitInequalityExpression(s) + } +} + +func (s *InequalityExpressionContext) Accept(visitor antlr.ParseTreeVisitor) interface{} { + switch t := visitor.(type) { + case FhirPathVisitor: + return t.VisitInequalityExpression(s) + + default: + return t.VisitChildren(s) + } +} + +type InvocationExpressionContext struct { + ExpressionContext +} + +func NewInvocationExpressionContext(parser antlr.Parser, ctx antlr.ParserRuleContext) *InvocationExpressionContext { + var p = new(InvocationExpressionContext) + + InitEmptyExpressionContext(&p.ExpressionContext) + p.parser = parser + p.CopyAll(ctx.(*ExpressionContext)) + + return p +} + +func (s *InvocationExpressionContext) GetRuleContext() antlr.RuleContext { + return s +} + +func (s *InvocationExpressionContext) Expression() IExpressionContext { + var t antlr.RuleContext + for _, ctx := range s.GetChildren() { + if _, ok := ctx.(IExpressionContext); ok { + t = ctx.(antlr.RuleContext) + break + } + } + + if t == nil { + return nil + } + + return t.(IExpressionContext) +} + +func (s *InvocationExpressionContext) Invocation() IInvocationContext { + var t antlr.RuleContext + for _, ctx := range s.GetChildren() { + if _, ok := ctx.(IInvocationContext); ok { + t = ctx.(antlr.RuleContext) + break + } + } + + if t == nil { + return nil + } + + return t.(IInvocationContext) +} + +func (s *InvocationExpressionContext) EnterRule(listener antlr.ParseTreeListener) { + if listenerT, ok := listener.(FhirPathListener); ok { + listenerT.EnterInvocationExpression(s) + } +} + +func (s *InvocationExpressionContext) ExitRule(listener antlr.ParseTreeListener) { + if listenerT, ok := listener.(FhirPathListener); ok { + listenerT.ExitInvocationExpression(s) + } +} + +func (s *InvocationExpressionContext) Accept(visitor antlr.ParseTreeVisitor) interface{} { + switch t := visitor.(type) { + case FhirPathVisitor: + return t.VisitInvocationExpression(s) + + default: + return t.VisitChildren(s) + } +} + +type EqualityExpressionContext struct { + ExpressionContext +} + +func NewEqualityExpressionContext(parser antlr.Parser, ctx antlr.ParserRuleContext) *EqualityExpressionContext { + var p = new(EqualityExpressionContext) + + InitEmptyExpressionContext(&p.ExpressionContext) + p.parser = parser + p.CopyAll(ctx.(*ExpressionContext)) + + return p +} + +func (s *EqualityExpressionContext) GetRuleContext() antlr.RuleContext { + return s +} + +func (s *EqualityExpressionContext) AllExpression() []IExpressionContext { + children := s.GetChildren() + len := 0 + for _, ctx := range children { + if _, ok := ctx.(IExpressionContext); ok { + len++ + } + } + + tst := make([]IExpressionContext, len) + i := 0 + for _, ctx := range children { + if t, ok := ctx.(IExpressionContext); ok { + tst[i] = t.(IExpressionContext) + i++ + } + } + + return tst +} + +func (s *EqualityExpressionContext) Expression(i int) IExpressionContext { + var t antlr.RuleContext + j := 0 + for _, ctx := range s.GetChildren() { + if _, ok := ctx.(IExpressionContext); ok { + if j == i { + t = ctx.(antlr.RuleContext) + break + } + j++ + } + } + + if t == nil { + return nil + } + + return t.(IExpressionContext) +} + +func (s *EqualityExpressionContext) EnterRule(listener antlr.ParseTreeListener) { + if listenerT, ok := listener.(FhirPathListener); ok { + listenerT.EnterEqualityExpression(s) + } +} + +func (s *EqualityExpressionContext) ExitRule(listener antlr.ParseTreeListener) { + if listenerT, ok := listener.(FhirPathListener); ok { + listenerT.ExitEqualityExpression(s) + } +} + +func (s *EqualityExpressionContext) Accept(visitor antlr.ParseTreeVisitor) interface{} { + switch t := visitor.(type) { + case FhirPathVisitor: + return t.VisitEqualityExpression(s) + + default: + return t.VisitChildren(s) + } +} + +type ImpliesExpressionContext struct { + ExpressionContext +} + +func NewImpliesExpressionContext(parser antlr.Parser, ctx antlr.ParserRuleContext) *ImpliesExpressionContext { + var p = new(ImpliesExpressionContext) + + InitEmptyExpressionContext(&p.ExpressionContext) + p.parser = parser + p.CopyAll(ctx.(*ExpressionContext)) + + return p +} + +func (s *ImpliesExpressionContext) GetRuleContext() antlr.RuleContext { + return s +} + +func (s *ImpliesExpressionContext) AllExpression() []IExpressionContext { + children := s.GetChildren() + len := 0 + for _, ctx := range children { + if _, ok := ctx.(IExpressionContext); ok { + len++ + } + } + + tst := make([]IExpressionContext, len) + i := 0 + for _, ctx := range children { + if t, ok := ctx.(IExpressionContext); ok { + tst[i] = t.(IExpressionContext) + i++ + } + } + + return tst +} + +func (s *ImpliesExpressionContext) Expression(i int) IExpressionContext { + var t antlr.RuleContext + j := 0 + for _, ctx := range s.GetChildren() { + if _, ok := ctx.(IExpressionContext); ok { + if j == i { + t = ctx.(antlr.RuleContext) + break + } + j++ + } + } + + if t == nil { + return nil + } + + return t.(IExpressionContext) +} + +func (s *ImpliesExpressionContext) EnterRule(listener antlr.ParseTreeListener) { + if listenerT, ok := listener.(FhirPathListener); ok { + listenerT.EnterImpliesExpression(s) + } +} + +func (s *ImpliesExpressionContext) ExitRule(listener antlr.ParseTreeListener) { + if listenerT, ok := listener.(FhirPathListener); ok { + listenerT.ExitImpliesExpression(s) + } +} + +func (s *ImpliesExpressionContext) Accept(visitor antlr.ParseTreeVisitor) interface{} { + switch t := visitor.(type) { + case FhirPathVisitor: + return t.VisitImpliesExpression(s) + + default: + return t.VisitChildren(s) + } +} + +type TermExpressionContext struct { + ExpressionContext +} + +func NewTermExpressionContext(parser antlr.Parser, ctx antlr.ParserRuleContext) *TermExpressionContext { + var p = new(TermExpressionContext) + + InitEmptyExpressionContext(&p.ExpressionContext) + p.parser = parser + p.CopyAll(ctx.(*ExpressionContext)) + + return p +} + +func (s *TermExpressionContext) GetRuleContext() antlr.RuleContext { + return s +} + +func (s *TermExpressionContext) Term() ITermContext { + var t antlr.RuleContext + for _, ctx := range s.GetChildren() { + if _, ok := ctx.(ITermContext); ok { + t = ctx.(antlr.RuleContext) + break + } + } + + if t == nil { + return nil + } + + return t.(ITermContext) +} + +func (s *TermExpressionContext) EnterRule(listener antlr.ParseTreeListener) { + if listenerT, ok := listener.(FhirPathListener); ok { + listenerT.EnterTermExpression(s) + } +} + +func (s *TermExpressionContext) ExitRule(listener antlr.ParseTreeListener) { + if listenerT, ok := listener.(FhirPathListener); ok { + listenerT.ExitTermExpression(s) + } +} + +func (s *TermExpressionContext) Accept(visitor antlr.ParseTreeVisitor) interface{} { + switch t := visitor.(type) { + case FhirPathVisitor: + return t.VisitTermExpression(s) + + default: + return t.VisitChildren(s) + } +} + +type TypeExpressionContext struct { + ExpressionContext +} + +func NewTypeExpressionContext(parser antlr.Parser, ctx antlr.ParserRuleContext) *TypeExpressionContext { + var p = new(TypeExpressionContext) + + InitEmptyExpressionContext(&p.ExpressionContext) + p.parser = parser + p.CopyAll(ctx.(*ExpressionContext)) + + return p +} + +func (s *TypeExpressionContext) GetRuleContext() antlr.RuleContext { + return s +} + +func (s *TypeExpressionContext) Expression() IExpressionContext { + var t antlr.RuleContext + for _, ctx := range s.GetChildren() { + if _, ok := ctx.(IExpressionContext); ok { + t = ctx.(antlr.RuleContext) + break + } + } + + if t == nil { + return nil + } + + return t.(IExpressionContext) +} + +func (s *TypeExpressionContext) TypeSpecifier() ITypeSpecifierContext { + var t antlr.RuleContext + for _, ctx := range s.GetChildren() { + if _, ok := ctx.(ITypeSpecifierContext); ok { + t = ctx.(antlr.RuleContext) + break + } + } + + if t == nil { + return nil + } + + return t.(ITypeSpecifierContext) +} + +func (s *TypeExpressionContext) EnterRule(listener antlr.ParseTreeListener) { + if listenerT, ok := listener.(FhirPathListener); ok { + listenerT.EnterTypeExpression(s) + } +} + +func (s *TypeExpressionContext) ExitRule(listener antlr.ParseTreeListener) { + if listenerT, ok := listener.(FhirPathListener); ok { + listenerT.ExitTypeExpression(s) + } +} + +func (s *TypeExpressionContext) Accept(visitor antlr.ParseTreeVisitor) interface{} { + switch t := visitor.(type) { + case FhirPathVisitor: + return t.VisitTypeExpression(s) + + default: + return t.VisitChildren(s) + } +} + +func (p *FhirPathParser) Expression() (localctx IExpressionContext) { + return p.expression(0) +} + +func (p *FhirPathParser) expression(_p int) (localctx IExpressionContext) { + var _parentctx antlr.ParserRuleContext = p.GetParserRuleContext() + + _parentState := p.GetState() + localctx = NewExpressionContext(p, p.GetParserRuleContext(), _parentState) + var _prevctx IExpressionContext = localctx + var _ antlr.ParserRuleContext = _prevctx // TODO: To prevent unused variable warning. + _startState := 0 + p.EnterRecursionRule(localctx, 0, FhirPathParserRULE_expression, _p) + var _la int + + var _alt int + + p.EnterOuterAlt(localctx, 1) + p.SetState(32) + p.GetErrorHandler().Sync(p) + if p.HasError() { + goto errorExit + } + + switch p.GetTokenStream().LA(1) { + case FhirPathParserT__10, FhirPathParserT__11, FhirPathParserT__21, FhirPathParserT__22, FhirPathParserT__27, FhirPathParserT__29, FhirPathParserT__31, FhirPathParserT__32, FhirPathParserT__33, FhirPathParserT__34, FhirPathParserT__35, FhirPathParserT__36, FhirPathParserDATE, FhirPathParserDATETIME, FhirPathParserTIME, FhirPathParserIDENTIFIER, FhirPathParserDELIMITEDIDENTIFIER, FhirPathParserSTRING, FhirPathParserNUMBER: + localctx = NewTermExpressionContext(p, localctx) + p.SetParserRuleContext(localctx) + _prevctx = localctx + + { + p.SetState(29) + p.Term() + } + + case FhirPathParserT__3, FhirPathParserT__4: + localctx = NewPolarityExpressionContext(p, localctx) + p.SetParserRuleContext(localctx) + _prevctx = localctx + { + p.SetState(30) + _la = p.GetTokenStream().LA(1) + + if !(_la == FhirPathParserT__3 || _la == FhirPathParserT__4) { + p.GetErrorHandler().RecoverInline(p) + } else { + p.GetErrorHandler().ReportMatch(p) + p.Consume() + } + } + { + p.SetState(31) + p.expression(11) + } + + default: + p.SetError(antlr.NewNoViableAltException(p, nil, nil, nil, nil, nil)) + goto errorExit + } + p.GetParserRuleContext().SetStop(p.GetTokenStream().LT(-1)) + p.SetState(74) + p.GetErrorHandler().Sync(p) + if p.HasError() { + goto errorExit + } + _alt = p.GetInterpreter().AdaptivePredict(p.BaseParser, p.GetTokenStream(), 2, p.GetParserRuleContext()) + if p.HasError() { + goto errorExit + } + for _alt != 2 && _alt != antlr.ATNInvalidAltNumber { + if _alt == 1 { + if p.GetParseListeners() != nil { + p.TriggerExitRuleEvent() + } + _prevctx = localctx + p.SetState(72) + p.GetErrorHandler().Sync(p) + if p.HasError() { + goto errorExit + } + + switch p.GetInterpreter().AdaptivePredict(p.BaseParser, p.GetTokenStream(), 1, p.GetParserRuleContext()) { + case 1: + localctx = NewMultiplicativeExpressionContext(p, NewExpressionContext(p, _parentctx, _parentState)) + p.PushNewRecursionContext(localctx, _startState, FhirPathParserRULE_expression) + p.SetState(34) + + if !(p.Precpred(p.GetParserRuleContext(), 10)) { + p.SetError(antlr.NewFailedPredicateException(p, "p.Precpred(p.GetParserRuleContext(), 10)", "")) + goto errorExit + } + { + p.SetState(35) + _la = p.GetTokenStream().LA(1) + + if !((int64(_la) & ^0x3f) == 0 && ((int64(1)<<_la)&960) != 0) { + p.GetErrorHandler().RecoverInline(p) + } else { + p.GetErrorHandler().ReportMatch(p) + p.Consume() + } + } + { + p.SetState(36) + p.expression(11) + } + + case 2: + localctx = NewAdditiveExpressionContext(p, NewExpressionContext(p, _parentctx, _parentState)) + p.PushNewRecursionContext(localctx, _startState, FhirPathParserRULE_expression) + p.SetState(37) + + if !(p.Precpred(p.GetParserRuleContext(), 9)) { + p.SetError(antlr.NewFailedPredicateException(p, "p.Precpred(p.GetParserRuleContext(), 9)", "")) + goto errorExit + } + { + p.SetState(38) + _la = p.GetTokenStream().LA(1) + + if !((int64(_la) & ^0x3f) == 0 && ((int64(1)<<_la)&1072) != 0) { + p.GetErrorHandler().RecoverInline(p) + } else { + p.GetErrorHandler().ReportMatch(p) + p.Consume() + } + } + { + p.SetState(39) + p.expression(10) + } + + case 3: + localctx = NewUnionExpressionContext(p, NewExpressionContext(p, _parentctx, _parentState)) + p.PushNewRecursionContext(localctx, _startState, FhirPathParserRULE_expression) + p.SetState(40) + + if !(p.Precpred(p.GetParserRuleContext(), 7)) { + p.SetError(antlr.NewFailedPredicateException(p, "p.Precpred(p.GetParserRuleContext(), 7)", "")) + goto errorExit + } + { + p.SetState(41) + p.Match(FhirPathParserT__12) + if p.HasError() { + // Recognition error - abort rule + goto errorExit + } + } + { + p.SetState(42) + p.expression(8) + } + + case 4: + localctx = NewInequalityExpressionContext(p, NewExpressionContext(p, _parentctx, _parentState)) + p.PushNewRecursionContext(localctx, _startState, FhirPathParserRULE_expression) + p.SetState(43) + + if !(p.Precpred(p.GetParserRuleContext(), 6)) { + p.SetError(antlr.NewFailedPredicateException(p, "p.Precpred(p.GetParserRuleContext(), 6)", "")) + goto errorExit + } + { + p.SetState(44) + _la = p.GetTokenStream().LA(1) + + if !((int64(_la) & ^0x3f) == 0 && ((int64(1)<<_la)&245760) != 0) { + p.GetErrorHandler().RecoverInline(p) + } else { + p.GetErrorHandler().ReportMatch(p) + p.Consume() + } + } + { + p.SetState(45) + p.expression(7) + } + + case 5: + localctx = NewEqualityExpressionContext(p, NewExpressionContext(p, _parentctx, _parentState)) + p.PushNewRecursionContext(localctx, _startState, FhirPathParserRULE_expression) + p.SetState(46) + + if !(p.Precpred(p.GetParserRuleContext(), 5)) { + p.SetError(antlr.NewFailedPredicateException(p, "p.Precpred(p.GetParserRuleContext(), 5)", "")) + goto errorExit + } + { + p.SetState(47) + _la = p.GetTokenStream().LA(1) + + if !((int64(_la) & ^0x3f) == 0 && ((int64(1)<<_la)&3932160) != 0) { + p.GetErrorHandler().RecoverInline(p) + } else { + p.GetErrorHandler().ReportMatch(p) + p.Consume() + } + } + { + p.SetState(48) + p.expression(6) + } + + case 6: + localctx = NewMembershipExpressionContext(p, NewExpressionContext(p, _parentctx, _parentState)) + p.PushNewRecursionContext(localctx, _startState, FhirPathParserRULE_expression) + p.SetState(49) + + if !(p.Precpred(p.GetParserRuleContext(), 4)) { + p.SetError(antlr.NewFailedPredicateException(p, "p.Precpred(p.GetParserRuleContext(), 4)", "")) + goto errorExit + } + { + p.SetState(50) + _la = p.GetTokenStream().LA(1) + + if !(_la == FhirPathParserT__21 || _la == FhirPathParserT__22) { + p.GetErrorHandler().RecoverInline(p) + } else { + p.GetErrorHandler().ReportMatch(p) + p.Consume() + } + } + { + p.SetState(51) + p.expression(5) + } + + case 7: + localctx = NewAndExpressionContext(p, NewExpressionContext(p, _parentctx, _parentState)) + p.PushNewRecursionContext(localctx, _startState, FhirPathParserRULE_expression) + p.SetState(52) + + if !(p.Precpred(p.GetParserRuleContext(), 3)) { + p.SetError(antlr.NewFailedPredicateException(p, "p.Precpred(p.GetParserRuleContext(), 3)", "")) + goto errorExit + } + { + p.SetState(53) + p.Match(FhirPathParserT__23) + if p.HasError() { + // Recognition error - abort rule + goto errorExit + } + } + { + p.SetState(54) + p.expression(4) + } + + case 8: + localctx = NewOrExpressionContext(p, NewExpressionContext(p, _parentctx, _parentState)) + p.PushNewRecursionContext(localctx, _startState, FhirPathParserRULE_expression) + p.SetState(55) + + if !(p.Precpred(p.GetParserRuleContext(), 2)) { + p.SetError(antlr.NewFailedPredicateException(p, "p.Precpred(p.GetParserRuleContext(), 2)", "")) + goto errorExit + } + { + p.SetState(56) + _la = p.GetTokenStream().LA(1) + + if !(_la == FhirPathParserT__24 || _la == FhirPathParserT__25) { + p.GetErrorHandler().RecoverInline(p) + } else { + p.GetErrorHandler().ReportMatch(p) + p.Consume() + } + } + { + p.SetState(57) + p.expression(3) + } + + case 9: + localctx = NewImpliesExpressionContext(p, NewExpressionContext(p, _parentctx, _parentState)) + p.PushNewRecursionContext(localctx, _startState, FhirPathParserRULE_expression) + p.SetState(58) + + if !(p.Precpred(p.GetParserRuleContext(), 1)) { + p.SetError(antlr.NewFailedPredicateException(p, "p.Precpred(p.GetParserRuleContext(), 1)", "")) + goto errorExit + } + { + p.SetState(59) + p.Match(FhirPathParserT__26) + if p.HasError() { + // Recognition error - abort rule + goto errorExit + } + } + { + p.SetState(60) + p.expression(2) + } + + case 10: + localctx = NewInvocationExpressionContext(p, NewExpressionContext(p, _parentctx, _parentState)) + p.PushNewRecursionContext(localctx, _startState, FhirPathParserRULE_expression) + p.SetState(61) + + if !(p.Precpred(p.GetParserRuleContext(), 13)) { + p.SetError(antlr.NewFailedPredicateException(p, "p.Precpred(p.GetParserRuleContext(), 13)", "")) + goto errorExit + } + { + p.SetState(62) + p.Match(FhirPathParserT__0) + if p.HasError() { + // Recognition error - abort rule + goto errorExit + } + } + { + p.SetState(63) + p.Invocation() + } + + case 11: + localctx = NewIndexerExpressionContext(p, NewExpressionContext(p, _parentctx, _parentState)) + p.PushNewRecursionContext(localctx, _startState, FhirPathParserRULE_expression) + p.SetState(64) + + if !(p.Precpred(p.GetParserRuleContext(), 12)) { + p.SetError(antlr.NewFailedPredicateException(p, "p.Precpred(p.GetParserRuleContext(), 12)", "")) + goto errorExit + } + { + p.SetState(65) + p.Match(FhirPathParserT__1) + if p.HasError() { + // Recognition error - abort rule + goto errorExit + } + } + { + p.SetState(66) + p.expression(0) + } + { + p.SetState(67) + p.Match(FhirPathParserT__2) + if p.HasError() { + // Recognition error - abort rule + goto errorExit + } + } + + case 12: + localctx = NewTypeExpressionContext(p, NewExpressionContext(p, _parentctx, _parentState)) + p.PushNewRecursionContext(localctx, _startState, FhirPathParserRULE_expression) + p.SetState(69) + + if !(p.Precpred(p.GetParserRuleContext(), 8)) { + p.SetError(antlr.NewFailedPredicateException(p, "p.Precpred(p.GetParserRuleContext(), 8)", "")) + goto errorExit + } + { + p.SetState(70) + _la = p.GetTokenStream().LA(1) + + if !(_la == FhirPathParserT__10 || _la == FhirPathParserT__11) { + p.GetErrorHandler().RecoverInline(p) + } else { + p.GetErrorHandler().ReportMatch(p) + p.Consume() + } + } + { + p.SetState(71) + p.TypeSpecifier() + } + + case antlr.ATNInvalidAltNumber: + goto errorExit + } + + } + p.SetState(76) + p.GetErrorHandler().Sync(p) + if p.HasError() { + goto errorExit + } + _alt = p.GetInterpreter().AdaptivePredict(p.BaseParser, p.GetTokenStream(), 2, p.GetParserRuleContext()) + if p.HasError() { + goto errorExit + } + } + +errorExit: + if p.HasError() { + v := p.GetError() + localctx.SetException(v) + p.GetErrorHandler().ReportError(p, v) + p.GetErrorHandler().Recover(p, v) + p.SetError(nil) + } + p.UnrollRecursionContexts(_parentctx) + return localctx + goto errorExit // Trick to prevent compiler error if the label is not used +} + +// ITermContext is an interface to support dynamic dispatch. +type ITermContext interface { + antlr.ParserRuleContext + + // GetParser returns the parser. + GetParser() antlr.Parser + // IsTermContext differentiates from other interfaces. + IsTermContext() +} + +type TermContext struct { + antlr.BaseParserRuleContext + parser antlr.Parser +} + +func NewEmptyTermContext() *TermContext { + var p = new(TermContext) + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) + p.RuleIndex = FhirPathParserRULE_term + return p +} + +func InitEmptyTermContext(p *TermContext) { + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) + p.RuleIndex = FhirPathParserRULE_term +} + +func (*TermContext) IsTermContext() {} + +func NewTermContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *TermContext { + var p = new(TermContext) + + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, parent, invokingState) + + p.parser = parser + p.RuleIndex = FhirPathParserRULE_term + + return p +} + +func (s *TermContext) GetParser() antlr.Parser { return s.parser } + +func (s *TermContext) CopyAll(ctx *TermContext) { + s.CopyFrom(&ctx.BaseParserRuleContext) +} + +func (s *TermContext) GetRuleContext() antlr.RuleContext { + return s +} + +func (s *TermContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string { + return antlr.TreesStringTree(s, ruleNames, recog) +} + +type ExternalConstantTermContext struct { + TermContext +} + +func NewExternalConstantTermContext(parser antlr.Parser, ctx antlr.ParserRuleContext) *ExternalConstantTermContext { + var p = new(ExternalConstantTermContext) + + InitEmptyTermContext(&p.TermContext) + p.parser = parser + p.CopyAll(ctx.(*TermContext)) + + return p +} + +func (s *ExternalConstantTermContext) GetRuleContext() antlr.RuleContext { + return s +} + +func (s *ExternalConstantTermContext) ExternalConstant() IExternalConstantContext { + var t antlr.RuleContext + for _, ctx := range s.GetChildren() { + if _, ok := ctx.(IExternalConstantContext); ok { + t = ctx.(antlr.RuleContext) + break + } + } + + if t == nil { + return nil + } + + return t.(IExternalConstantContext) +} + +func (s *ExternalConstantTermContext) EnterRule(listener antlr.ParseTreeListener) { + if listenerT, ok := listener.(FhirPathListener); ok { + listenerT.EnterExternalConstantTerm(s) + } +} + +func (s *ExternalConstantTermContext) ExitRule(listener antlr.ParseTreeListener) { + if listenerT, ok := listener.(FhirPathListener); ok { + listenerT.ExitExternalConstantTerm(s) + } +} + +func (s *ExternalConstantTermContext) Accept(visitor antlr.ParseTreeVisitor) interface{} { + switch t := visitor.(type) { + case FhirPathVisitor: + return t.VisitExternalConstantTerm(s) + + default: + return t.VisitChildren(s) + } +} + +type LiteralTermContext struct { + TermContext +} + +func NewLiteralTermContext(parser antlr.Parser, ctx antlr.ParserRuleContext) *LiteralTermContext { + var p = new(LiteralTermContext) + + InitEmptyTermContext(&p.TermContext) + p.parser = parser + p.CopyAll(ctx.(*TermContext)) + + return p +} + +func (s *LiteralTermContext) GetRuleContext() antlr.RuleContext { + return s +} + +func (s *LiteralTermContext) Literal() ILiteralContext { + var t antlr.RuleContext + for _, ctx := range s.GetChildren() { + if _, ok := ctx.(ILiteralContext); ok { + t = ctx.(antlr.RuleContext) + break + } + } + + if t == nil { + return nil + } + + return t.(ILiteralContext) +} + +func (s *LiteralTermContext) EnterRule(listener antlr.ParseTreeListener) { + if listenerT, ok := listener.(FhirPathListener); ok { + listenerT.EnterLiteralTerm(s) + } +} + +func (s *LiteralTermContext) ExitRule(listener antlr.ParseTreeListener) { + if listenerT, ok := listener.(FhirPathListener); ok { + listenerT.ExitLiteralTerm(s) + } +} + +func (s *LiteralTermContext) Accept(visitor antlr.ParseTreeVisitor) interface{} { + switch t := visitor.(type) { + case FhirPathVisitor: + return t.VisitLiteralTerm(s) + + default: + return t.VisitChildren(s) + } +} + +type ParenthesizedTermContext struct { + TermContext +} + +func NewParenthesizedTermContext(parser antlr.Parser, ctx antlr.ParserRuleContext) *ParenthesizedTermContext { + var p = new(ParenthesizedTermContext) + + InitEmptyTermContext(&p.TermContext) + p.parser = parser + p.CopyAll(ctx.(*TermContext)) + + return p +} + +func (s *ParenthesizedTermContext) GetRuleContext() antlr.RuleContext { + return s +} + +func (s *ParenthesizedTermContext) Expression() IExpressionContext { + var t antlr.RuleContext + for _, ctx := range s.GetChildren() { + if _, ok := ctx.(IExpressionContext); ok { + t = ctx.(antlr.RuleContext) + break + } + } + + if t == nil { + return nil + } + + return t.(IExpressionContext) +} + +func (s *ParenthesizedTermContext) EnterRule(listener antlr.ParseTreeListener) { + if listenerT, ok := listener.(FhirPathListener); ok { + listenerT.EnterParenthesizedTerm(s) + } +} + +func (s *ParenthesizedTermContext) ExitRule(listener antlr.ParseTreeListener) { + if listenerT, ok := listener.(FhirPathListener); ok { + listenerT.ExitParenthesizedTerm(s) + } +} + +func (s *ParenthesizedTermContext) Accept(visitor antlr.ParseTreeVisitor) interface{} { + switch t := visitor.(type) { + case FhirPathVisitor: + return t.VisitParenthesizedTerm(s) + + default: + return t.VisitChildren(s) + } +} + +type InvocationTermContext struct { + TermContext +} + +func NewInvocationTermContext(parser antlr.Parser, ctx antlr.ParserRuleContext) *InvocationTermContext { + var p = new(InvocationTermContext) + + InitEmptyTermContext(&p.TermContext) + p.parser = parser + p.CopyAll(ctx.(*TermContext)) + + return p +} + +func (s *InvocationTermContext) GetRuleContext() antlr.RuleContext { + return s +} + +func (s *InvocationTermContext) Invocation() IInvocationContext { + var t antlr.RuleContext + for _, ctx := range s.GetChildren() { + if _, ok := ctx.(IInvocationContext); ok { + t = ctx.(antlr.RuleContext) + break + } + } + + if t == nil { + return nil + } + + return t.(IInvocationContext) +} + +func (s *InvocationTermContext) EnterRule(listener antlr.ParseTreeListener) { + if listenerT, ok := listener.(FhirPathListener); ok { + listenerT.EnterInvocationTerm(s) + } +} + +func (s *InvocationTermContext) ExitRule(listener antlr.ParseTreeListener) { + if listenerT, ok := listener.(FhirPathListener); ok { + listenerT.ExitInvocationTerm(s) + } +} + +func (s *InvocationTermContext) Accept(visitor antlr.ParseTreeVisitor) interface{} { + switch t := visitor.(type) { + case FhirPathVisitor: + return t.VisitInvocationTerm(s) + + default: + return t.VisitChildren(s) + } +} + +func (p *FhirPathParser) Term() (localctx ITermContext) { + localctx = NewTermContext(p, p.GetParserRuleContext(), p.GetState()) + p.EnterRule(localctx, 2, FhirPathParserRULE_term) + p.SetState(84) + p.GetErrorHandler().Sync(p) + if p.HasError() { + goto errorExit + } + + switch p.GetTokenStream().LA(1) { + case FhirPathParserT__10, FhirPathParserT__11, FhirPathParserT__21, FhirPathParserT__22, FhirPathParserT__34, FhirPathParserT__35, FhirPathParserT__36, FhirPathParserIDENTIFIER, FhirPathParserDELIMITEDIDENTIFIER: + localctx = NewInvocationTermContext(p, localctx) + p.EnterOuterAlt(localctx, 1) + { + p.SetState(77) + p.Invocation() + } + + case FhirPathParserT__29, FhirPathParserT__31, FhirPathParserT__32, FhirPathParserDATE, FhirPathParserDATETIME, FhirPathParserTIME, FhirPathParserSTRING, FhirPathParserNUMBER: + localctx = NewLiteralTermContext(p, localctx) + p.EnterOuterAlt(localctx, 2) + { + p.SetState(78) + p.Literal() + } + + case FhirPathParserT__33: + localctx = NewExternalConstantTermContext(p, localctx) + p.EnterOuterAlt(localctx, 3) + { + p.SetState(79) + p.ExternalConstant() + } + + case FhirPathParserT__27: + localctx = NewParenthesizedTermContext(p, localctx) + p.EnterOuterAlt(localctx, 4) + { + p.SetState(80) + p.Match(FhirPathParserT__27) + if p.HasError() { + // Recognition error - abort rule + goto errorExit + } + } + { + p.SetState(81) + p.expression(0) + } + { + p.SetState(82) + p.Match(FhirPathParserT__28) + if p.HasError() { + // Recognition error - abort rule + goto errorExit + } + } + + default: + p.SetError(antlr.NewNoViableAltException(p, nil, nil, nil, nil, nil)) + goto errorExit + } + +errorExit: + if p.HasError() { + v := p.GetError() + localctx.SetException(v) + p.GetErrorHandler().ReportError(p, v) + p.GetErrorHandler().Recover(p, v) + p.SetError(nil) + } + p.ExitRule() + return localctx + goto errorExit // Trick to prevent compiler error if the label is not used +} + +// ILiteralContext is an interface to support dynamic dispatch. +type ILiteralContext interface { + antlr.ParserRuleContext + + // GetParser returns the parser. + GetParser() antlr.Parser + // IsLiteralContext differentiates from other interfaces. + IsLiteralContext() +} + +type LiteralContext struct { + antlr.BaseParserRuleContext + parser antlr.Parser +} + +func NewEmptyLiteralContext() *LiteralContext { + var p = new(LiteralContext) + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) + p.RuleIndex = FhirPathParserRULE_literal + return p +} + +func InitEmptyLiteralContext(p *LiteralContext) { + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) + p.RuleIndex = FhirPathParserRULE_literal +} + +func (*LiteralContext) IsLiteralContext() {} + +func NewLiteralContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *LiteralContext { + var p = new(LiteralContext) + + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, parent, invokingState) + + p.parser = parser + p.RuleIndex = FhirPathParserRULE_literal + + return p +} + +func (s *LiteralContext) GetParser() antlr.Parser { return s.parser } + +func (s *LiteralContext) CopyAll(ctx *LiteralContext) { + s.CopyFrom(&ctx.BaseParserRuleContext) +} + +func (s *LiteralContext) GetRuleContext() antlr.RuleContext { + return s +} + +func (s *LiteralContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string { + return antlr.TreesStringTree(s, ruleNames, recog) +} + +type TimeLiteralContext struct { + LiteralContext +} + +func NewTimeLiteralContext(parser antlr.Parser, ctx antlr.ParserRuleContext) *TimeLiteralContext { + var p = new(TimeLiteralContext) + + InitEmptyLiteralContext(&p.LiteralContext) + p.parser = parser + p.CopyAll(ctx.(*LiteralContext)) + + return p +} + +func (s *TimeLiteralContext) GetRuleContext() antlr.RuleContext { + return s +} + +func (s *TimeLiteralContext) TIME() antlr.TerminalNode { + return s.GetToken(FhirPathParserTIME, 0) +} + +func (s *TimeLiteralContext) EnterRule(listener antlr.ParseTreeListener) { + if listenerT, ok := listener.(FhirPathListener); ok { + listenerT.EnterTimeLiteral(s) + } +} + +func (s *TimeLiteralContext) ExitRule(listener antlr.ParseTreeListener) { + if listenerT, ok := listener.(FhirPathListener); ok { + listenerT.ExitTimeLiteral(s) + } +} + +func (s *TimeLiteralContext) Accept(visitor antlr.ParseTreeVisitor) interface{} { + switch t := visitor.(type) { + case FhirPathVisitor: + return t.VisitTimeLiteral(s) + + default: + return t.VisitChildren(s) + } +} + +type NullLiteralContext struct { + LiteralContext +} + +func NewNullLiteralContext(parser antlr.Parser, ctx antlr.ParserRuleContext) *NullLiteralContext { + var p = new(NullLiteralContext) + + InitEmptyLiteralContext(&p.LiteralContext) + p.parser = parser + p.CopyAll(ctx.(*LiteralContext)) + + return p +} + +func (s *NullLiteralContext) GetRuleContext() antlr.RuleContext { + return s +} + +func (s *NullLiteralContext) EnterRule(listener antlr.ParseTreeListener) { + if listenerT, ok := listener.(FhirPathListener); ok { + listenerT.EnterNullLiteral(s) + } +} + +func (s *NullLiteralContext) ExitRule(listener antlr.ParseTreeListener) { + if listenerT, ok := listener.(FhirPathListener); ok { + listenerT.ExitNullLiteral(s) + } +} + +func (s *NullLiteralContext) Accept(visitor antlr.ParseTreeVisitor) interface{} { + switch t := visitor.(type) { + case FhirPathVisitor: + return t.VisitNullLiteral(s) + + default: + return t.VisitChildren(s) + } +} + +type DateTimeLiteralContext struct { + LiteralContext +} + +func NewDateTimeLiteralContext(parser antlr.Parser, ctx antlr.ParserRuleContext) *DateTimeLiteralContext { + var p = new(DateTimeLiteralContext) + + InitEmptyLiteralContext(&p.LiteralContext) + p.parser = parser + p.CopyAll(ctx.(*LiteralContext)) + + return p +} + +func (s *DateTimeLiteralContext) GetRuleContext() antlr.RuleContext { + return s +} + +func (s *DateTimeLiteralContext) DATETIME() antlr.TerminalNode { + return s.GetToken(FhirPathParserDATETIME, 0) +} + +func (s *DateTimeLiteralContext) EnterRule(listener antlr.ParseTreeListener) { + if listenerT, ok := listener.(FhirPathListener); ok { + listenerT.EnterDateTimeLiteral(s) + } +} + +func (s *DateTimeLiteralContext) ExitRule(listener antlr.ParseTreeListener) { + if listenerT, ok := listener.(FhirPathListener); ok { + listenerT.ExitDateTimeLiteral(s) + } +} + +func (s *DateTimeLiteralContext) Accept(visitor antlr.ParseTreeVisitor) interface{} { + switch t := visitor.(type) { + case FhirPathVisitor: + return t.VisitDateTimeLiteral(s) + + default: + return t.VisitChildren(s) + } +} + +type StringLiteralContext struct { + LiteralContext +} + +func NewStringLiteralContext(parser antlr.Parser, ctx antlr.ParserRuleContext) *StringLiteralContext { + var p = new(StringLiteralContext) + + InitEmptyLiteralContext(&p.LiteralContext) + p.parser = parser + p.CopyAll(ctx.(*LiteralContext)) + + return p +} + +func (s *StringLiteralContext) GetRuleContext() antlr.RuleContext { + return s +} + +func (s *StringLiteralContext) STRING() antlr.TerminalNode { + return s.GetToken(FhirPathParserSTRING, 0) +} + +func (s *StringLiteralContext) EnterRule(listener antlr.ParseTreeListener) { + if listenerT, ok := listener.(FhirPathListener); ok { + listenerT.EnterStringLiteral(s) + } +} + +func (s *StringLiteralContext) ExitRule(listener antlr.ParseTreeListener) { + if listenerT, ok := listener.(FhirPathListener); ok { + listenerT.ExitStringLiteral(s) + } +} + +func (s *StringLiteralContext) Accept(visitor antlr.ParseTreeVisitor) interface{} { + switch t := visitor.(type) { + case FhirPathVisitor: + return t.VisitStringLiteral(s) + + default: + return t.VisitChildren(s) + } +} + +type DateLiteralContext struct { + LiteralContext +} + +func NewDateLiteralContext(parser antlr.Parser, ctx antlr.ParserRuleContext) *DateLiteralContext { + var p = new(DateLiteralContext) + + InitEmptyLiteralContext(&p.LiteralContext) + p.parser = parser + p.CopyAll(ctx.(*LiteralContext)) + + return p +} + +func (s *DateLiteralContext) GetRuleContext() antlr.RuleContext { + return s +} + +func (s *DateLiteralContext) DATE() antlr.TerminalNode { + return s.GetToken(FhirPathParserDATE, 0) +} + +func (s *DateLiteralContext) EnterRule(listener antlr.ParseTreeListener) { + if listenerT, ok := listener.(FhirPathListener); ok { + listenerT.EnterDateLiteral(s) + } +} + +func (s *DateLiteralContext) ExitRule(listener antlr.ParseTreeListener) { + if listenerT, ok := listener.(FhirPathListener); ok { + listenerT.ExitDateLiteral(s) + } +} + +func (s *DateLiteralContext) Accept(visitor antlr.ParseTreeVisitor) interface{} { + switch t := visitor.(type) { + case FhirPathVisitor: + return t.VisitDateLiteral(s) + + default: + return t.VisitChildren(s) + } +} + +type BooleanLiteralContext struct { + LiteralContext +} + +func NewBooleanLiteralContext(parser antlr.Parser, ctx antlr.ParserRuleContext) *BooleanLiteralContext { + var p = new(BooleanLiteralContext) + + InitEmptyLiteralContext(&p.LiteralContext) + p.parser = parser + p.CopyAll(ctx.(*LiteralContext)) + + return p +} + +func (s *BooleanLiteralContext) GetRuleContext() antlr.RuleContext { + return s +} + +func (s *BooleanLiteralContext) EnterRule(listener antlr.ParseTreeListener) { + if listenerT, ok := listener.(FhirPathListener); ok { + listenerT.EnterBooleanLiteral(s) + } +} + +func (s *BooleanLiteralContext) ExitRule(listener antlr.ParseTreeListener) { + if listenerT, ok := listener.(FhirPathListener); ok { + listenerT.ExitBooleanLiteral(s) + } +} + +func (s *BooleanLiteralContext) Accept(visitor antlr.ParseTreeVisitor) interface{} { + switch t := visitor.(type) { + case FhirPathVisitor: + return t.VisitBooleanLiteral(s) + + default: + return t.VisitChildren(s) + } +} + +type NumberLiteralContext struct { + LiteralContext +} + +func NewNumberLiteralContext(parser antlr.Parser, ctx antlr.ParserRuleContext) *NumberLiteralContext { + var p = new(NumberLiteralContext) + + InitEmptyLiteralContext(&p.LiteralContext) + p.parser = parser + p.CopyAll(ctx.(*LiteralContext)) + + return p +} + +func (s *NumberLiteralContext) GetRuleContext() antlr.RuleContext { + return s +} + +func (s *NumberLiteralContext) NUMBER() antlr.TerminalNode { + return s.GetToken(FhirPathParserNUMBER, 0) +} + +func (s *NumberLiteralContext) EnterRule(listener antlr.ParseTreeListener) { + if listenerT, ok := listener.(FhirPathListener); ok { + listenerT.EnterNumberLiteral(s) + } +} + +func (s *NumberLiteralContext) ExitRule(listener antlr.ParseTreeListener) { + if listenerT, ok := listener.(FhirPathListener); ok { + listenerT.ExitNumberLiteral(s) + } +} + +func (s *NumberLiteralContext) Accept(visitor antlr.ParseTreeVisitor) interface{} { + switch t := visitor.(type) { + case FhirPathVisitor: + return t.VisitNumberLiteral(s) + + default: + return t.VisitChildren(s) + } +} + +type QuantityLiteralContext struct { + LiteralContext +} + +func NewQuantityLiteralContext(parser antlr.Parser, ctx antlr.ParserRuleContext) *QuantityLiteralContext { + var p = new(QuantityLiteralContext) + + InitEmptyLiteralContext(&p.LiteralContext) + p.parser = parser + p.CopyAll(ctx.(*LiteralContext)) + + return p +} + +func (s *QuantityLiteralContext) GetRuleContext() antlr.RuleContext { + return s +} + +func (s *QuantityLiteralContext) Quantity() IQuantityContext { + var t antlr.RuleContext + for _, ctx := range s.GetChildren() { + if _, ok := ctx.(IQuantityContext); ok { + t = ctx.(antlr.RuleContext) + break + } + } + + if t == nil { + return nil + } + + return t.(IQuantityContext) +} + +func (s *QuantityLiteralContext) EnterRule(listener antlr.ParseTreeListener) { + if listenerT, ok := listener.(FhirPathListener); ok { + listenerT.EnterQuantityLiteral(s) + } +} + +func (s *QuantityLiteralContext) ExitRule(listener antlr.ParseTreeListener) { + if listenerT, ok := listener.(FhirPathListener); ok { + listenerT.ExitQuantityLiteral(s) + } +} + +func (s *QuantityLiteralContext) Accept(visitor antlr.ParseTreeVisitor) interface{} { + switch t := visitor.(type) { + case FhirPathVisitor: + return t.VisitQuantityLiteral(s) + + default: + return t.VisitChildren(s) + } +} + +func (p *FhirPathParser) Literal() (localctx ILiteralContext) { + localctx = NewLiteralContext(p, p.GetParserRuleContext(), p.GetState()) + p.EnterRule(localctx, 4, FhirPathParserRULE_literal) + var _la int + + p.SetState(95) + p.GetErrorHandler().Sync(p) + if p.HasError() { + goto errorExit + } + + switch p.GetInterpreter().AdaptivePredict(p.BaseParser, p.GetTokenStream(), 4, p.GetParserRuleContext()) { + case 1: + localctx = NewNullLiteralContext(p, localctx) + p.EnterOuterAlt(localctx, 1) + { + p.SetState(86) + p.Match(FhirPathParserT__29) + if p.HasError() { + // Recognition error - abort rule + goto errorExit + } + } + { + p.SetState(87) + p.Match(FhirPathParserT__30) + if p.HasError() { + // Recognition error - abort rule + goto errorExit + } + } + + case 2: + localctx = NewBooleanLiteralContext(p, localctx) + p.EnterOuterAlt(localctx, 2) + { + p.SetState(88) + _la = p.GetTokenStream().LA(1) + + if !(_la == FhirPathParserT__31 || _la == FhirPathParserT__32) { + p.GetErrorHandler().RecoverInline(p) + } else { + p.GetErrorHandler().ReportMatch(p) + p.Consume() + } + } + + case 3: + localctx = NewStringLiteralContext(p, localctx) + p.EnterOuterAlt(localctx, 3) + { + p.SetState(89) + p.Match(FhirPathParserSTRING) + if p.HasError() { + // Recognition error - abort rule + goto errorExit + } + } + + case 4: + localctx = NewNumberLiteralContext(p, localctx) + p.EnterOuterAlt(localctx, 4) + { + p.SetState(90) + p.Match(FhirPathParserNUMBER) + if p.HasError() { + // Recognition error - abort rule + goto errorExit + } + } + + case 5: + localctx = NewDateLiteralContext(p, localctx) + p.EnterOuterAlt(localctx, 5) + { + p.SetState(91) + p.Match(FhirPathParserDATE) + if p.HasError() { + // Recognition error - abort rule + goto errorExit + } + } + + case 6: + localctx = NewDateTimeLiteralContext(p, localctx) + p.EnterOuterAlt(localctx, 6) + { + p.SetState(92) + p.Match(FhirPathParserDATETIME) + if p.HasError() { + // Recognition error - abort rule + goto errorExit + } + } + + case 7: + localctx = NewTimeLiteralContext(p, localctx) + p.EnterOuterAlt(localctx, 7) + { + p.SetState(93) + p.Match(FhirPathParserTIME) + if p.HasError() { + // Recognition error - abort rule + goto errorExit + } + } + + case 8: + localctx = NewQuantityLiteralContext(p, localctx) + p.EnterOuterAlt(localctx, 8) + { + p.SetState(94) + p.Quantity() + } + + case antlr.ATNInvalidAltNumber: + goto errorExit + } + +errorExit: + if p.HasError() { + v := p.GetError() + localctx.SetException(v) + p.GetErrorHandler().ReportError(p, v) + p.GetErrorHandler().Recover(p, v) + p.SetError(nil) + } + p.ExitRule() + return localctx + goto errorExit // Trick to prevent compiler error if the label is not used +} + +// IExternalConstantContext is an interface to support dynamic dispatch. +type IExternalConstantContext interface { + antlr.ParserRuleContext + + // GetParser returns the parser. + GetParser() antlr.Parser + + // Getter signatures + Identifier() IIdentifierContext + STRING() antlr.TerminalNode + + // IsExternalConstantContext differentiates from other interfaces. + IsExternalConstantContext() +} + +type ExternalConstantContext struct { + antlr.BaseParserRuleContext + parser antlr.Parser +} + +func NewEmptyExternalConstantContext() *ExternalConstantContext { + var p = new(ExternalConstantContext) + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) + p.RuleIndex = FhirPathParserRULE_externalConstant + return p +} + +func InitEmptyExternalConstantContext(p *ExternalConstantContext) { + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) + p.RuleIndex = FhirPathParserRULE_externalConstant +} + +func (*ExternalConstantContext) IsExternalConstantContext() {} + +func NewExternalConstantContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *ExternalConstantContext { + var p = new(ExternalConstantContext) + + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, parent, invokingState) + + p.parser = parser + p.RuleIndex = FhirPathParserRULE_externalConstant + + return p +} + +func (s *ExternalConstantContext) GetParser() antlr.Parser { return s.parser } + +func (s *ExternalConstantContext) Identifier() IIdentifierContext { + var t antlr.RuleContext + for _, ctx := range s.GetChildren() { + if _, ok := ctx.(IIdentifierContext); ok { + t = ctx.(antlr.RuleContext) + break + } + } + + if t == nil { + return nil + } + + return t.(IIdentifierContext) +} + +func (s *ExternalConstantContext) STRING() antlr.TerminalNode { + return s.GetToken(FhirPathParserSTRING, 0) +} + +func (s *ExternalConstantContext) GetRuleContext() antlr.RuleContext { + return s +} + +func (s *ExternalConstantContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string { + return antlr.TreesStringTree(s, ruleNames, recog) +} + +func (s *ExternalConstantContext) EnterRule(listener antlr.ParseTreeListener) { + if listenerT, ok := listener.(FhirPathListener); ok { + listenerT.EnterExternalConstant(s) + } +} + +func (s *ExternalConstantContext) ExitRule(listener antlr.ParseTreeListener) { + if listenerT, ok := listener.(FhirPathListener); ok { + listenerT.ExitExternalConstant(s) + } +} + +func (s *ExternalConstantContext) Accept(visitor antlr.ParseTreeVisitor) interface{} { + switch t := visitor.(type) { + case FhirPathVisitor: + return t.VisitExternalConstant(s) + + default: + return t.VisitChildren(s) + } +} + +func (p *FhirPathParser) ExternalConstant() (localctx IExternalConstantContext) { + localctx = NewExternalConstantContext(p, p.GetParserRuleContext(), p.GetState()) + p.EnterRule(localctx, 6, FhirPathParserRULE_externalConstant) + p.EnterOuterAlt(localctx, 1) + { + p.SetState(97) + p.Match(FhirPathParserT__33) + if p.HasError() { + // Recognition error - abort rule + goto errorExit + } + } + p.SetState(100) + p.GetErrorHandler().Sync(p) + if p.HasError() { + goto errorExit + } + + switch p.GetTokenStream().LA(1) { + case FhirPathParserT__10, FhirPathParserT__11, FhirPathParserT__21, FhirPathParserT__22, FhirPathParserIDENTIFIER, FhirPathParserDELIMITEDIDENTIFIER: + { + p.SetState(98) + p.Identifier() + } + + case FhirPathParserSTRING: + { + p.SetState(99) + p.Match(FhirPathParserSTRING) + if p.HasError() { + // Recognition error - abort rule + goto errorExit + } + } + + default: + p.SetError(antlr.NewNoViableAltException(p, nil, nil, nil, nil, nil)) + goto errorExit + } + +errorExit: + if p.HasError() { + v := p.GetError() + localctx.SetException(v) + p.GetErrorHandler().ReportError(p, v) + p.GetErrorHandler().Recover(p, v) + p.SetError(nil) + } + p.ExitRule() + return localctx + goto errorExit // Trick to prevent compiler error if the label is not used +} + +// IInvocationContext is an interface to support dynamic dispatch. +type IInvocationContext interface { + antlr.ParserRuleContext + + // GetParser returns the parser. + GetParser() antlr.Parser + // IsInvocationContext differentiates from other interfaces. + IsInvocationContext() +} + +type InvocationContext struct { + antlr.BaseParserRuleContext + parser antlr.Parser +} + +func NewEmptyInvocationContext() *InvocationContext { + var p = new(InvocationContext) + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) + p.RuleIndex = FhirPathParserRULE_invocation + return p +} + +func InitEmptyInvocationContext(p *InvocationContext) { + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) + p.RuleIndex = FhirPathParserRULE_invocation +} + +func (*InvocationContext) IsInvocationContext() {} + +func NewInvocationContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *InvocationContext { + var p = new(InvocationContext) + + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, parent, invokingState) + + p.parser = parser + p.RuleIndex = FhirPathParserRULE_invocation + + return p +} + +func (s *InvocationContext) GetParser() antlr.Parser { return s.parser } + +func (s *InvocationContext) CopyAll(ctx *InvocationContext) { + s.CopyFrom(&ctx.BaseParserRuleContext) +} + +func (s *InvocationContext) GetRuleContext() antlr.RuleContext { + return s +} + +func (s *InvocationContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string { + return antlr.TreesStringTree(s, ruleNames, recog) +} + +type TotalInvocationContext struct { + InvocationContext +} + +func NewTotalInvocationContext(parser antlr.Parser, ctx antlr.ParserRuleContext) *TotalInvocationContext { + var p = new(TotalInvocationContext) + + InitEmptyInvocationContext(&p.InvocationContext) + p.parser = parser + p.CopyAll(ctx.(*InvocationContext)) + + return p +} + +func (s *TotalInvocationContext) GetRuleContext() antlr.RuleContext { + return s +} + +func (s *TotalInvocationContext) EnterRule(listener antlr.ParseTreeListener) { + if listenerT, ok := listener.(FhirPathListener); ok { + listenerT.EnterTotalInvocation(s) + } +} + +func (s *TotalInvocationContext) ExitRule(listener antlr.ParseTreeListener) { + if listenerT, ok := listener.(FhirPathListener); ok { + listenerT.ExitTotalInvocation(s) + } +} + +func (s *TotalInvocationContext) Accept(visitor antlr.ParseTreeVisitor) interface{} { + switch t := visitor.(type) { + case FhirPathVisitor: + return t.VisitTotalInvocation(s) + + default: + return t.VisitChildren(s) + } +} + +type ThisInvocationContext struct { + InvocationContext +} + +func NewThisInvocationContext(parser antlr.Parser, ctx antlr.ParserRuleContext) *ThisInvocationContext { + var p = new(ThisInvocationContext) + + InitEmptyInvocationContext(&p.InvocationContext) + p.parser = parser + p.CopyAll(ctx.(*InvocationContext)) + + return p +} + +func (s *ThisInvocationContext) GetRuleContext() antlr.RuleContext { + return s +} + +func (s *ThisInvocationContext) EnterRule(listener antlr.ParseTreeListener) { + if listenerT, ok := listener.(FhirPathListener); ok { + listenerT.EnterThisInvocation(s) + } +} + +func (s *ThisInvocationContext) ExitRule(listener antlr.ParseTreeListener) { + if listenerT, ok := listener.(FhirPathListener); ok { + listenerT.ExitThisInvocation(s) + } +} + +func (s *ThisInvocationContext) Accept(visitor antlr.ParseTreeVisitor) interface{} { + switch t := visitor.(type) { + case FhirPathVisitor: + return t.VisitThisInvocation(s) + + default: + return t.VisitChildren(s) + } +} + +type IndexInvocationContext struct { + InvocationContext +} + +func NewIndexInvocationContext(parser antlr.Parser, ctx antlr.ParserRuleContext) *IndexInvocationContext { + var p = new(IndexInvocationContext) + + InitEmptyInvocationContext(&p.InvocationContext) + p.parser = parser + p.CopyAll(ctx.(*InvocationContext)) + + return p +} + +func (s *IndexInvocationContext) GetRuleContext() antlr.RuleContext { + return s +} + +func (s *IndexInvocationContext) EnterRule(listener antlr.ParseTreeListener) { + if listenerT, ok := listener.(FhirPathListener); ok { + listenerT.EnterIndexInvocation(s) + } +} + +func (s *IndexInvocationContext) ExitRule(listener antlr.ParseTreeListener) { + if listenerT, ok := listener.(FhirPathListener); ok { + listenerT.ExitIndexInvocation(s) + } +} + +func (s *IndexInvocationContext) Accept(visitor antlr.ParseTreeVisitor) interface{} { + switch t := visitor.(type) { + case FhirPathVisitor: + return t.VisitIndexInvocation(s) + + default: + return t.VisitChildren(s) + } +} + +type FunctionInvocationContext struct { + InvocationContext +} + +func NewFunctionInvocationContext(parser antlr.Parser, ctx antlr.ParserRuleContext) *FunctionInvocationContext { + var p = new(FunctionInvocationContext) + + InitEmptyInvocationContext(&p.InvocationContext) + p.parser = parser + p.CopyAll(ctx.(*InvocationContext)) + + return p +} + +func (s *FunctionInvocationContext) GetRuleContext() antlr.RuleContext { + return s +} + +func (s *FunctionInvocationContext) Function() IFunctionContext { + var t antlr.RuleContext + for _, ctx := range s.GetChildren() { + if _, ok := ctx.(IFunctionContext); ok { + t = ctx.(antlr.RuleContext) + break + } + } + + if t == nil { + return nil + } + + return t.(IFunctionContext) +} + +func (s *FunctionInvocationContext) EnterRule(listener antlr.ParseTreeListener) { + if listenerT, ok := listener.(FhirPathListener); ok { + listenerT.EnterFunctionInvocation(s) + } +} + +func (s *FunctionInvocationContext) ExitRule(listener antlr.ParseTreeListener) { + if listenerT, ok := listener.(FhirPathListener); ok { + listenerT.ExitFunctionInvocation(s) + } +} + +func (s *FunctionInvocationContext) Accept(visitor antlr.ParseTreeVisitor) interface{} { + switch t := visitor.(type) { + case FhirPathVisitor: + return t.VisitFunctionInvocation(s) + + default: + return t.VisitChildren(s) + } +} + +type MemberInvocationContext struct { + InvocationContext +} + +func NewMemberInvocationContext(parser antlr.Parser, ctx antlr.ParserRuleContext) *MemberInvocationContext { + var p = new(MemberInvocationContext) + + InitEmptyInvocationContext(&p.InvocationContext) + p.parser = parser + p.CopyAll(ctx.(*InvocationContext)) + + return p +} + +func (s *MemberInvocationContext) GetRuleContext() antlr.RuleContext { + return s +} + +func (s *MemberInvocationContext) Identifier() IIdentifierContext { + var t antlr.RuleContext + for _, ctx := range s.GetChildren() { + if _, ok := ctx.(IIdentifierContext); ok { + t = ctx.(antlr.RuleContext) + break + } + } + + if t == nil { + return nil + } + + return t.(IIdentifierContext) +} + +func (s *MemberInvocationContext) EnterRule(listener antlr.ParseTreeListener) { + if listenerT, ok := listener.(FhirPathListener); ok { + listenerT.EnterMemberInvocation(s) + } +} + +func (s *MemberInvocationContext) ExitRule(listener antlr.ParseTreeListener) { + if listenerT, ok := listener.(FhirPathListener); ok { + listenerT.ExitMemberInvocation(s) + } +} + +func (s *MemberInvocationContext) Accept(visitor antlr.ParseTreeVisitor) interface{} { + switch t := visitor.(type) { + case FhirPathVisitor: + return t.VisitMemberInvocation(s) + + default: + return t.VisitChildren(s) + } +} + +func (p *FhirPathParser) Invocation() (localctx IInvocationContext) { + localctx = NewInvocationContext(p, p.GetParserRuleContext(), p.GetState()) + p.EnterRule(localctx, 8, FhirPathParserRULE_invocation) + p.SetState(107) + p.GetErrorHandler().Sync(p) + if p.HasError() { + goto errorExit + } + + switch p.GetInterpreter().AdaptivePredict(p.BaseParser, p.GetTokenStream(), 6, p.GetParserRuleContext()) { + case 1: + localctx = NewMemberInvocationContext(p, localctx) + p.EnterOuterAlt(localctx, 1) + { + p.SetState(102) + p.Identifier() + } + + case 2: + localctx = NewFunctionInvocationContext(p, localctx) + p.EnterOuterAlt(localctx, 2) + { + p.SetState(103) + p.Function() + } + + case 3: + localctx = NewThisInvocationContext(p, localctx) + p.EnterOuterAlt(localctx, 3) + { + p.SetState(104) + p.Match(FhirPathParserT__34) + if p.HasError() { + // Recognition error - abort rule + goto errorExit + } + } + + case 4: + localctx = NewIndexInvocationContext(p, localctx) + p.EnterOuterAlt(localctx, 4) + { + p.SetState(105) + p.Match(FhirPathParserT__35) + if p.HasError() { + // Recognition error - abort rule + goto errorExit + } + } + + case 5: + localctx = NewTotalInvocationContext(p, localctx) + p.EnterOuterAlt(localctx, 5) + { + p.SetState(106) + p.Match(FhirPathParserT__36) + if p.HasError() { + // Recognition error - abort rule + goto errorExit + } + } + + case antlr.ATNInvalidAltNumber: + goto errorExit + } + +errorExit: + if p.HasError() { + v := p.GetError() + localctx.SetException(v) + p.GetErrorHandler().ReportError(p, v) + p.GetErrorHandler().Recover(p, v) + p.SetError(nil) + } + p.ExitRule() + return localctx + goto errorExit // Trick to prevent compiler error if the label is not used +} + +// IFunctionContext is an interface to support dynamic dispatch. +type IFunctionContext interface { + antlr.ParserRuleContext + + // GetParser returns the parser. + GetParser() antlr.Parser + + // Getter signatures + Identifier() IIdentifierContext + ParamList() IParamListContext + + // IsFunctionContext differentiates from other interfaces. + IsFunctionContext() +} + +type FunctionContext struct { + antlr.BaseParserRuleContext + parser antlr.Parser +} + +func NewEmptyFunctionContext() *FunctionContext { + var p = new(FunctionContext) + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) + p.RuleIndex = FhirPathParserRULE_function + return p +} + +func InitEmptyFunctionContext(p *FunctionContext) { + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) + p.RuleIndex = FhirPathParserRULE_function +} + +func (*FunctionContext) IsFunctionContext() {} + +func NewFunctionContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *FunctionContext { + var p = new(FunctionContext) + + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, parent, invokingState) + + p.parser = parser + p.RuleIndex = FhirPathParserRULE_function + + return p +} + +func (s *FunctionContext) GetParser() antlr.Parser { return s.parser } + +func (s *FunctionContext) Identifier() IIdentifierContext { + var t antlr.RuleContext + for _, ctx := range s.GetChildren() { + if _, ok := ctx.(IIdentifierContext); ok { + t = ctx.(antlr.RuleContext) + break + } + } + + if t == nil { + return nil + } + + return t.(IIdentifierContext) +} + +func (s *FunctionContext) ParamList() IParamListContext { + var t antlr.RuleContext + for _, ctx := range s.GetChildren() { + if _, ok := ctx.(IParamListContext); ok { + t = ctx.(antlr.RuleContext) + break + } + } + + if t == nil { + return nil + } + + return t.(IParamListContext) +} + +func (s *FunctionContext) GetRuleContext() antlr.RuleContext { + return s +} + +func (s *FunctionContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string { + return antlr.TreesStringTree(s, ruleNames, recog) +} + +func (s *FunctionContext) EnterRule(listener antlr.ParseTreeListener) { + if listenerT, ok := listener.(FhirPathListener); ok { + listenerT.EnterFunction(s) + } +} + +func (s *FunctionContext) ExitRule(listener antlr.ParseTreeListener) { + if listenerT, ok := listener.(FhirPathListener); ok { + listenerT.ExitFunction(s) + } +} + +func (s *FunctionContext) Accept(visitor antlr.ParseTreeVisitor) interface{} { + switch t := visitor.(type) { + case FhirPathVisitor: + return t.VisitFunction(s) + + default: + return t.VisitChildren(s) + } +} + +func (p *FhirPathParser) Function() (localctx IFunctionContext) { + localctx = NewFunctionContext(p, p.GetParserRuleContext(), p.GetState()) + p.EnterRule(localctx, 10, FhirPathParserRULE_function) + var _la int + + p.EnterOuterAlt(localctx, 1) + { + p.SetState(109) + p.Identifier() + } + { + p.SetState(110) + p.Match(FhirPathParserT__27) + if p.HasError() { + // Recognition error - abort rule + goto errorExit + } + } + p.SetState(112) + p.GetErrorHandler().Sync(p) + if p.HasError() { + goto errorExit + } + _la = p.GetTokenStream().LA(1) + + if (int64(_la) & ^0x3f) == 0 && ((int64(1)<<_la)&4575657493346129968) != 0 { + { + p.SetState(111) + p.ParamList() + } + + } + { + p.SetState(114) + p.Match(FhirPathParserT__28) + if p.HasError() { + // Recognition error - abort rule + goto errorExit + } + } + +errorExit: + if p.HasError() { + v := p.GetError() + localctx.SetException(v) + p.GetErrorHandler().ReportError(p, v) + p.GetErrorHandler().Recover(p, v) + p.SetError(nil) + } + p.ExitRule() + return localctx + goto errorExit // Trick to prevent compiler error if the label is not used +} + +// IParamListContext is an interface to support dynamic dispatch. +type IParamListContext interface { + antlr.ParserRuleContext + + // GetParser returns the parser. + GetParser() antlr.Parser + + // Getter signatures + AllExpression() []IExpressionContext + Expression(i int) IExpressionContext + + // IsParamListContext differentiates from other interfaces. + IsParamListContext() +} + +type ParamListContext struct { + antlr.BaseParserRuleContext + parser antlr.Parser +} + +func NewEmptyParamListContext() *ParamListContext { + var p = new(ParamListContext) + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) + p.RuleIndex = FhirPathParserRULE_paramList + return p +} + +func InitEmptyParamListContext(p *ParamListContext) { + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) + p.RuleIndex = FhirPathParserRULE_paramList +} + +func (*ParamListContext) IsParamListContext() {} + +func NewParamListContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *ParamListContext { + var p = new(ParamListContext) + + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, parent, invokingState) + + p.parser = parser + p.RuleIndex = FhirPathParserRULE_paramList + + return p +} + +func (s *ParamListContext) GetParser() antlr.Parser { return s.parser } + +func (s *ParamListContext) AllExpression() []IExpressionContext { + children := s.GetChildren() + len := 0 + for _, ctx := range children { + if _, ok := ctx.(IExpressionContext); ok { + len++ + } + } + + tst := make([]IExpressionContext, len) + i := 0 + for _, ctx := range children { + if t, ok := ctx.(IExpressionContext); ok { + tst[i] = t.(IExpressionContext) + i++ + } + } + + return tst +} + +func (s *ParamListContext) Expression(i int) IExpressionContext { + var t antlr.RuleContext + j := 0 + for _, ctx := range s.GetChildren() { + if _, ok := ctx.(IExpressionContext); ok { + if j == i { + t = ctx.(antlr.RuleContext) + break + } + j++ + } + } + + if t == nil { + return nil + } + + return t.(IExpressionContext) +} + +func (s *ParamListContext) GetRuleContext() antlr.RuleContext { + return s +} + +func (s *ParamListContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string { + return antlr.TreesStringTree(s, ruleNames, recog) +} + +func (s *ParamListContext) EnterRule(listener antlr.ParseTreeListener) { + if listenerT, ok := listener.(FhirPathListener); ok { + listenerT.EnterParamList(s) + } +} + +func (s *ParamListContext) ExitRule(listener antlr.ParseTreeListener) { + if listenerT, ok := listener.(FhirPathListener); ok { + listenerT.ExitParamList(s) + } +} + +func (s *ParamListContext) Accept(visitor antlr.ParseTreeVisitor) interface{} { + switch t := visitor.(type) { + case FhirPathVisitor: + return t.VisitParamList(s) + + default: + return t.VisitChildren(s) + } +} + +func (p *FhirPathParser) ParamList() (localctx IParamListContext) { + localctx = NewParamListContext(p, p.GetParserRuleContext(), p.GetState()) + p.EnterRule(localctx, 12, FhirPathParserRULE_paramList) + var _la int + + p.EnterOuterAlt(localctx, 1) + { + p.SetState(116) + p.expression(0) + } + p.SetState(121) + p.GetErrorHandler().Sync(p) + if p.HasError() { + goto errorExit + } + _la = p.GetTokenStream().LA(1) + + for _la == FhirPathParserT__37 { + { + p.SetState(117) + p.Match(FhirPathParserT__37) + if p.HasError() { + // Recognition error - abort rule + goto errorExit + } + } + { + p.SetState(118) + p.expression(0) + } + + p.SetState(123) + p.GetErrorHandler().Sync(p) + if p.HasError() { + goto errorExit + } + _la = p.GetTokenStream().LA(1) + } + +errorExit: + if p.HasError() { + v := p.GetError() + localctx.SetException(v) + p.GetErrorHandler().ReportError(p, v) + p.GetErrorHandler().Recover(p, v) + p.SetError(nil) + } + p.ExitRule() + return localctx + goto errorExit // Trick to prevent compiler error if the label is not used +} + +// IQuantityContext is an interface to support dynamic dispatch. +type IQuantityContext interface { + antlr.ParserRuleContext + + // GetParser returns the parser. + GetParser() antlr.Parser + + // Getter signatures + NUMBER() antlr.TerminalNode + Unit() IUnitContext + + // IsQuantityContext differentiates from other interfaces. + IsQuantityContext() +} + +type QuantityContext struct { + antlr.BaseParserRuleContext + parser antlr.Parser +} + +func NewEmptyQuantityContext() *QuantityContext { + var p = new(QuantityContext) + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) + p.RuleIndex = FhirPathParserRULE_quantity + return p +} + +func InitEmptyQuantityContext(p *QuantityContext) { + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) + p.RuleIndex = FhirPathParserRULE_quantity +} + +func (*QuantityContext) IsQuantityContext() {} + +func NewQuantityContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *QuantityContext { + var p = new(QuantityContext) + + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, parent, invokingState) + + p.parser = parser + p.RuleIndex = FhirPathParserRULE_quantity + + return p +} + +func (s *QuantityContext) GetParser() antlr.Parser { return s.parser } + +func (s *QuantityContext) NUMBER() antlr.TerminalNode { + return s.GetToken(FhirPathParserNUMBER, 0) +} + +func (s *QuantityContext) Unit() IUnitContext { + var t antlr.RuleContext + for _, ctx := range s.GetChildren() { + if _, ok := ctx.(IUnitContext); ok { + t = ctx.(antlr.RuleContext) + break + } + } + + if t == nil { + return nil + } + + return t.(IUnitContext) +} + +func (s *QuantityContext) GetRuleContext() antlr.RuleContext { + return s +} + +func (s *QuantityContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string { + return antlr.TreesStringTree(s, ruleNames, recog) +} + +func (s *QuantityContext) EnterRule(listener antlr.ParseTreeListener) { + if listenerT, ok := listener.(FhirPathListener); ok { + listenerT.EnterQuantity(s) + } +} + +func (s *QuantityContext) ExitRule(listener antlr.ParseTreeListener) { + if listenerT, ok := listener.(FhirPathListener); ok { + listenerT.ExitQuantity(s) + } +} + +func (s *QuantityContext) Accept(visitor antlr.ParseTreeVisitor) interface{} { + switch t := visitor.(type) { + case FhirPathVisitor: + return t.VisitQuantity(s) + + default: + return t.VisitChildren(s) + } +} + +func (p *FhirPathParser) Quantity() (localctx IQuantityContext) { + localctx = NewQuantityContext(p, p.GetParserRuleContext(), p.GetState()) + p.EnterRule(localctx, 14, FhirPathParserRULE_quantity) + p.EnterOuterAlt(localctx, 1) + { + p.SetState(124) + p.Match(FhirPathParserNUMBER) + if p.HasError() { + // Recognition error - abort rule + goto errorExit + } + } + p.SetState(126) + p.GetErrorHandler().Sync(p) + + if p.GetInterpreter().AdaptivePredict(p.BaseParser, p.GetTokenStream(), 9, p.GetParserRuleContext()) == 1 { + { + p.SetState(125) + p.Unit() + } + + } else if p.HasError() { // JIM + goto errorExit + } + +errorExit: + if p.HasError() { + v := p.GetError() + localctx.SetException(v) + p.GetErrorHandler().ReportError(p, v) + p.GetErrorHandler().Recover(p, v) + p.SetError(nil) + } + p.ExitRule() + return localctx + goto errorExit // Trick to prevent compiler error if the label is not used +} + +// IUnitContext is an interface to support dynamic dispatch. +type IUnitContext interface { + antlr.ParserRuleContext + + // GetParser returns the parser. + GetParser() antlr.Parser + + // Getter signatures + DateTimePrecision() IDateTimePrecisionContext + PluralDateTimePrecision() IPluralDateTimePrecisionContext + STRING() antlr.TerminalNode + + // IsUnitContext differentiates from other interfaces. + IsUnitContext() +} + +type UnitContext struct { + antlr.BaseParserRuleContext + parser antlr.Parser +} + +func NewEmptyUnitContext() *UnitContext { + var p = new(UnitContext) + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) + p.RuleIndex = FhirPathParserRULE_unit + return p +} + +func InitEmptyUnitContext(p *UnitContext) { + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) + p.RuleIndex = FhirPathParserRULE_unit +} + +func (*UnitContext) IsUnitContext() {} + +func NewUnitContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *UnitContext { + var p = new(UnitContext) + + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, parent, invokingState) + + p.parser = parser + p.RuleIndex = FhirPathParserRULE_unit + + return p +} + +func (s *UnitContext) GetParser() antlr.Parser { return s.parser } + +func (s *UnitContext) DateTimePrecision() IDateTimePrecisionContext { + var t antlr.RuleContext + for _, ctx := range s.GetChildren() { + if _, ok := ctx.(IDateTimePrecisionContext); ok { + t = ctx.(antlr.RuleContext) + break + } + } + + if t == nil { + return nil + } + + return t.(IDateTimePrecisionContext) +} + +func (s *UnitContext) PluralDateTimePrecision() IPluralDateTimePrecisionContext { + var t antlr.RuleContext + for _, ctx := range s.GetChildren() { + if _, ok := ctx.(IPluralDateTimePrecisionContext); ok { + t = ctx.(antlr.RuleContext) + break + } + } + + if t == nil { + return nil + } + + return t.(IPluralDateTimePrecisionContext) +} + +func (s *UnitContext) STRING() antlr.TerminalNode { + return s.GetToken(FhirPathParserSTRING, 0) +} + +func (s *UnitContext) GetRuleContext() antlr.RuleContext { + return s +} + +func (s *UnitContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string { + return antlr.TreesStringTree(s, ruleNames, recog) +} + +func (s *UnitContext) EnterRule(listener antlr.ParseTreeListener) { + if listenerT, ok := listener.(FhirPathListener); ok { + listenerT.EnterUnit(s) + } +} + +func (s *UnitContext) ExitRule(listener antlr.ParseTreeListener) { + if listenerT, ok := listener.(FhirPathListener); ok { + listenerT.ExitUnit(s) + } +} + +func (s *UnitContext) Accept(visitor antlr.ParseTreeVisitor) interface{} { + switch t := visitor.(type) { + case FhirPathVisitor: + return t.VisitUnit(s) + + default: + return t.VisitChildren(s) + } +} + +func (p *FhirPathParser) Unit() (localctx IUnitContext) { + localctx = NewUnitContext(p, p.GetParserRuleContext(), p.GetState()) + p.EnterRule(localctx, 16, FhirPathParserRULE_unit) + p.SetState(131) + p.GetErrorHandler().Sync(p) + if p.HasError() { + goto errorExit + } + + switch p.GetTokenStream().LA(1) { + case FhirPathParserT__38, FhirPathParserT__39, FhirPathParserT__40, FhirPathParserT__41, FhirPathParserT__42, FhirPathParserT__43, FhirPathParserT__44, FhirPathParserT__45: + p.EnterOuterAlt(localctx, 1) + { + p.SetState(128) + p.DateTimePrecision() + } + + case FhirPathParserT__46, FhirPathParserT__47, FhirPathParserT__48, FhirPathParserT__49, FhirPathParserT__50, FhirPathParserT__51, FhirPathParserT__52, FhirPathParserT__53: + p.EnterOuterAlt(localctx, 2) + { + p.SetState(129) + p.PluralDateTimePrecision() + } + + case FhirPathParserSTRING: + p.EnterOuterAlt(localctx, 3) + { + p.SetState(130) + p.Match(FhirPathParserSTRING) + if p.HasError() { + // Recognition error - abort rule + goto errorExit + } + } + + default: + p.SetError(antlr.NewNoViableAltException(p, nil, nil, nil, nil, nil)) + goto errorExit + } + +errorExit: + if p.HasError() { + v := p.GetError() + localctx.SetException(v) + p.GetErrorHandler().ReportError(p, v) + p.GetErrorHandler().Recover(p, v) + p.SetError(nil) + } + p.ExitRule() + return localctx + goto errorExit // Trick to prevent compiler error if the label is not used +} + +// IDateTimePrecisionContext is an interface to support dynamic dispatch. +type IDateTimePrecisionContext interface { + antlr.ParserRuleContext + + // GetParser returns the parser. + GetParser() antlr.Parser + // IsDateTimePrecisionContext differentiates from other interfaces. + IsDateTimePrecisionContext() +} + +type DateTimePrecisionContext struct { + antlr.BaseParserRuleContext + parser antlr.Parser +} + +func NewEmptyDateTimePrecisionContext() *DateTimePrecisionContext { + var p = new(DateTimePrecisionContext) + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) + p.RuleIndex = FhirPathParserRULE_dateTimePrecision + return p +} + +func InitEmptyDateTimePrecisionContext(p *DateTimePrecisionContext) { + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) + p.RuleIndex = FhirPathParserRULE_dateTimePrecision +} + +func (*DateTimePrecisionContext) IsDateTimePrecisionContext() {} + +func NewDateTimePrecisionContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *DateTimePrecisionContext { + var p = new(DateTimePrecisionContext) + + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, parent, invokingState) + + p.parser = parser + p.RuleIndex = FhirPathParserRULE_dateTimePrecision + + return p +} + +func (s *DateTimePrecisionContext) GetParser() antlr.Parser { return s.parser } +func (s *DateTimePrecisionContext) GetRuleContext() antlr.RuleContext { + return s +} + +func (s *DateTimePrecisionContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string { + return antlr.TreesStringTree(s, ruleNames, recog) +} + +func (s *DateTimePrecisionContext) EnterRule(listener antlr.ParseTreeListener) { + if listenerT, ok := listener.(FhirPathListener); ok { + listenerT.EnterDateTimePrecision(s) + } +} + +func (s *DateTimePrecisionContext) ExitRule(listener antlr.ParseTreeListener) { + if listenerT, ok := listener.(FhirPathListener); ok { + listenerT.ExitDateTimePrecision(s) + } +} + +func (s *DateTimePrecisionContext) Accept(visitor antlr.ParseTreeVisitor) interface{} { + switch t := visitor.(type) { + case FhirPathVisitor: + return t.VisitDateTimePrecision(s) + + default: + return t.VisitChildren(s) + } +} + +func (p *FhirPathParser) DateTimePrecision() (localctx IDateTimePrecisionContext) { + localctx = NewDateTimePrecisionContext(p, p.GetParserRuleContext(), p.GetState()) + p.EnterRule(localctx, 18, FhirPathParserRULE_dateTimePrecision) + var _la int + + p.EnterOuterAlt(localctx, 1) + { + p.SetState(133) + _la = p.GetTokenStream().LA(1) + + if !((int64(_la) & ^0x3f) == 0 && ((int64(1)<<_la)&140187732541440) != 0) { + p.GetErrorHandler().RecoverInline(p) + } else { + p.GetErrorHandler().ReportMatch(p) + p.Consume() + } + } + +errorExit: + if p.HasError() { + v := p.GetError() + localctx.SetException(v) + p.GetErrorHandler().ReportError(p, v) + p.GetErrorHandler().Recover(p, v) + p.SetError(nil) + } + p.ExitRule() + return localctx + goto errorExit // Trick to prevent compiler error if the label is not used +} + +// IPluralDateTimePrecisionContext is an interface to support dynamic dispatch. +type IPluralDateTimePrecisionContext interface { + antlr.ParserRuleContext + + // GetParser returns the parser. + GetParser() antlr.Parser + // IsPluralDateTimePrecisionContext differentiates from other interfaces. + IsPluralDateTimePrecisionContext() +} + +type PluralDateTimePrecisionContext struct { + antlr.BaseParserRuleContext + parser antlr.Parser +} + +func NewEmptyPluralDateTimePrecisionContext() *PluralDateTimePrecisionContext { + var p = new(PluralDateTimePrecisionContext) + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) + p.RuleIndex = FhirPathParserRULE_pluralDateTimePrecision + return p +} + +func InitEmptyPluralDateTimePrecisionContext(p *PluralDateTimePrecisionContext) { + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) + p.RuleIndex = FhirPathParserRULE_pluralDateTimePrecision +} + +func (*PluralDateTimePrecisionContext) IsPluralDateTimePrecisionContext() {} + +func NewPluralDateTimePrecisionContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *PluralDateTimePrecisionContext { + var p = new(PluralDateTimePrecisionContext) + + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, parent, invokingState) + + p.parser = parser + p.RuleIndex = FhirPathParserRULE_pluralDateTimePrecision + + return p +} + +func (s *PluralDateTimePrecisionContext) GetParser() antlr.Parser { return s.parser } +func (s *PluralDateTimePrecisionContext) GetRuleContext() antlr.RuleContext { + return s +} + +func (s *PluralDateTimePrecisionContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string { + return antlr.TreesStringTree(s, ruleNames, recog) +} + +func (s *PluralDateTimePrecisionContext) EnterRule(listener antlr.ParseTreeListener) { + if listenerT, ok := listener.(FhirPathListener); ok { + listenerT.EnterPluralDateTimePrecision(s) + } +} + +func (s *PluralDateTimePrecisionContext) ExitRule(listener antlr.ParseTreeListener) { + if listenerT, ok := listener.(FhirPathListener); ok { + listenerT.ExitPluralDateTimePrecision(s) + } +} + +func (s *PluralDateTimePrecisionContext) Accept(visitor antlr.ParseTreeVisitor) interface{} { + switch t := visitor.(type) { + case FhirPathVisitor: + return t.VisitPluralDateTimePrecision(s) + + default: + return t.VisitChildren(s) + } +} + +func (p *FhirPathParser) PluralDateTimePrecision() (localctx IPluralDateTimePrecisionContext) { + localctx = NewPluralDateTimePrecisionContext(p, p.GetParserRuleContext(), p.GetState()) + p.EnterRule(localctx, 20, FhirPathParserRULE_pluralDateTimePrecision) + var _la int + + p.EnterOuterAlt(localctx, 1) + { + p.SetState(135) + _la = p.GetTokenStream().LA(1) + + if !((int64(_la) & ^0x3f) == 0 && ((int64(1)<<_la)&35888059530608640) != 0) { + p.GetErrorHandler().RecoverInline(p) + } else { + p.GetErrorHandler().ReportMatch(p) + p.Consume() + } + } + +errorExit: + if p.HasError() { + v := p.GetError() + localctx.SetException(v) + p.GetErrorHandler().ReportError(p, v) + p.GetErrorHandler().Recover(p, v) + p.SetError(nil) + } + p.ExitRule() + return localctx + goto errorExit // Trick to prevent compiler error if the label is not used +} + +// ITypeSpecifierContext is an interface to support dynamic dispatch. +type ITypeSpecifierContext interface { + antlr.ParserRuleContext + + // GetParser returns the parser. + GetParser() antlr.Parser + + // Getter signatures + QualifiedIdentifier() IQualifiedIdentifierContext + + // IsTypeSpecifierContext differentiates from other interfaces. + IsTypeSpecifierContext() +} + +type TypeSpecifierContext struct { + antlr.BaseParserRuleContext + parser antlr.Parser +} + +func NewEmptyTypeSpecifierContext() *TypeSpecifierContext { + var p = new(TypeSpecifierContext) + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) + p.RuleIndex = FhirPathParserRULE_typeSpecifier + return p +} + +func InitEmptyTypeSpecifierContext(p *TypeSpecifierContext) { + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) + p.RuleIndex = FhirPathParserRULE_typeSpecifier +} + +func (*TypeSpecifierContext) IsTypeSpecifierContext() {} + +func NewTypeSpecifierContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *TypeSpecifierContext { + var p = new(TypeSpecifierContext) + + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, parent, invokingState) + + p.parser = parser + p.RuleIndex = FhirPathParserRULE_typeSpecifier + + return p +} + +func (s *TypeSpecifierContext) GetParser() antlr.Parser { return s.parser } + +func (s *TypeSpecifierContext) QualifiedIdentifier() IQualifiedIdentifierContext { + var t antlr.RuleContext + for _, ctx := range s.GetChildren() { + if _, ok := ctx.(IQualifiedIdentifierContext); ok { + t = ctx.(antlr.RuleContext) + break + } + } + + if t == nil { + return nil + } + + return t.(IQualifiedIdentifierContext) +} + +func (s *TypeSpecifierContext) GetRuleContext() antlr.RuleContext { + return s +} + +func (s *TypeSpecifierContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string { + return antlr.TreesStringTree(s, ruleNames, recog) +} + +func (s *TypeSpecifierContext) EnterRule(listener antlr.ParseTreeListener) { + if listenerT, ok := listener.(FhirPathListener); ok { + listenerT.EnterTypeSpecifier(s) + } +} + +func (s *TypeSpecifierContext) ExitRule(listener antlr.ParseTreeListener) { + if listenerT, ok := listener.(FhirPathListener); ok { + listenerT.ExitTypeSpecifier(s) + } +} + +func (s *TypeSpecifierContext) Accept(visitor antlr.ParseTreeVisitor) interface{} { + switch t := visitor.(type) { + case FhirPathVisitor: + return t.VisitTypeSpecifier(s) + + default: + return t.VisitChildren(s) + } +} + +func (p *FhirPathParser) TypeSpecifier() (localctx ITypeSpecifierContext) { + localctx = NewTypeSpecifierContext(p, p.GetParserRuleContext(), p.GetState()) + p.EnterRule(localctx, 22, FhirPathParserRULE_typeSpecifier) + p.EnterOuterAlt(localctx, 1) + { + p.SetState(137) + p.QualifiedIdentifier() + } + +errorExit: + if p.HasError() { + v := p.GetError() + localctx.SetException(v) + p.GetErrorHandler().ReportError(p, v) + p.GetErrorHandler().Recover(p, v) + p.SetError(nil) + } + p.ExitRule() + return localctx + goto errorExit // Trick to prevent compiler error if the label is not used +} + +// IQualifiedIdentifierContext is an interface to support dynamic dispatch. +type IQualifiedIdentifierContext interface { + antlr.ParserRuleContext + + // GetParser returns the parser. + GetParser() antlr.Parser + + // Getter signatures + AllIdentifier() []IIdentifierContext + Identifier(i int) IIdentifierContext + + // IsQualifiedIdentifierContext differentiates from other interfaces. + IsQualifiedIdentifierContext() +} + +type QualifiedIdentifierContext struct { + antlr.BaseParserRuleContext + parser antlr.Parser +} + +func NewEmptyQualifiedIdentifierContext() *QualifiedIdentifierContext { + var p = new(QualifiedIdentifierContext) + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) + p.RuleIndex = FhirPathParserRULE_qualifiedIdentifier + return p +} + +func InitEmptyQualifiedIdentifierContext(p *QualifiedIdentifierContext) { + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) + p.RuleIndex = FhirPathParserRULE_qualifiedIdentifier +} + +func (*QualifiedIdentifierContext) IsQualifiedIdentifierContext() {} + +func NewQualifiedIdentifierContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *QualifiedIdentifierContext { + var p = new(QualifiedIdentifierContext) + + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, parent, invokingState) + + p.parser = parser + p.RuleIndex = FhirPathParserRULE_qualifiedIdentifier + + return p +} + +func (s *QualifiedIdentifierContext) GetParser() antlr.Parser { return s.parser } + +func (s *QualifiedIdentifierContext) AllIdentifier() []IIdentifierContext { + children := s.GetChildren() + len := 0 + for _, ctx := range children { + if _, ok := ctx.(IIdentifierContext); ok { + len++ + } + } + + tst := make([]IIdentifierContext, len) + i := 0 + for _, ctx := range children { + if t, ok := ctx.(IIdentifierContext); ok { + tst[i] = t.(IIdentifierContext) + i++ + } + } + + return tst +} + +func (s *QualifiedIdentifierContext) Identifier(i int) IIdentifierContext { + var t antlr.RuleContext + j := 0 + for _, ctx := range s.GetChildren() { + if _, ok := ctx.(IIdentifierContext); ok { + if j == i { + t = ctx.(antlr.RuleContext) + break + } + j++ + } + } + + if t == nil { + return nil + } + + return t.(IIdentifierContext) +} + +func (s *QualifiedIdentifierContext) GetRuleContext() antlr.RuleContext { + return s +} + +func (s *QualifiedIdentifierContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string { + return antlr.TreesStringTree(s, ruleNames, recog) +} + +func (s *QualifiedIdentifierContext) EnterRule(listener antlr.ParseTreeListener) { + if listenerT, ok := listener.(FhirPathListener); ok { + listenerT.EnterQualifiedIdentifier(s) + } +} + +func (s *QualifiedIdentifierContext) ExitRule(listener antlr.ParseTreeListener) { + if listenerT, ok := listener.(FhirPathListener); ok { + listenerT.ExitQualifiedIdentifier(s) + } +} + +func (s *QualifiedIdentifierContext) Accept(visitor antlr.ParseTreeVisitor) interface{} { + switch t := visitor.(type) { + case FhirPathVisitor: + return t.VisitQualifiedIdentifier(s) + + default: + return t.VisitChildren(s) + } +} + +func (p *FhirPathParser) QualifiedIdentifier() (localctx IQualifiedIdentifierContext) { + localctx = NewQualifiedIdentifierContext(p, p.GetParserRuleContext(), p.GetState()) + p.EnterRule(localctx, 24, FhirPathParserRULE_qualifiedIdentifier) + var _alt int + + p.EnterOuterAlt(localctx, 1) + { + p.SetState(139) + p.Identifier() + } + p.SetState(144) + p.GetErrorHandler().Sync(p) + if p.HasError() { + goto errorExit + } + _alt = p.GetInterpreter().AdaptivePredict(p.BaseParser, p.GetTokenStream(), 11, p.GetParserRuleContext()) + if p.HasError() { + goto errorExit + } + for _alt != 2 && _alt != antlr.ATNInvalidAltNumber { + if _alt == 1 { + { + p.SetState(140) + p.Match(FhirPathParserT__0) + if p.HasError() { + // Recognition error - abort rule + goto errorExit + } + } + { + p.SetState(141) + p.Identifier() + } + + } + p.SetState(146) + p.GetErrorHandler().Sync(p) + if p.HasError() { + goto errorExit + } + _alt = p.GetInterpreter().AdaptivePredict(p.BaseParser, p.GetTokenStream(), 11, p.GetParserRuleContext()) + if p.HasError() { + goto errorExit + } + } + +errorExit: + if p.HasError() { + v := p.GetError() + localctx.SetException(v) + p.GetErrorHandler().ReportError(p, v) + p.GetErrorHandler().Recover(p, v) + p.SetError(nil) + } + p.ExitRule() + return localctx + goto errorExit // Trick to prevent compiler error if the label is not used +} + +// IIdentifierContext is an interface to support dynamic dispatch. +type IIdentifierContext interface { + antlr.ParserRuleContext + + // GetParser returns the parser. + GetParser() antlr.Parser + + // Getter signatures + IDENTIFIER() antlr.TerminalNode + DELIMITEDIDENTIFIER() antlr.TerminalNode + + // IsIdentifierContext differentiates from other interfaces. + IsIdentifierContext() +} + +type IdentifierContext struct { + antlr.BaseParserRuleContext + parser antlr.Parser +} + +func NewEmptyIdentifierContext() *IdentifierContext { + var p = new(IdentifierContext) + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) + p.RuleIndex = FhirPathParserRULE_identifier + return p +} + +func InitEmptyIdentifierContext(p *IdentifierContext) { + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) + p.RuleIndex = FhirPathParserRULE_identifier +} + +func (*IdentifierContext) IsIdentifierContext() {} + +func NewIdentifierContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *IdentifierContext { + var p = new(IdentifierContext) + + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, parent, invokingState) + + p.parser = parser + p.RuleIndex = FhirPathParserRULE_identifier + + return p +} + +func (s *IdentifierContext) GetParser() antlr.Parser { return s.parser } + +func (s *IdentifierContext) IDENTIFIER() antlr.TerminalNode { + return s.GetToken(FhirPathParserIDENTIFIER, 0) +} + +func (s *IdentifierContext) DELIMITEDIDENTIFIER() antlr.TerminalNode { + return s.GetToken(FhirPathParserDELIMITEDIDENTIFIER, 0) +} + +func (s *IdentifierContext) GetRuleContext() antlr.RuleContext { + return s +} + +func (s *IdentifierContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string { + return antlr.TreesStringTree(s, ruleNames, recog) +} + +func (s *IdentifierContext) EnterRule(listener antlr.ParseTreeListener) { + if listenerT, ok := listener.(FhirPathListener); ok { + listenerT.EnterIdentifier(s) + } +} + +func (s *IdentifierContext) ExitRule(listener antlr.ParseTreeListener) { + if listenerT, ok := listener.(FhirPathListener); ok { + listenerT.ExitIdentifier(s) + } +} + +func (s *IdentifierContext) Accept(visitor antlr.ParseTreeVisitor) interface{} { + switch t := visitor.(type) { + case FhirPathVisitor: + return t.VisitIdentifier(s) + + default: + return t.VisitChildren(s) + } +} + +func (p *FhirPathParser) Identifier() (localctx IIdentifierContext) { + localctx = NewIdentifierContext(p, p.GetParserRuleContext(), p.GetState()) + p.EnterRule(localctx, 26, FhirPathParserRULE_identifier) + var _la int + + p.EnterOuterAlt(localctx, 1) + { + p.SetState(147) + _la = p.GetTokenStream().LA(1) + + if !((int64(_la) & ^0x3f) == 0 && ((int64(1)<<_la)&864691128467724288) != 0) { + p.GetErrorHandler().RecoverInline(p) + } else { + p.GetErrorHandler().ReportMatch(p) + p.Consume() + } + } + +errorExit: + if p.HasError() { + v := p.GetError() + localctx.SetException(v) + p.GetErrorHandler().ReportError(p, v) + p.GetErrorHandler().Recover(p, v) + p.SetError(nil) + } + p.ExitRule() + return localctx + goto errorExit // Trick to prevent compiler error if the label is not used +} + +func (p *FhirPathParser) Sempred(localctx antlr.RuleContext, ruleIndex, predIndex int) bool { + switch ruleIndex { + case 0: + var t *ExpressionContext = nil + if localctx != nil { + t = localctx.(*ExpressionContext) + } + return p.Expression_Sempred(t, predIndex) + + default: + panic("No predicate with index: " + fmt.Sprint(ruleIndex)) + } +} + +func (p *FhirPathParser) Expression_Sempred(localctx antlr.RuleContext, predIndex int) bool { + switch predIndex { + case 0: + return p.Precpred(p.GetParserRuleContext(), 10) + + case 1: + return p.Precpred(p.GetParserRuleContext(), 9) + + case 2: + return p.Precpred(p.GetParserRuleContext(), 7) + + case 3: + return p.Precpred(p.GetParserRuleContext(), 6) + + case 4: + return p.Precpred(p.GetParserRuleContext(), 5) + + case 5: + return p.Precpred(p.GetParserRuleContext(), 4) + + case 6: + return p.Precpred(p.GetParserRuleContext(), 3) + + case 7: + return p.Precpred(p.GetParserRuleContext(), 2) + + case 8: + return p.Precpred(p.GetParserRuleContext(), 1) + + case 9: + return p.Precpred(p.GetParserRuleContext(), 13) + + case 10: + return p.Precpred(p.GetParserRuleContext(), 12) + + case 11: + return p.Precpred(p.GetParserRuleContext(), 8) + + default: + panic("No predicate with index: " + fmt.Sprint(predIndex)) + } +} diff --git a/go/fhirpath/gen/fhirpath_visitor.go b/go/fhirpath/gen/fhirpath_visitor.go new file mode 100755 index 000000000..7cd8d500a --- /dev/null +++ b/go/fhirpath/gen/fhirpath_visitor.go @@ -0,0 +1,132 @@ +// Code generated from FhirPath.g4 by ANTLR 4.13.1. DO NOT EDIT. + +package gen // FhirPath +import "github.com/antlr4-go/antlr/v4" + +// A complete Visitor for a parse tree produced by FhirPathParser. +type FhirPathVisitor interface { + antlr.ParseTreeVisitor + + // Visit a parse tree produced by FhirPathParser#indexerExpression. + VisitIndexerExpression(ctx *IndexerExpressionContext) interface{} + + // Visit a parse tree produced by FhirPathParser#polarityExpression. + VisitPolarityExpression(ctx *PolarityExpressionContext) interface{} + + // Visit a parse tree produced by FhirPathParser#additiveExpression. + VisitAdditiveExpression(ctx *AdditiveExpressionContext) interface{} + + // Visit a parse tree produced by FhirPathParser#multiplicativeExpression. + VisitMultiplicativeExpression(ctx *MultiplicativeExpressionContext) interface{} + + // Visit a parse tree produced by FhirPathParser#unionExpression. + VisitUnionExpression(ctx *UnionExpressionContext) interface{} + + // Visit a parse tree produced by FhirPathParser#orExpression. + VisitOrExpression(ctx *OrExpressionContext) interface{} + + // Visit a parse tree produced by FhirPathParser#andExpression. + VisitAndExpression(ctx *AndExpressionContext) interface{} + + // Visit a parse tree produced by FhirPathParser#membershipExpression. + VisitMembershipExpression(ctx *MembershipExpressionContext) interface{} + + // Visit a parse tree produced by FhirPathParser#inequalityExpression. + VisitInequalityExpression(ctx *InequalityExpressionContext) interface{} + + // Visit a parse tree produced by FhirPathParser#invocationExpression. + VisitInvocationExpression(ctx *InvocationExpressionContext) interface{} + + // Visit a parse tree produced by FhirPathParser#equalityExpression. + VisitEqualityExpression(ctx *EqualityExpressionContext) interface{} + + // Visit a parse tree produced by FhirPathParser#impliesExpression. + VisitImpliesExpression(ctx *ImpliesExpressionContext) interface{} + + // Visit a parse tree produced by FhirPathParser#termExpression. + VisitTermExpression(ctx *TermExpressionContext) interface{} + + // Visit a parse tree produced by FhirPathParser#typeExpression. + VisitTypeExpression(ctx *TypeExpressionContext) interface{} + + // Visit a parse tree produced by FhirPathParser#invocationTerm. + VisitInvocationTerm(ctx *InvocationTermContext) interface{} + + // Visit a parse tree produced by FhirPathParser#literalTerm. + VisitLiteralTerm(ctx *LiteralTermContext) interface{} + + // Visit a parse tree produced by FhirPathParser#externalConstantTerm. + VisitExternalConstantTerm(ctx *ExternalConstantTermContext) interface{} + + // Visit a parse tree produced by FhirPathParser#parenthesizedTerm. + VisitParenthesizedTerm(ctx *ParenthesizedTermContext) interface{} + + // Visit a parse tree produced by FhirPathParser#nullLiteral. + VisitNullLiteral(ctx *NullLiteralContext) interface{} + + // Visit a parse tree produced by FhirPathParser#booleanLiteral. + VisitBooleanLiteral(ctx *BooleanLiteralContext) interface{} + + // Visit a parse tree produced by FhirPathParser#stringLiteral. + VisitStringLiteral(ctx *StringLiteralContext) interface{} + + // Visit a parse tree produced by FhirPathParser#numberLiteral. + VisitNumberLiteral(ctx *NumberLiteralContext) interface{} + + // Visit a parse tree produced by FhirPathParser#dateLiteral. + VisitDateLiteral(ctx *DateLiteralContext) interface{} + + // Visit a parse tree produced by FhirPathParser#dateTimeLiteral. + VisitDateTimeLiteral(ctx *DateTimeLiteralContext) interface{} + + // Visit a parse tree produced by FhirPathParser#timeLiteral. + VisitTimeLiteral(ctx *TimeLiteralContext) interface{} + + // Visit a parse tree produced by FhirPathParser#quantityLiteral. + VisitQuantityLiteral(ctx *QuantityLiteralContext) interface{} + + // Visit a parse tree produced by FhirPathParser#externalConstant. + VisitExternalConstant(ctx *ExternalConstantContext) interface{} + + // Visit a parse tree produced by FhirPathParser#memberInvocation. + VisitMemberInvocation(ctx *MemberInvocationContext) interface{} + + // Visit a parse tree produced by FhirPathParser#functionInvocation. + VisitFunctionInvocation(ctx *FunctionInvocationContext) interface{} + + // Visit a parse tree produced by FhirPathParser#thisInvocation. + VisitThisInvocation(ctx *ThisInvocationContext) interface{} + + // Visit a parse tree produced by FhirPathParser#indexInvocation. + VisitIndexInvocation(ctx *IndexInvocationContext) interface{} + + // Visit a parse tree produced by FhirPathParser#totalInvocation. + VisitTotalInvocation(ctx *TotalInvocationContext) interface{} + + // Visit a parse tree produced by FhirPathParser#function. + VisitFunction(ctx *FunctionContext) interface{} + + // Visit a parse tree produced by FhirPathParser#paramList. + VisitParamList(ctx *ParamListContext) interface{} + + // Visit a parse tree produced by FhirPathParser#quantity. + VisitQuantity(ctx *QuantityContext) interface{} + + // Visit a parse tree produced by FhirPathParser#unit. + VisitUnit(ctx *UnitContext) interface{} + + // Visit a parse tree produced by FhirPathParser#dateTimePrecision. + VisitDateTimePrecision(ctx *DateTimePrecisionContext) interface{} + + // Visit a parse tree produced by FhirPathParser#pluralDateTimePrecision. + VisitPluralDateTimePrecision(ctx *PluralDateTimePrecisionContext) interface{} + + // Visit a parse tree produced by FhirPathParser#typeSpecifier. + VisitTypeSpecifier(ctx *TypeSpecifierContext) interface{} + + // Visit a parse tree produced by FhirPathParser#qualifiedIdentifier. + VisitQualifiedIdentifier(ctx *QualifiedIdentifierContext) interface{} + + // Visit a parse tree produced by FhirPathParser#identifier. + VisitIdentifier(ctx *IdentifierContext) interface{} +} diff --git a/go/fhirpath/visitor.go b/go/fhirpath/visitor.go new file mode 100644 index 000000000..80b5bf3f9 --- /dev/null +++ b/go/fhirpath/visitor.go @@ -0,0 +1,70 @@ +// Copyright 2024 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package fhirpath + +import ( + "errors" + "fmt" + + "github.com/google/fhir/go/fhirpath/gen" + "github.com/antlr4-go/antlr/v4" +) + +var ( + _ gen.FhirPathVisitor = (*compilerVisitor)(nil) + _ antlr.ErrorListener = (*errorListener)(nil) +) + +// compilerVisitor is a ANTLR Visitor implementation. +type compilerVisitor struct { + *gen.BaseFhirPathVisitor + + errorListener *errorListener + err error +} + +// SetError implements FhirPathVisitor +func (v *compilerVisitor) SetError(err error) { + v.err = err +} + +// Err implements FhirPathVisitor +func (v *compilerVisitor) Err() error { + return v.err +} + +// Visit implements FhirPathVisitor +func (v *compilerVisitor) Visit(tree antlr.ParseTree) any { + v.err = fmt.Errorf("unimplemented") + return nil +} + +// VisitErrorNode implements FhirPathVisitor +func (v *compilerVisitor) VisitErrorNode(node antlr.ErrorNode) any { + v.SetError(fmt.Errorf("unknown error encountered: %s", node.GetText())) + return nil +} + +// errorListener is an ANTLR listener to report syntax errors. +type errorListener struct { + *antlr.DefaultErrorListener + + visitor *compilerVisitor +} + +// SyntaxError implements antlr.ErrorListener. +func (l *errorListener) SyntaxError(recognizer antlr.Recognizer, offendingSymbol any, line, column int, msg string, e antlr.RecognitionException) { + l.visitor.SetError(errors.New(msg)) +} diff --git a/go/go.mod b/go/go.mod index adcd5c5ea..95e62b538 100644 --- a/go/go.mod +++ b/go/go.mod @@ -4,12 +4,13 @@ go 1.19 require ( bitbucket.org/creachadair/stringset v0.0.9 + github.com/antlr4-go/antlr/v4 v4.13.0 github.com/bazelbuild/rules_go v0.24.5 github.com/golang/protobuf v1.5.0 github.com/google/go-cmp v0.5.8 github.com/json-iterator/go v1.1.10 github.com/serenize/snaker v0.0.0-20201027110005-a7ad2135616e - golang.org/x/exp v0.0.0-20230315142452-642cacee5cc0 + golang.org/x/exp v0.0.0-20230515195305-f3d0a9c9a5cc google.golang.org/protobuf v1.31.0 ) diff --git a/go/go.sum b/go/go.sum index 8028540fd..a81503ea2 100644 --- a/go/go.sum +++ b/go/go.sum @@ -1,6 +1,8 @@ bitbucket.org/creachadair/stringset v0.0.9 h1:L4vld9nzPt90UZNrXjNelTshD74ps4P5NGs3Iq6yN3o= bitbucket.org/creachadair/stringset v0.0.9/go.mod h1:t+4WcQ4+PXTa8aQdNKe40ZP6iwesoMFWAxPGd3UGjyY= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= +github.com/antlr4-go/antlr/v4 v4.13.0 h1:lxCg3LAv+EUK6t1i0y1V6/SLeUi0eKEKdhQAlS8TVTI= +github.com/antlr4-go/antlr/v4 v4.13.0/go.mod h1:pfChB/xh/Unjila75QW7+VU4TSnWnnk9UTnmpPaOR2g= github.com/bazelbuild/rules_go v0.24.5 h1:8S5qilf+Il5/TPMZQIOfzQDAZtkhB4jALiAnwRuisDM= github.com/bazelbuild/rules_go v0.24.5/go.mod h1:MC23Dc/wkXEyk3Wpq6lCqz0ZAYOZDw2DR5y3N1q2i7M= github.com/creachadair/staticfile v0.1.3/go.mod h1:a3qySzCIXEprDGxk6tSxSI+dBBdLzqeBOMhZ+o2d3pM= @@ -38,8 +40,8 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+ github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= -golang.org/x/exp v0.0.0-20230315142452-642cacee5cc0 h1:pVgRXcIictcr+lBQIFeiwuwtDIs4eL21OuM9nyAADmo= -golang.org/x/exp v0.0.0-20230315142452-642cacee5cc0/go.mod h1:CxIveKay+FTh1D0yPZemJVgC/95VzuuOLq5Qi4xnoYc= +golang.org/x/exp v0.0.0-20230515195305-f3d0a9c9a5cc h1:mCRnTeVUjcrhlRmO0VK8a6k6Rrf6TF9htwo2pJVSjIU= +golang.org/x/exp v0.0.0-20230515195305-f3d0a9c9a5cc/go.mod h1:V1LtkGg67GoY2N1AnLN78QLrzxkLyJw7RJb1gzOOz9w= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.18.0 h1:mIYleuAkSbHh0tCv7RvjL3F6ZVbLjq4+R7zbOn3Kokg= golang.org/x/net v0.18.0/go.mod h1:/czyP5RqHAH4odGYxBJ1qz0+CE5WZ+2j1YgoEo8F2jQ= diff --git a/go/jsonformat/internal/accessor/BUILD b/go/jsonformat/internal/accessor/BUILD index 109624d44..bf44df94d 100644 --- a/go/jsonformat/internal/accessor/BUILD +++ b/go/jsonformat/internal/accessor/BUILD @@ -1,5 +1,5 @@ -load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library") load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") +load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library") package(default_visibility = ["//visibility:public"]) diff --git a/go/jsonformat/internal/protopath/BUILD b/go/jsonformat/internal/protopath/BUILD index 312d4ea60..3031dfa47 100644 --- a/go/jsonformat/internal/protopath/BUILD +++ b/go/jsonformat/internal/protopath/BUILD @@ -1,5 +1,5 @@ -load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library") load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") +load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library") package(default_visibility = ["//visibility:public"]) diff --git a/go/jsonformat/internal/protopath/proto_path.go b/go/jsonformat/internal/protopath/proto_path.go index d5b807855..d9561cdee 100644 --- a/go/jsonformat/internal/protopath/proto_path.go +++ b/go/jsonformat/internal/protopath/proto_path.go @@ -204,7 +204,7 @@ func getAnyOneOfField(pb protoreflect.Message, oneofField protoreflect.OneofDesc return caseValue.Interface(), nil } -func oneOfFieldByMessageType(oneOfDesc protoreflect.OneofDescriptor, valPB protoreflect.Message) (protoreflect.FieldDescriptor, error) { +func oneOfFieldByMessageType(m protoreflect.Message, oneOfDesc protoreflect.OneofDescriptor, valPB protoreflect.Message) (protoreflect.FieldDescriptor, error) { var messageField protoreflect.FieldDescriptor valType := valPB.Descriptor() fields := oneOfDesc.Fields() @@ -213,7 +213,7 @@ func oneOfFieldByMessageType(oneOfDesc protoreflect.OneofDescriptor, valPB proto if f.Kind() != protoreflect.MessageKind { continue } - if canAssignValueToField(valPB.Interface(), f) { + if canAssignValueToField(m, f, valPB.Interface()) { if messageField != nil { return nil, fmt.Errorf("multiple fields of %s have type %s", oneOfDesc.FullName(), valType.FullName()) } @@ -237,7 +237,7 @@ func getEnumValueByName(ed protoreflect.EnumDescriptor, val string) (protoreflec return 0, false } -func canAssignValueToField(val any, fd protoreflect.FieldDescriptor) bool { +func canAssignValueToField(m protoreflect.Message, fd protoreflect.FieldDescriptor, val any) bool { fdKind := fd.Kind() if val == nil { return fdKind == protoreflect.MessageKind || fdKind == protoreflect.BytesKind || fd.IsList() @@ -249,6 +249,9 @@ func canAssignValueToField(val any, fd protoreflect.FieldDescriptor) bool { } if valType.Kind() == reflect.Slice { + if !fd.IsList() { + return false + } valType = valType.Elem() } @@ -270,7 +273,12 @@ func canAssignValueToField(val any, fd protoreflect.FieldDescriptor) bool { } } - def := reflect.ValueOf(fd.Default().Interface()) + var def reflect.Value + if fd.IsList() { + def = reflect.ValueOf(m.Get(fd).List().NewElement().Interface()) + } else { + def = reflect.ValueOf(fd.Default().Interface()) + } if !def.IsValid() { return false } @@ -288,13 +296,13 @@ func valAsReflectMessage(val any) (protoreflect.Message, bool) { } } -func oneOfFieldByPrimitiveType(oneOfDesc protoreflect.OneofDescriptor, val any) (protoreflect.FieldDescriptor, error) { +func oneOfFieldByPrimitiveType(m protoreflect.Message, oneOfDesc protoreflect.OneofDescriptor, val any) (protoreflect.FieldDescriptor, error) { var typeField protoreflect.FieldDescriptor valType := reflect.TypeOf(val) fields := oneOfDesc.Fields() for i := 0; i < fields.Len(); i++ { f := fields.Get(i) - if canAssignValueToField(val, f) { + if canAssignValueToField(m, f, val) { if typeField != nil { return nil, fmt.Errorf("multiple fields of %s have type %s", oneOfDesc.FullName(), valType.Name()) } @@ -312,9 +320,9 @@ func setOneOfFieldByType(m protoreflect.Message, oneOfDesc protoreflect.OneofDes var err error if rpb, ok := valAsReflectMessage(val); ok { val = rpb - innerField, err = oneOfFieldByMessageType(oneOfDesc, rpb) + innerField, err = oneOfFieldByMessageType(m, oneOfDesc, rpb) } else { - innerField, err = oneOfFieldByPrimitiveType(oneOfDesc, val) + innerField, err = oneOfFieldByPrimitiveType(m, oneOfDesc, val) } if err != nil { return err @@ -394,7 +402,7 @@ func assignValue(m protoreflect.Message, fd protoreflect.FieldDescriptor, path [ return nil } - if !canAssignValueToField(value, fd) { + if !canAssignValueToField(m, fd, value) { defVal, err := goValueFromProtoValue(fd, fd.Default()) if err != nil { return err @@ -413,7 +421,12 @@ func assignValue(m protoreflect.Message, fd protoreflect.FieldDescriptor, path [ } i, err := strconv.Atoi(string(path[0])) if err != nil { - return err + // Last element of path is not a valid index. + defVal, err := goValueFromProtoValue(fd, fd.Default()) + if err != nil { + return err + } + return fmt.Errorf("cannot assign %T to %T", value, defVal) } slice := m.Get(fd).List() // index has already been validated by `getSliceElement`, and the slice was @@ -568,7 +581,7 @@ func checkDefaultValue(m protoreflect.Message, fd protoreflect.FieldDescriptor, } return rv, nil } - if !canAssignValueToField(defVal, ft) { + if !canAssignValueToField(m, ft, defVal) { return nil, fmt.Errorf("invalid type %T for default value, expected %v", defVal, ft.Name()) } return defVal, nil diff --git a/go/jsonformat/internal/protopath/proto_path_test.go b/go/jsonformat/internal/protopath/proto_path_test.go index 563a60df5..8a41725cf 100644 --- a/go/jsonformat/internal/protopath/proto_path_test.go +++ b/go/jsonformat/internal/protopath/proto_path_test.go @@ -97,6 +97,41 @@ func TestSet(t *testing.T) { &pptpb.Message{RepeatedMessageField: []*pptpb.Message_InnerMessage{{InnerField: 3}}}, &pptpb.Message{RepeatedMessageField: []*pptpb.Message_InnerMessage{{InnerField: 1}, {InnerField: 2}}}, }, + { + "repeated scalar field - set", + NewPath("message_field.repeated_inner_field"), + []int32{1, 2}, + &pptpb.Message{MessageField: &pptpb.Message_InnerMessage{}}, + &pptpb.Message{MessageField: &pptpb.Message_InnerMessage{RepeatedInnerField: []int32{1, 2}}}, + }, + { + "repeated scalar field - clear", + NewPath("message_field.repeated_inner_field"), + Zero, + &pptpb.Message{MessageField: &pptpb.Message_InnerMessage{RepeatedInnerField: []int32{1, 2}}}, + &pptpb.Message{MessageField: &pptpb.Message_InnerMessage{}}, + }, + { + "repeated scalar field - no parent", + NewPath("message_field.repeated_inner_field"), + []int32{1, 2}, + &pptpb.Message{}, + &pptpb.Message{MessageField: &pptpb.Message_InnerMessage{RepeatedInnerField: []int32{1, 2}}}, + }, + { + "repeated nested scalar field - no parent", + NewPath("repeated_message_field.-1.repeated_inner_field"), + []int32{1, 2}, + &pptpb.Message{}, + &pptpb.Message{RepeatedMessageField: []*pptpb.Message_InnerMessage{{RepeatedInnerField: []int32{1, 2}}}}, + }, + { + "repeated scalar field element", + NewPath("message_field.repeated_inner_field.-1"), + int32(1), + &pptpb.Message{}, + &pptpb.Message{MessageField: &pptpb.Message_InnerMessage{RepeatedInnerField: []int32{1}}}, + }, { "repeated field element", NewPath("repeated_message_field.-1"), @@ -376,6 +411,36 @@ func TestSet_Errors(t *testing.T) { 1, &pptpb.Message{RepeatedMessageField: []*pptpb.Message_InnerMessage{{InnerField: 1}}}, }, + { + "repeated field - invalid scalar type for message field", + NewPath("message_field.repeated_inner_field"), + []int64{1}, + &pptpb.Message{MessageField: &pptpb.Message_InnerMessage{}}, + }, + { + "repeated field - invalid message type", + NewPath("message_field.repeated_inner_field"), + []*pptpb.Message{}, + &pptpb.Message{MessageField: &pptpb.Message_InnerMessage{}}, + }, + { + "repeated field - invalid repeated message type", + NewPath("repeated_message_field"), + []*pptpb.Message{}, + &pptpb.Message{}, + }, + { + "repeated field - invalid string type for repeated message field", + NewPath("repeated_message_field"), + "foo", + &pptpb.Message{}, + }, + { + "repeated field - invalid scalar type for repeated scalar field", + NewPath("message_field.repeated_inner_field"), + int32(1), + &pptpb.Message{MessageField: &pptpb.Message_InnerMessage{}}, + }, { "oneof", NewPath("foo.inner_field"), @@ -514,6 +579,15 @@ func TestGet(t *testing.T) { }, want: []proto.Message{proto.Message(innerMsg)}, }, + { + name: "scalar slice", + msg: &pptpb.Message{MessageField: &pptpb.Message_InnerMessage{RepeatedInnerField: []int32{1, 2}}}, + path: NewPath("message_field.repeated_inner_field"), + fn: func(m proto.Message, path Path) (any, error) { + return Get[[]int32](m, path) + }, + want: []int32{1, 2}, + }, } for _, test := range tests { t.Run(test.name, func(t *testing.T) { @@ -629,6 +703,13 @@ func TestGetWithDefault(t *testing.T) { &pptpb.Message{}, []*pptpb.Message_InnerMessage{}, }, + { + "missing field - repeated scalar", + NewPath("message_field.repeated_inner_field"), + Zero, + &pptpb.Message{}, + []int32{}, + }, { "missing field - zero", NewPath("message_field"), diff --git a/testdata/r4/profiles/split/BUILD b/testdata/r4/profiles/split/BUILD index cf2390155..3b3703ff3 100644 --- a/testdata/r4/profiles/split/BUILD +++ b/testdata/r4/profiles/split/BUILD @@ -1,5 +1,5 @@ -load("//bazel:protogen.bzl", "gen_fhir_definitions_and_protos") load("//bazel:proto.bzl", "fhir_proto_library") +load("//bazel:protogen.bzl", "gen_fhir_definitions_and_protos") licenses(["notice"])