diff --git a/.fallout/build.schema.json b/.fallout/build.schema.json index d94f6a5ba..de5699384 100644 --- a/.fallout/build.schema.json +++ b/.fallout/build.schema.json @@ -24,7 +24,6 @@ "ExecutableTarget": { "type": "string", "enum": [ - "Antlr", "Ci", "Clean", "Compile", diff --git a/AGENTS.md b/AGENTS.md index 24f28af42..ecd31b7a6 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -16,7 +16,6 @@ Build orchestration is Fallout (`build-support/build`), the maintained successor ./build.cmd Test # run the default test suite ./build.cmd Ci # Compile + Test + Pack — what CI runs ./build.cmd Clean -./build.cmd Antlr # regenerate the expression-language parser (Windows only) ``` Plain `dotnet` CLI works too — the solution is `Spring.Net.sln`: @@ -59,7 +58,7 @@ Key mechanics (defined in `src/Directory.Build.props` and `test/Directory.Build. - **Multi-targeting**: most libraries target `netstandard2.0;net472;net10.0`; web projects are net472-only. Projects reference the shared MSBuild variables `$(TargetFullFrameworkVersion)` (= net472) and `$(TargetModernFrameworkVersion)` (= net10.0) instead of literal TFMs. Framework differences are handled with conditional ``/`` blocks in csproj files, not scattered `#if` directives. Key them to what they mean (`'$(TargetFrameworkIdentifier)' == '.NETFramework'` or `NETFRAMEWORK`, never "not netstandard"). The one exception is the legacy-serialization obsoletion: `ObsoleteAttribute.DiagnosticId` only exists on modern .NET, so each serialization constructor and `GetObjectData` carries a `#if NET` guard around its `[Obsolete(Obsoletions...)]` (constants in `src/Spring/Obsoletions.cs`, linked into each library). - **Strong naming**: all assemblies signed with the committed `Spring.Net.snk`. - **Central package management**: versions live in `Directory.Packages.props`; csproj `PackageReference`s are versionless. -- **ANTLR expression parser**: the grammar is `src/Spring/Spring.Core/Expressions/Expression.g`. The generated lexer/parser under `Expressions/Parser/` and a vendored, hand-patched ANTLR 2.7.7 runtime under `Expressions/Parser/antlr/` are **committed — never hand-edit generated files**; regenerate with `./build.cmd Antlr` (see `src/Spring/Spring.Core/README_ANTLR.txt`). +- **Expression parser**: the grammar is `src/Spring/Spring.Core/Expressions/ExpressionGrammar.parlot.cs`, a build-only file that the `Parlot.SourceGenerator` analyzer turns into code of `Spring.Core`, with no runtime dependency on Parlot. It needs the Roslyn of the .NET 10 SDK. Its tokens, tree and syntax errors are in `ExpressionGrammar.cs`, and `ExpressionGrammarTests` holds the trees of the former ANTLR parser. `src/Spring/Spring.Core/Expressions/README.md` has the quirks kept on purpose and how the grammar stays equivalent. - **Versioning**: the git tag is the version authority (`v3.1.0` → 3.1.0); untagged builds fall back to the `ProjectVersion` placeholder in `build-support/build/Build.cs` plus a `dev-`/`preview-` suffix. Publishing runs from the tag workflow only. `DetermineVersion()` sets three distinct facets, applied to **both** `Compile` and `Pack` so packaged and `bin/` assemblies agree: `AssemblyVersion` is pinned to `major.minor.0.0` (the assemblies are strong-named, so this is their binding identity — keeping it stable across patches means consumers need no new binding redirect for a fix release), `FileVersion` carries the exact numeric version, and `InformationalVersion` is left to MSBuild so SourceLink can append `+`. Never set a bare `Version` property instead — it overrides the prefix/suffix composition and silently drops the preview suffix. - **Trusted publishing**: `.github/workflows/publish.yml` is the only workflow allowed to push to nuget.org. It needs `permissions: id-token: write` and `environment: nuget`; the `Publish` target exchanges that OIDC token for a short-lived API key in `build-support/build/Build.Publish.cs`. The nuget.org policy is keyed to the **workflow filename** `publish.yml` plus the `nuget` environment, so renaming, moving or splitting that workflow breaks publishing until the policy is updated. Do not reintroduce a `NUGET_API_KEY` secret — the `NuGetApiKey` parameter stays only as a manual override. - **Package READMEs and package validation**: every packable project under `src/Spring` has a `README.md` next to its csproj, which `src/Directory.Build.props` packs as the NuGet readme; a new package needs one (what it does, `dotnet add package`, target frameworks, a minimal snippet whose types, members and XML are checked against the code, and links). Pack also runs package validation (`EnablePackageValidation`) against the 3.1.0 packages (`PackageValidationBaselineVersion`) and between the target frameworks of one package; never suppress a difference between two TFMs of one package (Spring.Messaging turns validation off for that reason, see its csproj). Accepted baseline differences live in each project's `CompatibilitySuppressions.xml`; regenerate one with `dotnet pack -c Release -p:ApiCompatGenerateSuppressionFile=true -p:AssemblyVersion=..0.0` and review the diff. A direct `dotnet pack` needs that `-p:AssemblyVersion=..0.0` (what Fallout passes), because the default 1.0.0.0 is below the baseline and fails with CP0003; do not gate the baseline on AssemblyVersion, since Fallout's Restore passes no version and the baseline download would vanish. The baseline has a coverage gap: 3.1.0 shipped net462, which no 4.0 asset is compatible with, so Spring.Web, Spring.Web.Mvc5, Spring.Web.Conversation.NHibernate5 and Spring.Testing.NUnit get no baseline API comparison (PKV006), and for the other packages the 3.1.0 net462 asset is compared with the 4.0 netstandard2.0 build, so no net472 build is compared with 3.1.0. The gap closes when the baseline moves to 4.0.0 once 4.0.0 ships; then delete the 3.1.0 suppression files. @@ -74,7 +73,6 @@ Key mechanics (defined in `src/Directory.Build.props` and `test/Directory.Build. ## Legacy areas — do not modify - `doc/` — DocBook reference sources and their vendored toolchain (CI ignores `doc/**`); kept until the documentation moves to Markdown. -- `build-support/tools/antlr-2.7.6` — used by the `Antlr` target until the Parlot parser (#375) replaces ANTLR. ## Website diff --git a/BreakingChanges.txt b/BreakingChanges.txt index dc201a68d..a43b1d79f 100644 --- a/BreakingChanges.txt +++ b/BreakingChanges.txt @@ -119,6 +119,30 @@ Changes (3.1 to 4.0) - Before: ActionExpressionText="#log.Fatal('msg', #e)" - After: ActionExpressionText="'msg'" LogLevel="Critical" +11. The expression language is parsed by a parser generated with Parlot at build time, without a + runtime dependency on it, instead of the ANTLR 2 runtime that Spring.Core embedded: + - The namespaces Spring.Expressions.Parser.antlr, .antlr.debug, .antlr.collections and + .antlr.collections.impl are gone, with all their public types. + - Spring.Expressions.SpringAST has no base class any more, and getFirstChild, getNextSibling, addChild, + setFirstChild and setNextSibling use SpringAST instead of the AST interface. It lost the protected down and + right fields, ICloneable and Clone, SpringAST(IToken) and initialize(IToken), and the helpers it inherited + from BaseAST: EqualsList, EqualsListPartial, EqualsTree, EqualsTreePartial, findAll, findAllPartial, ToTree, + xmlSerialize, xmlSerializeNode, xmlSerializeRootOpen, xmlSerializeRootClose, encode, decode and + setVerboseStringConversion. + - Syntax errors are still Spring.Expressions.SyntaxErrorException, which is now public and derives from + Exception: catch it instead of RecognitionException or TokenStreamRecognitionException. + - An error can report a later position than it did, at the token that could not be read, and its + message can be different. The expressions accepted and their trees are the same, except that a + QualifiedIdentifier has no child nodes any more (getText() returns the same value). The serialized form of + a parsed expression is the same. + - U+FFFF in an expression is now an invalid char. ANTLR took it for the end of the input and silently dropped + what followed. + - A nested expression too deep for the stack of the thread, or 2,000 levels of parentheses or prefix + operators, is a SyntaxErrorException instead of a stack overflow. + - Evaluating a tree too deep for the stack of the thread throws InsufficientExecutionStackException + instead of overflowing it. + - Spring.Core depends on System.Memory explicitly on .NET Framework and .NET Standard 2.0. + Changes (3.0.x to 3.1) ======================== diff --git a/Directory.Packages.props b/Directory.Packages.props index 8a841aff9..aba8616eb 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -29,11 +29,13 @@ + + diff --git a/build-support/build/Build.cs b/build-support/build/Build.cs index 516dd72a6..ea1ee461e 100644 --- a/build-support/build/Build.cs +++ b/build-support/build/Build.cs @@ -161,19 +161,6 @@ void DetermineVersion() } }); - Target Antlr => _ => _ - .Executes(() => - { - var projectDir = Solution.GetProject("Spring.Core"); - var expressionsDir = Path.Combine(projectDir.Directory, "Expressions"); - var antlrExecutable = Path.Combine(Solution.Directory, "build-support/tools/antlr-2.7.6/antlr-2.7.6.exe"); - var process = StartProcess( - toolPath: antlrExecutable, - arguments: $"-o {expressionsDir}/Parser {expressionsDir}/Expression.g" - ); - process.WaitForExit(); - }); - Target Pack => _ => _ .After(Test) .DependsOn(Restore) diff --git a/build-support/tools/antlr-2.7.6/antlr-2.7.6.exe b/build-support/tools/antlr-2.7.6/antlr-2.7.6.exe deleted file mode 100644 index 038e7653e..000000000 Binary files a/build-support/tools/antlr-2.7.6/antlr-2.7.6.exe and /dev/null differ diff --git a/build-support/tools/antlr-2.7.6/antlr.jar b/build-support/tools/antlr-2.7.6/antlr.jar deleted file mode 100644 index 3702b645f..000000000 Binary files a/build-support/tools/antlr-2.7.6/antlr.jar and /dev/null differ diff --git a/build-support/tools/antlr-2.7.6/charset.dll b/build-support/tools/antlr-2.7.6/charset.dll deleted file mode 100644 index 6fdc358b2..000000000 Binary files a/build-support/tools/antlr-2.7.6/charset.dll and /dev/null differ diff --git a/build-support/tools/antlr-2.7.6/libiconv-2.dll b/build-support/tools/antlr-2.7.6/libiconv-2.dll deleted file mode 100644 index b53575f1a..000000000 Binary files a/build-support/tools/antlr-2.7.6/libiconv-2.dll and /dev/null differ diff --git a/examples/Directory.Packages.props b/examples/Directory.Packages.props new file mode 100644 index 000000000..0c50b0862 --- /dev/null +++ b/examples/Directory.Packages.props @@ -0,0 +1,7 @@ + + + + + + + diff --git a/src/Spring/Spring.Core/CompatibilitySuppressions.xml b/src/Spring/Spring.Core/CompatibilitySuppressions.xml index 865588986..f4a270178 100644 --- a/src/Spring/Spring.Core/CompatibilitySuppressions.xml +++ b/src/Spring/Spring.Core/CompatibilitySuppressions.xml @@ -1,6 +1,748 @@  + + CP0001 + T:Spring.Expressions.Parser.antlr.ANTLRException + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.ANTLRPanicException + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.ASTFactory + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.ASTNodeCreator + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.ASTNULLType + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.ASTPair + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.ASTVisitor + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.BaseAST + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.ByteBuffer + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.CharBuffer + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.CharQueue + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.CharScanner + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.CharStreamException + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.CharStreamIOException + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.collections.AST + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.collections.impl.ASTArray + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.collections.impl.BitSet + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.CommonAST + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.CommonASTWithHiddenTokens + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.CommonHiddenStreamToken + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.CommonToken + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.debug.ANTLREventArgs + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.debug.DebuggingCharScanner + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.debug.DebuggingInputBuffer + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.debug.DebuggingParser + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.debug.GuessingEventArgs + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.debug.ICharScannerDebugSubject + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.debug.IDebugSubject + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.debug.InputBufferEventArgs + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.debug.InputBufferEventSupport + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.debug.InputBufferListener + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.debug.InputBufferListenerBase + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.debug.InputBufferReporter + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.debug.IParserDebugSubject + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.debug.Listener + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.debug.LLkDebuggingParser + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.debug.MatchEventArgs + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.debug.MatchEventHandler + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.debug.MessageEventArgs + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.debug.MessageEventHandler + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.debug.MessageListener + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.debug.MessageListenerBase + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.debug.NewLineEventArgs + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.debug.NewLineEventHandler + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.debug.NewLineListener + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.debug.ParserController + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.debug.ParserEventSupport + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.debug.ParserListener + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.debug.ParserListenerBase + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.debug.ParserMatchListener + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.debug.ParserMatchListenerBase + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.debug.ParserReporter + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.debug.ParserTokenListener + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.debug.ParserTokenListenerBase + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.debug.ParseTreeDebugParser + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.debug.ScannerEventSupport + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.debug.SemanticPredicateEventArgs + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.debug.SemanticPredicateEventHandler + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.debug.SemanticPredicateListener + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.debug.SemanticPredicateListenerBase + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.debug.SyntacticPredicateEventArgs + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.debug.SyntacticPredicateEventHandler + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.debug.SyntacticPredicateListener + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.debug.SyntacticPredicateListenerBase + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.debug.TokenEventArgs + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.debug.TokenEventHandler + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.debug.TraceEventArgs + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.debug.TraceEventHandler + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.debug.TraceListener + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.debug.TraceListenerBase + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.debug.Tracer + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.DefaultFileLineFormatter + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.DumpASTVisitor + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.FileLineFormatter + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.IHiddenStreamToken + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.InputBuffer + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.IToken + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.LexerSharedInputState + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.LLkParser + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.MismatchedCharException + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.MismatchedTokenException + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.NoViableAltException + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.NoViableAltForCharException + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.Parser + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.ParserSharedInputState + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.ParseTree + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.ParseTreeRule + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.ParseTreeToken + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.RecognitionException + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.SemanticException + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.StringUtils + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.Token + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.TokenBuffer + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.TokenCreator + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.TokenStream + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.TokenStreamBasicFilter + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.TokenStreamException + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.TokenStreamHiddenTokenFilter + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.TokenStreamIOException + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.TokenStreamRecognitionException + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.TokenStreamRetryException + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.TokenStreamRewriteEngine + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.TokenStreamSelector + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.TokenWithIndex + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.TreeParser + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.TreeParserSharedInputState + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + CP0001 T:Spring.Threading.CallContextStorage @@ -8,507 +750,2033 @@ lib/netstandard2.0/Spring.Core.dll true + + CP0001 + T:Spring.Expressions.Parser.antlr.ANTLRException + lib/netstandard2.0/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.ANTLRPanicException + lib/netstandard2.0/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.ASTFactory + lib/netstandard2.0/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.ASTNodeCreator + lib/netstandard2.0/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.ASTNULLType + lib/netstandard2.0/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.ASTPair + lib/netstandard2.0/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.ASTVisitor + lib/netstandard2.0/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.BaseAST + lib/netstandard2.0/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.ByteBuffer + lib/netstandard2.0/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.CharBuffer + lib/netstandard2.0/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.CharQueue + lib/netstandard2.0/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.CharScanner + lib/netstandard2.0/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.CharStreamException + lib/netstandard2.0/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.CharStreamIOException + lib/netstandard2.0/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.collections.AST + lib/netstandard2.0/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.collections.impl.ASTArray + lib/netstandard2.0/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.collections.impl.BitSet + lib/netstandard2.0/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.CommonAST + lib/netstandard2.0/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.CommonASTWithHiddenTokens + lib/netstandard2.0/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.CommonHiddenStreamToken + lib/netstandard2.0/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.CommonToken + lib/netstandard2.0/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.debug.ANTLREventArgs + lib/netstandard2.0/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.debug.DebuggingCharScanner + lib/netstandard2.0/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.debug.DebuggingInputBuffer + lib/netstandard2.0/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.debug.DebuggingParser + lib/netstandard2.0/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.debug.GuessingEventArgs + lib/netstandard2.0/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.debug.ICharScannerDebugSubject + lib/netstandard2.0/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.debug.IDebugSubject + lib/netstandard2.0/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.debug.InputBufferEventArgs + lib/netstandard2.0/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.debug.InputBufferEventSupport + lib/netstandard2.0/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.debug.InputBufferListener + lib/netstandard2.0/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.debug.InputBufferListenerBase + lib/netstandard2.0/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.debug.InputBufferReporter + lib/netstandard2.0/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.debug.IParserDebugSubject + lib/netstandard2.0/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.debug.Listener + lib/netstandard2.0/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.debug.LLkDebuggingParser + lib/netstandard2.0/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.debug.MatchEventArgs + lib/netstandard2.0/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.debug.MatchEventHandler + lib/netstandard2.0/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.debug.MessageEventArgs + lib/netstandard2.0/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.debug.MessageEventHandler + lib/netstandard2.0/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.debug.MessageListener + lib/netstandard2.0/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.debug.MessageListenerBase + lib/netstandard2.0/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.debug.NewLineEventArgs + lib/netstandard2.0/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.debug.NewLineEventHandler + lib/netstandard2.0/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.debug.NewLineListener + lib/netstandard2.0/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.debug.ParserController + lib/netstandard2.0/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.debug.ParserEventSupport + lib/netstandard2.0/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.debug.ParserListener + lib/netstandard2.0/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.debug.ParserListenerBase + lib/netstandard2.0/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.debug.ParserMatchListener + lib/netstandard2.0/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.debug.ParserMatchListenerBase + lib/netstandard2.0/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.debug.ParserReporter + lib/netstandard2.0/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.debug.ParserTokenListener + lib/netstandard2.0/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.debug.ParserTokenListenerBase + lib/netstandard2.0/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.debug.ParseTreeDebugParser + lib/netstandard2.0/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.debug.ScannerEventSupport + lib/netstandard2.0/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.debug.SemanticPredicateEventArgs + lib/netstandard2.0/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.debug.SemanticPredicateEventHandler + lib/netstandard2.0/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.debug.SemanticPredicateListener + lib/netstandard2.0/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.debug.SemanticPredicateListenerBase + lib/netstandard2.0/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.debug.SyntacticPredicateEventArgs + lib/netstandard2.0/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.debug.SyntacticPredicateEventHandler + lib/netstandard2.0/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.debug.SyntacticPredicateListener + lib/netstandard2.0/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.debug.SyntacticPredicateListenerBase + lib/netstandard2.0/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.debug.TokenEventArgs + lib/netstandard2.0/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.debug.TokenEventHandler + lib/netstandard2.0/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.debug.TraceEventArgs + lib/netstandard2.0/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.debug.TraceEventHandler + lib/netstandard2.0/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.debug.TraceListener + lib/netstandard2.0/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.debug.TraceListenerBase + lib/netstandard2.0/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.debug.Tracer + lib/netstandard2.0/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.DefaultFileLineFormatter + lib/netstandard2.0/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.DumpASTVisitor + lib/netstandard2.0/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.FileLineFormatter + lib/netstandard2.0/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.IHiddenStreamToken + lib/netstandard2.0/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.InputBuffer + lib/netstandard2.0/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.IToken + lib/netstandard2.0/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.LexerSharedInputState + lib/netstandard2.0/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.LLkParser + lib/netstandard2.0/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.MismatchedCharException + lib/netstandard2.0/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.MismatchedTokenException + lib/netstandard2.0/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.NoViableAltException + lib/netstandard2.0/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.NoViableAltForCharException + lib/netstandard2.0/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.Parser + lib/netstandard2.0/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.ParserSharedInputState + lib/netstandard2.0/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.ParseTree + lib/netstandard2.0/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.ParseTreeRule + lib/netstandard2.0/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.ParseTreeToken + lib/netstandard2.0/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.RecognitionException + lib/netstandard2.0/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.SemanticException + lib/netstandard2.0/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.StringUtils + lib/netstandard2.0/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.Token + lib/netstandard2.0/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.TokenBuffer + lib/netstandard2.0/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.TokenCreator + lib/netstandard2.0/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.TokenStream + lib/netstandard2.0/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.TokenStreamBasicFilter + lib/netstandard2.0/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.TokenStreamException + lib/netstandard2.0/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.TokenStreamHiddenTokenFilter + lib/netstandard2.0/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.TokenStreamIOException + lib/netstandard2.0/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.TokenStreamRecognitionException + lib/netstandard2.0/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.TokenStreamRetryException + lib/netstandard2.0/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.TokenStreamRewriteEngine + lib/netstandard2.0/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.TokenStreamSelector + lib/netstandard2.0/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.TokenWithIndex + lib/netstandard2.0/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.TreeParser + lib/netstandard2.0/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0001 + T:Spring.Expressions.Parser.antlr.TreeParserSharedInputState + lib/netstandard2.0/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0002 + M:Spring.Expressions.SpringAST.#ctor(Spring.Expressions.Parser.antlr.IToken) + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0002 + M:Spring.Expressions.SpringAST.#ctor(Spring.Expressions.Parser.antlr.IToken) + lib/netstandard2.0/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0007 + T:Spring.Expressions.SpringAST + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0007 + T:Spring.Expressions.SpringAST + lib/netstandard2.0/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0008 + T:Spring.Caching.BaseCacheAttribute + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0008 + T:Spring.Caching.CacheParameterAttribute + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0008 + T:Spring.Caching.CacheResultAttribute + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0008 + T:Spring.Caching.CacheResultItemsAttribute + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0008 + T:Spring.Caching.InvalidateCacheAttribute + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0008 + T:Spring.Collections.NoElementsException + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0008 + T:Spring.Context.ApplicationContextException + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0008 + T:Spring.Context.Attributes.ConfigurationAttribute + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0008 + T:Spring.Context.Attributes.DependsOnAttribute + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0008 + T:Spring.Context.Attributes.ImportAttribute + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0008 + T:Spring.Context.Attributes.ImportResourceAttribute + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0008 + T:Spring.Context.Attributes.LazyAttribute + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0008 + T:Spring.Context.Attributes.ObjectDefAttribute + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0008 + T:Spring.Context.Attributes.ScopeAttribute + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0008 + T:Spring.Context.EventListenerAttribute + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0008 + T:Spring.Context.NoSuchMessageException + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0008 + T:Spring.Context.Support.ReferenceNode + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0008 + T:Spring.Core.CannotLoadObjectTypeException + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0008 + T:Spring.Core.InvalidPropertyException + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0008 + T:Spring.Core.MethodInvocationException + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0008 + T:Spring.Core.NotReadablePropertyException + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0008 + T:Spring.Core.NotWritablePropertyException + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0008 + T:Spring.Core.NullValueInNestedPathException + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0008 + T:Spring.Core.PropertyAccessException + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0008 + T:Spring.Core.TypeMismatchException + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0008 + T:Spring.Expressions.ArrayConstructorNode + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0008 + T:Spring.Expressions.AssignNode + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0008 + T:Spring.Expressions.AttributeNode + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0008 + T:Spring.Expressions.BaseNode + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0008 + T:Spring.Expressions.BaseNode.ArgumentMismatchException + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0008 + T:Spring.Expressions.BinaryOperator + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0008 + T:Spring.Expressions.BooleanLiteralNode + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0008 + T:Spring.Expressions.ConstructorNode + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0008 + T:Spring.Expressions.DefaultNode + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0008 + T:Spring.Expressions.Expression + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0008 + T:Spring.Expressions.ExpressionListNode + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0008 + T:Spring.Expressions.FunctionNode + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0008 + T:Spring.Expressions.HexLiteralNode + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0008 + T:Spring.Expressions.IndexerNode + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0008 + T:Spring.Expressions.IntLiteralNode + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0008 + T:Spring.Expressions.LambdaExpressionNode + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0008 + T:Spring.Expressions.ListInitializerNode + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0008 + T:Spring.Expressions.LocalFunctionNode + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0008 + T:Spring.Expressions.LocalVariableNode + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0008 + T:Spring.Expressions.MapEntryNode + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0008 + T:Spring.Expressions.MapInitializerNode + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0008 + T:Spring.Expressions.MethodNode + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0008 + T:Spring.Expressions.NamedArgumentNode + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0008 + T:Spring.Expressions.NodeWithArguments + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0008 + T:Spring.Expressions.NullLiteralNode + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0008 + T:Spring.Expressions.OpADD + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0008 + T:Spring.Expressions.OpAND + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0008 + T:Spring.Expressions.OpBetween + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0008 + T:Spring.Expressions.OpDIVIDE + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0008 + T:Spring.Expressions.OpEqual + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0008 + T:Spring.Expressions.OpGreater + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0008 + T:Spring.Expressions.OpGreaterOrEqual + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0008 + T:Spring.Expressions.OpIn + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0008 + T:Spring.Expressions.OpIs + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0008 + T:Spring.Expressions.OpLess + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0008 + T:Spring.Expressions.OpLessOrEqual + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0008 + T:Spring.Expressions.OpLike + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0008 + T:Spring.Expressions.OpMatches + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0008 + T:Spring.Expressions.OpMODULUS + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0008 + T:Spring.Expressions.OpMULTIPLY + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0008 + T:Spring.Expressions.OpNOT + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0008 + T:Spring.Expressions.OpNotEqual + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0008 + T:Spring.Expressions.OpOR + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0008 + T:Spring.Expressions.OpPOWER + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0008 + T:Spring.Expressions.OpSUBTRACT + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0008 + T:Spring.Expressions.OpUnaryMinus + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0008 + T:Spring.Expressions.OpUnaryPlus + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0008 + T:Spring.Expressions.OpXOR + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0008 + T:Spring.Expressions.ProjectionNode + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0008 + T:Spring.Expressions.PropertyOrFieldNode + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0008 + T:Spring.Expressions.QualifiedIdentifier + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0008 + T:Spring.Expressions.RealLiteralNode + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0008 + T:Spring.Expressions.SelectionFirstNode + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0008 + T:Spring.Expressions.SelectionLastNode + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0008 + T:Spring.Expressions.SelectionNode + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0008 + T:Spring.Expressions.SpringAST + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0008 + T:Spring.Expressions.StringLiteralNode + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0008 + T:Spring.Expressions.TernaryNode + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0008 + T:Spring.Expressions.TypeNode + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0008 + T:Spring.Expressions.UnaryOperator + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0008 + T:Spring.Expressions.VariableNode + lib/net462/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + CP0008 - T:Spring.Caching.BaseCacheAttribute + T:Spring.Objects.Factory.Attributes.AutowiredAttribute lib/net462/Spring.Core.dll lib/netstandard2.0/Spring.Core.dll true CP0008 - T:Spring.Caching.CacheParameterAttribute + T:Spring.Objects.Factory.Attributes.PostConstructAttribute lib/net462/Spring.Core.dll lib/netstandard2.0/Spring.Core.dll true CP0008 - T:Spring.Caching.CacheResultAttribute + T:Spring.Objects.Factory.Attributes.PreDestroyAttribute lib/net462/Spring.Core.dll lib/netstandard2.0/Spring.Core.dll true CP0008 - T:Spring.Caching.CacheResultItemsAttribute + T:Spring.Objects.Factory.Attributes.QualifierAttribute lib/net462/Spring.Core.dll lib/netstandard2.0/Spring.Core.dll true CP0008 - T:Spring.Caching.InvalidateCacheAttribute + T:Spring.Objects.Factory.Attributes.RequiredAttribute lib/net462/Spring.Core.dll lib/netstandard2.0/Spring.Core.dll true CP0008 - T:Spring.Collections.NoElementsException + T:Spring.Objects.Factory.Attributes.ValueAttribute lib/net462/Spring.Core.dll lib/netstandard2.0/Spring.Core.dll true CP0008 - T:Spring.Context.ApplicationContextException + T:Spring.Objects.Factory.FactoryObjectNotInitializedException lib/net462/Spring.Core.dll lib/netstandard2.0/Spring.Core.dll true CP0008 - T:Spring.Context.Attributes.ConfigurationAttribute + T:Spring.Objects.Factory.NoSuchObjectDefinitionException lib/net462/Spring.Core.dll lib/netstandard2.0/Spring.Core.dll true CP0008 - T:Spring.Context.Attributes.DependsOnAttribute + T:Spring.Objects.Factory.ObjectCreationException lib/net462/Spring.Core.dll lib/netstandard2.0/Spring.Core.dll true CP0008 - T:Spring.Context.Attributes.ImportAttribute + T:Spring.Objects.Factory.ObjectCurrentlyInCreationException lib/net462/Spring.Core.dll lib/netstandard2.0/Spring.Core.dll true CP0008 - T:Spring.Context.Attributes.ImportResourceAttribute + T:Spring.Objects.Factory.ObjectDefinitionException lib/net462/Spring.Core.dll lib/netstandard2.0/Spring.Core.dll true CP0008 - T:Spring.Context.Attributes.LazyAttribute + T:Spring.Objects.Factory.ObjectDefinitionStoreException lib/net462/Spring.Core.dll lib/netstandard2.0/Spring.Core.dll true CP0008 - T:Spring.Context.Attributes.ObjectDefAttribute + T:Spring.Objects.Factory.ObjectInitializationException lib/net462/Spring.Core.dll lib/netstandard2.0/Spring.Core.dll true CP0008 - T:Spring.Context.Attributes.ScopeAttribute + T:Spring.Objects.Factory.ObjectIsNotAFactoryException lib/net462/Spring.Core.dll lib/netstandard2.0/Spring.Core.dll true CP0008 - T:Spring.Context.EventListenerAttribute + T:Spring.Objects.Factory.ObjectNotOfRequiredTypeException lib/net462/Spring.Core.dll lib/netstandard2.0/Spring.Core.dll true CP0008 - T:Spring.Context.NoSuchMessageException + T:Spring.Objects.Factory.Parsing.ObjectDefinitionParsingException lib/net462/Spring.Core.dll lib/netstandard2.0/Spring.Core.dll true CP0008 - T:Spring.Core.CannotLoadObjectTypeException + T:Spring.Objects.Factory.Support.ObjectDefinitionValidationException lib/net462/Spring.Core.dll lib/netstandard2.0/Spring.Core.dll true CP0008 - T:Spring.Core.InvalidPropertyException + T:Spring.Objects.Factory.UnsatisfiedDependencyException lib/net462/Spring.Core.dll lib/netstandard2.0/Spring.Core.dll true CP0008 - T:Spring.Core.MethodInvocationException + T:Spring.Objects.Factory.Xml.NamespaceParserAttribute lib/net462/Spring.Core.dll lib/netstandard2.0/Spring.Core.dll true CP0008 - T:Spring.Core.NotReadablePropertyException + T:Spring.Objects.FatalObjectException lib/net462/Spring.Core.dll lib/netstandard2.0/Spring.Core.dll true CP0008 - T:Spring.Core.NotWritablePropertyException + T:Spring.Objects.ObjectsException lib/net462/Spring.Core.dll lib/netstandard2.0/Spring.Core.dll true CP0008 - T:Spring.Core.NullValueInNestedPathException + T:Spring.Objects.PropertyAccessExceptionsException lib/net462/Spring.Core.dll lib/netstandard2.0/Spring.Core.dll true CP0008 - T:Spring.Core.PropertyAccessException + T:Spring.Pool.PoolException lib/net462/Spring.Core.dll lib/netstandard2.0/Spring.Core.dll true CP0008 - T:Spring.Core.TypeMismatchException + T:Spring.Proxy.ProxyIgnoreAttribute lib/net462/Spring.Core.dll lib/netstandard2.0/Spring.Core.dll true CP0008 - T:Spring.Expressions.BaseNode.ArgumentMismatchException + T:Spring.Stereotype.ComponentAttribute lib/net462/Spring.Core.dll lib/netstandard2.0/Spring.Core.dll true CP0008 - T:Spring.Expressions.Parser.antlr.ANTLRException + T:Spring.Stereotype.ControllerAttribute lib/net462/Spring.Core.dll lib/netstandard2.0/Spring.Core.dll true CP0008 - T:Spring.Expressions.Parser.antlr.ANTLRPanicException + T:Spring.Stereotype.RepositoryAttribute lib/net462/Spring.Core.dll lib/netstandard2.0/Spring.Core.dll true CP0008 - T:Spring.Expressions.Parser.antlr.CharStreamException + T:Spring.Stereotype.ServiceAttribute lib/net462/Spring.Core.dll lib/netstandard2.0/Spring.Core.dll true CP0008 - T:Spring.Expressions.Parser.antlr.CharStreamIOException + T:Spring.Threading.TimeoutException lib/net462/Spring.Core.dll lib/netstandard2.0/Spring.Core.dll true CP0008 - T:Spring.Expressions.Parser.antlr.MismatchedCharException + T:Spring.Util.FatalReflectionException lib/net462/Spring.Core.dll lib/netstandard2.0/Spring.Core.dll true CP0008 - T:Spring.Expressions.Parser.antlr.MismatchedTokenException + T:Spring.Util.ReflectionException lib/net462/Spring.Core.dll lib/netstandard2.0/Spring.Core.dll true CP0008 - T:Spring.Expressions.Parser.antlr.NoViableAltException + T:Spring.Validation.ValidatedAttribute lib/net462/Spring.Core.dll lib/netstandard2.0/Spring.Core.dll true CP0008 - T:Spring.Expressions.Parser.antlr.NoViableAltForCharException + T:Spring.Validation.ValidationException lib/net462/Spring.Core.dll lib/netstandard2.0/Spring.Core.dll true CP0008 - T:Spring.Expressions.Parser.antlr.RecognitionException - lib/net462/Spring.Core.dll + T:Spring.Context.Support.ReferenceNode + lib/netstandard2.0/Spring.Core.dll lib/netstandard2.0/Spring.Core.dll true CP0008 - T:Spring.Expressions.Parser.antlr.SemanticException - lib/net462/Spring.Core.dll + T:Spring.Expressions.ArrayConstructorNode + lib/netstandard2.0/Spring.Core.dll lib/netstandard2.0/Spring.Core.dll true CP0008 - T:Spring.Expressions.Parser.antlr.TokenStreamException - lib/net462/Spring.Core.dll + T:Spring.Expressions.AssignNode + lib/netstandard2.0/Spring.Core.dll lib/netstandard2.0/Spring.Core.dll true CP0008 - T:Spring.Expressions.Parser.antlr.TokenStreamIOException - lib/net462/Spring.Core.dll + T:Spring.Expressions.AttributeNode + lib/netstandard2.0/Spring.Core.dll lib/netstandard2.0/Spring.Core.dll true CP0008 - T:Spring.Expressions.Parser.antlr.TokenStreamRecognitionException - lib/net462/Spring.Core.dll + T:Spring.Expressions.BaseNode + lib/netstandard2.0/Spring.Core.dll lib/netstandard2.0/Spring.Core.dll true CP0008 - T:Spring.Expressions.Parser.antlr.TokenStreamRetryException - lib/net462/Spring.Core.dll + T:Spring.Expressions.BinaryOperator + lib/netstandard2.0/Spring.Core.dll lib/netstandard2.0/Spring.Core.dll true CP0008 - T:Spring.Objects.Factory.Attributes.AutowiredAttribute - lib/net462/Spring.Core.dll + T:Spring.Expressions.BooleanLiteralNode + lib/netstandard2.0/Spring.Core.dll lib/netstandard2.0/Spring.Core.dll true CP0008 - T:Spring.Objects.Factory.Attributes.PostConstructAttribute - lib/net462/Spring.Core.dll + T:Spring.Expressions.ConstructorNode + lib/netstandard2.0/Spring.Core.dll lib/netstandard2.0/Spring.Core.dll true CP0008 - T:Spring.Objects.Factory.Attributes.PreDestroyAttribute - lib/net462/Spring.Core.dll + T:Spring.Expressions.DefaultNode + lib/netstandard2.0/Spring.Core.dll lib/netstandard2.0/Spring.Core.dll true CP0008 - T:Spring.Objects.Factory.Attributes.QualifierAttribute - lib/net462/Spring.Core.dll + T:Spring.Expressions.Expression + lib/netstandard2.0/Spring.Core.dll lib/netstandard2.0/Spring.Core.dll true CP0008 - T:Spring.Objects.Factory.Attributes.RequiredAttribute - lib/net462/Spring.Core.dll + T:Spring.Expressions.ExpressionListNode + lib/netstandard2.0/Spring.Core.dll lib/netstandard2.0/Spring.Core.dll true CP0008 - T:Spring.Objects.Factory.Attributes.ValueAttribute - lib/net462/Spring.Core.dll + T:Spring.Expressions.FunctionNode + lib/netstandard2.0/Spring.Core.dll lib/netstandard2.0/Spring.Core.dll true CP0008 - T:Spring.Objects.Factory.FactoryObjectNotInitializedException - lib/net462/Spring.Core.dll + T:Spring.Expressions.HexLiteralNode + lib/netstandard2.0/Spring.Core.dll lib/netstandard2.0/Spring.Core.dll true CP0008 - T:Spring.Objects.Factory.NoSuchObjectDefinitionException - lib/net462/Spring.Core.dll + T:Spring.Expressions.IndexerNode + lib/netstandard2.0/Spring.Core.dll lib/netstandard2.0/Spring.Core.dll true CP0008 - T:Spring.Objects.Factory.ObjectCreationException - lib/net462/Spring.Core.dll + T:Spring.Expressions.IntLiteralNode + lib/netstandard2.0/Spring.Core.dll lib/netstandard2.0/Spring.Core.dll true CP0008 - T:Spring.Objects.Factory.ObjectCurrentlyInCreationException - lib/net462/Spring.Core.dll + T:Spring.Expressions.LambdaExpressionNode + lib/netstandard2.0/Spring.Core.dll lib/netstandard2.0/Spring.Core.dll true CP0008 - T:Spring.Objects.Factory.ObjectDefinitionException - lib/net462/Spring.Core.dll + T:Spring.Expressions.ListInitializerNode + lib/netstandard2.0/Spring.Core.dll lib/netstandard2.0/Spring.Core.dll true CP0008 - T:Spring.Objects.Factory.ObjectDefinitionStoreException - lib/net462/Spring.Core.dll + T:Spring.Expressions.LocalFunctionNode + lib/netstandard2.0/Spring.Core.dll lib/netstandard2.0/Spring.Core.dll true CP0008 - T:Spring.Objects.Factory.ObjectInitializationException - lib/net462/Spring.Core.dll + T:Spring.Expressions.LocalVariableNode + lib/netstandard2.0/Spring.Core.dll lib/netstandard2.0/Spring.Core.dll true CP0008 - T:Spring.Objects.Factory.ObjectIsNotAFactoryException - lib/net462/Spring.Core.dll + T:Spring.Expressions.MapEntryNode + lib/netstandard2.0/Spring.Core.dll lib/netstandard2.0/Spring.Core.dll true CP0008 - T:Spring.Objects.Factory.ObjectNotOfRequiredTypeException - lib/net462/Spring.Core.dll + T:Spring.Expressions.MapInitializerNode + lib/netstandard2.0/Spring.Core.dll lib/netstandard2.0/Spring.Core.dll true CP0008 - T:Spring.Objects.Factory.Parsing.ObjectDefinitionParsingException - lib/net462/Spring.Core.dll + T:Spring.Expressions.MethodNode + lib/netstandard2.0/Spring.Core.dll lib/netstandard2.0/Spring.Core.dll true CP0008 - T:Spring.Objects.Factory.Support.ObjectDefinitionValidationException - lib/net462/Spring.Core.dll + T:Spring.Expressions.NamedArgumentNode + lib/netstandard2.0/Spring.Core.dll lib/netstandard2.0/Spring.Core.dll true CP0008 - T:Spring.Objects.Factory.UnsatisfiedDependencyException - lib/net462/Spring.Core.dll + T:Spring.Expressions.NodeWithArguments + lib/netstandard2.0/Spring.Core.dll lib/netstandard2.0/Spring.Core.dll true CP0008 - T:Spring.Objects.Factory.Xml.NamespaceParserAttribute - lib/net462/Spring.Core.dll + T:Spring.Expressions.NullLiteralNode + lib/netstandard2.0/Spring.Core.dll lib/netstandard2.0/Spring.Core.dll true CP0008 - T:Spring.Objects.FatalObjectException - lib/net462/Spring.Core.dll + T:Spring.Expressions.OpADD + lib/netstandard2.0/Spring.Core.dll lib/netstandard2.0/Spring.Core.dll true CP0008 - T:Spring.Objects.ObjectsException - lib/net462/Spring.Core.dll + T:Spring.Expressions.OpAND + lib/netstandard2.0/Spring.Core.dll lib/netstandard2.0/Spring.Core.dll true CP0008 - T:Spring.Objects.PropertyAccessExceptionsException - lib/net462/Spring.Core.dll + T:Spring.Expressions.OpBetween + lib/netstandard2.0/Spring.Core.dll lib/netstandard2.0/Spring.Core.dll true CP0008 - T:Spring.Pool.PoolException - lib/net462/Spring.Core.dll + T:Spring.Expressions.OpDIVIDE + lib/netstandard2.0/Spring.Core.dll lib/netstandard2.0/Spring.Core.dll true CP0008 - T:Spring.Proxy.ProxyIgnoreAttribute - lib/net462/Spring.Core.dll + T:Spring.Expressions.OpEqual + lib/netstandard2.0/Spring.Core.dll lib/netstandard2.0/Spring.Core.dll true CP0008 - T:Spring.Stereotype.ComponentAttribute - lib/net462/Spring.Core.dll + T:Spring.Expressions.OpGreater + lib/netstandard2.0/Spring.Core.dll lib/netstandard2.0/Spring.Core.dll true CP0008 - T:Spring.Stereotype.ControllerAttribute - lib/net462/Spring.Core.dll + T:Spring.Expressions.OpGreaterOrEqual + lib/netstandard2.0/Spring.Core.dll lib/netstandard2.0/Spring.Core.dll true CP0008 - T:Spring.Stereotype.RepositoryAttribute - lib/net462/Spring.Core.dll + T:Spring.Expressions.OpIn + lib/netstandard2.0/Spring.Core.dll lib/netstandard2.0/Spring.Core.dll true CP0008 - T:Spring.Stereotype.ServiceAttribute - lib/net462/Spring.Core.dll + T:Spring.Expressions.OpIs + lib/netstandard2.0/Spring.Core.dll lib/netstandard2.0/Spring.Core.dll true CP0008 - T:Spring.Threading.TimeoutException - lib/net462/Spring.Core.dll + T:Spring.Expressions.OpLess + lib/netstandard2.0/Spring.Core.dll lib/netstandard2.0/Spring.Core.dll true CP0008 - T:Spring.Util.FatalReflectionException - lib/net462/Spring.Core.dll + T:Spring.Expressions.OpLessOrEqual + lib/netstandard2.0/Spring.Core.dll lib/netstandard2.0/Spring.Core.dll true CP0008 - T:Spring.Util.ReflectionException - lib/net462/Spring.Core.dll + T:Spring.Expressions.OpLike + lib/netstandard2.0/Spring.Core.dll lib/netstandard2.0/Spring.Core.dll true CP0008 - T:Spring.Validation.ValidatedAttribute - lib/net462/Spring.Core.dll + T:Spring.Expressions.OpMatches + lib/netstandard2.0/Spring.Core.dll lib/netstandard2.0/Spring.Core.dll true CP0008 - T:Spring.Validation.ValidationException - lib/net462/Spring.Core.dll + T:Spring.Expressions.OpMODULUS + lib/netstandard2.0/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0008 + T:Spring.Expressions.OpMULTIPLY + lib/netstandard2.0/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0008 + T:Spring.Expressions.OpNOT + lib/netstandard2.0/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0008 + T:Spring.Expressions.OpNotEqual + lib/netstandard2.0/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0008 + T:Spring.Expressions.OpOR + lib/netstandard2.0/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0008 + T:Spring.Expressions.OpPOWER + lib/netstandard2.0/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0008 + T:Spring.Expressions.OpSUBTRACT + lib/netstandard2.0/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0008 + T:Spring.Expressions.OpUnaryMinus + lib/netstandard2.0/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0008 + T:Spring.Expressions.OpUnaryPlus + lib/netstandard2.0/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0008 + T:Spring.Expressions.OpXOR + lib/netstandard2.0/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0008 + T:Spring.Expressions.ProjectionNode + lib/netstandard2.0/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0008 + T:Spring.Expressions.PropertyOrFieldNode + lib/netstandard2.0/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0008 + T:Spring.Expressions.QualifiedIdentifier + lib/netstandard2.0/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0008 + T:Spring.Expressions.RealLiteralNode + lib/netstandard2.0/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0008 + T:Spring.Expressions.SelectionFirstNode + lib/netstandard2.0/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0008 + T:Spring.Expressions.SelectionLastNode + lib/netstandard2.0/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0008 + T:Spring.Expressions.SelectionNode + lib/netstandard2.0/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0008 + T:Spring.Expressions.SpringAST + lib/netstandard2.0/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0008 + T:Spring.Expressions.StringLiteralNode + lib/netstandard2.0/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0008 + T:Spring.Expressions.TernaryNode + lib/netstandard2.0/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0008 + T:Spring.Expressions.TypeNode + lib/netstandard2.0/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0008 + T:Spring.Expressions.UnaryOperator + lib/netstandard2.0/Spring.Core.dll + lib/netstandard2.0/Spring.Core.dll + true + + + CP0008 + T:Spring.Expressions.VariableNode + lib/netstandard2.0/Spring.Core.dll lib/netstandard2.0/Spring.Core.dll true diff --git a/src/Spring/Spring.Core/Expressions/ArrayConstructorNode.cs b/src/Spring/Spring.Core/Expressions/ArrayConstructorNode.cs index ceb1c2013..b0036ae89 100644 --- a/src/Spring/Spring.Core/Expressions/ArrayConstructorNode.cs +++ b/src/Spring/Spring.Core/Expressions/ArrayConstructorNode.cs @@ -17,7 +17,6 @@ using System.Collections; using System.Runtime.Serialization; using Spring.Core.TypeResolution; -using Spring.Expressions.Parser.antlr.collections; namespace Spring.Expressions; @@ -66,13 +65,13 @@ protected override object Get(object context, EvaluationContext evalContext) } } - AST rankRoot = getFirstChild(); + SpringAST rankRoot = getFirstChild(); int dimensions = rankRoot.getNumberOfChildren(); int[] ranks = new int[dimensions]; if (dimensions > 0) { int i = 0; - AST rankNode = rankRoot.getFirstChild(); + SpringAST rankNode = rankRoot.getFirstChild(); while (rankNode != null) { ranks[i++] = (int) GetValue((BaseNode) rankNode, context, evalContext); @@ -83,7 +82,7 @@ protected override object Get(object context, EvaluationContext evalContext) } else { - AST valuesRoot = getFirstChild().getNextSibling(); + SpringAST valuesRoot = getFirstChild().getNextSibling(); if (valuesRoot != null) { ArrayList values = (ArrayList) GetValue(((BaseNode) valuesRoot), context, evalContext); diff --git a/src/Spring/Spring.Core/Expressions/AssignNode.cs b/src/Spring/Spring.Core/Expressions/AssignNode.cs index 3613117ab..5f7d619d9 100644 --- a/src/Spring/Spring.Core/Expressions/AssignNode.cs +++ b/src/Spring/Spring.Core/Expressions/AssignNode.cs @@ -15,7 +15,6 @@ */ using System.Runtime.Serialization; -using Spring.Expressions.Parser.antlr.collections; namespace Spring.Expressions; @@ -52,8 +51,8 @@ protected AssignNode(SerializationInfo info, StreamingContext context) /// Node's value. protected override object Get(object context, EvaluationContext evalContext) { - AST left = getFirstChild(); - AST right = left.getNextSibling(); + SpringAST left = getFirstChild(); + SpringAST right = left.getNextSibling(); object result; diff --git a/src/Spring/Spring.Core/Expressions/BaseNode.cs b/src/Spring/Spring.Core/Expressions/BaseNode.cs index c71a6cf2a..c8a5428c3 100644 --- a/src/Spring/Spring.Core/Expressions/BaseNode.cs +++ b/src/Spring/Spring.Core/Expressions/BaseNode.cs @@ -249,11 +249,14 @@ protected object GetValueWithArguments(BaseNode node, object context, Evaluation protected object GetValue(BaseNode node, object context, EvaluationContext evalContext) { + // An overflow would end the process, and the depth of a tree depends on the input + System.Runtime.CompilerServices.RuntimeHelpers.EnsureSufficientExecutionStack(); return node.Get(context, evalContext); } protected void SetValue(BaseNode node, object context, EvaluationContext evalContext, object newValue) { + System.Runtime.CompilerServices.RuntimeHelpers.EnsureSufficientExecutionStack(); node.Set(context, evalContext, newValue); } } diff --git a/src/Spring/Spring.Core/Expressions/Expression.cs b/src/Spring/Spring.Core/Expressions/Expression.cs index 1962261bd..184ea442c 100644 --- a/src/Spring/Spring.Core/Expressions/Expression.cs +++ b/src/Spring/Spring.Core/Expressions/Expression.cs @@ -17,9 +17,6 @@ using System.Collections; using System.Reflection; using System.Runtime.Serialization; -using Spring.Expressions.Parser; -using Spring.Expressions.Parser.antlr; -using Spring.Expressions.Parser.antlr.collections; using Spring.Core; using Spring.Reflection.Dynamic; using Spring.Util; @@ -63,77 +60,6 @@ public class ReservedVariableNames internal static readonly string ExpressionExtensions = RESERVEDPREFIX + "ExpressionExtensions"; } - private class ASTNodeCreator : Parser.antlr.ASTNodeCreator - { - private readonly SafeConstructor ctor; - private readonly string name; - - public ASTNodeCreator(ConstructorInfo ctor) - { - this.ctor = new SafeConstructor(ctor); - this.name = ctor.DeclaringType.FullName; - } - - public override AST Create() - { - return (AST) ctor.Invoke(new object[0]); - } - - public override string ASTNodeTypeName - { - get { return name; } - } - } - - private class SpringASTFactory : ASTFactory - { - private static readonly Type BASENODE_TYPE; - private static readonly Hashtable Typename2Creator; - - static SpringASTFactory() - { - BASENODE_TYPE = typeof(SpringAST); - - Typename2Creator = new Hashtable(); - foreach (Type type in typeof(SpringASTFactory).Assembly.GetTypes()) - { - if (BASENODE_TYPE.IsAssignableFrom(type) && !type.IsAbstract) - { - ConstructorInfo ctor = type.GetConstructor(System.Type.EmptyTypes); - if (ctor != null) - { - ASTNodeCreator creator = new ASTNodeCreator(ctor); - Typename2Creator[creator.ASTNodeTypeName] = creator; - } - } - } - - Typename2Creator[BASENODE_TYPE.FullName] = SpringAST.Creator; - } - - public SpringASTFactory() : base(BASENODE_TYPE) - { - base.defaultASTNodeTypeObject_ = BASENODE_TYPE; - base.typename2creator_ = Typename2Creator; - } - } - - private class SpringExpressionParser : ExpressionParser - { - public SpringExpressionParser(TokenStream lexer) - : base(lexer) - { - base.astFactory = new SpringASTFactory(); - base.initialize(); - } - } - - static Expression() - { - // Ensure antlr is loaded (fixes GAC issues)! - Assembly antlrAss = typeof(Parser.antlr.LLkParser).Assembly; - } - /// /// Initializes a new instance of the class /// by parsing specified expression string. @@ -143,19 +69,7 @@ public static IExpression Parse(string expression) { if (StringUtils.HasText(expression)) { - ExpressionLexer lexer = new ExpressionLexer(new StringReader(expression)); - ExpressionParser parser = new SpringExpressionParser(lexer); - - try - { - parser.expr(); - } - catch (TokenStreamRecognitionException ex) - { - throw new SyntaxErrorException(ex.recog.Message, ex.recog.getLine(), ex.recog.getColumn(), expression); - } - - return (IExpression) parser.getAST(); + return ExpressionGrammar.ParseExpression(expression); } else { @@ -402,19 +316,7 @@ private static void AssertReceiverParameter(Type targetType, Delegate implementa private static LambdaExpressionNode ParseLambda(string lambdaExpression) { - ExpressionLexer lexer = new ExpressionLexer(new StringReader(lambdaExpression)); - ExpressionParser parser = new SpringExpressionParser(lexer); - - try - { - parser.lambda(); - } - catch (TokenStreamRecognitionException ex) - { - throw new SyntaxErrorException(ex.recog.Message, ex.recog.getLine(), ex.recog.getColumn(), lambdaExpression); - } - - return (LambdaExpressionNode) parser.getAST(); + return ExpressionGrammar.ParseLambda(lambdaExpression); } /// @@ -426,19 +328,7 @@ internal static IExpression ParsePrimary(string expression) { if (StringUtils.HasText(expression)) { - ExpressionLexer lexer = new ExpressionLexer(new StringReader(expression)); - ExpressionParser parser = new SpringExpressionParser(lexer); - - try - { - parser.primaryExpression(); - } - catch (TokenStreamRecognitionException ex) - { - throw new SyntaxErrorException(ex.recog.Message, ex.recog.getLine(), ex.recog.getColumn(), expression); - } - - return (IExpression) parser.getAST(); + return ExpressionGrammar.ParsePrimary(expression); } else { @@ -455,19 +345,7 @@ internal static IExpression ParseProperty(string expression) { if (StringUtils.HasText(expression)) { - ExpressionLexer lexer = new ExpressionLexer(new StringReader(expression)); - ExpressionParser parser = new SpringExpressionParser(lexer); - - try - { - parser.property(); - } - catch (TokenStreamRecognitionException ex) - { - throw new SyntaxErrorException(ex.recog.Message, ex.recog.getLine(), ex.recog.getColumn(), expression); - } - - return (IExpression) parser.getAST(); + return ExpressionGrammar.ParseProperty(expression); } else { @@ -506,7 +384,7 @@ protected override object Get(object context, EvaluationContext evalContext) if (this.getNumberOfChildren() > 0) { - AST node = this.getFirstChild(); + SpringAST node = this.getFirstChild(); while (node != null) { result = GetValue(((BaseNode) node), result, evalContext); @@ -532,7 +410,7 @@ protected override void Set(object context, EvaluationContext evalContext, objec if (this.getNumberOfChildren() > 0) { - AST node = this.getFirstChild(); + SpringAST node = this.getFirstChild(); for (int i = 0; i < this.getNumberOfChildren() - 1; i++) { @@ -567,7 +445,7 @@ internal PropertyInfo GetPropertyInfo(object context, IDictionary 0) { object target = context; - AST node = this.getFirstChild(); + SpringAST node = this.getFirstChild(); for (int i = 0; i < this.getNumberOfChildren() - 1; i++) { diff --git a/src/Spring/Spring.Core/Expressions/Expression.g b/src/Spring/Spring.Core/Expressions/Expression.g deleted file mode 100644 index 313932869..000000000 --- a/src/Spring/Spring.Core/Expressions/Expression.g +++ /dev/null @@ -1,549 +0,0 @@ -options -{ - language = "CSharp"; - namespace = "Spring.Expressions.Parser"; -} - -class ExpressionParser extends Parser; - -options { - codeGenMakeSwitchThreshold = 3; - codeGenBitsetTestThreshold = 4; - classHeaderPrefix = "internal"; - buildAST=true; - ASTLabelType = "Spring.Expressions.SpringAST"; - k = 2; -} - -tokens { - EXPR; - OPERAND; - FALSE = "false"; - TRUE = "true"; - AND = "and"; - OR = "or"; - XOR = "xor"; - IN = "in"; - IS = "is"; - BETWEEN = "between"; - LIKE = "like"; - MATCHES = "matches"; - NULL_LITERAL = "null"; -} - -{ - // CLOVER:OFF - - public override void reportError(RecognitionException ex) - { - //base.reportError(ex); - throw new antlr.TokenStreamRecognitionException(ex); - } - - public override void reportError(string error) - { - //base.reportError(error); - throw new RecognitionException(error); - } - - private string GetRelationalOperatorNodeType(string op) - { - switch (op) - { - case "==" : return "Spring.Expressions.OpEqual"; - case "!=" : return "Spring.Expressions.OpNotEqual"; - case "<" : return "Spring.Expressions.OpLess"; - case "<=" : return "Spring.Expressions.OpLessOrEqual"; - case ">" : return "Spring.Expressions.OpGreater"; - case ">=" : return "Spring.Expressions.OpGreaterOrEqual"; - case "in" : return "Spring.Expressions.OpIn"; - case "is" : return "Spring.Expressions.OpIs"; - case "between" : return "Spring.Expressions.OpBetween"; - case "like" : return "Spring.Expressions.OpLike"; - case "matches" : return "Spring.Expressions.OpMatches"; - default : - throw new ArgumentException("Node type for operator '" + op + "' is not defined."); - } - } -} - -expr : expression EOF!; - -exprList - : LPAREN! expression (SEMI! expression)+ RPAREN! - { #exprList = #([EXPR,"expressionList","Spring.Expressions.ExpressionListNode"], #exprList); } - ; - -expression : logicalOrExpression - ( - (ASSIGN^ logicalOrExpression) - | (DEFAULT^ logicalOrExpression) - | (QMARK^ expression COLON! expression) - )? - ; - -parenExpr - : LPAREN! expression RPAREN!; - -logicalOrExpression : logicalXorExpression (OR^ logicalXorExpression)* ; - -logicalXorExpression : logicalAndExpression (XOR^ logicalAndExpression)* ; - -logicalAndExpression : relationalExpression (AND^ relationalExpression)* ; - -relationalExpression - : e1:sumExpr - (op:relationalOperator! e2:sumExpr - {#relationalExpression = #(#[EXPR, op_AST.getText(), GetRelationalOperatorNodeType(op_AST.getText())], #relationalExpression);} - )? - ; - -sumExpr : prodExpr ( - (PLUS^ - | MINUS^ ) prodExpr)* ; - -prodExpr : powExpr ( - (STAR^ - | DIV^ - | MOD^ ) powExpr)* ; - -powExpr : unaryExpression (POWER^ unaryExpression)? ; - -unaryExpression - : (PLUS^ - | MINUS^ - | BANG^ ) unaryExpression - | primaryExpression - ; - -unaryOperator - : PLUS | MINUS | BANG - ; - -primaryExpression : startNode (node)? - { #primaryExpression = #([EXPR,"expression","Spring.Expressions.Expression"], #primaryExpression); }; - -startNode - : - ( (LPAREN expression SEMI) => exprList - | parenExpr - | methodOrProperty - | functionOrVar - | localFunctionOrVar - | reference - | indexer - | literal - | type - | constructor - | projection - | selection - | firstSelection - | lastSelection - | listInitializer - | mapInitializer - | lambda - | attribute - ) - ; - -node : - ( methodOrProperty - | indexer - | projection - | selection - | firstSelection - | lastSelection - | exprList - | DOT! - )+ - ; - -functionOrVar - : (POUND ID LPAREN) => function - | var - ; - -function : POUND! ID^ methodArgs - ; - -var : POUND! ID^ ; - -localFunctionOrVar - : (DOLLAR ID LPAREN) => localFunction - | localVar - ; - -localFunction - : DOLLAR! ID^ methodArgs - ; - -localVar - : DOLLAR! ID^ - ; - -methodOrProperty - : (ID LPAREN)=> ID^ methodArgs - | property - ; - -methodArgs - : LPAREN! (argument (COMMA! argument)*)? RPAREN! - ; - -property - : ID - ; - -reference - : (AT! LPAREN! quotableName COLON) => - AT! LPAREN! cn:quotableName! COLON! id:quotableName! RPAREN! - { #reference = #([EXPR, "ref", "Spring.Context.Support.ReferenceNode"], #cn, #id); } - - | AT! LPAREN! localid:quotableName! RPAREN! - { #reference = #([EXPR, "ref", "Spring.Context.Support.ReferenceNode"], null, #localid); } - ; - -indexer - : LBRACKET^ argument (COMMA! argument)* RBRACKET! - ; - -projection - : - PROJECT^ expression RCURLY! - ; - -selection - : - SELECT^ expression (COMMA! expression)* RCURLY! - ; - -firstSelection - : - SELECT_FIRST^ expression RCURLY! - ; - -lastSelection - : - SELECT_LAST^ expression RCURLY! - ; - -type - : TYPE! tn:name! RPAREN! - { #type = #([EXPR, tn_AST.getText(), "Spring.Expressions.TypeNode"], #type); } - ; - -name - : ID^ (~(RPAREN|COLON|QUOTE))* - ; - -quotableName - : STRING_LITERAL^ - | name - ; - -attribute - : AT! LBRACKET! tn:qualifiedId! (ctorArgs)? RBRACKET! - { #attribute = #([EXPR, tn_AST.getText(), "Spring.Expressions.AttributeNode"], #attribute); } - ; - -lambda - : LAMBDA! (argList)? PIPE! expression RCURLY! - { #lambda = #([EXPR, "lambda", "Spring.Expressions.LambdaExpressionNode"], #lambda); } - ; - -argList : (ID (COMMA! ID)*) - { #argList = #([EXPR, "args"], #argList); } - ; - -constructor - : ("new" qualifiedId LPAREN) => "new"! type:qualifiedId! ctorArgs - { #constructor = #([EXPR, type_AST.getText(), "Spring.Expressions.ConstructorNode"], #constructor); } - | arrayConstructor - ; - -arrayConstructor - : "new"! type:qualifiedId! arrayRank (listInitializer)? - { #arrayConstructor = #([EXPR, type_AST.getText(), "Spring.Expressions.ArrayConstructorNode"], #arrayConstructor); } - ; - -arrayRank - : LBRACKET^ (expression (COMMA! expression)*)? RBRACKET! - ; - -listInitializer - : LCURLY^ expression (COMMA! expression)* RCURLY! - ; - -mapInitializer - : POUND! LCURLY^ mapEntry (COMMA! mapEntry)* RCURLY! - ; - -mapEntry - : expression COLON! expression - { #mapEntry = #([EXPR, "entry", "Spring.Expressions.MapEntryNode"], #mapEntry); } - ; - -ctorArgs : LPAREN! (namedArgument (COMMA! namedArgument)*)? RPAREN!; - -argument : expression; - -namedArgument - : (ID ASSIGN) => ID^ ASSIGN! expression - | argument - ; - -qualifiedId - : ID^ (DOT ID)* - ; - -literal - : NULL_LITERAL - | INTEGER_LITERAL - | HEXADECIMAL_INTEGER_LITERAL - | REAL_LITERAL - | STRING_LITERAL - | boolLiteral - ; - -boolLiteral - : TRUE - | FALSE - ; - -relationalOperator - : EQUAL - | NOT_EQUAL - | LESS_THAN - | LESS_THAN_OR_EQUAL - | GREATER_THAN - | GREATER_THAN_OR_EQUAL - | IN - | IS - | BETWEEN - | LIKE - | MATCHES - ; - - - -class ExpressionLexer extends Lexer; - -options { - charVocabulary = '\u0000' .. '\uFFFE'; - classHeaderPrefix = "internal"; - k = 2; - testLiterals = false; -} - -{ - // CLOVER:OFF -} - -WS : (' ' - | '\t' - | '\n' - | '\r') - { _ttype = Token.SKIP; } - ; - -AT: '@' - ; - -BACKTICK: '`' - ; - -BACKSLASH: '\\' - ; - -PIPE: '|' - ; - -BANG: '!' - ; - -QMARK: '?' - ; - -DOLLAR: '$' - ; - -POUND: '#' - ; - -LPAREN: '(' - ; - -RPAREN: ')' - ; - -LBRACKET: '[' - ; - -RBRACKET: ']' - ; - -LCURLY: '{' - ; - -RCURLY: '}' - ; - -COMMA : ',' - ; - -SEMI: ';' - ; - -COLON: ':' - ; - -ASSIGN: '=' - ; - -DEFAULT: "??" - ; - -PLUS: '+' - ; - -MINUS: '-' - ; - -DIV: '/' - ; - -STAR: '*' - ; - -MOD: '%' - ; - -POWER: '^' - ; - -EQUAL: "==" - ; - -NOT_EQUAL: "!=" - ; - -LESS_THAN: '<' - ; - -LESS_THAN_OR_EQUAL: "<=" - ; - -GREATER_THAN: '>' - ; - -GREATER_THAN_OR_EQUAL: ">=" - ; - -PROJECT: "!{" - ; - -SELECT: "?{" - ; - -SELECT_FIRST: "^{" - ; - -SELECT_LAST: "${" - ; - -TYPE: "T(" - ; - -LAMBDA: "{|" - ; - -DOT_ESCAPED: "\\." - ; - -QUOTE: '\'' - ; - -STRING_LITERAL - : QUOTE! (APOS|~'\'')* QUOTE! - ; - -protected -APOS : QUOTE! QUOTE - ; - -ID -options { - testLiterals = true; -} - : ('a'..'z'|'A'..'Z'|'_') ('a'..'z'|'A'..'Z'|'_'|'0'..'9')* - ; - -NUMERIC_LITERAL - - // real - : ('.' DECIMAL_DIGIT) => - '.' (DECIMAL_DIGIT)+ (EXPONENT_PART)? (REAL_TYPE_SUFFIX)? - {$setType(REAL_LITERAL);} - - | ((DECIMAL_DIGIT)+ '.' DECIMAL_DIGIT) => - (DECIMAL_DIGIT)+ '.' (DECIMAL_DIGIT)+ (EXPONENT_PART)? (REAL_TYPE_SUFFIX)? - {$setType(REAL_LITERAL);} - - | ((DECIMAL_DIGIT)+ (EXPONENT_PART)) => - (DECIMAL_DIGIT)+ (EXPONENT_PART) (REAL_TYPE_SUFFIX)? - {$setType(REAL_LITERAL);} - - | ((DECIMAL_DIGIT)+ (REAL_TYPE_SUFFIX)) => - (DECIMAL_DIGIT)+ (REAL_TYPE_SUFFIX) - {$setType(REAL_LITERAL);} - - // integer - | (DECIMAL_DIGIT)+ (INTEGER_TYPE_SUFFIX)? - {$setType(INTEGER_LITERAL);} - - // just a dot - | '.'{$setType(DOT);} - ; - - -HEXADECIMAL_INTEGER_LITERAL - : "0x" (HEX_DIGIT)+ (INTEGER_TYPE_SUFFIX)? - ; - -protected -DECIMAL_DIGIT - : '0'..'9' - ; - -protected -INTEGER_TYPE_SUFFIX - : - ( options {generateAmbigWarnings=false;} - : "UL" | "LU" | "ul" | "lu" - | "UL" | "LU" | "uL" | "lU" - | "U" | "L" | "u" | "l" - ) - ; - -protected -HEX_DIGIT - : '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9' | - 'A' | 'B' | 'C' | 'D' | 'E' | 'F' | - 'a' | 'b' | 'c' | 'd' | 'e' | 'f' - ; - -protected -EXPONENT_PART - : "e" (SIGN)* (DECIMAL_DIGIT)+ - | "E" (SIGN)* (DECIMAL_DIGIT)+ - ; - -protected -SIGN - : '+' | '-' - ; - -protected -REAL_TYPE_SUFFIX - : 'F' | 'f' | 'D' | 'd' | 'M' | 'm' - ; diff --git a/src/Spring/Spring.Core/Expressions/ExpressionGrammar.cs b/src/Spring/Spring.Core/Expressions/ExpressionGrammar.cs new file mode 100644 index 000000000..d60725eed --- /dev/null +++ b/src/Spring/Spring.Core/Expressions/ExpressionGrammar.cs @@ -0,0 +1,821 @@ +using System.Text; +using Spring.Context.Support; +using static Spring.Expressions.Parser.ExpressionParserTokenTypes; + +namespace Spring.Expressions; + +/// +/// Parses the expression language into a tree of nodes. +/// +/// +/// The grammar is in ExpressionGrammar.parlot.cs. That file is only read at build time by the Parlot source +/// generator, which emits into this assembly, so that there is no runtime dependency on a parsing +/// library. This file has its tokens, the tree it builds and its syntax errors. +/// +internal static partial class ExpressionGrammar +{ + internal enum Rule + { + Expression, + Primary, + Lambda + } + + private const string IdStart = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_"; + private const string IdPart = IdStart + "0123456789"; + private const string NumberStart = "0123456789."; + + private const char EndOfText = '\uFFFF'; + + // The parser fails at the limit on nesting, or when the stack of the thread ends. A small stack can end at this depth + private const int SuspiciousDepth = 32; + + private static partial bool TryParse(string input, Rule rule, out BaseNode value, out int failure); + + /// Parses a whole expression. + public static BaseNode ParseExpression(string input) => Parse(input, Rule.Expression); + + /// Parses the lambda expression at the start of the input, whatever follows it. + public static LambdaExpressionNode ParseLambda(string input) => (LambdaExpressionNode) Parse(input, Rule.Lambda); + + /// + /// Parses the primary expression at the start of the input and stops at the first token that can't continue it, which + /// has to be a token that can follow a primary expression. + /// + public static BaseNode ParsePrimary(string input) => Parse(input, Rule.Primary); + + /// Parses the property name at the start of the input, whatever follows it. + public static BaseNode ParseProperty(string input) + { + var start = SkipSpaces(input, 0); + var length = ScanId(input.AsSpan(start)); + if (length == 0) + { + throw CreateSyntaxError(input, start, "ID", mayBeTooDeep: false); + } + + return WithType(new PropertyOrFieldNode(), ID, input.Substring(start, length)); + } + + private static BaseNode Parse(string input, Rule rule) + { + if (TryParse(input, rule, out var node, out var failure)) + { + return node; + } + + var offset = SkipSpaces(input.AsSpan(), failure); + ReadTokensBefore(input, offset, out var depth, out var afterOperand); + + // The parser doesn't return why it failed: at this depth it can be the limit on nesting + var expected = rule == Rule.Lambda && offset == SkipSpaces(input.AsSpan(), 0) ? "LAMBDA" + : rule == Rule.Expression && depth == 0 && afterOperand && offset < input.Length ? "EOF" + : null; + + throw CreateSyntaxError(input, offset, expected, depth >= SuspiciousDepth); + } + + // Tokens + + private static bool IsIdStart(char c) => (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || c == '_'; + + private static bool IsDigit(char c) => c >= '0' && c <= '9'; + + private static bool IsIdPart(char c) => IsIdStart(c) || IsDigit(c); + + private static bool IsHexDigit(char c) => IsDigit(c) || (c >= 'a' && c <= 'f') || (c >= 'A' && c <= 'F'); + + private static bool IsWhiteSpace(char c) => c == ' ' || c == '\t' || c == '\n' || c == '\r'; + + private static char CharAt(ReadOnlySpan span, int index) => index < span.Length ? span[index] : EndOfText; + + private static int SkipSpaces(ReadOnlySpan span, int offset) + { + while (offset < span.Length && IsWhiteSpace(span[offset])) + { + offset++; + } + + return offset; + } + + /// The token of this type at the start of the text, which isn't the start of a longer one. + private static int ScanToken(ReadOnlySpan span, int expected) + { + if (span.IsEmpty) + { + return 0; + } + + var length = NextToken(span, out var type); + return type == expected ? length : 0; + } + + private static int ScanLeftCurly(ReadOnlySpan span) => ScanToken(span, LCURLY); + + private static int ScanAssign(ReadOnlySpan span) => ScanToken(span, ASSIGN); + + private static int ScanDollar(ReadOnlySpan span) => ScanToken(span, DOLLAR); + + private static int ScanPower(ReadOnlySpan span) => ScanToken(span, POWER); + + private static int ScanDot(ReadOnlySpan span) => CharAt(span, 0) == '.' && !IsDigit(CharAt(span, 1)) ? 1 : 0; + + private static int ScanBang(ReadOnlySpan span) => ScanToken(span, BANG); + + private static int ScanQuestion(ReadOnlySpan span) => ScanToken(span, QMARK); + + private static int ScanWord(ReadOnlySpan span) + { + if (!IsIdStart(CharAt(span, 0))) + { + return 0; + } + + var size = 1; + while (size < span.Length && IsIdPart(span[size])) + { + size++; + } + + return size; + } + + /// Returns the type of the keyword is, or ID. + private static int WordType(ReadOnlySpan word) + { + static bool Is(ReadOnlySpan word, string keyword) => word.SequenceEqual(keyword.AsSpan()); + + switch (word.Length) + { + case 2: + return Is(word, "or") ? OR : Is(word, "in") ? IN : Is(word, "is") ? IS : ID; + case 3: + return Is(word, "and") ? AND : Is(word, "xor") ? XOR : Is(word, "new") ? LITERAL_new : ID; + case 4: + return Is(word, "true") ? TRUE : Is(word, "like") ? LIKE : Is(word, "null") ? NULL_LITERAL : ID; + case 5: + return Is(word, "false") ? FALSE : ID; + case 7: + return Is(word, "between") ? BETWEEN : Is(word, "matches") ? MATCHES : ID; + default: + return ID; + } + } + + /// An identifier: neither a keyword nor the T( of a type. + private static int ScanId(ReadOnlySpan span) + { + var size = ScanWord(span); + if (size == 0 || WordType(span.Slice(0, size)) != ID || (size == 1 && CharAt(span, 0) == 'T' && CharAt(span, 1) == '(')) + { + return 0; + } + + return size; + } + + /// ID (DOT ID)*, with any white space between the tokens. + private static int ScanQualifiedId(ReadOnlySpan span) + { + var size = ScanId(span); + while (size > 0) + { + var dot = SkipSpaces(span, size); + if (CharAt(span, dot) != '.' || IsDigit(CharAt(span, dot + 1))) + { + break; + } + + var next = SkipSpaces(span, dot + 1); + var length = next < span.Length ? ScanId(span.Slice(next)) : 0; + if (length == 0) + { + break; + } + + size = next + length; + } + + return size; + } + + /// + /// A type or object name: an identifier, then any tokens but ')', ':' and a lone quote. It stops before anything that + /// isn't a token, which then fails in the parser that follows. + /// + private static int ScanName(ReadOnlySpan span) + { + var size = ScanId(span); + while (size > 0) + { + var next = SkipSpaces(span, size); + if (next == span.Length) + { + break; + } + + var length = NextToken(span.Slice(next), out var type); + if (length == 0 || type == RPAREN || type == COLON || type == QUOTE) + { + break; + } + + size = next + length; + } + + return size; + } + + private static int ScanString(ReadOnlySpan span) + { + if (CharAt(span, 0) != '\'') + { + return 0; + } + + for (var i = 1; i < span.Length; i++) + { + if (span[i] == '\'') + { + if (CharAt(span, i + 1) != '\'') + { + return i + 1; + } + + i++; + } + } + + return 0; + } + + private static int SkipDigits(ReadOnlySpan span, int offset) + { + while (offset < span.Length && IsDigit(span[offset])) + { + offset++; + } + + return offset; + } + + /// + /// The exponent and suffix of a real number. After a fraction 'e' has to start an exponent: there is no token then. + /// + private static int SkipRealEnd(ReadOnlySpan span, int offset, bool isFraction) + { + var c = CharAt(span, offset); + if (c == 'e' || c == 'E') + { + var digits = offset + 1; + while (CharAt(span, digits) == '+' || CharAt(span, digits) == '-') + { + digits++; + } + + if (IsDigit(CharAt(span, digits))) + { + offset = SkipDigits(span, digits); + c = CharAt(span, offset); + } + else if (isFraction) + { + return 0; + } + } + + return IsRealSuffix(c) ? offset + 1 : offset; + } + + private static bool IsRealSuffix(char c) => c == 'F' || c == 'f' || c == 'D' || c == 'd' || c == 'M' || c == 'm'; + + private static int SkipIntegerSuffix(ReadOnlySpan span, int offset) + { + var first = CharAt(span, offset); + var second = CharAt(span, offset + 1); + switch (first) + { + case 'U': + return second == 'L' ? offset + 2 : offset + 1; + case 'L': + return second == 'U' ? offset + 2 : offset + 1; + case 'u': + return second == 'l' || second == 'L' ? offset + 2 : offset + 1; + case 'l': + return second == 'u' || second == 'U' ? offset + 2 : offset + 1; + default: + return offset; + } + } + + /// A decimal integer, a hexadecimal integer or a real number. + private static int ScanNumber(ReadOnlySpan span) + { + if (CharAt(span, 0) == '.') + { + return IsDigit(CharAt(span, 1)) ? SkipRealEnd(span, SkipDigits(span, 1), isFraction: true) : 0; + } + + if (!IsDigit(CharAt(span, 0))) + { + return 0; + } + + if (CharAt(span, 0) == '0' && CharAt(span, 1) == 'x') + { + var hex = 2; + while (IsHexDigit(CharAt(span, hex))) + { + hex++; + } + + return hex == 2 ? 0 : SkipIntegerSuffix(span, hex); + } + + var size = SkipDigits(span, 1); + if (CharAt(span, size) == '.' && IsDigit(CharAt(span, size + 1))) + { + return SkipRealEnd(span, SkipDigits(span, size + 1), isFraction: true); + } + + var end = SkipRealEnd(span, size, isFraction: false); + return end != size ? end : SkipIntegerSuffix(span, size); + } + + private static int NumberType(ReadOnlySpan number) + { + if (number.Length > 1 && number[0] == '0' && number[1] == 'x') + { + return HEXADECIMAL_INTEGER_LITERAL; + } + + foreach (var c in number) + { + if (c == '.' || c == 'e' || c == 'E' || IsRealSuffix(c)) + { + return REAL_LITERAL; + } + } + + return INTEGER_LITERAL; + } + + /// + /// Reads the token at the start of , which isn't empty and doesn't start with white space, and + /// returns its length, or 0 when the text is not a token. + /// + private static int NextToken(ReadOnlySpan span, out int type) + { + var next = CharAt(span, 1); + switch (span[0]) + { + case '@': type = AT; return 1; + case '`': type = BACKTICK; return 1; + case '|': type = PIPE; return 1; + case '#': type = POUND; return 1; + case '(': type = LPAREN; return 1; + case ')': type = RPAREN; return 1; + case '[': type = LBRACKET; return 1; + case ']': type = RBRACKET; return 1; + case '}': type = RCURLY; return 1; + case ',': type = COMMA; return 1; + case ';': type = SEMI; return 1; + case ':': type = COLON; return 1; + case '+': type = PLUS; return 1; + case '-': type = MINUS; return 1; + case '/': type = DIV; return 1; + case '*': type = STAR; return 1; + case '%': type = MOD; return 1; + case '?': + type = next == '?' ? DEFAULT : next == '{' ? SELECT : QMARK; + return type == QMARK ? 1 : 2; + case '=': + type = next == '=' ? EQUAL : ASSIGN; + return type == ASSIGN ? 1 : 2; + case '!': + type = next == '=' ? NOT_EQUAL : next == '{' ? PROJECT : BANG; + return type == BANG ? 1 : 2; + case '<': + type = next == '=' ? LESS_THAN_OR_EQUAL : LESS_THAN; + return type == LESS_THAN ? 1 : 2; + case '>': + type = next == '=' ? GREATER_THAN_OR_EQUAL : GREATER_THAN; + return type == GREATER_THAN ? 1 : 2; + case '^': + type = next == '{' ? SELECT_FIRST : POWER; + return type == POWER ? 1 : 2; + case '$': + type = next == '{' ? SELECT_LAST : DOLLAR; + return type == DOLLAR ? 1 : 2; + case '{': + type = next == '|' ? LAMBDA : LCURLY; + return type == LCURLY ? 1 : 2; + case '\\': + type = next == '.' ? DOT_ESCAPED : BACKSLASH; + return type == BACKSLASH ? 1 : 2; + case '\'': + type = span.Length == 1 ? QUOTE : STRING_LITERAL; + return span.Length == 1 ? 1 : ScanString(span); + case 'T' when next == '(': + type = TYPE; + return 2; + } + + var size = ScanWord(span); + if (size > 0) + { + type = WordType(span.Slice(0, size)); + return size; + } + + size = ScanNumber(span); + if (size > 0) + { + type = NumberType(span.Slice(0, size)); + return size; + } + + // A dot followed by a digit starts a number, even if it is not a valid one + var isDot = span[0] == '.' && !IsDigit(next); + type = isDot ? DOT : 0; + return isDot ? 1 : 0; + } + + /// The text of the tokens of a name, without the white space between them and the quotes of its strings. + private static string TokensText(string text) + { + if (text.IndexOfAny(TokensTextChars) < 0) + { + return text; + } + + var builder = new StringBuilder(text.Length); + var offset = 0; + while ((offset = SkipSpaces(text.AsSpan(), offset)) < text.Length) + { + var length = NextToken(text.AsSpan(offset), out var type); + var token = text.Substring(offset, length); + builder.Append(type == STRING_LITERAL ? StringText(token) : token); + offset += length; + } + + return builder.ToString(); + } + + private static readonly char[] TokensTextChars = { ' ', '\t', '\n', '\r', '\'' }; + + private static string StringText(string token) + { + var text = token.Substring(1, token.Length - 2); + return text.IndexOf('\'') < 0 ? text : text.Replace("''", "'"); + } + + /// + /// Whether what follows a primary expression is acceptable: the rule that parses it alone doesn't read until the end + /// of the input, but it does look at the next token to choose between its alternatives. + /// + private static bool CanFollowPrimary(BaseNode node, string input, int offset) + { + var next = SkipSpaces(input.AsSpan(), offset); + if (next == input.Length) + { + return true; + } + + if (NextToken(input.AsSpan(next), out var type) == 0 || Contains(NodeStarts, type)) + { + // Not a token, or a node that failed: the primary expression stopped before it + return false; + } + + if (input[offset - 1] == '.') + { + return true; + } + + var last = node.getFirstChild(); + if (last.getNextSibling() == null) + { + return Contains(TokensAfterStartNode, type); + } + + while (last.getNextSibling() != null) + { + last = last.getNextSibling(); + } + + return !(last is PropertyOrFieldNode) || Contains(TokensAfterName, type); + } + + private static bool Contains(long tokens, int type) => type < 64 && (tokens & (1L << type)) != 0; + + // The tokens a node of a primary expression starts with + private const long NodeStarts = + (1L << LPAREN) | (1L << DOT) | (1L << ID) | (1L << LBRACKET) | (1L << PROJECT) | (1L << SELECT) | (1L << SELECT_FIRST) | (1L << SELECT_LAST); + + // The tokens that can follow a primary expression without any further node, in the grammar + private const long TokensAfterStartNode = + (1L << EOF) | (1L << AND) | (1L << OR) | (1L << XOR) | (1L << IN) | (1L << IS) | (1L << BETWEEN) | (1L << LIKE) | (1L << MATCHES) + | (1L << SEMI) | (1L << RPAREN) | (1L << ASSIGN) | (1L << DEFAULT) | (1L << QMARK) | (1L << COLON) | (1L << PLUS) | (1L << MINUS) + | (1L << STAR) | (1L << DIV) | (1L << MOD) | (1L << POWER) | (1L << COMMA) | (1L << RBRACKET) | (1L << RCURLY) | (1L << EQUAL) + | (1L << NOT_EQUAL) | (1L << LESS_THAN) | (1L << LESS_THAN_OR_EQUAL) | (1L << GREATER_THAN) | (1L << GREATER_THAN_OR_EQUAL); + + // The tokens that can follow a name, in the grammar + private const long TokensAfterName = TokensAfterStartNode | NodeStarts; + + // The tree + + private static BaseNode WithType(BaseNode node, int type, string text) + { + node.Type = type; + node.setText(text); + return node; + } + + private static SpringAST TokenNode(int type, string text) + { + var node = new SpringAST(); + node.Type = type; + node.setText(text); + return node; + } + + private static BaseNode WithText(BaseNode node, string text) + { + node.setText(text); + return node; + } + + private static void SetChildren(SpringAST node, IReadOnlyList children) + { + if (children == null || children.Count == 0) + { + return; + } + + SpringAST previous = children[0]; + node.setFirstChild(previous); + for (var i = 1; i < children.Count; i++) + { + SpringAST child = children[i]; + previous.setNextSibling(child); + previous = child; + } + } + + private static BaseNode Node(BaseNode node, int type, string text, IReadOnlyList children) + { + SetChildren(node, children); + return WithType(node, type, text); + } + + private static BaseNode Operator(BaseNode node, int type, string text, BaseNode child) + { + node.setFirstChild(child); + return WithType(node, type, text); + } + + private static BaseNode Operator(BaseNode node, int type, string text, BaseNode first, BaseNode second) => + WithChildren(WithType(node, type, text), first, second); + + private static BaseNode WithChildren(BaseNode node, BaseNode first, BaseNode second) + { + first.setNextSibling(second); + node.setFirstChild(first); + return node; + } + + private static BaseNode NumberLiteral(string text) + { + var type = NumberType(text.AsSpan()); + BaseNode node = type == HEXADECIMAL_INTEGER_LITERAL ? new HexLiteralNode() : type == REAL_LITERAL ? new RealLiteralNode() : new IntLiteralNode(); + return WithType(node, type, text); + } + + /// Makes the first child of , before those it has. + private static BaseNode PrependChild(BaseNode node, BaseNode child) + { + child.setNextSibling(node.getFirstChild()); + node.setFirstChild(child); + return node; + } + + // While a primary expression is read its first child is the last one, whose next sibling is the first one, so that a + // long path doesn't walk its nodes for each one + private static BaseNode Primary(BaseNode startNode) + { + startNode.setNextSibling(startNode); + return Operator(new Expression(), EXPR, "expression", startNode); + } + + private static BaseNode AppendToPrimary(BaseNode primary, BaseNode child) + { + var last = primary.getFirstChild(); + child.setNextSibling(last.getNextSibling()); + last.setNextSibling(child); + primary.setFirstChild(child); + return primary; + } + + private static BaseNode FinishPrimary(BaseNode primary) + { + var last = primary.getFirstChild(); + primary.setFirstChild(last.getNextSibling()); + last.setNextSibling(null); + return primary; + } + + private static BaseNode MethodOrProperty(string name, IReadOnlyList arguments) => + arguments == null ? WithType(new PropertyOrFieldNode(), ID, name) : Node(new MethodNode(), ID, name, arguments); + + private static BaseNode FunctionOrVariable(string name, IReadOnlyList arguments) => + arguments == null ? WithType(new VariableNode(), ID, name) : Node(new FunctionNode(), ID, name, arguments); + + private static BaseNode LocalFunctionOrVariable(string name, IReadOnlyList arguments) => + arguments == null ? WithType(new LocalVariableNode(), ID, name) : Node(new LocalFunctionNode(), ID, name, arguments); + + private static BaseNode MapEntry(BaseNode key, BaseNode value) => Operator(new MapEntryNode(), EXPR, "entry", key, value); + + private static BaseNode QuotableName(string name, int type) => WithType(new QualifiedIdentifier(), type, name); + + private static BaseNode Reference(BaseNode first, BaseNode second) => + second == null ? Operator(new ReferenceNode(), EXPR, "ref", first) : Operator(new ReferenceNode(), EXPR, "ref", first, second); + + private static BaseNode NamedArgument(string name, BaseNode value) => Operator(new NamedArgumentNode(), ID, name, value); + + private static BaseNode ExpressionList(BaseNode first, IReadOnlyList others) + { + var previous = first; + foreach (var other in others) + { + previous.setNextSibling(other); + previous = other; + } + + return Operator(new ExpressionListNode(), EXPR, "expressionList", first); + } + + private static BaseNode ArrayConstructor(IReadOnlyList rank, BaseNode initializer) + { + var rankNode = TokenNode(LBRACKET, "["); + SetChildren(rankNode, rank); + + var node = WithType(new ArrayConstructorNode(), EXPR, null); + node.setFirstChild(rankNode); + rankNode.setNextSibling(initializer); + return node; + } + + private static BaseNode Lambda(IReadOnlyList arguments, BaseNode body) + { + var node = WithType(new LambdaExpressionNode(), EXPR, "lambda"); + + if (arguments.Count == 0) + { + node.setFirstChild(body); + return node; + } + + var args = TokenNode(EXPR, "args"); + + SpringAST previous = null; + foreach (var name in arguments) + { + var argument = TokenNode(ID, name); + if (previous == null) + { + args.setFirstChild(argument); + } + else + { + previous.setNextSibling(argument); + } + + previous = argument; + } + + node.setFirstChild(args); + args.setNextSibling(body); + return node; + } + + // Syntax errors + + /// + /// The line is always 1 and a tab moves to the next multiple of 8, as in the parser this one replaced, which counted + /// the columns of the whole expression and never the lines. + /// + private static int ColumnOf(string input, int offset) + { + var column = 1; + for (var i = 0; i < offset; i++) + { + column = input[i] == '\t' ? ((column - 1) / 8 + 1) * 8 + 1 : column + 1; + } + + return column; + } + + /// + /// Reads the tokens before to tell how many brackets are open and prefix operators are + /// pending there, and whether the last one ends an operand. + /// + private static void ReadTokensBefore(string input, int offset, out int depth, out bool afterOperand) + { + var open = 0; + var prefixes = 0; + afterOperand = false; + + for (var position = SkipSpaces(input.AsSpan(), 0); position < offset; position = SkipSpaces(input.AsSpan(), position)) + { + var length = NextToken(input.AsSpan(position), out var type); + if (length == 0) + { + break; + } + + position += length; + switch (type) + { + case LPAREN or LBRACKET or LCURLY or LAMBDA or PROJECT or SELECT or SELECT_FIRST or SELECT_LAST or TYPE: + open++; + afterOperand = false; + break; + case RPAREN or RBRACKET or RCURLY: + open--; + afterOperand = true; + break; + case ID or STRING_LITERAL or INTEGER_LITERAL or HEXADECIMAL_INTEGER_LITERAL or REAL_LITERAL or TRUE or FALSE or NULL_LITERAL or DOT: + afterOperand = true; + break; + default: + afterOperand = false; + break; + } + + prefixes = !afterOperand && type is PLUS or MINUS or BANG ? prefixes + 1 : 0; + } + + depth = open + prefixes; + } + + private static SyntaxErrorException CreateSyntaxError(string input, int offset, string expected, bool mayBeTooDeep) + { + if (offset >= input.Length) + { + return SyntaxError(input, input.Length, expected != null ? $"expecting \"{expected}\", found ''" : "unexpected end of expression"); + } + + var span = input.AsSpan(offset); + var length = NextToken(span, out var type); + if (length == 0) + { + return CreateLexicalError(input, offset); + } + + var text = type == STRING_LITERAL ? StringText(input.Substring(offset, length)) : input.Substring(offset, length); + if (mayBeTooDeep) + { + return SyntaxError(input, offset, $"unexpected token or expression nested too deeply: \"{text}\""); + } + + return SyntaxError(input, offset, expected != null + ? $"expecting \"{expected}\", found '{text}'" + : $"unexpected token: [\"{text}\",<{type}>,line=1,col={ColumnOf(input, offset)}]"); + } + + /// The error for the text at , which is not a token. + private static SyntaxErrorException CreateLexicalError(string input, int offset) + { + if (input[offset] == '\'') + { + return SyntaxError(input, input.Length, "expecting ''', found ''"); + } + + // A number is only invalid at the char that follows its "0x", or the 'e' of the exponent of its fraction + var end = offset; + if (input[end] == '0' && end + 1 < input.Length && input[end + 1] == 'x') + { + end += 2; + } + else if (IsDigit(input[end]) || input[end] == '.') + { + while (end < input.Length && (IsDigit(input[end]) || input[end] == '.')) + { + end++; + } + + end++; + while (end < input.Length && (input[end] == '+' || input[end] == '-')) + { + end++; + } + } + + return SyntaxError(input, end, end < input.Length ? "unexpected char: '" + input[end] + "'" : "unexpected end of expression"); + } + + private static SyntaxErrorException SyntaxError(string input, int offset, string message) => + new SyntaxErrorException(message, 1, ColumnOf(input, offset), input); +} diff --git a/src/Spring/Spring.Core/Expressions/ExpressionGrammar.parlot.cs b/src/Spring/Spring.Core/Expressions/ExpressionGrammar.parlot.cs new file mode 100644 index 000000000..b8a0b902b --- /dev/null +++ b/src/Spring/Spring.Core/Expressions/ExpressionGrammar.parlot.cs @@ -0,0 +1,186 @@ +using Parlot; +using Parlot.Fluent; +using Parlot.SourceGenerator; +using static Parlot.Fluent.Parsers; +using static Spring.Expressions.Parser.ExpressionParserTokenTypes; + +namespace Spring.Expressions; + +/// +/// The grammar of the expression language. This file is build-only: the Parlot source generator runs it at compile time +/// and emits and everything it needs into this assembly. +/// +/// +/// Tokens that are the start of a longer one, such as the '^' of "^{", are scanned so as not to match it, like a lexer +/// would. Without that an alternative that fails could be read again another way, which an LL(k) grammar never does. +/// +internal static partial class ExpressionGrammar +{ + [GenerateParser(nameof(TryParse), MaxRecursionDepth = 2000)] + private static Parser Build(Rule rule) + { + var expression = Deferred(); + + var lparen = Terms.Char('('); + var rparen = Terms.Char(')'); + var lbracket = Terms.Char('['); + var rbracket = Terms.Char(']'); + var lcurly = Terms.Scan(ScanLeftCurly, "{"); + var rcurly = Terms.Char('}'); + var comma = Terms.Char(','); + var colon = Terms.Char(':'); + var semi = Terms.Char(';'); + var assign = Terms.Scan(ScanAssign, "="); + + var id = Terms.Scan(ScanId, IdStart); + var qualifiedId = Terms.Scan(ScanQualifiedId, IdStart).Then(static x => TokensText(x.ToString())); + var name = Terms.Scan(ScanName, IdStart).Then(static x => TokensText(x.ToString())); + var stringLiteral = Terms.Scan(ScanString, "'").Then(static x => StringText(x.ToString())); + + // A name followed by '(' is a call, it can't be read again as a name followed by an expression list + var arguments = lparen.SkipAnd(Separated(comma, expression, min: 0)).AndSkip(rparen); + var call = arguments.Or(Not(lparen).Then(static _ => (IReadOnlyList) null)); + + var expressions = Separated(comma, expression, min: 1); + + var methodOrProperty = id.And(call).Then(static x => MethodOrProperty(x.Item1.ToString(), x.Item2)); + var indexer = lbracket.SkipAnd(expressions).AndSkip(rbracket).Then(static x => Node(new IndexerNode(), LBRACKET, "[", x)); + var projection = Terms.Text("!{").SkipAnd(expression).AndSkip(rcurly).Then(static x => Operator(new ProjectionNode(), PROJECT, "!{", x)); + var selection = Terms.Text("?{").SkipAnd(expressions).AndSkip(rcurly).Then(static x => Node(new SelectionNode(), SELECT, "?{", x)); + var firstSelection = Terms.Text("^{").SkipAnd(expression).AndSkip(rcurly).Then(static x => Operator(new SelectionFirstNode(), SELECT_FIRST, "^{", x)); + var lastSelection = Terms.Text("${").SkipAnd(expression).AndSkip(rcurly).Then(static x => Operator(new SelectionLastNode(), SELECT_LAST, "${", x)); + + var functionOrVariable = id.And(call).Then(static x => FunctionOrVariable(x.Item1.ToString(), x.Item2)); + var mapEntry = expression.AndSkip(colon).And(expression).Then(static x => MapEntry(x.Item1, x.Item2)); + var mapInitializer = lcurly.SkipAnd(Separated(comma, mapEntry, min: 1)).AndSkip(rcurly).Then(static x => Node(new MapInitializerNode(), LCURLY, "{", x)); + var pound = Terms.Char('#').SkipAnd(functionOrVariable.Or(mapInitializer)); + + var dollar = Terms.Scan(ScanDollar, "$").SkipAnd(id).And(call).Then(static x => LocalFunctionOrVariable(x.Item1.ToString(), x.Item2)); + + var quotableName = stringLiteral.Then(static x => QuotableName(x, STRING_LITERAL)).Or(name.Then(static x => QuotableName(x, ID))); + var reference = lparen.SkipAnd(quotableName).And(colon.SkipAnd(quotableName).Optional()).AndSkip(rparen) + .Then(static x => Reference(x.Item1, x.Item2.TryGetValue(out var second) ? second : null)); + + // An argument that starts with a name and '=' is a named one: it isn't read again as an assignment when it fails + var namedArgument = id.AndSkip(assign).And(expression).Then(static x => NamedArgument(x.Item1.ToString(), x.Item2)); + var positionalArgument = Not(id.AndSkip(assign)).SkipAnd(expression); + var constructorArguments = lparen.SkipAnd(Separated(comma, namedArgument.Or(positionalArgument), min: 0)).AndSkip(rparen); + var attribute = lbracket.SkipAnd(qualifiedId).And(constructorArguments.Optional()).AndSkip(rbracket) + .Then(static x => Node(new AttributeNode(), EXPR, x.Item1, x.Item2.TryGetValue(out var args) ? args : null)); + var at = Terms.Char('@').SkipAnd(reference.Or(attribute)); + + var listInitializer = lcurly.SkipAnd(expressions).AndSkip(rcurly).Then(static x => Node(new ListInitializerNode(), LCURLY, "{", x)); + var arrayRank = lbracket.SkipAnd(Separated(comma, expression, min: 0)).AndSkip(rbracket); + var constructor = Terms.Keyword("new", IdPart).SkipAnd(qualifiedId).And( + constructorArguments.Then(static x => Node(new ConstructorNode(), EXPR, null, x)) + .Or(arrayRank.And(listInitializer.Optional()).Then(static x => ArrayConstructor(x.Item1, x.Item2.TryGetValue(out var list) ? list : null)))) + .Then(static x => WithText(x.Item2, x.Item1)); + + var type = Terms.Text("T(").SkipAnd(name).AndSkip(rparen).Then(static x => WithType(new TypeNode(), EXPR, x)); + + var lambda = Terms.Text("{|").SkipAnd(Separated(comma, id.Then(static x => x.ToString()), min: 0)).AndSkip(Terms.Char('|')) + .And(expression).AndSkip(rcurly).Then(static x => Lambda(x.Item1, x.Item2)); + + // '(' expression ')' is the expression, with the type of node it has + var parenthesized = lparen.SkipAnd(expression).And(ZeroOrMany(semi.SkipAnd(expression))).AndSkip(rparen) + .Then(static x => x.Item2.Count == 0 ? x.Item1 : ExpressionList(x.Item1, x.Item2)); + var expressionList = lparen.SkipAnd(expression).And(OneOrMany(semi.SkipAnd(expression))).AndSkip(rparen) + .Then(static x => ExpressionList(x.Item1, x.Item2)); + + var literal = OneOf( + Terms.Scan(ScanNumber, NumberStart).Then(static x => NumberLiteral(x.ToString())), + stringLiteral.Then(static x => WithType(new StringLiteralNode(), STRING_LITERAL, x)), + Terms.Keyword("null", IdPart).Then(static _ => WithType(new NullLiteralNode(), NULL_LITERAL, "null")), + Terms.Keyword("true", IdPart).Then(static _ => WithType(new BooleanLiteralNode(), TRUE, "true")), + Terms.Keyword("false", IdPart).Then(static _ => WithType(new BooleanLiteralNode(), FALSE, "false"))); + + var startNode = OneOf( + methodOrProperty, + parenthesized, + pound, + dollar, + at, + indexer, + literal, + type, + constructor, + projection, + selection, + firstSelection, + lastSelection, + lambda, + listInitializer); + + var node = OneOf( + methodOrProperty, + indexer, + projection, + selection, + firstSelection, + lastSelection, + expressionList); + + // The nodes of a primary expression are its children, the dots between them being optional + var primary = startNode.Then(static x => Primary(x)).Operators() + .Postfix( + (node, static (x, child) => AppendToPrimary(x, child)), + (Terms.Scan(ScanDot, "."), static (x, _) => x)) + .Then(static x => FinishPrimary(x)); + + var unary = primary.Operators() + .Unary( + (Terms.Char('+'), static x => Operator(new OpUnaryPlus(), PLUS, "+", x)), + (Terms.Char('-'), static x => Operator(new OpUnaryMinus(), MINUS, "-", x)), + (Terms.Scan(ScanBang, "!").Then(static _ => '!'), static x => Operator(new OpNOT(), BANG, "!", x))); + + // Neither the power nor the relational operators chain, which an operator table can't express + var power = unary.And(Terms.Scan(ScanPower, "^").SkipAnd(unary).Optional()) + .Then(static x => x.Item2.TryGetValue(out var right) ? Operator(new OpPOWER(), POWER, "^", x.Item1, right) : x.Item1); + + var sum = power.Operators() + .LeftAssociative( + (Terms.Char('*'), static (a, b) => Operator(new OpMULTIPLY(), STAR, "*", a, b)), + (Terms.Char('/'), static (a, b) => Operator(new OpDIVIDE(), DIV, "/", a, b)), + (Terms.Char('%'), static (a, b) => Operator(new OpMODULUS(), MOD, "%", a, b))) + .LeftAssociative( + (Terms.Char('+'), static (a, b) => Operator(new OpADD(), PLUS, "+", a, b)), + (Terms.Char('-'), static (a, b) => Operator(new OpSUBTRACT(), MINUS, "-", a, b))); + + var relationalOperator = OneOf( + Terms.Text("==").Then(static _ => WithType(new OpEqual(), EXPR, "==")), + Terms.Text("!=").Then(static _ => WithType(new OpNotEqual(), EXPR, "!=")), + Terms.Text("<=").Then(static _ => WithType(new OpLessOrEqual(), EXPR, "<=")), + Terms.Text("<").Then(static _ => WithType(new OpLess(), EXPR, "<")), + Terms.Text(">=").Then(static _ => WithType(new OpGreaterOrEqual(), EXPR, ">=")), + Terms.Text(">").Then(static _ => WithType(new OpGreater(), EXPR, ">")), + Terms.Keyword("in", IdPart).Then(static _ => WithType(new OpIn(), EXPR, "in")), + Terms.Keyword("is", IdPart).Then(static _ => WithType(new OpIs(), EXPR, "is")), + Terms.Keyword("between", IdPart).Then(static _ => WithType(new OpBetween(), EXPR, "between")), + Terms.Keyword("like", IdPart).Then(static _ => WithType(new OpLike(), EXPR, "like")), + Terms.Keyword("matches", IdPart).Then(static _ => WithType(new OpMatches(), EXPR, "matches"))); + + var relational = sum.And(relationalOperator.And(sum).Optional()) + .Then(static x => x.Item2.TryGetValue(out var rest) ? WithChildren(rest.Item1, x.Item1, rest.Item2) : x.Item1); + + var logical = relational.Operators() + .LeftAssociative((Terms.Keyword("and", IdPart), static (a, b) => Operator(new OpAND(), AND, "and", a, b))) + .LeftAssociative((Terms.Keyword("xor", IdPart), static (a, b) => Operator(new OpXOR(), XOR, "xor", a, b))) + .LeftAssociative((Terms.Keyword("or", IdPart), static (a, b) => Operator(new OpOR(), OR, "or", a, b))); + + // Neither do these, and the last operand of a conditional is any expression: not levels of the table either + var tail = OneOf( + assign.SkipAnd(logical).Then(static x => Operator(new AssignNode(), ASSIGN, "=", x)), + Terms.Text("??").SkipAnd(logical).Then(static x => Operator(new DefaultNode(), DEFAULT, "??", x)), + Terms.Scan(ScanQuestion, "?").SkipAnd(expression).AndSkip(colon).And(expression) + .Then(static x => Operator(new TernaryNode(), QMARK, "?", x.Item1, x.Item2))); + + expression.Parser = logical.And(tail.Optional()) + .Then(static x => x.Item2.TryGetValue(out var parent) ? PrependChild(parent, x.Item1) : x.Item1); + + Parser wholeExpression = expression.AndSkip(SkipWhiteSpace(Eof())); + Parser primaryAlone = primary.When(static (context, x) => CanFollowPrimary(x, context.Scanner.Cursor.Buffer, context.Scanner.Cursor.Offset)); + + return If(() => rule == Rule.Expression, wholeExpression, If(() => rule == Rule.Primary, primaryAlone, lambda)) + .WithWhiteSpaceSet(WhiteSpaceSet.SpaceTabCrLf); + } +} diff --git a/src/Spring/Spring.Core/Expressions/ExpressionListNode.cs b/src/Spring/Spring.Core/Expressions/ExpressionListNode.cs index 3a0e753e0..89c1615cf 100644 --- a/src/Spring/Spring.Core/Expressions/ExpressionListNode.cs +++ b/src/Spring/Spring.Core/Expressions/ExpressionListNode.cs @@ -15,7 +15,6 @@ */ using System.Runtime.Serialization; -using Spring.Expressions.Parser.antlr.collections; namespace Spring.Expressions; @@ -54,7 +53,7 @@ protected override object Get(object context, EvaluationContext evalContext) { object result = context; - AST node = this.getFirstChild(); + SpringAST node = this.getFirstChild(); while (node != null) { result = GetValue(((BaseNode) node), context, evalContext); diff --git a/src/Spring/Spring.Core/Expressions/LambdaExpressionNode.cs b/src/Spring/Spring.Core/Expressions/LambdaExpressionNode.cs index a2b76333d..7dfc17c45 100644 --- a/src/Spring/Spring.Core/Expressions/LambdaExpressionNode.cs +++ b/src/Spring/Spring.Core/Expressions/LambdaExpressionNode.cs @@ -16,7 +16,6 @@ using System.Collections; using System.Runtime.Serialization; -using Spring.Expressions.Parser.antlr.collections; namespace Spring.Expressions; @@ -127,9 +126,9 @@ private void InitializeLambda() } else { - AST argsNode = this.getFirstChild(); + SpringAST argsNode = this.getFirstChild(); argumentNames = new string[argsNode.getNumberOfChildren()]; - AST argNode = argsNode.getFirstChild(); + SpringAST argNode = argsNode.getFirstChild(); int i = 0; while (argNode != null) { diff --git a/src/Spring/Spring.Core/Expressions/MapInitializerNode.cs b/src/Spring/Spring.Core/Expressions/MapInitializerNode.cs index 98179497c..64c9acfcb 100644 --- a/src/Spring/Spring.Core/Expressions/MapInitializerNode.cs +++ b/src/Spring/Spring.Core/Expressions/MapInitializerNode.cs @@ -16,7 +16,6 @@ using System.Collections; using System.Runtime.Serialization; -using Spring.Expressions.Parser.antlr.collections; namespace Spring.Expressions; @@ -54,7 +53,7 @@ protected MapInitializerNode(SerializationInfo info, StreamingContext context) protected override object Get(object context, EvaluationContext evalContext) { IDictionary entries = new Hashtable(); - AST entryNode = this.getFirstChild(); + SpringAST entryNode = this.getFirstChild(); while (entryNode != null) { DictionaryEntry entry = (DictionaryEntry) GetValue(((MapEntryNode) entryNode), evalContext.RootContext, evalContext); diff --git a/src/Spring/Spring.Core/Expressions/NodeWithArguments.cs b/src/Spring/Spring.Core/Expressions/NodeWithArguments.cs index d6156750a..9acda2086 100644 --- a/src/Spring/Spring.Core/Expressions/NodeWithArguments.cs +++ b/src/Spring/Spring.Core/Expressions/NodeWithArguments.cs @@ -16,7 +16,6 @@ using System.Collections; using System.Runtime.Serialization; -using Spring.Expressions.Parser.antlr.collections; namespace Spring.Expressions; @@ -77,7 +76,7 @@ private void InitializeNode() List argList = new List(); namedArgs = new Hashtable(); - AST node = this.getFirstChild(); + SpringAST node = this.getFirstChild(); while (node != null) { diff --git a/src/Spring/Spring.Core/Expressions/Parser/ExpressionLexer.cs b/src/Spring/Spring.Core/Expressions/Parser/ExpressionLexer.cs deleted file mode 100644 index 916fad735..000000000 --- a/src/Spring/Spring.Core/Expressions/Parser/ExpressionLexer.cs +++ /dev/null @@ -1,2402 +0,0 @@ -// $ANTLR 2.7.6 (2005-12-22): "Expression.g" -> "ExpressionLexer.cs"$ - -namespace Spring.Expressions.Parser; - -// Generate header specific to lexer CSharp file -using Stream = System.IO.Stream; -using TextReader = System.IO.TextReader; -using Hashtable = System.Collections.Hashtable; -using Comparer = System.Collections.Comparer; -using TokenStreamException = antlr.TokenStreamException; -using TokenStreamIOException = antlr.TokenStreamIOException; -using TokenStreamRecognitionException = antlr.TokenStreamRecognitionException; -using CharStreamException = antlr.CharStreamException; -using CharStreamIOException = antlr.CharStreamIOException; -using InputBuffer = antlr.InputBuffer; -using ByteBuffer = antlr.ByteBuffer; -using CharBuffer = antlr.CharBuffer; -using Token = antlr.Token; -using IToken = antlr.IToken; -using RecognitionException = antlr.RecognitionException; -using NoViableAltForCharException = antlr.NoViableAltForCharException; -using TokenStream = antlr.TokenStream; -using LexerSharedInputState = antlr.LexerSharedInputState; -using BitSet = antlr.collections.impl.BitSet; - -internal class ExpressionLexer : antlr.CharScanner, TokenStream -{ - public const int EOF = 1; - public const int NULL_TREE_LOOKAHEAD = 3; - public const int EXPR = 4; - public const int OPERAND = 5; - public const int FALSE = 6; - public const int TRUE = 7; - public const int AND = 8; - public const int OR = 9; - public const int XOR = 10; - public const int IN = 11; - public const int IS = 12; - public const int BETWEEN = 13; - public const int LIKE = 14; - public const int MATCHES = 15; - public const int NULL_LITERAL = 16; - public const int LPAREN = 17; - public const int SEMI = 18; - public const int RPAREN = 19; - public const int ASSIGN = 20; - public const int DEFAULT = 21; - public const int QMARK = 22; - public const int COLON = 23; - public const int PLUS = 24; - public const int MINUS = 25; - public const int STAR = 26; - public const int DIV = 27; - public const int MOD = 28; - public const int POWER = 29; - public const int BANG = 30; - public const int DOT = 31; - public const int POUND = 32; - public const int ID = 33; - public const int DOLLAR = 34; - public const int COMMA = 35; - public const int AT = 36; - public const int LBRACKET = 37; - public const int RBRACKET = 38; - public const int PROJECT = 39; - public const int RCURLY = 40; - public const int SELECT = 41; - public const int SELECT_FIRST = 42; - public const int SELECT_LAST = 43; - public const int TYPE = 44; - public const int QUOTE = 45; - public const int STRING_LITERAL = 46; - public const int LAMBDA = 47; - public const int PIPE = 48; - public const int LITERAL_new = 49; - public const int LCURLY = 50; - public const int INTEGER_LITERAL = 51; - public const int HEXADECIMAL_INTEGER_LITERAL = 52; - public const int REAL_LITERAL = 53; - public const int EQUAL = 54; - public const int NOT_EQUAL = 55; - public const int LESS_THAN = 56; - public const int LESS_THAN_OR_EQUAL = 57; - public const int GREATER_THAN = 58; - public const int GREATER_THAN_OR_EQUAL = 59; - public const int WS = 60; - public const int BACKTICK = 61; - public const int BACKSLASH = 62; - public const int DOT_ESCAPED = 63; - public const int APOS = 64; - public const int NUMERIC_LITERAL = 65; - public const int DECIMAL_DIGIT = 66; - public const int INTEGER_TYPE_SUFFIX = 67; - public const int HEX_DIGIT = 68; - public const int EXPONENT_PART = 69; - public const int SIGN = 70; - public const int REAL_TYPE_SUFFIX = 71; - - // CLOVER:OFF - public ExpressionLexer(Stream ins) : this(new ByteBuffer(ins)) - { - } - - public ExpressionLexer(TextReader r) : this(new CharBuffer(r)) - { - } - - public ExpressionLexer(InputBuffer ib) : this(new LexerSharedInputState(ib)) - { - } - - public ExpressionLexer(LexerSharedInputState state) : base(state) - { - initialize(); - } - - private void initialize() - { - caseSensitiveLiterals = true; - setCaseSensitive(true); - literals = new Hashtable(100, (float) 0.4, null, Comparer.Default); - literals.Add("true", 7); - literals.Add("and", 8); - literals.Add("matches", 15); - literals.Add("in", 11); - literals.Add("xor", 10); - literals.Add("null", 16); - literals.Add("between", 13); - literals.Add("or", 9); - literals.Add("is", 12); - literals.Add("like", 14); - literals.Add("new", 49); - literals.Add("false", 6); - } - - override public IToken nextToken() //throws TokenStreamException - { - IToken theRetToken = null; - tryAgain: - for (;;) - { - IToken _token = null; - int _ttype = Token.INVALID_TYPE; - resetText(); - try // for char stream error handling - { - try // for lexical error handling - { - switch (cached_LA1) - { - case '\t': - case '\n': - case '\r': - case ' ': - { - mWS(true); - theRetToken = returnToken_; - break; - } - case '@': - { - mAT(true); - theRetToken = returnToken_; - break; - } - case '`': - { - mBACKTICK(true); - theRetToken = returnToken_; - break; - } - case '|': - { - mPIPE(true); - theRetToken = returnToken_; - break; - } - case '#': - { - mPOUND(true); - theRetToken = returnToken_; - break; - } - case '(': - { - mLPAREN(true); - theRetToken = returnToken_; - break; - } - case ')': - { - mRPAREN(true); - theRetToken = returnToken_; - break; - } - case '[': - { - mLBRACKET(true); - theRetToken = returnToken_; - break; - } - case ']': - { - mRBRACKET(true); - theRetToken = returnToken_; - break; - } - case '}': - { - mRCURLY(true); - theRetToken = returnToken_; - break; - } - case ',': - { - mCOMMA(true); - theRetToken = returnToken_; - break; - } - case ';': - { - mSEMI(true); - theRetToken = returnToken_; - break; - } - case ':': - { - mCOLON(true); - theRetToken = returnToken_; - break; - } - case '+': - { - mPLUS(true); - theRetToken = returnToken_; - break; - } - case '-': - { - mMINUS(true); - theRetToken = returnToken_; - break; - } - case '/': - { - mDIV(true); - theRetToken = returnToken_; - break; - } - case '*': - { - mSTAR(true); - theRetToken = returnToken_; - break; - } - case '%': - { - mMOD(true); - theRetToken = returnToken_; - break; - } - default: - if ((cached_LA1 == '?') && (cached_LA2 == '?')) - { - mDEFAULT(true); - theRetToken = returnToken_; - } - else if ((cached_LA1 == '=') && (cached_LA2 == '=')) - { - mEQUAL(true); - theRetToken = returnToken_; - } - else if ((cached_LA1 == '!') && (cached_LA2 == '=')) - { - mNOT_EQUAL(true); - theRetToken = returnToken_; - } - else if ((cached_LA1 == '<') && (cached_LA2 == '=')) - { - mLESS_THAN_OR_EQUAL(true); - theRetToken = returnToken_; - } - else if ((cached_LA1 == '>') && (cached_LA2 == '=')) - { - mGREATER_THAN_OR_EQUAL(true); - theRetToken = returnToken_; - } - else if ((cached_LA1 == '!') && (cached_LA2 == '{')) - { - mPROJECT(true); - theRetToken = returnToken_; - } - else if ((cached_LA1 == '?') && (cached_LA2 == '{')) - { - mSELECT(true); - theRetToken = returnToken_; - } - else if ((cached_LA1 == '^') && (cached_LA2 == '{')) - { - mSELECT_FIRST(true); - theRetToken = returnToken_; - } - else if ((cached_LA1 == '$') && (cached_LA2 == '{')) - { - mSELECT_LAST(true); - theRetToken = returnToken_; - } - else if ((cached_LA1 == 'T') && (cached_LA2 == '(')) - { - mTYPE(true); - theRetToken = returnToken_; - } - else if ((cached_LA1 == '{') && (cached_LA2 == '|')) - { - mLAMBDA(true); - theRetToken = returnToken_; - } - else if ((cached_LA1 == '\\') && (cached_LA2 == '.')) - { - mDOT_ESCAPED(true); - theRetToken = returnToken_; - } - else if ((cached_LA1 == '\'') && ((cached_LA2 >= '\u0000' && cached_LA2 <= '\ufffe'))) - { - mSTRING_LITERAL(true); - theRetToken = returnToken_; - } - else if ((cached_LA1 == '0') && (cached_LA2 == 'x')) - { - mHEXADECIMAL_INTEGER_LITERAL(true); - theRetToken = returnToken_; - } - else if ((cached_LA1 == '\\') && (true)) - { - mBACKSLASH(true); - theRetToken = returnToken_; - } - else if ((cached_LA1 == '!') && (true)) - { - mBANG(true); - theRetToken = returnToken_; - } - else if ((cached_LA1 == '?') && (true)) - { - mQMARK(true); - theRetToken = returnToken_; - } - else if ((cached_LA1 == '$') && (true)) - { - mDOLLAR(true); - theRetToken = returnToken_; - } - else if ((cached_LA1 == '{') && (true)) - { - mLCURLY(true); - theRetToken = returnToken_; - } - else if ((cached_LA1 == '=') && (true)) - { - mASSIGN(true); - theRetToken = returnToken_; - } - else if ((cached_LA1 == '^') && (true)) - { - mPOWER(true); - theRetToken = returnToken_; - } - else if ((cached_LA1 == '<') && (true)) - { - mLESS_THAN(true); - theRetToken = returnToken_; - } - else if ((cached_LA1 == '>') && (true)) - { - mGREATER_THAN(true); - theRetToken = returnToken_; - } - else if ((cached_LA1 == '\'') && (true)) - { - mQUOTE(true); - theRetToken = returnToken_; - } - else if ((tokenSet_0_.member(cached_LA1)) && (true)) - { - mID(true); - theRetToken = returnToken_; - } - else if ((tokenSet_1_.member(cached_LA1)) && (true)) - { - mNUMERIC_LITERAL(true); - theRetToken = returnToken_; - } - else - { - if (cached_LA1 == EOF_CHAR) - { - uponEOF(); - returnToken_ = makeToken(Token.EOF_TYPE); - } - else { throw new NoViableAltForCharException(cached_LA1, getFilename(), getLine(), getColumn()); } - } - - break; - } - - if (null == returnToken_) goto tryAgain; // found SKIP token - _ttype = returnToken_.Type; - returnToken_.Type = _ttype; - return returnToken_; - } - catch (RecognitionException e) - { - throw new TokenStreamRecognitionException(e); - } - } - catch (CharStreamException cse) - { - if (cse is CharStreamIOException) - { - throw new TokenStreamIOException(((CharStreamIOException) cse).io); - } - else - { - throw new TokenStreamException(cse.Message); - } - } - } - } - - public void mWS(bool _createToken) //throws RecognitionException, CharStreamException, TokenStreamException - { - int _ttype; - IToken _token = null; - int _begin = text.Length; - _ttype = WS; - - { - switch (cached_LA1) - { - case ' ': - { - match(' '); - break; - } - case '\t': - { - match('\t'); - break; - } - case '\n': - { - match('\n'); - break; - } - case '\r': - { - match('\r'); - break; - } - default: - { - throw new NoViableAltForCharException(cached_LA1, getFilename(), getLine(), getColumn()); - } - } - } - if (0 == inputState.guessing) - { - _ttype = Token.SKIP; - } - - if (_createToken && (null == _token) && (_ttype != Token.SKIP)) - { - _token = makeToken(_ttype); - _token.setText(text.ToString(_begin, text.Length - _begin)); - } - - returnToken_ = _token; - } - - public void mAT(bool _createToken) //throws RecognitionException, CharStreamException, TokenStreamException - { - int _ttype; - IToken _token = null; - int _begin = text.Length; - _ttype = AT; - - match('@'); - if (_createToken && (null == _token) && (_ttype != Token.SKIP)) - { - _token = makeToken(_ttype); - _token.setText(text.ToString(_begin, text.Length - _begin)); - } - - returnToken_ = _token; - } - - public void mBACKTICK(bool _createToken) //throws RecognitionException, CharStreamException, TokenStreamException - { - int _ttype; - IToken _token = null; - int _begin = text.Length; - _ttype = BACKTICK; - - match('`'); - if (_createToken && (null == _token) && (_ttype != Token.SKIP)) - { - _token = makeToken(_ttype); - _token.setText(text.ToString(_begin, text.Length - _begin)); - } - - returnToken_ = _token; - } - - public void mBACKSLASH(bool _createToken) //throws RecognitionException, CharStreamException, TokenStreamException - { - int _ttype; - IToken _token = null; - int _begin = text.Length; - _ttype = BACKSLASH; - - match('\\'); - if (_createToken && (null == _token) && (_ttype != Token.SKIP)) - { - _token = makeToken(_ttype); - _token.setText(text.ToString(_begin, text.Length - _begin)); - } - - returnToken_ = _token; - } - - public void mPIPE(bool _createToken) //throws RecognitionException, CharStreamException, TokenStreamException - { - int _ttype; - IToken _token = null; - int _begin = text.Length; - _ttype = PIPE; - - match('|'); - if (_createToken && (null == _token) && (_ttype != Token.SKIP)) - { - _token = makeToken(_ttype); - _token.setText(text.ToString(_begin, text.Length - _begin)); - } - - returnToken_ = _token; - } - - public void mBANG(bool _createToken) //throws RecognitionException, CharStreamException, TokenStreamException - { - int _ttype; - IToken _token = null; - int _begin = text.Length; - _ttype = BANG; - - match('!'); - if (_createToken && (null == _token) && (_ttype != Token.SKIP)) - { - _token = makeToken(_ttype); - _token.setText(text.ToString(_begin, text.Length - _begin)); - } - - returnToken_ = _token; - } - - public void mQMARK(bool _createToken) //throws RecognitionException, CharStreamException, TokenStreamException - { - int _ttype; - IToken _token = null; - int _begin = text.Length; - _ttype = QMARK; - - match('?'); - if (_createToken && (null == _token) && (_ttype != Token.SKIP)) - { - _token = makeToken(_ttype); - _token.setText(text.ToString(_begin, text.Length - _begin)); - } - - returnToken_ = _token; - } - - public void mDOLLAR(bool _createToken) //throws RecognitionException, CharStreamException, TokenStreamException - { - int _ttype; - IToken _token = null; - int _begin = text.Length; - _ttype = DOLLAR; - - match('$'); - if (_createToken && (null == _token) && (_ttype != Token.SKIP)) - { - _token = makeToken(_ttype); - _token.setText(text.ToString(_begin, text.Length - _begin)); - } - - returnToken_ = _token; - } - - public void mPOUND(bool _createToken) //throws RecognitionException, CharStreamException, TokenStreamException - { - int _ttype; - IToken _token = null; - int _begin = text.Length; - _ttype = POUND; - - match('#'); - if (_createToken && (null == _token) && (_ttype != Token.SKIP)) - { - _token = makeToken(_ttype); - _token.setText(text.ToString(_begin, text.Length - _begin)); - } - - returnToken_ = _token; - } - - public void mLPAREN(bool _createToken) //throws RecognitionException, CharStreamException, TokenStreamException - { - int _ttype; - IToken _token = null; - int _begin = text.Length; - _ttype = LPAREN; - - match('('); - if (_createToken && (null == _token) && (_ttype != Token.SKIP)) - { - _token = makeToken(_ttype); - _token.setText(text.ToString(_begin, text.Length - _begin)); - } - - returnToken_ = _token; - } - - public void mRPAREN(bool _createToken) //throws RecognitionException, CharStreamException, TokenStreamException - { - int _ttype; - IToken _token = null; - int _begin = text.Length; - _ttype = RPAREN; - - match(')'); - if (_createToken && (null == _token) && (_ttype != Token.SKIP)) - { - _token = makeToken(_ttype); - _token.setText(text.ToString(_begin, text.Length - _begin)); - } - - returnToken_ = _token; - } - - public void mLBRACKET(bool _createToken) //throws RecognitionException, CharStreamException, TokenStreamException - { - int _ttype; - IToken _token = null; - int _begin = text.Length; - _ttype = LBRACKET; - - match('['); - if (_createToken && (null == _token) && (_ttype != Token.SKIP)) - { - _token = makeToken(_ttype); - _token.setText(text.ToString(_begin, text.Length - _begin)); - } - - returnToken_ = _token; - } - - public void mRBRACKET(bool _createToken) //throws RecognitionException, CharStreamException, TokenStreamException - { - int _ttype; - IToken _token = null; - int _begin = text.Length; - _ttype = RBRACKET; - - match(']'); - if (_createToken && (null == _token) && (_ttype != Token.SKIP)) - { - _token = makeToken(_ttype); - _token.setText(text.ToString(_begin, text.Length - _begin)); - } - - returnToken_ = _token; - } - - public void mLCURLY(bool _createToken) //throws RecognitionException, CharStreamException, TokenStreamException - { - int _ttype; - IToken _token = null; - int _begin = text.Length; - _ttype = LCURLY; - - match('{'); - if (_createToken && (null == _token) && (_ttype != Token.SKIP)) - { - _token = makeToken(_ttype); - _token.setText(text.ToString(_begin, text.Length - _begin)); - } - - returnToken_ = _token; - } - - public void mRCURLY(bool _createToken) //throws RecognitionException, CharStreamException, TokenStreamException - { - int _ttype; - IToken _token = null; - int _begin = text.Length; - _ttype = RCURLY; - - match('}'); - if (_createToken && (null == _token) && (_ttype != Token.SKIP)) - { - _token = makeToken(_ttype); - _token.setText(text.ToString(_begin, text.Length - _begin)); - } - - returnToken_ = _token; - } - - public void mCOMMA(bool _createToken) //throws RecognitionException, CharStreamException, TokenStreamException - { - int _ttype; - IToken _token = null; - int _begin = text.Length; - _ttype = COMMA; - - match(','); - if (_createToken && (null == _token) && (_ttype != Token.SKIP)) - { - _token = makeToken(_ttype); - _token.setText(text.ToString(_begin, text.Length - _begin)); - } - - returnToken_ = _token; - } - - public void mSEMI(bool _createToken) //throws RecognitionException, CharStreamException, TokenStreamException - { - int _ttype; - IToken _token = null; - int _begin = text.Length; - _ttype = SEMI; - - match(';'); - if (_createToken && (null == _token) && (_ttype != Token.SKIP)) - { - _token = makeToken(_ttype); - _token.setText(text.ToString(_begin, text.Length - _begin)); - } - - returnToken_ = _token; - } - - public void mCOLON(bool _createToken) //throws RecognitionException, CharStreamException, TokenStreamException - { - int _ttype; - IToken _token = null; - int _begin = text.Length; - _ttype = COLON; - - match(':'); - if (_createToken && (null == _token) && (_ttype != Token.SKIP)) - { - _token = makeToken(_ttype); - _token.setText(text.ToString(_begin, text.Length - _begin)); - } - - returnToken_ = _token; - } - - public void mASSIGN(bool _createToken) //throws RecognitionException, CharStreamException, TokenStreamException - { - int _ttype; - IToken _token = null; - int _begin = text.Length; - _ttype = ASSIGN; - - match('='); - if (_createToken && (null == _token) && (_ttype != Token.SKIP)) - { - _token = makeToken(_ttype); - _token.setText(text.ToString(_begin, text.Length - _begin)); - } - - returnToken_ = _token; - } - - public void mDEFAULT(bool _createToken) //throws RecognitionException, CharStreamException, TokenStreamException - { - int _ttype; - IToken _token = null; - int _begin = text.Length; - _ttype = DEFAULT; - - match("??"); - if (_createToken && (null == _token) && (_ttype != Token.SKIP)) - { - _token = makeToken(_ttype); - _token.setText(text.ToString(_begin, text.Length - _begin)); - } - - returnToken_ = _token; - } - - public void mPLUS(bool _createToken) //throws RecognitionException, CharStreamException, TokenStreamException - { - int _ttype; - IToken _token = null; - int _begin = text.Length; - _ttype = PLUS; - - match('+'); - if (_createToken && (null == _token) && (_ttype != Token.SKIP)) - { - _token = makeToken(_ttype); - _token.setText(text.ToString(_begin, text.Length - _begin)); - } - - returnToken_ = _token; - } - - public void mMINUS(bool _createToken) //throws RecognitionException, CharStreamException, TokenStreamException - { - int _ttype; - IToken _token = null; - int _begin = text.Length; - _ttype = MINUS; - - match('-'); - if (_createToken && (null == _token) && (_ttype != Token.SKIP)) - { - _token = makeToken(_ttype); - _token.setText(text.ToString(_begin, text.Length - _begin)); - } - - returnToken_ = _token; - } - - public void mDIV(bool _createToken) //throws RecognitionException, CharStreamException, TokenStreamException - { - int _ttype; - IToken _token = null; - int _begin = text.Length; - _ttype = DIV; - - match('/'); - if (_createToken && (null == _token) && (_ttype != Token.SKIP)) - { - _token = makeToken(_ttype); - _token.setText(text.ToString(_begin, text.Length - _begin)); - } - - returnToken_ = _token; - } - - public void mSTAR(bool _createToken) //throws RecognitionException, CharStreamException, TokenStreamException - { - int _ttype; - IToken _token = null; - int _begin = text.Length; - _ttype = STAR; - - match('*'); - if (_createToken && (null == _token) && (_ttype != Token.SKIP)) - { - _token = makeToken(_ttype); - _token.setText(text.ToString(_begin, text.Length - _begin)); - } - - returnToken_ = _token; - } - - public void mMOD(bool _createToken) //throws RecognitionException, CharStreamException, TokenStreamException - { - int _ttype; - IToken _token = null; - int _begin = text.Length; - _ttype = MOD; - - match('%'); - if (_createToken && (null == _token) && (_ttype != Token.SKIP)) - { - _token = makeToken(_ttype); - _token.setText(text.ToString(_begin, text.Length - _begin)); - } - - returnToken_ = _token; - } - - public void mPOWER(bool _createToken) //throws RecognitionException, CharStreamException, TokenStreamException - { - int _ttype; - IToken _token = null; - int _begin = text.Length; - _ttype = POWER; - - match('^'); - if (_createToken && (null == _token) && (_ttype != Token.SKIP)) - { - _token = makeToken(_ttype); - _token.setText(text.ToString(_begin, text.Length - _begin)); - } - - returnToken_ = _token; - } - - public void mEQUAL(bool _createToken) //throws RecognitionException, CharStreamException, TokenStreamException - { - int _ttype; - IToken _token = null; - int _begin = text.Length; - _ttype = EQUAL; - - match("=="); - if (_createToken && (null == _token) && (_ttype != Token.SKIP)) - { - _token = makeToken(_ttype); - _token.setText(text.ToString(_begin, text.Length - _begin)); - } - - returnToken_ = _token; - } - - public void mNOT_EQUAL(bool _createToken) //throws RecognitionException, CharStreamException, TokenStreamException - { - int _ttype; - IToken _token = null; - int _begin = text.Length; - _ttype = NOT_EQUAL; - - match("!="); - if (_createToken && (null == _token) && (_ttype != Token.SKIP)) - { - _token = makeToken(_ttype); - _token.setText(text.ToString(_begin, text.Length - _begin)); - } - - returnToken_ = _token; - } - - public void mLESS_THAN(bool _createToken) //throws RecognitionException, CharStreamException, TokenStreamException - { - int _ttype; - IToken _token = null; - int _begin = text.Length; - _ttype = LESS_THAN; - - match('<'); - if (_createToken && (null == _token) && (_ttype != Token.SKIP)) - { - _token = makeToken(_ttype); - _token.setText(text.ToString(_begin, text.Length - _begin)); - } - - returnToken_ = _token; - } - - public void mLESS_THAN_OR_EQUAL(bool _createToken) //throws RecognitionException, CharStreamException, TokenStreamException - { - int _ttype; - IToken _token = null; - int _begin = text.Length; - _ttype = LESS_THAN_OR_EQUAL; - - match("<="); - if (_createToken && (null == _token) && (_ttype != Token.SKIP)) - { - _token = makeToken(_ttype); - _token.setText(text.ToString(_begin, text.Length - _begin)); - } - - returnToken_ = _token; - } - - public void mGREATER_THAN(bool _createToken) //throws RecognitionException, CharStreamException, TokenStreamException - { - int _ttype; - IToken _token = null; - int _begin = text.Length; - _ttype = GREATER_THAN; - - match('>'); - if (_createToken && (null == _token) && (_ttype != Token.SKIP)) - { - _token = makeToken(_ttype); - _token.setText(text.ToString(_begin, text.Length - _begin)); - } - - returnToken_ = _token; - } - - public void mGREATER_THAN_OR_EQUAL(bool _createToken) //throws RecognitionException, CharStreamException, TokenStreamException - { - int _ttype; - IToken _token = null; - int _begin = text.Length; - _ttype = GREATER_THAN_OR_EQUAL; - - match(">="); - if (_createToken && (null == _token) && (_ttype != Token.SKIP)) - { - _token = makeToken(_ttype); - _token.setText(text.ToString(_begin, text.Length - _begin)); - } - - returnToken_ = _token; - } - - public void mPROJECT(bool _createToken) //throws RecognitionException, CharStreamException, TokenStreamException - { - int _ttype; - IToken _token = null; - int _begin = text.Length; - _ttype = PROJECT; - - match("!{"); - if (_createToken && (null == _token) && (_ttype != Token.SKIP)) - { - _token = makeToken(_ttype); - _token.setText(text.ToString(_begin, text.Length - _begin)); - } - - returnToken_ = _token; - } - - public void mSELECT(bool _createToken) //throws RecognitionException, CharStreamException, TokenStreamException - { - int _ttype; - IToken _token = null; - int _begin = text.Length; - _ttype = SELECT; - - match("?{"); - if (_createToken && (null == _token) && (_ttype != Token.SKIP)) - { - _token = makeToken(_ttype); - _token.setText(text.ToString(_begin, text.Length - _begin)); - } - - returnToken_ = _token; - } - - public void mSELECT_FIRST(bool _createToken) //throws RecognitionException, CharStreamException, TokenStreamException - { - int _ttype; - IToken _token = null; - int _begin = text.Length; - _ttype = SELECT_FIRST; - - match("^{"); - if (_createToken && (null == _token) && (_ttype != Token.SKIP)) - { - _token = makeToken(_ttype); - _token.setText(text.ToString(_begin, text.Length - _begin)); - } - - returnToken_ = _token; - } - - public void mSELECT_LAST(bool _createToken) //throws RecognitionException, CharStreamException, TokenStreamException - { - int _ttype; - IToken _token = null; - int _begin = text.Length; - _ttype = SELECT_LAST; - - match("${"); - if (_createToken && (null == _token) && (_ttype != Token.SKIP)) - { - _token = makeToken(_ttype); - _token.setText(text.ToString(_begin, text.Length - _begin)); - } - - returnToken_ = _token; - } - - public void mTYPE(bool _createToken) //throws RecognitionException, CharStreamException, TokenStreamException - { - int _ttype; - IToken _token = null; - int _begin = text.Length; - _ttype = TYPE; - - match("T("); - if (_createToken && (null == _token) && (_ttype != Token.SKIP)) - { - _token = makeToken(_ttype); - _token.setText(text.ToString(_begin, text.Length - _begin)); - } - - returnToken_ = _token; - } - - public void mLAMBDA(bool _createToken) //throws RecognitionException, CharStreamException, TokenStreamException - { - int _ttype; - IToken _token = null; - int _begin = text.Length; - _ttype = LAMBDA; - - match("{|"); - if (_createToken && (null == _token) && (_ttype != Token.SKIP)) - { - _token = makeToken(_ttype); - _token.setText(text.ToString(_begin, text.Length - _begin)); - } - - returnToken_ = _token; - } - - public void mDOT_ESCAPED(bool _createToken) //throws RecognitionException, CharStreamException, TokenStreamException - { - int _ttype; - IToken _token = null; - int _begin = text.Length; - _ttype = DOT_ESCAPED; - - match("\\."); - if (_createToken && (null == _token) && (_ttype != Token.SKIP)) - { - _token = makeToken(_ttype); - _token.setText(text.ToString(_begin, text.Length - _begin)); - } - - returnToken_ = _token; - } - - public void mQUOTE(bool _createToken) //throws RecognitionException, CharStreamException, TokenStreamException - { - int _ttype; - IToken _token = null; - int _begin = text.Length; - _ttype = QUOTE; - - match('\''); - if (_createToken && (null == _token) && (_ttype != Token.SKIP)) - { - _token = makeToken(_ttype); - _token.setText(text.ToString(_begin, text.Length - _begin)); - } - - returnToken_ = _token; - } - - public void mSTRING_LITERAL(bool _createToken) //throws RecognitionException, CharStreamException, TokenStreamException - { - int _ttype; - IToken _token = null; - int _begin = text.Length; - _ttype = STRING_LITERAL; - - int _saveIndex = 0; - _saveIndex = text.Length; - mQUOTE(false); - text.Length = _saveIndex; - { - // ( ... )* - for (;;) - { - if ((cached_LA1 == '\'') && (cached_LA2 == '\'')) - { - mAPOS(false); - } - else if ((tokenSet_2_.member(cached_LA1))) - { - matchNot('\''); - } - else - { - goto _loop161_breakloop; - } - } - - _loop161_breakloop: ; - } // ( ... )* - _saveIndex = text.Length; - mQUOTE(false); - text.Length = _saveIndex; - if (_createToken && (null == _token) && (_ttype != Token.SKIP)) - { - _token = makeToken(_ttype); - _token.setText(text.ToString(_begin, text.Length - _begin)); - } - - returnToken_ = _token; - } - - protected void mAPOS(bool _createToken) //throws RecognitionException, CharStreamException, TokenStreamException - { - int _ttype; - IToken _token = null; - int _begin = text.Length; - _ttype = APOS; - - int _saveIndex = 0; - _saveIndex = text.Length; - mQUOTE(false); - text.Length = _saveIndex; - mQUOTE(false); - if (_createToken && (null == _token) && (_ttype != Token.SKIP)) - { - _token = makeToken(_ttype); - _token.setText(text.ToString(_begin, text.Length - _begin)); - } - - returnToken_ = _token; - } - - public void mID(bool _createToken) //throws RecognitionException, CharStreamException, TokenStreamException - { - int _ttype; - IToken _token = null; - int _begin = text.Length; - _ttype = ID; - - { - switch (cached_LA1) - { - case 'a': - case 'b': - case 'c': - case 'd': - case 'e': - case 'f': - case 'g': - case 'h': - case 'i': - case 'j': - case 'k': - case 'l': - case 'm': - case 'n': - case 'o': - case 'p': - case 'q': - case 'r': - case 's': - case 't': - case 'u': - case 'v': - case 'w': - case 'x': - case 'y': - case 'z': - { - matchRange('a', 'z'); - break; - } - case 'A': - case 'B': - case 'C': - case 'D': - case 'E': - case 'F': - case 'G': - case 'H': - case 'I': - case 'J': - case 'K': - case 'L': - case 'M': - case 'N': - case 'O': - case 'P': - case 'Q': - case 'R': - case 'S': - case 'T': - case 'U': - case 'V': - case 'W': - case 'X': - case 'Y': - case 'Z': - { - matchRange('A', 'Z'); - break; - } - case '_': - { - match('_'); - break; - } - default: - { - throw new NoViableAltForCharException(cached_LA1, getFilename(), getLine(), getColumn()); - } - } - } - { - // ( ... )* - for (;;) - { - switch (cached_LA1) - { - case 'a': - case 'b': - case 'c': - case 'd': - case 'e': - case 'f': - case 'g': - case 'h': - case 'i': - case 'j': - case 'k': - case 'l': - case 'm': - case 'n': - case 'o': - case 'p': - case 'q': - case 'r': - case 's': - case 't': - case 'u': - case 'v': - case 'w': - case 'x': - case 'y': - case 'z': - { - matchRange('a', 'z'); - break; - } - case 'A': - case 'B': - case 'C': - case 'D': - case 'E': - case 'F': - case 'G': - case 'H': - case 'I': - case 'J': - case 'K': - case 'L': - case 'M': - case 'N': - case 'O': - case 'P': - case 'Q': - case 'R': - case 'S': - case 'T': - case 'U': - case 'V': - case 'W': - case 'X': - case 'Y': - case 'Z': - { - matchRange('A', 'Z'); - break; - } - case '_': - { - match('_'); - break; - } - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - { - matchRange('0', '9'); - break; - } - default: - { - goto _loop166_breakloop; - } - } - } - - _loop166_breakloop: ; - } // ( ... )* - _ttype = testLiteralsTable(_ttype); - if (_createToken && (null == _token) && (_ttype != Token.SKIP)) - { - _token = makeToken(_ttype); - _token.setText(text.ToString(_begin, text.Length - _begin)); - } - - returnToken_ = _token; - } - - public void mNUMERIC_LITERAL(bool _createToken) //throws RecognitionException, CharStreamException, TokenStreamException - { - int _ttype; - IToken _token = null; - int _begin = text.Length; - _ttype = NUMERIC_LITERAL; - - bool synPredMatched169 = false; - if (((cached_LA1 == '.') && ((cached_LA2 >= '0' && cached_LA2 <= '9')))) - { - int _m169 = mark(); - synPredMatched169 = true; - inputState.guessing++; - try - { - { - match('.'); - mDECIMAL_DIGIT(false); - } - } - catch (RecognitionException) - { - synPredMatched169 = false; - } - - rewind(_m169); - inputState.guessing--; - } - - if (synPredMatched169) - { - match('.'); - { - // ( ... )+ - int _cnt171 = 0; - for (;;) - { - if (((cached_LA1 >= '0' && cached_LA1 <= '9'))) - { - mDECIMAL_DIGIT(false); - } - else - { - if (_cnt171 >= 1) { goto _loop171_breakloop; } - else - { - throw new NoViableAltForCharException(cached_LA1, getFilename(), getLine(), getColumn()); - ; - } - } - - _cnt171++; - } - - _loop171_breakloop: ; - } // ( ... )+ - { - if ((cached_LA1 == 'E' || cached_LA1 == 'e')) - { - mEXPONENT_PART(false); - } - else - { - } - } - { - if ((tokenSet_3_.member(cached_LA1))) - { - mREAL_TYPE_SUFFIX(false); - } - else - { - } - } - if (0 == inputState.guessing) - { - _ttype = REAL_LITERAL; - } - } - else - { - bool synPredMatched177 = false; - if ((((cached_LA1 >= '0' && cached_LA1 <= '9')) && (tokenSet_1_.member(cached_LA2)))) - { - int _m177 = mark(); - synPredMatched177 = true; - inputState.guessing++; - try - { - { - { - // ( ... )+ - int _cnt176 = 0; - for (;;) - { - if (((cached_LA1 >= '0' && cached_LA1 <= '9'))) - { - mDECIMAL_DIGIT(false); - } - else - { - if (_cnt176 >= 1) { goto _loop176_breakloop; } - else - { - throw new NoViableAltForCharException(cached_LA1, getFilename(), getLine(), getColumn()); - ; - } - } - - _cnt176++; - } - - _loop176_breakloop: ; - } // ( ... )+ - match('.'); - mDECIMAL_DIGIT(false); - } - } - catch (RecognitionException) - { - synPredMatched177 = false; - } - - rewind(_m177); - inputState.guessing--; - } - - if (synPredMatched177) - { - { - // ( ... )+ - int _cnt179 = 0; - for (;;) - { - if (((cached_LA1 >= '0' && cached_LA1 <= '9'))) - { - mDECIMAL_DIGIT(false); - } - else - { - if (_cnt179 >= 1) { goto _loop179_breakloop; } - else - { - throw new NoViableAltForCharException(cached_LA1, getFilename(), getLine(), getColumn()); - ; - } - } - - _cnt179++; - } - - _loop179_breakloop: ; - } // ( ... )+ - match('.'); - { - // ( ... )+ - int _cnt181 = 0; - for (;;) - { - if (((cached_LA1 >= '0' && cached_LA1 <= '9'))) - { - mDECIMAL_DIGIT(false); - } - else - { - if (_cnt181 >= 1) { goto _loop181_breakloop; } - else - { - throw new NoViableAltForCharException(cached_LA1, getFilename(), getLine(), getColumn()); - ; - } - } - - _cnt181++; - } - - _loop181_breakloop: ; - } // ( ... )+ - { - if ((cached_LA1 == 'E' || cached_LA1 == 'e')) - { - mEXPONENT_PART(false); - } - else - { - } - } - { - if ((tokenSet_3_.member(cached_LA1))) - { - mREAL_TYPE_SUFFIX(false); - } - else - { - } - } - if (0 == inputState.guessing) - { - _ttype = REAL_LITERAL; - } - } - else - { - bool synPredMatched188 = false; - if ((((cached_LA1 >= '0' && cached_LA1 <= '9')) && (tokenSet_4_.member(cached_LA2)))) - { - int _m188 = mark(); - synPredMatched188 = true; - inputState.guessing++; - try - { - { - { - // ( ... )+ - int _cnt186 = 0; - for (;;) - { - if (((cached_LA1 >= '0' && cached_LA1 <= '9'))) - { - mDECIMAL_DIGIT(false); - } - else - { - if (_cnt186 >= 1) { goto _loop186_breakloop; } - else - { - throw new NoViableAltForCharException(cached_LA1, getFilename(), getLine(), getColumn()); - ; - } - } - - _cnt186++; - } - - _loop186_breakloop: ; - } // ( ... )+ - { - mEXPONENT_PART(false); - } - } - } - catch (RecognitionException) - { - synPredMatched188 = false; - } - - rewind(_m188); - inputState.guessing--; - } - - if (synPredMatched188) - { - { - // ( ... )+ - int _cnt190 = 0; - for (;;) - { - if (((cached_LA1 >= '0' && cached_LA1 <= '9'))) - { - mDECIMAL_DIGIT(false); - } - else - { - if (_cnt190 >= 1) { goto _loop190_breakloop; } - else - { - throw new NoViableAltForCharException(cached_LA1, getFilename(), getLine(), getColumn()); - ; - } - } - - _cnt190++; - } - - _loop190_breakloop: ; - } // ( ... )+ - { - mEXPONENT_PART(false); - } - { - if ((tokenSet_3_.member(cached_LA1))) - { - mREAL_TYPE_SUFFIX(false); - } - else - { - } - } - if (0 == inputState.guessing) - { - _ttype = REAL_LITERAL; - } - } - else - { - bool synPredMatched197 = false; - if ((((cached_LA1 >= '0' && cached_LA1 <= '9')) && (tokenSet_5_.member(cached_LA2)))) - { - int _m197 = mark(); - synPredMatched197 = true; - inputState.guessing++; - try - { - { - { - // ( ... )+ - int _cnt195 = 0; - for (;;) - { - if (((cached_LA1 >= '0' && cached_LA1 <= '9'))) - { - mDECIMAL_DIGIT(false); - } - else - { - if (_cnt195 >= 1) { goto _loop195_breakloop; } - else - { - throw new NoViableAltForCharException(cached_LA1, getFilename(), getLine(), getColumn()); - ; - } - } - - _cnt195++; - } - - _loop195_breakloop: ; - } // ( ... )+ - { - mREAL_TYPE_SUFFIX(false); - } - } - } - catch (RecognitionException) - { - synPredMatched197 = false; - } - - rewind(_m197); - inputState.guessing--; - } - - if (synPredMatched197) - { - { - // ( ... )+ - int _cnt199 = 0; - for (;;) - { - if (((cached_LA1 >= '0' && cached_LA1 <= '9'))) - { - mDECIMAL_DIGIT(false); - } - else - { - if (_cnt199 >= 1) { goto _loop199_breakloop; } - else - { - throw new NoViableAltForCharException(cached_LA1, getFilename(), getLine(), getColumn()); - ; - } - } - - _cnt199++; - } - - _loop199_breakloop: ; - } // ( ... )+ - { - mREAL_TYPE_SUFFIX(false); - } - if (0 == inputState.guessing) - { - _ttype = REAL_LITERAL; - } - } - else if (((cached_LA1 >= '0' && cached_LA1 <= '9')) && (true)) - { - { - // ( ... )+ - int _cnt202 = 0; - for (;;) - { - if (((cached_LA1 >= '0' && cached_LA1 <= '9'))) - { - mDECIMAL_DIGIT(false); - } - else - { - if (_cnt202 >= 1) { goto _loop202_breakloop; } - else - { - throw new NoViableAltForCharException(cached_LA1, getFilename(), getLine(), getColumn()); - ; - } - } - - _cnt202++; - } - - _loop202_breakloop: ; - } // ( ... )+ - { - if ((tokenSet_6_.member(cached_LA1))) - { - mINTEGER_TYPE_SUFFIX(false); - } - else - { - } - } - if (0 == inputState.guessing) - { - _ttype = INTEGER_LITERAL; - } - } - else if ((cached_LA1 == '.') && (true)) - { - match('.'); - if (0 == inputState.guessing) - { - _ttype = DOT; - } - } - else - { - throw new NoViableAltForCharException(cached_LA1, getFilename(), getLine(), getColumn()); - } - } - } - } - - if (_createToken && (null == _token) && (_ttype != Token.SKIP)) - { - _token = makeToken(_ttype); - _token.setText(text.ToString(_begin, text.Length - _begin)); - } - - returnToken_ = _token; - } - - protected void mDECIMAL_DIGIT(bool _createToken) //throws RecognitionException, CharStreamException, TokenStreamException - { - int _ttype; - IToken _token = null; - int _begin = text.Length; - _ttype = DECIMAL_DIGIT; - - matchRange('0', '9'); - if (_createToken && (null == _token) && (_ttype != Token.SKIP)) - { - _token = makeToken(_ttype); - _token.setText(text.ToString(_begin, text.Length - _begin)); - } - - returnToken_ = _token; - } - - protected void mEXPONENT_PART(bool _createToken) //throws RecognitionException, CharStreamException, TokenStreamException - { - int _ttype; - IToken _token = null; - int _begin = text.Length; - _ttype = EXPONENT_PART; - - switch (cached_LA1) - { - case 'e': - { - match("e"); - { - // ( ... )* - for (;;) - { - if ((cached_LA1 == '+' || cached_LA1 == '-')) - { - mSIGN(false); - } - else - { - goto _loop214_breakloop; - } - } - - _loop214_breakloop: ; - } // ( ... )* - { - // ( ... )+ - int _cnt216 = 0; - for (;;) - { - if (((cached_LA1 >= '0' && cached_LA1 <= '9'))) - { - mDECIMAL_DIGIT(false); - } - else - { - if (_cnt216 >= 1) { goto _loop216_breakloop; } - else - { - throw new NoViableAltForCharException(cached_LA1, getFilename(), getLine(), getColumn()); - ; - } - } - - _cnt216++; - } - - _loop216_breakloop: ; - } // ( ... )+ - break; - } - case 'E': - { - match("E"); - { - // ( ... )* - for (;;) - { - if ((cached_LA1 == '+' || cached_LA1 == '-')) - { - mSIGN(false); - } - else - { - goto _loop218_breakloop; - } - } - - _loop218_breakloop: ; - } // ( ... )* - { - // ( ... )+ - int _cnt220 = 0; - for (;;) - { - if (((cached_LA1 >= '0' && cached_LA1 <= '9'))) - { - mDECIMAL_DIGIT(false); - } - else - { - if (_cnt220 >= 1) { goto _loop220_breakloop; } - else - { - throw new NoViableAltForCharException(cached_LA1, getFilename(), getLine(), getColumn()); - ; - } - } - - _cnt220++; - } - - _loop220_breakloop: ; - } // ( ... )+ - break; - } - default: - { - throw new NoViableAltForCharException(cached_LA1, getFilename(), getLine(), getColumn()); - } - } - - if (_createToken && (null == _token) && (_ttype != Token.SKIP)) - { - _token = makeToken(_ttype); - _token.setText(text.ToString(_begin, text.Length - _begin)); - } - - returnToken_ = _token; - } - - protected void mREAL_TYPE_SUFFIX(bool _createToken) //throws RecognitionException, CharStreamException, TokenStreamException - { - int _ttype; - IToken _token = null; - int _begin = text.Length; - _ttype = REAL_TYPE_SUFFIX; - - switch (cached_LA1) - { - case 'F': - { - match('F'); - break; - } - case 'f': - { - match('f'); - break; - } - case 'D': - { - match('D'); - break; - } - case 'd': - { - match('d'); - break; - } - case 'M': - { - match('M'); - break; - } - case 'm': - { - match('m'); - break; - } - default: - { - throw new NoViableAltForCharException(cached_LA1, getFilename(), getLine(), getColumn()); - } - } - - if (_createToken && (null == _token) && (_ttype != Token.SKIP)) - { - _token = makeToken(_ttype); - _token.setText(text.ToString(_begin, text.Length - _begin)); - } - - returnToken_ = _token; - } - - protected void mINTEGER_TYPE_SUFFIX(bool _createToken) //throws RecognitionException, CharStreamException, TokenStreamException - { - int _ttype; - IToken _token = null; - int _begin = text.Length; - _ttype = INTEGER_TYPE_SUFFIX; - - { - if ((cached_LA1 == 'U') && (cached_LA2 == 'L')) - { - match("UL"); - } - else if ((cached_LA1 == 'L') && (cached_LA2 == 'U')) - { - match("LU"); - } - else if ((cached_LA1 == 'u') && (cached_LA2 == 'l')) - { - match("ul"); - } - else if ((cached_LA1 == 'l') && (cached_LA2 == 'u')) - { - match("lu"); - } - else if ((cached_LA1 == 'U') && (cached_LA2 == 'L')) - { - match("UL"); - } - else if ((cached_LA1 == 'L') && (cached_LA2 == 'U')) - { - match("LU"); - } - else if ((cached_LA1 == 'u') && (cached_LA2 == 'L')) - { - match("uL"); - } - else if ((cached_LA1 == 'l') && (cached_LA2 == 'U')) - { - match("lU"); - } - else if ((cached_LA1 == 'U') && (true)) - { - match("U"); - } - else if ((cached_LA1 == 'L') && (true)) - { - match("L"); - } - else if ((cached_LA1 == 'u') && (true)) - { - match("u"); - } - else if ((cached_LA1 == 'l') && (true)) - { - match("l"); - } - else - { - throw new NoViableAltForCharException(cached_LA1, getFilename(), getLine(), getColumn()); - } - } - if (_createToken && (null == _token) && (_ttype != Token.SKIP)) - { - _token = makeToken(_ttype); - _token.setText(text.ToString(_begin, text.Length - _begin)); - } - - returnToken_ = _token; - } - - public void mHEXADECIMAL_INTEGER_LITERAL(bool _createToken) //throws RecognitionException, CharStreamException, TokenStreamException - { - int _ttype; - IToken _token = null; - int _begin = text.Length; - _ttype = HEXADECIMAL_INTEGER_LITERAL; - - match("0x"); - { - // ( ... )+ - int _cnt206 = 0; - for (;;) - { - if ((tokenSet_7_.member(cached_LA1))) - { - mHEX_DIGIT(false); - } - else - { - if (_cnt206 >= 1) { goto _loop206_breakloop; } - else - { - throw new NoViableAltForCharException(cached_LA1, getFilename(), getLine(), getColumn()); - ; - } - } - - _cnt206++; - } - - _loop206_breakloop: ; - } // ( ... )+ - { - if ((tokenSet_6_.member(cached_LA1))) - { - mINTEGER_TYPE_SUFFIX(false); - } - else - { - } - } - if (_createToken && (null == _token) && (_ttype != Token.SKIP)) - { - _token = makeToken(_ttype); - _token.setText(text.ToString(_begin, text.Length - _begin)); - } - - returnToken_ = _token; - } - - protected void mHEX_DIGIT(bool _createToken) //throws RecognitionException, CharStreamException, TokenStreamException - { - int _ttype; - IToken _token = null; - int _begin = text.Length; - _ttype = HEX_DIGIT; - - switch (cached_LA1) - { - case '0': - { - match('0'); - break; - } - case '1': - { - match('1'); - break; - } - case '2': - { - match('2'); - break; - } - case '3': - { - match('3'); - break; - } - case '4': - { - match('4'); - break; - } - case '5': - { - match('5'); - break; - } - case '6': - { - match('6'); - break; - } - case '7': - { - match('7'); - break; - } - case '8': - { - match('8'); - break; - } - case '9': - { - match('9'); - break; - } - case 'A': - { - match('A'); - break; - } - case 'B': - { - match('B'); - break; - } - case 'C': - { - match('C'); - break; - } - case 'D': - { - match('D'); - break; - } - case 'E': - { - match('E'); - break; - } - case 'F': - { - match('F'); - break; - } - case 'a': - { - match('a'); - break; - } - case 'b': - { - match('b'); - break; - } - case 'c': - { - match('c'); - break; - } - case 'd': - { - match('d'); - break; - } - case 'e': - { - match('e'); - break; - } - case 'f': - { - match('f'); - break; - } - default: - { - throw new NoViableAltForCharException(cached_LA1, getFilename(), getLine(), getColumn()); - } - } - - if (_createToken && (null == _token) && (_ttype != Token.SKIP)) - { - _token = makeToken(_ttype); - _token.setText(text.ToString(_begin, text.Length - _begin)); - } - - returnToken_ = _token; - } - - protected void mSIGN(bool _createToken) //throws RecognitionException, CharStreamException, TokenStreamException - { - int _ttype; - IToken _token = null; - int _begin = text.Length; - _ttype = SIGN; - - switch (cached_LA1) - { - case '+': - { - match('+'); - break; - } - case '-': - { - match('-'); - break; - } - default: - { - throw new NoViableAltForCharException(cached_LA1, getFilename(), getLine(), getColumn()); - } - } - - if (_createToken && (null == _token) && (_ttype != Token.SKIP)) - { - _token = makeToken(_ttype); - _token.setText(text.ToString(_begin, text.Length - _begin)); - } - - returnToken_ = _token; - } - - private static long[] mk_tokenSet_0_() - { - long[] data = new long[1025]; - data[0] = 0L; - data[1] = 576460745995190270L; - for (int i = 2; i <= 1024; i++) { data[i] = 0L; } - - return data; - } - - public static readonly BitSet tokenSet_0_ = new BitSet(mk_tokenSet_0_()); - - private static long[] mk_tokenSet_1_() - { - long[] data = new long[1025]; - data[0] = 288019269919178752L; - for (int i = 1; i <= 1024; i++) { data[i] = 0L; } - - return data; - } - - public static readonly BitSet tokenSet_1_ = new BitSet(mk_tokenSet_1_()); - - private static long[] mk_tokenSet_2_() - { - long[] data = new long[2048]; - data[0] = -549755813889L; - for (int i = 1; i <= 1022; i++) { data[i] = -1L; } - - data[1023] = 9223372036854775807L; - for (int i = 1024; i <= 2047; i++) { data[i] = 0L; } - - return data; - } - - public static readonly BitSet tokenSet_2_ = new BitSet(mk_tokenSet_2_()); - - private static long[] mk_tokenSet_3_() - { - long[] data = new long[1025]; - data[0] = 0L; - data[1] = 35527969480784L; - for (int i = 2; i <= 1024; i++) { data[i] = 0L; } - - return data; - } - - public static readonly BitSet tokenSet_3_ = new BitSet(mk_tokenSet_3_()); - - private static long[] mk_tokenSet_4_() - { - long[] data = new long[1025]; - data[0] = 287948901175001088L; - data[1] = 137438953504L; - for (int i = 2; i <= 1024; i++) { data[i] = 0L; } - - return data; - } - - public static readonly BitSet tokenSet_4_ = new BitSet(mk_tokenSet_4_()); - - private static long[] mk_tokenSet_5_() - { - long[] data = new long[1025]; - data[0] = 287948901175001088L; - data[1] = 35527969480784L; - for (int i = 2; i <= 1024; i++) { data[i] = 0L; } - - return data; - } - - public static readonly BitSet tokenSet_5_ = new BitSet(mk_tokenSet_5_()); - - private static long[] mk_tokenSet_6_() - { - long[] data = new long[1025]; - data[0] = 0L; - data[1] = 9024791442886656L; - for (int i = 2; i <= 1024; i++) { data[i] = 0L; } - - return data; - } - - public static readonly BitSet tokenSet_6_ = new BitSet(mk_tokenSet_6_()); - - private static long[] mk_tokenSet_7_() - { - long[] data = new long[1025]; - data[0] = 287948901175001088L; - data[1] = 541165879422L; - for (int i = 2; i <= 1024; i++) { data[i] = 0L; } - - return data; - } - - public static readonly BitSet tokenSet_7_ = new BitSet(mk_tokenSet_7_()); -} diff --git a/src/Spring/Spring.Core/Expressions/Parser/ExpressionParser.cs b/src/Spring/Spring.Core/Expressions/Parser/ExpressionParser.cs deleted file mode 100644 index a9f30c6a5..000000000 --- a/src/Spring/Spring.Core/Expressions/Parser/ExpressionParser.cs +++ /dev/null @@ -1,3694 +0,0 @@ -// $ANTLR 2.7.6 (2005-12-22): "Expression.g" -> "ExpressionParser.cs"$ - -namespace Spring.Expressions.Parser; - -// Generate the header common to all output files. -using System; -using TokenBuffer = antlr.TokenBuffer; -using Token = antlr.Token; -using TokenStream = antlr.TokenStream; -using RecognitionException = antlr.RecognitionException; -using NoViableAltException = antlr.NoViableAltException; -using ParserSharedInputState = antlr.ParserSharedInputState; -using BitSet = antlr.collections.impl.BitSet; -using AST = antlr.collections.AST; -using ASTPair = antlr.ASTPair; -using ASTFactory = antlr.ASTFactory; - -internal class ExpressionParser : antlr.LLkParser -{ - public const int EOF = 1; - public const int NULL_TREE_LOOKAHEAD = 3; - public const int EXPR = 4; - public const int OPERAND = 5; - public const int FALSE = 6; - public const int TRUE = 7; - public const int AND = 8; - public const int OR = 9; - public const int XOR = 10; - public const int IN = 11; - public const int IS = 12; - public const int BETWEEN = 13; - public const int LIKE = 14; - public const int MATCHES = 15; - public const int NULL_LITERAL = 16; - public const int LPAREN = 17; - public const int SEMI = 18; - public const int RPAREN = 19; - public const int ASSIGN = 20; - public const int DEFAULT = 21; - public const int QMARK = 22; - public const int COLON = 23; - public const int PLUS = 24; - public const int MINUS = 25; - public const int STAR = 26; - public const int DIV = 27; - public const int MOD = 28; - public const int POWER = 29; - public const int BANG = 30; - public const int DOT = 31; - public const int POUND = 32; - public const int ID = 33; - public const int DOLLAR = 34; - public const int COMMA = 35; - public const int AT = 36; - public const int LBRACKET = 37; - public const int RBRACKET = 38; - public const int PROJECT = 39; - public const int RCURLY = 40; - public const int SELECT = 41; - public const int SELECT_FIRST = 42; - public const int SELECT_LAST = 43; - public const int TYPE = 44; - public const int QUOTE = 45; - public const int STRING_LITERAL = 46; - public const int LAMBDA = 47; - public const int PIPE = 48; - public const int LITERAL_new = 49; - public const int LCURLY = 50; - public const int INTEGER_LITERAL = 51; - public const int HEXADECIMAL_INTEGER_LITERAL = 52; - public const int REAL_LITERAL = 53; - public const int EQUAL = 54; - public const int NOT_EQUAL = 55; - public const int LESS_THAN = 56; - public const int LESS_THAN_OR_EQUAL = 57; - public const int GREATER_THAN = 58; - public const int GREATER_THAN_OR_EQUAL = 59; - public const int WS = 60; - public const int BACKTICK = 61; - public const int BACKSLASH = 62; - public const int DOT_ESCAPED = 63; - public const int APOS = 64; - public const int NUMERIC_LITERAL = 65; - public const int DECIMAL_DIGIT = 66; - public const int INTEGER_TYPE_SUFFIX = 67; - public const int HEX_DIGIT = 68; - public const int EXPONENT_PART = 69; - public const int SIGN = 70; - public const int REAL_TYPE_SUFFIX = 71; - - public override void reportError(RecognitionException ex) - { - //base.reportError(ex); - throw new antlr.TokenStreamRecognitionException(ex); - } - - public override void reportError(string error) - { - //base.reportError(error); - throw new RecognitionException(error); - } - - private string GetRelationalOperatorNodeType(string op) - { - switch (op) - { - case "==": return "Spring.Expressions.OpEqual"; - case "!=": return "Spring.Expressions.OpNotEqual"; - case "<": return "Spring.Expressions.OpLess"; - case "<=": return "Spring.Expressions.OpLessOrEqual"; - case ">": return "Spring.Expressions.OpGreater"; - case ">=": return "Spring.Expressions.OpGreaterOrEqual"; - case "in": return "Spring.Expressions.OpIn"; - case "is": return "Spring.Expressions.OpIs"; - case "between": return "Spring.Expressions.OpBetween"; - case "like": return "Spring.Expressions.OpLike"; - case "matches": return "Spring.Expressions.OpMatches"; - default: - throw new ArgumentException("Node type for operator '" + op + "' is not defined."); - } - } - - protected void initialize() - { - tokenNames = tokenNames_; - initializeFactory(); - } - - protected ExpressionParser(TokenBuffer tokenBuf, int k) : base(tokenBuf, k) - { - initialize(); - } - - public ExpressionParser(TokenBuffer tokenBuf) : this(tokenBuf, 2) - { - } - - protected ExpressionParser(TokenStream lexer, int k) : base(lexer, k) - { - initialize(); - } - - public ExpressionParser(TokenStream lexer) : this(lexer, 2) - { - } - - public ExpressionParser(ParserSharedInputState state) : base(state, 2) - { - initialize(); - } - - public void expr() //throws RecognitionException, TokenStreamException - { - returnAST = null; - ASTPair currentAST = new ASTPair(); - Spring.Expressions.SpringAST expr_AST = null; - - try - { - // for error handling - expression(); - if (0 == inputState.guessing) - { - astFactory.addASTChild(ref currentAST, (AST) returnAST); - } - - match(Token.EOF_TYPE); - expr_AST = (Spring.Expressions.SpringAST) currentAST.root; - } - catch (RecognitionException ex) - { - if (0 == inputState.guessing) - { - reportError(ex); - recover(ex, tokenSet_0_); - } - else - { - throw ex; - } - } - - returnAST = expr_AST; - } - - public void expression() //throws RecognitionException, TokenStreamException - { - returnAST = null; - ASTPair currentAST = new ASTPair(); - Spring.Expressions.SpringAST expression_AST = null; - - try - { - // for error handling - logicalOrExpression(); - if (0 == inputState.guessing) - { - astFactory.addASTChild(ref currentAST, (AST) returnAST); - } - - { - switch (LA(1)) - { - case ASSIGN: - { - { - Spring.Expressions.AssignNode tmp2_AST = null; - tmp2_AST = (Spring.Expressions.AssignNode) astFactory.create(LT(1), "Spring.Expressions.AssignNode"); - astFactory.makeASTRoot(ref currentAST, (AST) tmp2_AST); - match(ASSIGN); - logicalOrExpression(); - if (0 == inputState.guessing) - { - astFactory.addASTChild(ref currentAST, (AST) returnAST); - } - } - break; - } - case DEFAULT: - { - { - Spring.Expressions.DefaultNode tmp3_AST = null; - tmp3_AST = (Spring.Expressions.DefaultNode) astFactory.create(LT(1), "Spring.Expressions.DefaultNode"); - astFactory.makeASTRoot(ref currentAST, (AST) tmp3_AST); - match(DEFAULT); - logicalOrExpression(); - if (0 == inputState.guessing) - { - astFactory.addASTChild(ref currentAST, (AST) returnAST); - } - } - break; - } - case QMARK: - { - { - Spring.Expressions.TernaryNode tmp4_AST = null; - tmp4_AST = (Spring.Expressions.TernaryNode) astFactory.create(LT(1), "Spring.Expressions.TernaryNode"); - astFactory.makeASTRoot(ref currentAST, (AST) tmp4_AST); - match(QMARK); - expression(); - if (0 == inputState.guessing) - { - astFactory.addASTChild(ref currentAST, (AST) returnAST); - } - - match(COLON); - expression(); - if (0 == inputState.guessing) - { - astFactory.addASTChild(ref currentAST, (AST) returnAST); - } - } - break; - } - case EOF: - case SEMI: - case RPAREN: - case COLON: - case COMMA: - case RBRACKET: - case RCURLY: - { - break; - } - default: - { - throw new NoViableAltException(LT(1), getFilename()); - } - } - } - expression_AST = (Spring.Expressions.SpringAST) currentAST.root; - } - catch (RecognitionException ex) - { - if (0 == inputState.guessing) - { - reportError(ex); - recover(ex, tokenSet_1_); - } - else - { - throw ex; - } - } - - returnAST = expression_AST; - } - - public void exprList() //throws RecognitionException, TokenStreamException - { - returnAST = null; - ASTPair currentAST = new ASTPair(); - Spring.Expressions.SpringAST exprList_AST = null; - - try - { - // for error handling - match(LPAREN); - expression(); - if (0 == inputState.guessing) - { - astFactory.addASTChild(ref currentAST, (AST) returnAST); - } - - { - // ( ... )+ - int _cnt4 = 0; - for (;;) - { - if ((LA(1) == SEMI)) - { - match(SEMI); - expression(); - if (0 == inputState.guessing) - { - astFactory.addASTChild(ref currentAST, (AST) returnAST); - } - } - else - { - if (_cnt4 >= 1) { goto _loop4_breakloop; } - else - { - throw new NoViableAltException(LT(1), getFilename()); - ; - } - } - - _cnt4++; - } - - _loop4_breakloop: ; - } // ( ... )+ - match(RPAREN); - if (0 == inputState.guessing) - { - exprList_AST = (Spring.Expressions.SpringAST) currentAST.root; - exprList_AST = (Spring.Expressions.SpringAST) astFactory.make((AST) (Spring.Expressions.SpringAST) astFactory.create(EXPR, "expressionList", "Spring.Expressions.ExpressionListNode"), (AST) exprList_AST); - currentAST.root = exprList_AST; - if ((null != exprList_AST) && (null != exprList_AST.getFirstChild())) - currentAST.child = exprList_AST.getFirstChild(); - else - currentAST.child = exprList_AST; - currentAST.advanceChildToEnd(); - } - - exprList_AST = (Spring.Expressions.SpringAST) currentAST.root; - } - catch (RecognitionException ex) - { - if (0 == inputState.guessing) - { - reportError(ex); - recover(ex, tokenSet_2_); - } - else - { - throw ex; - } - } - - returnAST = exprList_AST; - } - - public void logicalOrExpression() //throws RecognitionException, TokenStreamException - { - returnAST = null; - ASTPair currentAST = new ASTPair(); - Spring.Expressions.SpringAST logicalOrExpression_AST = null; - - try - { - // for error handling - logicalXorExpression(); - if (0 == inputState.guessing) - { - astFactory.addASTChild(ref currentAST, (AST) returnAST); - } - - { - // ( ... )* - for (;;) - { - if ((LA(1) == OR)) - { - Spring.Expressions.OpOR tmp9_AST = null; - tmp9_AST = (Spring.Expressions.OpOR) astFactory.create(LT(1), "Spring.Expressions.OpOR"); - astFactory.makeASTRoot(ref currentAST, (AST) tmp9_AST); - match(OR); - logicalXorExpression(); - if (0 == inputState.guessing) - { - astFactory.addASTChild(ref currentAST, (AST) returnAST); - } - } - else - { - goto _loop13_breakloop; - } - } - - _loop13_breakloop: ; - } // ( ... )* - logicalOrExpression_AST = (Spring.Expressions.SpringAST) currentAST.root; - } - catch (RecognitionException ex) - { - if (0 == inputState.guessing) - { - reportError(ex); - recover(ex, tokenSet_3_); - } - else - { - throw ex; - } - } - - returnAST = logicalOrExpression_AST; - } - - public void parenExpr() //throws RecognitionException, TokenStreamException - { - returnAST = null; - ASTPair currentAST = new ASTPair(); - Spring.Expressions.SpringAST parenExpr_AST = null; - - try - { - // for error handling - match(LPAREN); - expression(); - if (0 == inputState.guessing) - { - astFactory.addASTChild(ref currentAST, (AST) returnAST); - } - - match(RPAREN); - parenExpr_AST = (Spring.Expressions.SpringAST) currentAST.root; - } - catch (RecognitionException ex) - { - if (0 == inputState.guessing) - { - reportError(ex); - recover(ex, tokenSet_2_); - } - else - { - throw ex; - } - } - - returnAST = parenExpr_AST; - } - - public void logicalXorExpression() //throws RecognitionException, TokenStreamException - { - returnAST = null; - ASTPair currentAST = new ASTPair(); - Spring.Expressions.SpringAST logicalXorExpression_AST = null; - - try - { - // for error handling - logicalAndExpression(); - if (0 == inputState.guessing) - { - astFactory.addASTChild(ref currentAST, (AST) returnAST); - } - - { - // ( ... )* - for (;;) - { - if ((LA(1) == XOR)) - { - Spring.Expressions.OpXOR tmp12_AST = null; - tmp12_AST = (Spring.Expressions.OpXOR) astFactory.create(LT(1), "Spring.Expressions.OpXOR"); - astFactory.makeASTRoot(ref currentAST, (AST) tmp12_AST); - match(XOR); - logicalAndExpression(); - if (0 == inputState.guessing) - { - astFactory.addASTChild(ref currentAST, (AST) returnAST); - } - } - else - { - goto _loop16_breakloop; - } - } - - _loop16_breakloop: ; - } // ( ... )* - logicalXorExpression_AST = (Spring.Expressions.SpringAST) currentAST.root; - } - catch (RecognitionException ex) - { - if (0 == inputState.guessing) - { - reportError(ex); - recover(ex, tokenSet_4_); - } - else - { - throw ex; - } - } - - returnAST = logicalXorExpression_AST; - } - - public void logicalAndExpression() //throws RecognitionException, TokenStreamException - { - returnAST = null; - ASTPair currentAST = new ASTPair(); - Spring.Expressions.SpringAST logicalAndExpression_AST = null; - - try - { - // for error handling - relationalExpression(); - if (0 == inputState.guessing) - { - astFactory.addASTChild(ref currentAST, (AST) returnAST); - } - - { - // ( ... )* - for (;;) - { - if ((LA(1) == AND)) - { - Spring.Expressions.OpAND tmp13_AST = null; - tmp13_AST = (Spring.Expressions.OpAND) astFactory.create(LT(1), "Spring.Expressions.OpAND"); - astFactory.makeASTRoot(ref currentAST, (AST) tmp13_AST); - match(AND); - relationalExpression(); - if (0 == inputState.guessing) - { - astFactory.addASTChild(ref currentAST, (AST) returnAST); - } - } - else - { - goto _loop19_breakloop; - } - } - - _loop19_breakloop: ; - } // ( ... )* - logicalAndExpression_AST = (Spring.Expressions.SpringAST) currentAST.root; - } - catch (RecognitionException ex) - { - if (0 == inputState.guessing) - { - reportError(ex); - recover(ex, tokenSet_5_); - } - else - { - throw ex; - } - } - - returnAST = logicalAndExpression_AST; - } - - public void relationalExpression() //throws RecognitionException, TokenStreamException - { - returnAST = null; - ASTPair currentAST = new ASTPair(); - Spring.Expressions.SpringAST relationalExpression_AST = null; - Spring.Expressions.SpringAST e1_AST = null; - Spring.Expressions.SpringAST op_AST = null; - Spring.Expressions.SpringAST e2_AST = null; - - try - { - // for error handling - sumExpr(); - if (0 == inputState.guessing) - { - e1_AST = (Spring.Expressions.SpringAST) returnAST; - astFactory.addASTChild(ref currentAST, (AST) returnAST); - } - - { - if ((tokenSet_6_.member(LA(1)))) - { - relationalOperator(); - if (0 == inputState.guessing) - { - op_AST = (Spring.Expressions.SpringAST) returnAST; - } - - sumExpr(); - if (0 == inputState.guessing) - { - e2_AST = (Spring.Expressions.SpringAST) returnAST; - astFactory.addASTChild(ref currentAST, (AST) returnAST); - } - - if (0 == inputState.guessing) - { - relationalExpression_AST = (Spring.Expressions.SpringAST) currentAST.root; - relationalExpression_AST = (Spring.Expressions.SpringAST) astFactory.make((AST) (Spring.Expressions.SpringAST) astFactory.create(EXPR, op_AST.getText(), GetRelationalOperatorNodeType(op_AST.getText())), (AST) relationalExpression_AST); - currentAST.root = relationalExpression_AST; - if ((null != relationalExpression_AST) && (null != relationalExpression_AST.getFirstChild())) - currentAST.child = relationalExpression_AST.getFirstChild(); - else - currentAST.child = relationalExpression_AST; - currentAST.advanceChildToEnd(); - } - } - else if ((tokenSet_7_.member(LA(1)))) - { - } - else - { - throw new NoViableAltException(LT(1), getFilename()); - } - } - relationalExpression_AST = (Spring.Expressions.SpringAST) currentAST.root; - } - catch (RecognitionException ex) - { - if (0 == inputState.guessing) - { - reportError(ex); - recover(ex, tokenSet_7_); - } - else - { - throw ex; - } - } - - returnAST = relationalExpression_AST; - } - - public void sumExpr() //throws RecognitionException, TokenStreamException - { - returnAST = null; - ASTPair currentAST = new ASTPair(); - Spring.Expressions.SpringAST sumExpr_AST = null; - - try - { - // for error handling - prodExpr(); - if (0 == inputState.guessing) - { - astFactory.addASTChild(ref currentAST, (AST) returnAST); - } - - { - // ( ... )* - for (;;) - { - if ((LA(1) == PLUS || LA(1) == MINUS)) - { - { - if ((LA(1) == PLUS)) - { - Spring.Expressions.OpADD tmp14_AST = null; - tmp14_AST = (Spring.Expressions.OpADD) astFactory.create(LT(1), "Spring.Expressions.OpADD"); - astFactory.makeASTRoot(ref currentAST, (AST) tmp14_AST); - match(PLUS); - } - else if ((LA(1) == MINUS)) - { - Spring.Expressions.OpSUBTRACT tmp15_AST = null; - tmp15_AST = (Spring.Expressions.OpSUBTRACT) astFactory.create(LT(1), "Spring.Expressions.OpSUBTRACT"); - astFactory.makeASTRoot(ref currentAST, (AST) tmp15_AST); - match(MINUS); - } - else - { - throw new NoViableAltException(LT(1), getFilename()); - } - } - prodExpr(); - if (0 == inputState.guessing) - { - astFactory.addASTChild(ref currentAST, (AST) returnAST); - } - } - else - { - goto _loop25_breakloop; - } - } - - _loop25_breakloop: ; - } // ( ... )* - sumExpr_AST = (Spring.Expressions.SpringAST) currentAST.root; - } - catch (RecognitionException ex) - { - if (0 == inputState.guessing) - { - reportError(ex); - recover(ex, tokenSet_8_); - } - else - { - throw ex; - } - } - - returnAST = sumExpr_AST; - } - - public void relationalOperator() //throws RecognitionException, TokenStreamException - { - returnAST = null; - ASTPair currentAST = new ASTPair(); - Spring.Expressions.SpringAST relationalOperator_AST = null; - - try - { - // for error handling - switch (LA(1)) - { - case EQUAL: - { - Spring.Expressions.SpringAST tmp16_AST = null; - tmp16_AST = (Spring.Expressions.SpringAST) astFactory.create(LT(1)); - astFactory.addASTChild(ref currentAST, (AST) tmp16_AST); - match(EQUAL); - relationalOperator_AST = (Spring.Expressions.SpringAST) currentAST.root; - break; - } - case NOT_EQUAL: - { - Spring.Expressions.SpringAST tmp17_AST = null; - tmp17_AST = (Spring.Expressions.SpringAST) astFactory.create(LT(1)); - astFactory.addASTChild(ref currentAST, (AST) tmp17_AST); - match(NOT_EQUAL); - relationalOperator_AST = (Spring.Expressions.SpringAST) currentAST.root; - break; - } - case LESS_THAN: - { - Spring.Expressions.SpringAST tmp18_AST = null; - tmp18_AST = (Spring.Expressions.SpringAST) astFactory.create(LT(1)); - astFactory.addASTChild(ref currentAST, (AST) tmp18_AST); - match(LESS_THAN); - relationalOperator_AST = (Spring.Expressions.SpringAST) currentAST.root; - break; - } - case LESS_THAN_OR_EQUAL: - { - Spring.Expressions.SpringAST tmp19_AST = null; - tmp19_AST = (Spring.Expressions.SpringAST) astFactory.create(LT(1)); - astFactory.addASTChild(ref currentAST, (AST) tmp19_AST); - match(LESS_THAN_OR_EQUAL); - relationalOperator_AST = (Spring.Expressions.SpringAST) currentAST.root; - break; - } - case GREATER_THAN: - { - Spring.Expressions.SpringAST tmp20_AST = null; - tmp20_AST = (Spring.Expressions.SpringAST) astFactory.create(LT(1)); - astFactory.addASTChild(ref currentAST, (AST) tmp20_AST); - match(GREATER_THAN); - relationalOperator_AST = (Spring.Expressions.SpringAST) currentAST.root; - break; - } - case GREATER_THAN_OR_EQUAL: - { - Spring.Expressions.SpringAST tmp21_AST = null; - tmp21_AST = (Spring.Expressions.SpringAST) astFactory.create(LT(1)); - astFactory.addASTChild(ref currentAST, (AST) tmp21_AST); - match(GREATER_THAN_OR_EQUAL); - relationalOperator_AST = (Spring.Expressions.SpringAST) currentAST.root; - break; - } - case IN: - { - Spring.Expressions.SpringAST tmp22_AST = null; - tmp22_AST = (Spring.Expressions.SpringAST) astFactory.create(LT(1)); - astFactory.addASTChild(ref currentAST, (AST) tmp22_AST); - match(IN); - relationalOperator_AST = (Spring.Expressions.SpringAST) currentAST.root; - break; - } - case IS: - { - Spring.Expressions.SpringAST tmp23_AST = null; - tmp23_AST = (Spring.Expressions.SpringAST) astFactory.create(LT(1)); - astFactory.addASTChild(ref currentAST, (AST) tmp23_AST); - match(IS); - relationalOperator_AST = (Spring.Expressions.SpringAST) currentAST.root; - break; - } - case BETWEEN: - { - Spring.Expressions.SpringAST tmp24_AST = null; - tmp24_AST = (Spring.Expressions.SpringAST) astFactory.create(LT(1)); - astFactory.addASTChild(ref currentAST, (AST) tmp24_AST); - match(BETWEEN); - relationalOperator_AST = (Spring.Expressions.SpringAST) currentAST.root; - break; - } - case LIKE: - { - Spring.Expressions.SpringAST tmp25_AST = null; - tmp25_AST = (Spring.Expressions.SpringAST) astFactory.create(LT(1)); - astFactory.addASTChild(ref currentAST, (AST) tmp25_AST); - match(LIKE); - relationalOperator_AST = (Spring.Expressions.SpringAST) currentAST.root; - break; - } - case MATCHES: - { - Spring.Expressions.SpringAST tmp26_AST = null; - tmp26_AST = (Spring.Expressions.SpringAST) astFactory.create(LT(1)); - astFactory.addASTChild(ref currentAST, (AST) tmp26_AST); - match(MATCHES); - relationalOperator_AST = (Spring.Expressions.SpringAST) currentAST.root; - break; - } - default: - { - throw new NoViableAltException(LT(1), getFilename()); - } - } - } - catch (RecognitionException ex) - { - if (0 == inputState.guessing) - { - reportError(ex); - recover(ex, tokenSet_9_); - } - else - { - throw ex; - } - } - - returnAST = relationalOperator_AST; - } - - public void prodExpr() //throws RecognitionException, TokenStreamException - { - returnAST = null; - ASTPair currentAST = new ASTPair(); - Spring.Expressions.SpringAST prodExpr_AST = null; - - try - { - // for error handling - powExpr(); - if (0 == inputState.guessing) - { - astFactory.addASTChild(ref currentAST, (AST) returnAST); - } - - { - // ( ... )* - for (;;) - { - if (((LA(1) >= STAR && LA(1) <= MOD))) - { - { - switch (LA(1)) - { - case STAR: - { - Spring.Expressions.OpMULTIPLY tmp27_AST = null; - tmp27_AST = (Spring.Expressions.OpMULTIPLY) astFactory.create(LT(1), "Spring.Expressions.OpMULTIPLY"); - astFactory.makeASTRoot(ref currentAST, (AST) tmp27_AST); - match(STAR); - break; - } - case DIV: - { - Spring.Expressions.OpDIVIDE tmp28_AST = null; - tmp28_AST = (Spring.Expressions.OpDIVIDE) astFactory.create(LT(1), "Spring.Expressions.OpDIVIDE"); - astFactory.makeASTRoot(ref currentAST, (AST) tmp28_AST); - match(DIV); - break; - } - case MOD: - { - Spring.Expressions.OpMODULUS tmp29_AST = null; - tmp29_AST = (Spring.Expressions.OpMODULUS) astFactory.create(LT(1), "Spring.Expressions.OpMODULUS"); - astFactory.makeASTRoot(ref currentAST, (AST) tmp29_AST); - match(MOD); - break; - } - default: - { - throw new NoViableAltException(LT(1), getFilename()); - } - } - } - powExpr(); - if (0 == inputState.guessing) - { - astFactory.addASTChild(ref currentAST, (AST) returnAST); - } - } - else - { - goto _loop29_breakloop; - } - } - - _loop29_breakloop: ; - } // ( ... )* - prodExpr_AST = (Spring.Expressions.SpringAST) currentAST.root; - } - catch (RecognitionException ex) - { - if (0 == inputState.guessing) - { - reportError(ex); - recover(ex, tokenSet_10_); - } - else - { - throw ex; - } - } - - returnAST = prodExpr_AST; - } - - public void powExpr() //throws RecognitionException, TokenStreamException - { - returnAST = null; - ASTPair currentAST = new ASTPair(); - Spring.Expressions.SpringAST powExpr_AST = null; - - try - { - // for error handling - unaryExpression(); - if (0 == inputState.guessing) - { - astFactory.addASTChild(ref currentAST, (AST) returnAST); - } - - { - if ((LA(1) == POWER)) - { - Spring.Expressions.OpPOWER tmp30_AST = null; - tmp30_AST = (Spring.Expressions.OpPOWER) astFactory.create(LT(1), "Spring.Expressions.OpPOWER"); - astFactory.makeASTRoot(ref currentAST, (AST) tmp30_AST); - match(POWER); - unaryExpression(); - if (0 == inputState.guessing) - { - astFactory.addASTChild(ref currentAST, (AST) returnAST); - } - } - else if ((tokenSet_11_.member(LA(1)))) - { - } - else - { - throw new NoViableAltException(LT(1), getFilename()); - } - } - powExpr_AST = (Spring.Expressions.SpringAST) currentAST.root; - } - catch (RecognitionException ex) - { - if (0 == inputState.guessing) - { - reportError(ex); - recover(ex, tokenSet_11_); - } - else - { - throw ex; - } - } - - returnAST = powExpr_AST; - } - - public void unaryExpression() //throws RecognitionException, TokenStreamException - { - returnAST = null; - ASTPair currentAST = new ASTPair(); - Spring.Expressions.SpringAST unaryExpression_AST = null; - - try - { - // for error handling - if ((LA(1) == PLUS || LA(1) == MINUS || LA(1) == BANG)) - { - { - switch (LA(1)) - { - case PLUS: - { - Spring.Expressions.OpUnaryPlus tmp31_AST = null; - tmp31_AST = (Spring.Expressions.OpUnaryPlus) astFactory.create(LT(1), "Spring.Expressions.OpUnaryPlus"); - astFactory.makeASTRoot(ref currentAST, (AST) tmp31_AST); - match(PLUS); - break; - } - case MINUS: - { - Spring.Expressions.OpUnaryMinus tmp32_AST = null; - tmp32_AST = (Spring.Expressions.OpUnaryMinus) astFactory.create(LT(1), "Spring.Expressions.OpUnaryMinus"); - astFactory.makeASTRoot(ref currentAST, (AST) tmp32_AST); - match(MINUS); - break; - } - case BANG: - { - Spring.Expressions.OpNOT tmp33_AST = null; - tmp33_AST = (Spring.Expressions.OpNOT) astFactory.create(LT(1), "Spring.Expressions.OpNOT"); - astFactory.makeASTRoot(ref currentAST, (AST) tmp33_AST); - match(BANG); - break; - } - default: - { - throw new NoViableAltException(LT(1), getFilename()); - } - } - } - unaryExpression(); - if (0 == inputState.guessing) - { - astFactory.addASTChild(ref currentAST, (AST) returnAST); - } - - unaryExpression_AST = (Spring.Expressions.SpringAST) currentAST.root; - } - else if ((tokenSet_12_.member(LA(1)))) - { - primaryExpression(); - if (0 == inputState.guessing) - { - astFactory.addASTChild(ref currentAST, (AST) returnAST); - } - - unaryExpression_AST = (Spring.Expressions.SpringAST) currentAST.root; - } - else - { - throw new NoViableAltException(LT(1), getFilename()); - } - } - catch (RecognitionException ex) - { - if (0 == inputState.guessing) - { - reportError(ex); - recover(ex, tokenSet_13_); - } - else - { - throw ex; - } - } - - returnAST = unaryExpression_AST; - } - - public void primaryExpression() //throws RecognitionException, TokenStreamException - { - returnAST = null; - ASTPair currentAST = new ASTPair(); - Spring.Expressions.SpringAST primaryExpression_AST = null; - - try - { - // for error handling - startNode(); - if (0 == inputState.guessing) - { - astFactory.addASTChild(ref currentAST, (AST) returnAST); - } - - { - if ((tokenSet_14_.member(LA(1)))) - { - node(); - if (0 == inputState.guessing) - { - astFactory.addASTChild(ref currentAST, (AST) returnAST); - } - } - else if ((tokenSet_13_.member(LA(1)))) - { - } - else - { - throw new NoViableAltException(LT(1), getFilename()); - } - } - if (0 == inputState.guessing) - { - primaryExpression_AST = (Spring.Expressions.SpringAST) currentAST.root; - primaryExpression_AST = (Spring.Expressions.SpringAST) astFactory.make((AST) (Spring.Expressions.SpringAST) astFactory.create(EXPR, "expression", "Spring.Expressions.Expression"), (AST) primaryExpression_AST); - currentAST.root = primaryExpression_AST; - if ((null != primaryExpression_AST) && (null != primaryExpression_AST.getFirstChild())) - currentAST.child = primaryExpression_AST.getFirstChild(); - else - currentAST.child = primaryExpression_AST; - currentAST.advanceChildToEnd(); - } - - primaryExpression_AST = (Spring.Expressions.SpringAST) currentAST.root; - } - catch (RecognitionException ex) - { - if (0 == inputState.guessing) - { - reportError(ex); - recover(ex, tokenSet_13_); - } - else - { - throw ex; - } - } - - returnAST = primaryExpression_AST; - } - - public void unaryOperator() //throws RecognitionException, TokenStreamException - { - returnAST = null; - ASTPair currentAST = new ASTPair(); - Spring.Expressions.SpringAST unaryOperator_AST = null; - - try - { - // for error handling - switch (LA(1)) - { - case PLUS: - { - Spring.Expressions.SpringAST tmp34_AST = null; - tmp34_AST = (Spring.Expressions.SpringAST) astFactory.create(LT(1)); - astFactory.addASTChild(ref currentAST, (AST) tmp34_AST); - match(PLUS); - unaryOperator_AST = (Spring.Expressions.SpringAST) currentAST.root; - break; - } - case MINUS: - { - Spring.Expressions.SpringAST tmp35_AST = null; - tmp35_AST = (Spring.Expressions.SpringAST) astFactory.create(LT(1)); - astFactory.addASTChild(ref currentAST, (AST) tmp35_AST); - match(MINUS); - unaryOperator_AST = (Spring.Expressions.SpringAST) currentAST.root; - break; - } - case BANG: - { - Spring.Expressions.SpringAST tmp36_AST = null; - tmp36_AST = (Spring.Expressions.SpringAST) astFactory.create(LT(1)); - astFactory.addASTChild(ref currentAST, (AST) tmp36_AST); - match(BANG); - unaryOperator_AST = (Spring.Expressions.SpringAST) currentAST.root; - break; - } - default: - { - throw new NoViableAltException(LT(1), getFilename()); - } - } - } - catch (RecognitionException ex) - { - if (0 == inputState.guessing) - { - reportError(ex); - recover(ex, tokenSet_0_); - } - else - { - throw ex; - } - } - - returnAST = unaryOperator_AST; - } - - public void startNode() //throws RecognitionException, TokenStreamException - { - returnAST = null; - ASTPair currentAST = new ASTPair(); - Spring.Expressions.SpringAST startNode_AST = null; - - try - { - // for error handling - { - switch (LA(1)) - { - case ID: - { - methodOrProperty(); - if (0 == inputState.guessing) - { - astFactory.addASTChild(ref currentAST, (AST) returnAST); - } - - break; - } - case DOLLAR: - { - localFunctionOrVar(); - if (0 == inputState.guessing) - { - astFactory.addASTChild(ref currentAST, (AST) returnAST); - } - - break; - } - case LBRACKET: - { - indexer(); - if (0 == inputState.guessing) - { - astFactory.addASTChild(ref currentAST, (AST) returnAST); - } - - break; - } - case FALSE: - case TRUE: - case NULL_LITERAL: - case STRING_LITERAL: - case INTEGER_LITERAL: - case HEXADECIMAL_INTEGER_LITERAL: - case REAL_LITERAL: - { - literal(); - if (0 == inputState.guessing) - { - astFactory.addASTChild(ref currentAST, (AST) returnAST); - } - - break; - } - case TYPE: - { - type(); - if (0 == inputState.guessing) - { - astFactory.addASTChild(ref currentAST, (AST) returnAST); - } - - break; - } - case LITERAL_new: - { - constructor(); - if (0 == inputState.guessing) - { - astFactory.addASTChild(ref currentAST, (AST) returnAST); - } - - break; - } - case PROJECT: - { - projection(); - if (0 == inputState.guessing) - { - astFactory.addASTChild(ref currentAST, (AST) returnAST); - } - - break; - } - case SELECT: - { - selection(); - if (0 == inputState.guessing) - { - astFactory.addASTChild(ref currentAST, (AST) returnAST); - } - - break; - } - case SELECT_FIRST: - { - firstSelection(); - if (0 == inputState.guessing) - { - astFactory.addASTChild(ref currentAST, (AST) returnAST); - } - - break; - } - case SELECT_LAST: - { - lastSelection(); - if (0 == inputState.guessing) - { - astFactory.addASTChild(ref currentAST, (AST) returnAST); - } - - break; - } - case LCURLY: - { - listInitializer(); - if (0 == inputState.guessing) - { - astFactory.addASTChild(ref currentAST, (AST) returnAST); - } - - break; - } - case LAMBDA: - { - lambda(); - if (0 == inputState.guessing) - { - astFactory.addASTChild(ref currentAST, (AST) returnAST); - } - - break; - } - default: - bool synPredMatched40 = false; - if (((LA(1) == LPAREN) && (tokenSet_9_.member(LA(2))))) - { - int _m40 = mark(); - synPredMatched40 = true; - inputState.guessing++; - try - { - { - match(LPAREN); - expression(); - match(SEMI); - } - } - catch (RecognitionException) - { - synPredMatched40 = false; - } - - rewind(_m40); - inputState.guessing--; - } - - if (synPredMatched40) - { - exprList(); - if (0 == inputState.guessing) - { - astFactory.addASTChild(ref currentAST, (AST) returnAST); - } - } - else if ((LA(1) == LPAREN) && (tokenSet_9_.member(LA(2)))) - { - parenExpr(); - if (0 == inputState.guessing) - { - astFactory.addASTChild(ref currentAST, (AST) returnAST); - } - } - else if ((LA(1) == POUND) && (LA(2) == ID)) - { - functionOrVar(); - if (0 == inputState.guessing) - { - astFactory.addASTChild(ref currentAST, (AST) returnAST); - } - } - else if ((LA(1) == AT) && (LA(2) == LPAREN)) - { - reference(); - if (0 == inputState.guessing) - { - astFactory.addASTChild(ref currentAST, (AST) returnAST); - } - } - else if ((LA(1) == POUND) && (LA(2) == LCURLY)) - { - mapInitializer(); - if (0 == inputState.guessing) - { - astFactory.addASTChild(ref currentAST, (AST) returnAST); - } - } - else if ((LA(1) == AT) && (LA(2) == LBRACKET)) - { - attribute(); - if (0 == inputState.guessing) - { - astFactory.addASTChild(ref currentAST, (AST) returnAST); - } - } - else - { - throw new NoViableAltException(LT(1), getFilename()); - } - - break; - } - } - startNode_AST = (Spring.Expressions.SpringAST) currentAST.root; - } - catch (RecognitionException ex) - { - if (0 == inputState.guessing) - { - reportError(ex); - recover(ex, tokenSet_2_); - } - else - { - throw ex; - } - } - - returnAST = startNode_AST; - } - - public void node() //throws RecognitionException, TokenStreamException - { - returnAST = null; - ASTPair currentAST = new ASTPair(); - Spring.Expressions.SpringAST node_AST = null; - - try - { - // for error handling - { - // ( ... )+ - int _cnt43 = 0; - for (;;) - { - switch (LA(1)) - { - case ID: - { - methodOrProperty(); - if (0 == inputState.guessing) - { - astFactory.addASTChild(ref currentAST, (AST) returnAST); - } - - break; - } - case LBRACKET: - { - indexer(); - if (0 == inputState.guessing) - { - astFactory.addASTChild(ref currentAST, (AST) returnAST); - } - - break; - } - case PROJECT: - { - projection(); - if (0 == inputState.guessing) - { - astFactory.addASTChild(ref currentAST, (AST) returnAST); - } - - break; - } - case SELECT: - { - selection(); - if (0 == inputState.guessing) - { - astFactory.addASTChild(ref currentAST, (AST) returnAST); - } - - break; - } - case SELECT_FIRST: - { - firstSelection(); - if (0 == inputState.guessing) - { - astFactory.addASTChild(ref currentAST, (AST) returnAST); - } - - break; - } - case SELECT_LAST: - { - lastSelection(); - if (0 == inputState.guessing) - { - astFactory.addASTChild(ref currentAST, (AST) returnAST); - } - - break; - } - case LPAREN: - { - exprList(); - if (0 == inputState.guessing) - { - astFactory.addASTChild(ref currentAST, (AST) returnAST); - } - - break; - } - case DOT: - { - match(DOT); - break; - } - default: - { - if (_cnt43 >= 1) { goto _loop43_breakloop; } - else - { - throw new NoViableAltException(LT(1), getFilename()); - ; - } - } - break; - } - - _cnt43++; - } - - _loop43_breakloop: ; - } // ( ... )+ - node_AST = (Spring.Expressions.SpringAST) currentAST.root; - } - catch (RecognitionException ex) - { - if (0 == inputState.guessing) - { - reportError(ex); - recover(ex, tokenSet_13_); - } - else - { - throw ex; - } - } - - returnAST = node_AST; - } - - public void methodOrProperty() //throws RecognitionException, TokenStreamException - { - returnAST = null; - ASTPair currentAST = new ASTPair(); - Spring.Expressions.SpringAST methodOrProperty_AST = null; - - try - { - // for error handling - bool synPredMatched56 = false; - if (((LA(1) == ID) && (LA(2) == LPAREN))) - { - int _m56 = mark(); - synPredMatched56 = true; - inputState.guessing++; - try - { - { - match(ID); - match(LPAREN); - } - } - catch (RecognitionException) - { - synPredMatched56 = false; - } - - rewind(_m56); - inputState.guessing--; - } - - if (synPredMatched56) - { - Spring.Expressions.MethodNode tmp38_AST = null; - tmp38_AST = (Spring.Expressions.MethodNode) astFactory.create(LT(1), "Spring.Expressions.MethodNode"); - astFactory.makeASTRoot(ref currentAST, (AST) tmp38_AST); - match(ID); - methodArgs(); - if (0 == inputState.guessing) - { - astFactory.addASTChild(ref currentAST, (AST) returnAST); - } - - methodOrProperty_AST = (Spring.Expressions.SpringAST) currentAST.root; - } - else if ((LA(1) == ID) && (tokenSet_2_.member(LA(2)))) - { - property(); - if (0 == inputState.guessing) - { - astFactory.addASTChild(ref currentAST, (AST) returnAST); - } - - methodOrProperty_AST = (Spring.Expressions.SpringAST) currentAST.root; - } - else - { - throw new NoViableAltException(LT(1), getFilename()); - } - } - catch (RecognitionException ex) - { - if (0 == inputState.guessing) - { - reportError(ex); - recover(ex, tokenSet_2_); - } - else - { - throw ex; - } - } - - returnAST = methodOrProperty_AST; - } - - public void functionOrVar() //throws RecognitionException, TokenStreamException - { - returnAST = null; - ASTPair currentAST = new ASTPair(); - Spring.Expressions.SpringAST functionOrVar_AST = null; - - try - { - // for error handling - bool synPredMatched46 = false; - if (((LA(1) == POUND) && (LA(2) == ID))) - { - int _m46 = mark(); - synPredMatched46 = true; - inputState.guessing++; - try - { - { - match(POUND); - match(ID); - match(LPAREN); - } - } - catch (RecognitionException) - { - synPredMatched46 = false; - } - - rewind(_m46); - inputState.guessing--; - } - - if (synPredMatched46) - { - function(); - if (0 == inputState.guessing) - { - astFactory.addASTChild(ref currentAST, (AST) returnAST); - } - - functionOrVar_AST = (Spring.Expressions.SpringAST) currentAST.root; - } - else if ((LA(1) == POUND) && (LA(2) == ID)) - { - var(); - if (0 == inputState.guessing) - { - astFactory.addASTChild(ref currentAST, (AST) returnAST); - } - - functionOrVar_AST = (Spring.Expressions.SpringAST) currentAST.root; - } - else - { - throw new NoViableAltException(LT(1), getFilename()); - } - } - catch (RecognitionException ex) - { - if (0 == inputState.guessing) - { - reportError(ex); - recover(ex, tokenSet_2_); - } - else - { - throw ex; - } - } - - returnAST = functionOrVar_AST; - } - - public void localFunctionOrVar() //throws RecognitionException, TokenStreamException - { - returnAST = null; - ASTPair currentAST = new ASTPair(); - Spring.Expressions.SpringAST localFunctionOrVar_AST = null; - - try - { - // for error handling - bool synPredMatched51 = false; - if (((LA(1) == DOLLAR) && (LA(2) == ID))) - { - int _m51 = mark(); - synPredMatched51 = true; - inputState.guessing++; - try - { - { - match(DOLLAR); - match(ID); - match(LPAREN); - } - } - catch (RecognitionException) - { - synPredMatched51 = false; - } - - rewind(_m51); - inputState.guessing--; - } - - if (synPredMatched51) - { - localFunction(); - if (0 == inputState.guessing) - { - astFactory.addASTChild(ref currentAST, (AST) returnAST); - } - - localFunctionOrVar_AST = (Spring.Expressions.SpringAST) currentAST.root; - } - else if ((LA(1) == DOLLAR) && (LA(2) == ID)) - { - localVar(); - if (0 == inputState.guessing) - { - astFactory.addASTChild(ref currentAST, (AST) returnAST); - } - - localFunctionOrVar_AST = (Spring.Expressions.SpringAST) currentAST.root; - } - else - { - throw new NoViableAltException(LT(1), getFilename()); - } - } - catch (RecognitionException ex) - { - if (0 == inputState.guessing) - { - reportError(ex); - recover(ex, tokenSet_2_); - } - else - { - throw ex; - } - } - - returnAST = localFunctionOrVar_AST; - } - - public void reference() //throws RecognitionException, TokenStreamException - { - returnAST = null; - ASTPair currentAST = new ASTPair(); - Spring.Expressions.SpringAST reference_AST = null; - Spring.Expressions.SpringAST cn_AST = null; - Spring.Expressions.SpringAST id_AST = null; - Spring.Expressions.SpringAST localid_AST = null; - - try - { - // for error handling - bool synPredMatched64 = false; - if (((LA(1) == AT) && (LA(2) == LPAREN))) - { - int _m64 = mark(); - synPredMatched64 = true; - inputState.guessing++; - try - { - { - match(AT); - match(LPAREN); - quotableName(); - match(COLON); - } - } - catch (RecognitionException) - { - synPredMatched64 = false; - } - - rewind(_m64); - inputState.guessing--; - } - - if (synPredMatched64) - { - match(AT); - match(LPAREN); - quotableName(); - if (0 == inputState.guessing) - { - cn_AST = (Spring.Expressions.SpringAST) returnAST; - } - - match(COLON); - quotableName(); - if (0 == inputState.guessing) - { - id_AST = (Spring.Expressions.SpringAST) returnAST; - } - - match(RPAREN); - if (0 == inputState.guessing) - { - reference_AST = (Spring.Expressions.SpringAST) currentAST.root; - reference_AST = (Spring.Expressions.SpringAST) astFactory.make((AST) (Spring.Expressions.SpringAST) astFactory.create(EXPR, "ref", "Spring.Context.Support.ReferenceNode"), (AST) cn_AST, (AST) id_AST); - currentAST.root = reference_AST; - if ((null != reference_AST) && (null != reference_AST.getFirstChild())) - currentAST.child = reference_AST.getFirstChild(); - else - currentAST.child = reference_AST; - currentAST.advanceChildToEnd(); - } - - reference_AST = (Spring.Expressions.SpringAST) currentAST.root; - } - else if ((LA(1) == AT) && (LA(2) == LPAREN)) - { - match(AT); - match(LPAREN); - quotableName(); - if (0 == inputState.guessing) - { - localid_AST = (Spring.Expressions.SpringAST) returnAST; - } - - match(RPAREN); - if (0 == inputState.guessing) - { - reference_AST = (Spring.Expressions.SpringAST) currentAST.root; - reference_AST = (Spring.Expressions.SpringAST) astFactory.make((AST) (Spring.Expressions.SpringAST) astFactory.create(EXPR, "ref", "Spring.Context.Support.ReferenceNode"), (AST) null, (AST) localid_AST); - currentAST.root = reference_AST; - if ((null != reference_AST) && (null != reference_AST.getFirstChild())) - currentAST.child = reference_AST.getFirstChild(); - else - currentAST.child = reference_AST; - currentAST.advanceChildToEnd(); - } - - reference_AST = (Spring.Expressions.SpringAST) currentAST.root; - } - else - { - throw new NoViableAltException(LT(1), getFilename()); - } - } - catch (RecognitionException ex) - { - if (0 == inputState.guessing) - { - reportError(ex); - recover(ex, tokenSet_2_); - } - else - { - throw ex; - } - } - - returnAST = reference_AST; - } - - public void indexer() //throws RecognitionException, TokenStreamException - { - returnAST = null; - ASTPair currentAST = new ASTPair(); - Spring.Expressions.SpringAST indexer_AST = null; - - try - { - // for error handling - Spring.Expressions.IndexerNode tmp46_AST = null; - tmp46_AST = (Spring.Expressions.IndexerNode) astFactory.create(LT(1), "Spring.Expressions.IndexerNode"); - astFactory.makeASTRoot(ref currentAST, (AST) tmp46_AST); - match(LBRACKET); - argument(); - if (0 == inputState.guessing) - { - astFactory.addASTChild(ref currentAST, (AST) returnAST); - } - - { - // ( ... )* - for (;;) - { - if ((LA(1) == COMMA)) - { - match(COMMA); - argument(); - if (0 == inputState.guessing) - { - astFactory.addASTChild(ref currentAST, (AST) returnAST); - } - } - else - { - goto _loop67_breakloop; - } - } - - _loop67_breakloop: ; - } // ( ... )* - match(RBRACKET); - indexer_AST = (Spring.Expressions.SpringAST) currentAST.root; - } - catch (RecognitionException ex) - { - if (0 == inputState.guessing) - { - reportError(ex); - recover(ex, tokenSet_2_); - } - else - { - throw ex; - } - } - - returnAST = indexer_AST; - } - - public void literal() //throws RecognitionException, TokenStreamException - { - returnAST = null; - ASTPair currentAST = new ASTPair(); - Spring.Expressions.SpringAST literal_AST = null; - - try - { - // for error handling - switch (LA(1)) - { - case NULL_LITERAL: - { - Spring.Expressions.NullLiteralNode tmp49_AST = null; - tmp49_AST = (Spring.Expressions.NullLiteralNode) astFactory.create(LT(1), "Spring.Expressions.NullLiteralNode"); - astFactory.addASTChild(ref currentAST, (AST) tmp49_AST); - match(NULL_LITERAL); - literal_AST = (Spring.Expressions.SpringAST) currentAST.root; - break; - } - case INTEGER_LITERAL: - { - Spring.Expressions.IntLiteralNode tmp50_AST = null; - tmp50_AST = (Spring.Expressions.IntLiteralNode) astFactory.create(LT(1), "Spring.Expressions.IntLiteralNode"); - astFactory.addASTChild(ref currentAST, (AST) tmp50_AST); - match(INTEGER_LITERAL); - literal_AST = (Spring.Expressions.SpringAST) currentAST.root; - break; - } - case HEXADECIMAL_INTEGER_LITERAL: - { - Spring.Expressions.HexLiteralNode tmp51_AST = null; - tmp51_AST = (Spring.Expressions.HexLiteralNode) astFactory.create(LT(1), "Spring.Expressions.HexLiteralNode"); - astFactory.addASTChild(ref currentAST, (AST) tmp51_AST); - match(HEXADECIMAL_INTEGER_LITERAL); - literal_AST = (Spring.Expressions.SpringAST) currentAST.root; - break; - } - case REAL_LITERAL: - { - Spring.Expressions.RealLiteralNode tmp52_AST = null; - tmp52_AST = (Spring.Expressions.RealLiteralNode) astFactory.create(LT(1), "Spring.Expressions.RealLiteralNode"); - astFactory.addASTChild(ref currentAST, (AST) tmp52_AST); - match(REAL_LITERAL); - literal_AST = (Spring.Expressions.SpringAST) currentAST.root; - break; - } - case STRING_LITERAL: - { - Spring.Expressions.StringLiteralNode tmp53_AST = null; - tmp53_AST = (Spring.Expressions.StringLiteralNode) astFactory.create(LT(1), "Spring.Expressions.StringLiteralNode"); - astFactory.addASTChild(ref currentAST, (AST) tmp53_AST); - match(STRING_LITERAL); - literal_AST = (Spring.Expressions.SpringAST) currentAST.root; - break; - } - case FALSE: - case TRUE: - { - boolLiteral(); - if (0 == inputState.guessing) - { - astFactory.addASTChild(ref currentAST, (AST) returnAST); - } - - literal_AST = (Spring.Expressions.SpringAST) currentAST.root; - break; - } - default: - { - throw new NoViableAltException(LT(1), getFilename()); - } - } - } - catch (RecognitionException ex) - { - if (0 == inputState.guessing) - { - reportError(ex); - recover(ex, tokenSet_2_); - } - else - { - throw ex; - } - } - - returnAST = literal_AST; - } - - public void type() //throws RecognitionException, TokenStreamException - { - returnAST = null; - ASTPair currentAST = new ASTPair(); - Spring.Expressions.SpringAST type_AST = null; - Spring.Expressions.SpringAST tn_AST = null; - - try - { - // for error handling - match(TYPE); - name(); - if (0 == inputState.guessing) - { - tn_AST = (Spring.Expressions.SpringAST) returnAST; - } - - match(RPAREN); - if (0 == inputState.guessing) - { - type_AST = (Spring.Expressions.SpringAST) currentAST.root; - type_AST = (Spring.Expressions.SpringAST) astFactory.make((AST) (Spring.Expressions.SpringAST) astFactory.create(EXPR, tn_AST.getText(), "Spring.Expressions.TypeNode"), (AST) type_AST); - currentAST.root = type_AST; - if ((null != type_AST) && (null != type_AST.getFirstChild())) - currentAST.child = type_AST.getFirstChild(); - else - currentAST.child = type_AST; - currentAST.advanceChildToEnd(); - } - - type_AST = (Spring.Expressions.SpringAST) currentAST.root; - } - catch (RecognitionException ex) - { - if (0 == inputState.guessing) - { - reportError(ex); - recover(ex, tokenSet_2_); - } - else - { - throw ex; - } - } - - returnAST = type_AST; - } - - public void constructor() //throws RecognitionException, TokenStreamException - { - returnAST = null; - ASTPair currentAST = new ASTPair(); - Spring.Expressions.SpringAST constructor_AST = null; - Spring.Expressions.SpringAST type_AST = null; - - try - { - // for error handling - bool synPredMatched90 = false; - if (((LA(1) == LITERAL_new) && (LA(2) == ID))) - { - int _m90 = mark(); - synPredMatched90 = true; - inputState.guessing++; - try - { - { - match(LITERAL_new); - qualifiedId(); - match(LPAREN); - } - } - catch (RecognitionException) - { - synPredMatched90 = false; - } - - rewind(_m90); - inputState.guessing--; - } - - if (synPredMatched90) - { - match(LITERAL_new); - qualifiedId(); - if (0 == inputState.guessing) - { - type_AST = (Spring.Expressions.SpringAST) returnAST; - } - - ctorArgs(); - if (0 == inputState.guessing) - { - astFactory.addASTChild(ref currentAST, (AST) returnAST); - } - - if (0 == inputState.guessing) - { - constructor_AST = (Spring.Expressions.SpringAST) currentAST.root; - constructor_AST = (Spring.Expressions.SpringAST) astFactory.make((AST) (Spring.Expressions.SpringAST) astFactory.create(EXPR, type_AST.getText(), "Spring.Expressions.ConstructorNode"), (AST) constructor_AST); - currentAST.root = constructor_AST; - if ((null != constructor_AST) && (null != constructor_AST.getFirstChild())) - currentAST.child = constructor_AST.getFirstChild(); - else - currentAST.child = constructor_AST; - currentAST.advanceChildToEnd(); - } - - constructor_AST = (Spring.Expressions.SpringAST) currentAST.root; - } - else if ((LA(1) == LITERAL_new) && (LA(2) == ID)) - { - arrayConstructor(); - if (0 == inputState.guessing) - { - astFactory.addASTChild(ref currentAST, (AST) returnAST); - } - - constructor_AST = (Spring.Expressions.SpringAST) currentAST.root; - } - else - { - throw new NoViableAltException(LT(1), getFilename()); - } - } - catch (RecognitionException ex) - { - if (0 == inputState.guessing) - { - reportError(ex); - recover(ex, tokenSet_2_); - } - else - { - throw ex; - } - } - - returnAST = constructor_AST; - } - - public void projection() //throws RecognitionException, TokenStreamException - { - returnAST = null; - ASTPair currentAST = new ASTPair(); - Spring.Expressions.SpringAST projection_AST = null; - - try - { - // for error handling - Spring.Expressions.ProjectionNode tmp57_AST = null; - tmp57_AST = (Spring.Expressions.ProjectionNode) astFactory.create(LT(1), "Spring.Expressions.ProjectionNode"); - astFactory.makeASTRoot(ref currentAST, (AST) tmp57_AST); - match(PROJECT); - expression(); - if (0 == inputState.guessing) - { - astFactory.addASTChild(ref currentAST, (AST) returnAST); - } - - match(RCURLY); - projection_AST = (Spring.Expressions.SpringAST) currentAST.root; - } - catch (RecognitionException ex) - { - if (0 == inputState.guessing) - { - reportError(ex); - recover(ex, tokenSet_2_); - } - else - { - throw ex; - } - } - - returnAST = projection_AST; - } - - public void selection() //throws RecognitionException, TokenStreamException - { - returnAST = null; - ASTPair currentAST = new ASTPair(); - Spring.Expressions.SpringAST selection_AST = null; - - try - { - // for error handling - Spring.Expressions.SelectionNode tmp59_AST = null; - tmp59_AST = (Spring.Expressions.SelectionNode) astFactory.create(LT(1), "Spring.Expressions.SelectionNode"); - astFactory.makeASTRoot(ref currentAST, (AST) tmp59_AST); - match(SELECT); - expression(); - if (0 == inputState.guessing) - { - astFactory.addASTChild(ref currentAST, (AST) returnAST); - } - - { - // ( ... )* - for (;;) - { - if ((LA(1) == COMMA)) - { - match(COMMA); - expression(); - if (0 == inputState.guessing) - { - astFactory.addASTChild(ref currentAST, (AST) returnAST); - } - } - else - { - goto _loop71_breakloop; - } - } - - _loop71_breakloop: ; - } // ( ... )* - match(RCURLY); - selection_AST = (Spring.Expressions.SpringAST) currentAST.root; - } - catch (RecognitionException ex) - { - if (0 == inputState.guessing) - { - reportError(ex); - recover(ex, tokenSet_2_); - } - else - { - throw ex; - } - } - - returnAST = selection_AST; - } - - public void firstSelection() //throws RecognitionException, TokenStreamException - { - returnAST = null; - ASTPair currentAST = new ASTPair(); - Spring.Expressions.SpringAST firstSelection_AST = null; - - try - { - // for error handling - Spring.Expressions.SelectionFirstNode tmp62_AST = null; - tmp62_AST = (Spring.Expressions.SelectionFirstNode) astFactory.create(LT(1), "Spring.Expressions.SelectionFirstNode"); - astFactory.makeASTRoot(ref currentAST, (AST) tmp62_AST); - match(SELECT_FIRST); - expression(); - if (0 == inputState.guessing) - { - astFactory.addASTChild(ref currentAST, (AST) returnAST); - } - - match(RCURLY); - firstSelection_AST = (Spring.Expressions.SpringAST) currentAST.root; - } - catch (RecognitionException ex) - { - if (0 == inputState.guessing) - { - reportError(ex); - recover(ex, tokenSet_2_); - } - else - { - throw ex; - } - } - - returnAST = firstSelection_AST; - } - - public void lastSelection() //throws RecognitionException, TokenStreamException - { - returnAST = null; - ASTPair currentAST = new ASTPair(); - Spring.Expressions.SpringAST lastSelection_AST = null; - - try - { - // for error handling - Spring.Expressions.SelectionLastNode tmp64_AST = null; - tmp64_AST = (Spring.Expressions.SelectionLastNode) astFactory.create(LT(1), "Spring.Expressions.SelectionLastNode"); - astFactory.makeASTRoot(ref currentAST, (AST) tmp64_AST); - match(SELECT_LAST); - expression(); - if (0 == inputState.guessing) - { - astFactory.addASTChild(ref currentAST, (AST) returnAST); - } - - match(RCURLY); - lastSelection_AST = (Spring.Expressions.SpringAST) currentAST.root; - } - catch (RecognitionException ex) - { - if (0 == inputState.guessing) - { - reportError(ex); - recover(ex, tokenSet_2_); - } - else - { - throw ex; - } - } - - returnAST = lastSelection_AST; - } - - public void listInitializer() //throws RecognitionException, TokenStreamException - { - returnAST = null; - ASTPair currentAST = new ASTPair(); - Spring.Expressions.SpringAST listInitializer_AST = null; - - try - { - // for error handling - Spring.Expressions.ListInitializerNode tmp66_AST = null; - tmp66_AST = (Spring.Expressions.ListInitializerNode) astFactory.create(LT(1), "Spring.Expressions.ListInitializerNode"); - astFactory.makeASTRoot(ref currentAST, (AST) tmp66_AST); - match(LCURLY); - expression(); - if (0 == inputState.guessing) - { - astFactory.addASTChild(ref currentAST, (AST) returnAST); - } - - { - // ( ... )* - for (;;) - { - if ((LA(1) == COMMA)) - { - match(COMMA); - expression(); - if (0 == inputState.guessing) - { - astFactory.addASTChild(ref currentAST, (AST) returnAST); - } - } - else - { - goto _loop99_breakloop; - } - } - - _loop99_breakloop: ; - } // ( ... )* - match(RCURLY); - listInitializer_AST = (Spring.Expressions.SpringAST) currentAST.root; - } - catch (RecognitionException ex) - { - if (0 == inputState.guessing) - { - reportError(ex); - recover(ex, tokenSet_2_); - } - else - { - throw ex; - } - } - - returnAST = listInitializer_AST; - } - - public void mapInitializer() //throws RecognitionException, TokenStreamException - { - returnAST = null; - ASTPair currentAST = new ASTPair(); - Spring.Expressions.SpringAST mapInitializer_AST = null; - - try - { - // for error handling - match(POUND); - Spring.Expressions.MapInitializerNode tmp70_AST = null; - tmp70_AST = (Spring.Expressions.MapInitializerNode) astFactory.create(LT(1), "Spring.Expressions.MapInitializerNode"); - astFactory.makeASTRoot(ref currentAST, (AST) tmp70_AST); - match(LCURLY); - mapEntry(); - if (0 == inputState.guessing) - { - astFactory.addASTChild(ref currentAST, (AST) returnAST); - } - - { - // ( ... )* - for (;;) - { - if ((LA(1) == COMMA)) - { - match(COMMA); - mapEntry(); - if (0 == inputState.guessing) - { - astFactory.addASTChild(ref currentAST, (AST) returnAST); - } - } - else - { - goto _loop102_breakloop; - } - } - - _loop102_breakloop: ; - } // ( ... )* - match(RCURLY); - mapInitializer_AST = (Spring.Expressions.SpringAST) currentAST.root; - } - catch (RecognitionException ex) - { - if (0 == inputState.guessing) - { - reportError(ex); - recover(ex, tokenSet_2_); - } - else - { - throw ex; - } - } - - returnAST = mapInitializer_AST; - } - - public void lambda() //throws RecognitionException, TokenStreamException - { - returnAST = null; - ASTPair currentAST = new ASTPair(); - Spring.Expressions.SpringAST lambda_AST = null; - - try - { - // for error handling - match(LAMBDA); - { - if ((LA(1) == ID)) - { - argList(); - if (0 == inputState.guessing) - { - astFactory.addASTChild(ref currentAST, (AST) returnAST); - } - } - else if ((LA(1) == PIPE)) - { - } - else - { - throw new NoViableAltException(LT(1), getFilename()); - } - } - match(PIPE); - expression(); - if (0 == inputState.guessing) - { - astFactory.addASTChild(ref currentAST, (AST) returnAST); - } - - match(RCURLY); - if (0 == inputState.guessing) - { - lambda_AST = (Spring.Expressions.SpringAST) currentAST.root; - lambda_AST = (Spring.Expressions.SpringAST) astFactory.make((AST) (Spring.Expressions.SpringAST) astFactory.create(EXPR, "lambda", "Spring.Expressions.LambdaExpressionNode"), (AST) lambda_AST); - currentAST.root = lambda_AST; - if ((null != lambda_AST) && (null != lambda_AST.getFirstChild())) - currentAST.child = lambda_AST.getFirstChild(); - else - currentAST.child = lambda_AST; - currentAST.advanceChildToEnd(); - } - - lambda_AST = (Spring.Expressions.SpringAST) currentAST.root; - } - catch (RecognitionException ex) - { - if (0 == inputState.guessing) - { - reportError(ex); - recover(ex, tokenSet_2_); - } - else - { - throw ex; - } - } - - returnAST = lambda_AST; - } - - public void attribute() //throws RecognitionException, TokenStreamException - { - returnAST = null; - ASTPair currentAST = new ASTPair(); - Spring.Expressions.SpringAST attribute_AST = null; - Spring.Expressions.SpringAST tn_AST = null; - - try - { - // for error handling - match(AT); - match(LBRACKET); - qualifiedId(); - if (0 == inputState.guessing) - { - tn_AST = (Spring.Expressions.SpringAST) returnAST; - } - - { - if ((LA(1) == LPAREN)) - { - ctorArgs(); - if (0 == inputState.guessing) - { - astFactory.addASTChild(ref currentAST, (AST) returnAST); - } - } - else if ((LA(1) == RBRACKET)) - { - } - else - { - throw new NoViableAltException(LT(1), getFilename()); - } - } - match(RBRACKET); - if (0 == inputState.guessing) - { - attribute_AST = (Spring.Expressions.SpringAST) currentAST.root; - attribute_AST = (Spring.Expressions.SpringAST) astFactory.make((AST) (Spring.Expressions.SpringAST) astFactory.create(EXPR, tn_AST.getText(), "Spring.Expressions.AttributeNode"), (AST) attribute_AST); - currentAST.root = attribute_AST; - if ((null != attribute_AST) && (null != attribute_AST.getFirstChild())) - currentAST.child = attribute_AST.getFirstChild(); - else - currentAST.child = attribute_AST; - currentAST.advanceChildToEnd(); - } - - attribute_AST = (Spring.Expressions.SpringAST) currentAST.root; - } - catch (RecognitionException ex) - { - if (0 == inputState.guessing) - { - reportError(ex); - recover(ex, tokenSet_2_); - } - else - { - throw ex; - } - } - - returnAST = attribute_AST; - } - - public void function() //throws RecognitionException, TokenStreamException - { - returnAST = null; - ASTPair currentAST = new ASTPair(); - Spring.Expressions.SpringAST function_AST = null; - - try - { - // for error handling - match(POUND); - Spring.Expressions.FunctionNode tmp80_AST = null; - tmp80_AST = (Spring.Expressions.FunctionNode) astFactory.create(LT(1), "Spring.Expressions.FunctionNode"); - astFactory.makeASTRoot(ref currentAST, (AST) tmp80_AST); - match(ID); - methodArgs(); - if (0 == inputState.guessing) - { - astFactory.addASTChild(ref currentAST, (AST) returnAST); - } - - function_AST = (Spring.Expressions.SpringAST) currentAST.root; - } - catch (RecognitionException ex) - { - if (0 == inputState.guessing) - { - reportError(ex); - recover(ex, tokenSet_2_); - } - else - { - throw ex; - } - } - - returnAST = function_AST; - } - - public void var() //throws RecognitionException, TokenStreamException - { - returnAST = null; - ASTPair currentAST = new ASTPair(); - Spring.Expressions.SpringAST var_AST = null; - - try - { - // for error handling - match(POUND); - Spring.Expressions.VariableNode tmp82_AST = null; - tmp82_AST = (Spring.Expressions.VariableNode) astFactory.create(LT(1), "Spring.Expressions.VariableNode"); - astFactory.makeASTRoot(ref currentAST, (AST) tmp82_AST); - match(ID); - var_AST = (Spring.Expressions.SpringAST) currentAST.root; - } - catch (RecognitionException ex) - { - if (0 == inputState.guessing) - { - reportError(ex); - recover(ex, tokenSet_2_); - } - else - { - throw ex; - } - } - - returnAST = var_AST; - } - - public void methodArgs() //throws RecognitionException, TokenStreamException - { - returnAST = null; - ASTPair currentAST = new ASTPair(); - Spring.Expressions.SpringAST methodArgs_AST = null; - - try - { - // for error handling - match(LPAREN); - { - if ((tokenSet_9_.member(LA(1)))) - { - argument(); - if (0 == inputState.guessing) - { - astFactory.addASTChild(ref currentAST, (AST) returnAST); - } - - { - // ( ... )* - for (;;) - { - if ((LA(1) == COMMA)) - { - match(COMMA); - argument(); - if (0 == inputState.guessing) - { - astFactory.addASTChild(ref currentAST, (AST) returnAST); - } - } - else - { - goto _loop60_breakloop; - } - } - - _loop60_breakloop: ; - } // ( ... )* - } - else if ((LA(1) == RPAREN)) - { - } - else - { - throw new NoViableAltException(LT(1), getFilename()); - } - } - match(RPAREN); - methodArgs_AST = (Spring.Expressions.SpringAST) currentAST.root; - } - catch (RecognitionException ex) - { - if (0 == inputState.guessing) - { - reportError(ex); - recover(ex, tokenSet_2_); - } - else - { - throw ex; - } - } - - returnAST = methodArgs_AST; - } - - public void localFunction() //throws RecognitionException, TokenStreamException - { - returnAST = null; - ASTPair currentAST = new ASTPair(); - Spring.Expressions.SpringAST localFunction_AST = null; - - try - { - // for error handling - match(DOLLAR); - Spring.Expressions.LocalFunctionNode tmp87_AST = null; - tmp87_AST = (Spring.Expressions.LocalFunctionNode) astFactory.create(LT(1), "Spring.Expressions.LocalFunctionNode"); - astFactory.makeASTRoot(ref currentAST, (AST) tmp87_AST); - match(ID); - methodArgs(); - if (0 == inputState.guessing) - { - astFactory.addASTChild(ref currentAST, (AST) returnAST); - } - - localFunction_AST = (Spring.Expressions.SpringAST) currentAST.root; - } - catch (RecognitionException ex) - { - if (0 == inputState.guessing) - { - reportError(ex); - recover(ex, tokenSet_2_); - } - else - { - throw ex; - } - } - - returnAST = localFunction_AST; - } - - public void localVar() //throws RecognitionException, TokenStreamException - { - returnAST = null; - ASTPair currentAST = new ASTPair(); - Spring.Expressions.SpringAST localVar_AST = null; - - try - { - // for error handling - match(DOLLAR); - Spring.Expressions.LocalVariableNode tmp89_AST = null; - tmp89_AST = (Spring.Expressions.LocalVariableNode) astFactory.create(LT(1), "Spring.Expressions.LocalVariableNode"); - astFactory.makeASTRoot(ref currentAST, (AST) tmp89_AST); - match(ID); - localVar_AST = (Spring.Expressions.SpringAST) currentAST.root; - } - catch (RecognitionException ex) - { - if (0 == inputState.guessing) - { - reportError(ex); - recover(ex, tokenSet_2_); - } - else - { - throw ex; - } - } - - returnAST = localVar_AST; - } - - public void property() //throws RecognitionException, TokenStreamException - { - returnAST = null; - ASTPair currentAST = new ASTPair(); - Spring.Expressions.SpringAST property_AST = null; - - try - { - // for error handling - Spring.Expressions.PropertyOrFieldNode tmp90_AST = null; - tmp90_AST = (Spring.Expressions.PropertyOrFieldNode) astFactory.create(LT(1), "Spring.Expressions.PropertyOrFieldNode"); - astFactory.addASTChild(ref currentAST, (AST) tmp90_AST); - match(ID); - property_AST = (Spring.Expressions.SpringAST) currentAST.root; - } - catch (RecognitionException ex) - { - if (0 == inputState.guessing) - { - reportError(ex); - recover(ex, tokenSet_2_); - } - else - { - throw ex; - } - } - - returnAST = property_AST; - } - - public void argument() //throws RecognitionException, TokenStreamException - { - returnAST = null; - ASTPair currentAST = new ASTPair(); - Spring.Expressions.SpringAST argument_AST = null; - - try - { - // for error handling - expression(); - if (0 == inputState.guessing) - { - astFactory.addASTChild(ref currentAST, (AST) returnAST); - } - - argument_AST = (Spring.Expressions.SpringAST) currentAST.root; - } - catch (RecognitionException ex) - { - if (0 == inputState.guessing) - { - reportError(ex); - recover(ex, tokenSet_15_); - } - else - { - throw ex; - } - } - - returnAST = argument_AST; - } - - public void quotableName() //throws RecognitionException, TokenStreamException - { - returnAST = null; - ASTPair currentAST = new ASTPair(); - Spring.Expressions.SpringAST quotableName_AST = null; - - try - { - // for error handling - if ((LA(1) == STRING_LITERAL)) - { - Spring.Expressions.QualifiedIdentifier tmp91_AST = null; - tmp91_AST = (Spring.Expressions.QualifiedIdentifier) astFactory.create(LT(1), "Spring.Expressions.QualifiedIdentifier"); - astFactory.makeASTRoot(ref currentAST, (AST) tmp91_AST); - match(STRING_LITERAL); - quotableName_AST = (Spring.Expressions.SpringAST) currentAST.root; - } - else if ((LA(1) == ID)) - { - name(); - if (0 == inputState.guessing) - { - astFactory.addASTChild(ref currentAST, (AST) returnAST); - } - - quotableName_AST = (Spring.Expressions.SpringAST) currentAST.root; - } - else - { - throw new NoViableAltException(LT(1), getFilename()); - } - } - catch (RecognitionException ex) - { - if (0 == inputState.guessing) - { - reportError(ex); - recover(ex, tokenSet_16_); - } - else - { - throw ex; - } - } - - returnAST = quotableName_AST; - } - - public void name() //throws RecognitionException, TokenStreamException - { - returnAST = null; - ASTPair currentAST = new ASTPair(); - Spring.Expressions.SpringAST name_AST = null; - - try - { - // for error handling - Spring.Expressions.QualifiedIdentifier tmp92_AST = null; - tmp92_AST = (Spring.Expressions.QualifiedIdentifier) astFactory.create(LT(1), "Spring.Expressions.QualifiedIdentifier"); - astFactory.makeASTRoot(ref currentAST, (AST) tmp92_AST); - match(ID); - { - // ( ... )* - for (;;) - { - if ((tokenSet_17_.member(LA(1)))) - { - { - Spring.Expressions.SpringAST tmp93_AST = null; - tmp93_AST = (Spring.Expressions.SpringAST) astFactory.create(LT(1)); - astFactory.addASTChild(ref currentAST, (AST) tmp93_AST); - match(tokenSet_17_); - } - } - else - { - goto _loop78_breakloop; - } - } - - _loop78_breakloop: ; - } // ( ... )* - name_AST = (Spring.Expressions.SpringAST) currentAST.root; - } - catch (RecognitionException ex) - { - if (0 == inputState.guessing) - { - reportError(ex); - recover(ex, tokenSet_16_); - } - else - { - throw ex; - } - } - - returnAST = name_AST; - } - - public void qualifiedId() //throws RecognitionException, TokenStreamException - { - returnAST = null; - ASTPair currentAST = new ASTPair(); - Spring.Expressions.SpringAST qualifiedId_AST = null; - - try - { - // for error handling - Spring.Expressions.QualifiedIdentifier tmp94_AST = null; - tmp94_AST = (Spring.Expressions.QualifiedIdentifier) astFactory.create(LT(1), "Spring.Expressions.QualifiedIdentifier"); - astFactory.makeASTRoot(ref currentAST, (AST) tmp94_AST); - match(ID); - { - // ( ... )* - for (;;) - { - if ((LA(1) == DOT)) - { - Spring.Expressions.SpringAST tmp95_AST = null; - tmp95_AST = (Spring.Expressions.SpringAST) astFactory.create(LT(1)); - astFactory.addASTChild(ref currentAST, (AST) tmp95_AST); - match(DOT); - Spring.Expressions.SpringAST tmp96_AST = null; - tmp96_AST = (Spring.Expressions.SpringAST) astFactory.create(LT(1)); - astFactory.addASTChild(ref currentAST, (AST) tmp96_AST); - match(ID); - } - else - { - goto _loop114_breakloop; - } - } - - _loop114_breakloop: ; - } // ( ... )* - qualifiedId_AST = (Spring.Expressions.SpringAST) currentAST.root; - } - catch (RecognitionException ex) - { - if (0 == inputState.guessing) - { - reportError(ex); - recover(ex, tokenSet_18_); - } - else - { - throw ex; - } - } - - returnAST = qualifiedId_AST; - } - - public void ctorArgs() //throws RecognitionException, TokenStreamException - { - returnAST = null; - ASTPair currentAST = new ASTPair(); - Spring.Expressions.SpringAST ctorArgs_AST = null; - - try - { - // for error handling - match(LPAREN); - { - if ((tokenSet_9_.member(LA(1)))) - { - namedArgument(); - if (0 == inputState.guessing) - { - astFactory.addASTChild(ref currentAST, (AST) returnAST); - } - - { - // ( ... )* - for (;;) - { - if ((LA(1) == COMMA)) - { - match(COMMA); - namedArgument(); - if (0 == inputState.guessing) - { - astFactory.addASTChild(ref currentAST, (AST) returnAST); - } - } - else - { - goto _loop107_breakloop; - } - } - - _loop107_breakloop: ; - } // ( ... )* - } - else if ((LA(1) == RPAREN)) - { - } - else - { - throw new NoViableAltException(LT(1), getFilename()); - } - } - match(RPAREN); - ctorArgs_AST = (Spring.Expressions.SpringAST) currentAST.root; - } - catch (RecognitionException ex) - { - if (0 == inputState.guessing) - { - reportError(ex); - recover(ex, tokenSet_2_); - } - else - { - throw ex; - } - } - - returnAST = ctorArgs_AST; - } - - public void argList() //throws RecognitionException, TokenStreamException - { - returnAST = null; - ASTPair currentAST = new ASTPair(); - Spring.Expressions.SpringAST argList_AST = null; - - try - { - // for error handling - { - Spring.Expressions.SpringAST tmp100_AST = null; - tmp100_AST = (Spring.Expressions.SpringAST) astFactory.create(LT(1)); - astFactory.addASTChild(ref currentAST, (AST) tmp100_AST); - match(ID); - { - // ( ... )* - for (;;) - { - if ((LA(1) == COMMA)) - { - match(COMMA); - Spring.Expressions.SpringAST tmp102_AST = null; - tmp102_AST = (Spring.Expressions.SpringAST) astFactory.create(LT(1)); - astFactory.addASTChild(ref currentAST, (AST) tmp102_AST); - match(ID); - } - else - { - goto _loop87_breakloop; - } - } - - _loop87_breakloop: ; - } // ( ... )* - } - if (0 == inputState.guessing) - { - argList_AST = (Spring.Expressions.SpringAST) currentAST.root; - argList_AST = (Spring.Expressions.SpringAST) astFactory.make((AST) (Spring.Expressions.SpringAST) astFactory.create(EXPR, "args"), (AST) argList_AST); - currentAST.root = argList_AST; - if ((null != argList_AST) && (null != argList_AST.getFirstChild())) - currentAST.child = argList_AST.getFirstChild(); - else - currentAST.child = argList_AST; - currentAST.advanceChildToEnd(); - } - - argList_AST = (Spring.Expressions.SpringAST) currentAST.root; - } - catch (RecognitionException ex) - { - if (0 == inputState.guessing) - { - reportError(ex); - recover(ex, tokenSet_19_); - } - else - { - throw ex; - } - } - - returnAST = argList_AST; - } - - public void arrayConstructor() //throws RecognitionException, TokenStreamException - { - returnAST = null; - ASTPair currentAST = new ASTPair(); - Spring.Expressions.SpringAST arrayConstructor_AST = null; - Spring.Expressions.SpringAST type_AST = null; - - try - { - // for error handling - match(LITERAL_new); - qualifiedId(); - if (0 == inputState.guessing) - { - type_AST = (Spring.Expressions.SpringAST) returnAST; - } - - arrayRank(); - if (0 == inputState.guessing) - { - astFactory.addASTChild(ref currentAST, (AST) returnAST); - } - - { - if ((LA(1) == LCURLY)) - { - listInitializer(); - if (0 == inputState.guessing) - { - astFactory.addASTChild(ref currentAST, (AST) returnAST); - } - } - else if ((tokenSet_2_.member(LA(1)))) - { - } - else - { - throw new NoViableAltException(LT(1), getFilename()); - } - } - if (0 == inputState.guessing) - { - arrayConstructor_AST = (Spring.Expressions.SpringAST) currentAST.root; - arrayConstructor_AST = (Spring.Expressions.SpringAST) astFactory.make((AST) (Spring.Expressions.SpringAST) astFactory.create(EXPR, type_AST.getText(), "Spring.Expressions.ArrayConstructorNode"), (AST) arrayConstructor_AST); - currentAST.root = arrayConstructor_AST; - if ((null != arrayConstructor_AST) && (null != arrayConstructor_AST.getFirstChild())) - currentAST.child = arrayConstructor_AST.getFirstChild(); - else - currentAST.child = arrayConstructor_AST; - currentAST.advanceChildToEnd(); - } - - arrayConstructor_AST = (Spring.Expressions.SpringAST) currentAST.root; - } - catch (RecognitionException ex) - { - if (0 == inputState.guessing) - { - reportError(ex); - recover(ex, tokenSet_2_); - } - else - { - throw ex; - } - } - - returnAST = arrayConstructor_AST; - } - - public void arrayRank() //throws RecognitionException, TokenStreamException - { - returnAST = null; - ASTPair currentAST = new ASTPair(); - Spring.Expressions.SpringAST arrayRank_AST = null; - - try - { - // for error handling - Spring.Expressions.SpringAST tmp104_AST = null; - tmp104_AST = (Spring.Expressions.SpringAST) astFactory.create(LT(1)); - astFactory.makeASTRoot(ref currentAST, (AST) tmp104_AST); - match(LBRACKET); - { - if ((tokenSet_9_.member(LA(1)))) - { - expression(); - if (0 == inputState.guessing) - { - astFactory.addASTChild(ref currentAST, (AST) returnAST); - } - - { - // ( ... )* - for (;;) - { - if ((LA(1) == COMMA)) - { - match(COMMA); - expression(); - if (0 == inputState.guessing) - { - astFactory.addASTChild(ref currentAST, (AST) returnAST); - } - } - else - { - goto _loop96_breakloop; - } - } - - _loop96_breakloop: ; - } // ( ... )* - } - else if ((LA(1) == RBRACKET)) - { - } - else - { - throw new NoViableAltException(LT(1), getFilename()); - } - } - match(RBRACKET); - arrayRank_AST = (Spring.Expressions.SpringAST) currentAST.root; - } - catch (RecognitionException ex) - { - if (0 == inputState.guessing) - { - reportError(ex); - recover(ex, tokenSet_20_); - } - else - { - throw ex; - } - } - - returnAST = arrayRank_AST; - } - - public void mapEntry() //throws RecognitionException, TokenStreamException - { - returnAST = null; - ASTPair currentAST = new ASTPair(); - Spring.Expressions.SpringAST mapEntry_AST = null; - - try - { - // for error handling - expression(); - if (0 == inputState.guessing) - { - astFactory.addASTChild(ref currentAST, (AST) returnAST); - } - - match(COLON); - expression(); - if (0 == inputState.guessing) - { - astFactory.addASTChild(ref currentAST, (AST) returnAST); - } - - if (0 == inputState.guessing) - { - mapEntry_AST = (Spring.Expressions.SpringAST) currentAST.root; - mapEntry_AST = (Spring.Expressions.SpringAST) astFactory.make((AST) (Spring.Expressions.SpringAST) astFactory.create(EXPR, "entry", "Spring.Expressions.MapEntryNode"), (AST) mapEntry_AST); - currentAST.root = mapEntry_AST; - if ((null != mapEntry_AST) && (null != mapEntry_AST.getFirstChild())) - currentAST.child = mapEntry_AST.getFirstChild(); - else - currentAST.child = mapEntry_AST; - currentAST.advanceChildToEnd(); - } - - mapEntry_AST = (Spring.Expressions.SpringAST) currentAST.root; - } - catch (RecognitionException ex) - { - if (0 == inputState.guessing) - { - reportError(ex); - recover(ex, tokenSet_21_); - } - else - { - throw ex; - } - } - - returnAST = mapEntry_AST; - } - - public void namedArgument() //throws RecognitionException, TokenStreamException - { - returnAST = null; - ASTPair currentAST = new ASTPair(); - Spring.Expressions.SpringAST namedArgument_AST = null; - - try - { - // for error handling - bool synPredMatched111 = false; - if (((LA(1) == ID) && (LA(2) == ASSIGN))) - { - int _m111 = mark(); - synPredMatched111 = true; - inputState.guessing++; - try - { - { - match(ID); - match(ASSIGN); - } - } - catch (RecognitionException) - { - synPredMatched111 = false; - } - - rewind(_m111); - inputState.guessing--; - } - - if (synPredMatched111) - { - Spring.Expressions.NamedArgumentNode tmp108_AST = null; - tmp108_AST = (Spring.Expressions.NamedArgumentNode) astFactory.create(LT(1), "Spring.Expressions.NamedArgumentNode"); - astFactory.makeASTRoot(ref currentAST, (AST) tmp108_AST); - match(ID); - match(ASSIGN); - expression(); - if (0 == inputState.guessing) - { - astFactory.addASTChild(ref currentAST, (AST) returnAST); - } - - namedArgument_AST = (Spring.Expressions.SpringAST) currentAST.root; - } - else if ((tokenSet_9_.member(LA(1))) && (tokenSet_22_.member(LA(2)))) - { - argument(); - if (0 == inputState.guessing) - { - astFactory.addASTChild(ref currentAST, (AST) returnAST); - } - - namedArgument_AST = (Spring.Expressions.SpringAST) currentAST.root; - } - else - { - throw new NoViableAltException(LT(1), getFilename()); - } - } - catch (RecognitionException ex) - { - if (0 == inputState.guessing) - { - reportError(ex); - recover(ex, tokenSet_23_); - } - else - { - throw ex; - } - } - - returnAST = namedArgument_AST; - } - - public void boolLiteral() //throws RecognitionException, TokenStreamException - { - returnAST = null; - ASTPair currentAST = new ASTPair(); - Spring.Expressions.SpringAST boolLiteral_AST = null; - - try - { - // for error handling - if ((LA(1) == TRUE)) - { - Spring.Expressions.BooleanLiteralNode tmp110_AST = null; - tmp110_AST = (Spring.Expressions.BooleanLiteralNode) astFactory.create(LT(1), "Spring.Expressions.BooleanLiteralNode"); - astFactory.addASTChild(ref currentAST, (AST) tmp110_AST); - match(TRUE); - boolLiteral_AST = (Spring.Expressions.SpringAST) currentAST.root; - } - else if ((LA(1) == FALSE)) - { - Spring.Expressions.BooleanLiteralNode tmp111_AST = null; - tmp111_AST = (Spring.Expressions.BooleanLiteralNode) astFactory.create(LT(1), "Spring.Expressions.BooleanLiteralNode"); - astFactory.addASTChild(ref currentAST, (AST) tmp111_AST); - match(FALSE); - boolLiteral_AST = (Spring.Expressions.SpringAST) currentAST.root; - } - else - { - throw new NoViableAltException(LT(1), getFilename()); - } - } - catch (RecognitionException ex) - { - if (0 == inputState.guessing) - { - reportError(ex); - recover(ex, tokenSet_2_); - } - else - { - throw ex; - } - } - - returnAST = boolLiteral_AST; - } - - public new Spring.Expressions.SpringAST getAST() - { - return (Spring.Expressions.SpringAST) returnAST; - } - - private void initializeFactory() - { - if (astFactory == null) - { - astFactory = new ASTFactory("Spring.Expressions.SpringAST"); - } - - initializeASTFactory(astFactory); - } - - static public void initializeASTFactory(ASTFactory factory) - { - factory.setMaxNodeType(71); - } - - public static readonly string[] tokenNames_ = new string[] { @"""<0>""", @"""EOF""", @"""<2>""", @"""NULL_TREE_LOOKAHEAD""", @"""EXPR""", @"""OPERAND""", @"""false""", @"""true""", @"""and""", @"""or""", @"""xor""", @"""in""", @"""is""", @"""between""", @"""like""", @"""matches""", @"""null""", @"""LPAREN""", @"""SEMI""", @"""RPAREN""", @"""ASSIGN""", @"""DEFAULT""", @"""QMARK""", @"""COLON""", @"""PLUS""", @"""MINUS""", @"""STAR""", @"""DIV""", @"""MOD""", @"""POWER""", @"""BANG""", @"""DOT""", @"""POUND""", @"""ID""", @"""DOLLAR""", @"""COMMA""", @"""AT""", @"""LBRACKET""", @"""RBRACKET""", @"""PROJECT""", @"""RCURLY""", @"""SELECT""", @"""SELECT_FIRST""", @"""SELECT_LAST""", @"""TYPE""", @"""QUOTE""", @"""STRING_LITERAL""", @"""LAMBDA""", @"""PIPE""", @"""new""", @"""LCURLY""", @"""INTEGER_LITERAL""", @"""HEXADECIMAL_INTEGER_LITERAL""", @"""REAL_LITERAL""", @"""EQUAL""", @"""NOT_EQUAL""", @"""LESS_THAN""", @"""LESS_THAN_OR_EQUAL""", @"""GREATER_THAN""", @"""GREATER_THAN_OR_EQUAL""", @"""WS""", @"""BACKTICK""", @"""BACKSLASH""", @"""DOT_ESCAPED""", @"""APOS""", @"""NUMERIC_LITERAL""", @"""DECIMAL_DIGIT""", @"""INTEGER_TYPE_SUFFIX""", @"""HEX_DIGIT""", @"""EXPONENT_PART""", @"""SIGN""", @"""REAL_TYPE_SUFFIX""" }; - - private static long[] mk_tokenSet_0_() - { - long[] data = { 2L, 0L }; - return data; - } - - public static readonly BitSet tokenSet_0_ = new BitSet(mk_tokenSet_0_()); - - private static long[] mk_tokenSet_1_() - { - long[] data = { 1408758448130L, 0L }; - return data; - } - - public static readonly BitSet tokenSet_1_ = new BitSet(mk_tokenSet_1_()); - - private static long[] mk_tokenSet_2_() - { - long[] data = { 1134924607015288578L, 0L }; - return data; - } - - public static readonly BitSet tokenSet_2_ = new BitSet(mk_tokenSet_2_()); - - private static long[] mk_tokenSet_3_() - { - long[] data = { 1408765788162L, 0L }; - return data; - } - - public static readonly BitSet tokenSet_3_ = new BitSet(mk_tokenSet_3_()); - - private static long[] mk_tokenSet_4_() - { - long[] data = { 1408765788674L, 0L }; - return data; - } - - public static readonly BitSet tokenSet_4_ = new BitSet(mk_tokenSet_4_()); - - private static long[] mk_tokenSet_5_() - { - long[] data = { 1408765789698L, 0L }; - return data; - } - - public static readonly BitSet tokenSet_5_ = new BitSet(mk_tokenSet_5_()); - - private static long[] mk_tokenSet_6_() - { - long[] data = { 1134907106097428480L, 0L }; - return data; - } - - public static readonly BitSet tokenSet_6_ = new BitSet(mk_tokenSet_6_()); - - private static long[] mk_tokenSet_7_() - { - long[] data = { 1408765789954L, 0L }; - return data; - } - - public static readonly BitSet tokenSet_7_ = new BitSet(mk_tokenSet_7_()); - - private static long[] mk_tokenSet_8_() - { - long[] data = { 1134908514863218434L, 0L }; - return data; - } - - public static readonly BitSet tokenSet_8_ = new BitSet(mk_tokenSet_8_()); - - private static long[] mk_tokenSet_9_() - { - long[] data = { 17696327240712384L, 0L }; - return data; - } - - public static readonly BitSet tokenSet_9_ = new BitSet(mk_tokenSet_9_()); - - private static long[] mk_tokenSet_10_() - { - long[] data = { 1134908514913550082L, 0L }; - return data; - } - - public static readonly BitSet tokenSet_10_ = new BitSet(mk_tokenSet_10_()); - - private static long[] mk_tokenSet_11_() - { - long[] data = { 1134908515383312130L, 0L }; - return data; - } - - public static readonly BitSet tokenSet_11_ = new BitSet(mk_tokenSet_11_()); - - private static long[] mk_tokenSet_12_() - { - long[] data = { 17696326116638912L, 0L }; - return data; - } - - public static readonly BitSet tokenSet_12_ = new BitSet(mk_tokenSet_12_()); - - private static long[] mk_tokenSet_13_() - { - long[] data = { 1134908515920183042L, 0L }; - return data; - } - - public static readonly BitSet tokenSet_13_ = new BitSet(mk_tokenSet_13_()); - - private static long[] mk_tokenSet_14_() - { - long[] data = { 16091095105536L, 0L }; - return data; - } - - public static readonly BitSet tokenSet_14_ = new BitSet(mk_tokenSet_14_()); - - private static long[] mk_tokenSet_15_() - { - long[] data = { 309238169600L, 0L }; - return data; - } - - public static readonly BitSet tokenSet_15_ = new BitSet(mk_tokenSet_15_()); - - private static long[] mk_tokenSet_16_() - { - long[] data = { 8912896L, 0L }; - return data; - } - - public static readonly BitSet tokenSet_16_ = new BitSet(mk_tokenSet_16_()); - - private static long[] mk_tokenSet_17_() - { - long[] data = { -35184381001744L, 255L, 0L, 0L }; - return data; - } - - public static readonly BitSet tokenSet_17_ = new BitSet(mk_tokenSet_17_()); - - private static long[] mk_tokenSet_18_() - { - long[] data = { 412316991488L, 0L }; - return data; - } - - public static readonly BitSet tokenSet_18_ = new BitSet(mk_tokenSet_18_()); - - private static long[] mk_tokenSet_19_() - { - long[] data = { 281474976710656L, 0L }; - return data; - } - - public static readonly BitSet tokenSet_19_ = new BitSet(mk_tokenSet_19_()); - - private static long[] mk_tokenSet_20_() - { - long[] data = { 1136050506922131202L, 0L }; - return data; - } - - public static readonly BitSet tokenSet_20_ = new BitSet(mk_tokenSet_20_()); - - private static long[] mk_tokenSet_21_() - { - long[] data = { 1133871366144L, 0L }; - return data; - } - - public static readonly BitSet tokenSet_21_ = new BitSet(mk_tokenSet_21_()); - - private static long[] mk_tokenSet_22_() - { - long[] data = { 1152884945836572608L, 0L }; - return data; - } - - public static readonly BitSet tokenSet_22_ = new BitSet(mk_tokenSet_22_()); - - private static long[] mk_tokenSet_23_() - { - long[] data = { 34360262656L, 0L }; - return data; - } - - public static readonly BitSet tokenSet_23_ = new BitSet(mk_tokenSet_23_()); -} diff --git a/src/Spring/Spring.Core/Expressions/Parser/ExpressionParserTokenTypes.cs b/src/Spring/Spring.Core/Expressions/Parser/ExpressionParserTokenTypes.cs index 4a7f760d1..1aa1c402d 100644 --- a/src/Spring/Spring.Core/Expressions/Parser/ExpressionParserTokenTypes.cs +++ b/src/Spring/Spring.Core/Expressions/Parser/ExpressionParserTokenTypes.cs @@ -1,7 +1,9 @@ -// $ANTLR 2.7.6 (2005-12-22): "Expression.g" -> "ExpressionLexer.cs"$ - namespace Spring.Expressions.Parser; +/// +/// The values of : the token a node comes from, or when it comes from +/// a whole grammar rule. Part of the serialized form of a parsed expression. +/// public class ExpressionParserTokenTypes { public const int EOF = 1; diff --git a/src/Spring/Spring.Core/Expressions/Parser/ExpressionParserTokenTypes.txt b/src/Spring/Spring.Core/Expressions/Parser/ExpressionParserTokenTypes.txt deleted file mode 100644 index bd2a50213..000000000 --- a/src/Spring/Spring.Core/Expressions/Parser/ExpressionParserTokenTypes.txt +++ /dev/null @@ -1,70 +0,0 @@ -// $ANTLR 2.7.6 (2005-12-22): Expression.g -> ExpressionParserTokenTypes.txt$ -ExpressionParser // output token vocab name -EXPR=4 -OPERAND=5 -FALSE="false"=6 -TRUE="true"=7 -AND="and"=8 -OR="or"=9 -XOR="xor"=10 -IN="in"=11 -IS="is"=12 -BETWEEN="between"=13 -LIKE="like"=14 -MATCHES="matches"=15 -NULL_LITERAL="null"=16 -LPAREN=17 -SEMI=18 -RPAREN=19 -ASSIGN=20 -DEFAULT=21 -QMARK=22 -COLON=23 -PLUS=24 -MINUS=25 -STAR=26 -DIV=27 -MOD=28 -POWER=29 -BANG=30 -DOT=31 -POUND=32 -ID=33 -DOLLAR=34 -COMMA=35 -AT=36 -LBRACKET=37 -RBRACKET=38 -PROJECT=39 -RCURLY=40 -SELECT=41 -SELECT_FIRST=42 -SELECT_LAST=43 -TYPE=44 -QUOTE=45 -STRING_LITERAL=46 -LAMBDA=47 -PIPE=48 -LITERAL_new="new"=49 -LCURLY=50 -INTEGER_LITERAL=51 -HEXADECIMAL_INTEGER_LITERAL=52 -REAL_LITERAL=53 -EQUAL=54 -NOT_EQUAL=55 -LESS_THAN=56 -LESS_THAN_OR_EQUAL=57 -GREATER_THAN=58 -GREATER_THAN_OR_EQUAL=59 -WS=60 -BACKTICK=61 -BACKSLASH=62 -DOT_ESCAPED=63 -APOS=64 -NUMERIC_LITERAL=65 -DECIMAL_DIGIT=66 -INTEGER_TYPE_SUFFIX=67 -HEX_DIGIT=68 -EXPONENT_PART=69 -SIGN=70 -REAL_TYPE_SUFFIX=71 diff --git a/src/Spring/Spring.Core/Expressions/Parser/antlr/ANTLRException.cs b/src/Spring/Spring.Core/Expressions/Parser/antlr/ANTLRException.cs deleted file mode 100644 index f1c084dad..000000000 --- a/src/Spring/Spring.Core/Expressions/Parser/antlr/ANTLRException.cs +++ /dev/null @@ -1,33 +0,0 @@ -namespace Spring.Expressions.Parser.antlr; - -/*ANTLR Translator Generator - * Project led by Terence Parr at http://www.jGuru.com - * Software rights: http://www.antlr.org/license.html - * - * $Id:$ - */ - -// -// ANTLR C# Code Generator by Micheal Jordan -// Kunle Odutola : kunle UNDERSCORE odutola AT hotmail DOT com -// Anthony Oguntimehin -// -// With many thanks to Eric V. Smith from the ANTLR list. -// -using System; - -[Serializable] -public class ANTLRException : Exception -{ - public ANTLRException() : base() - { - } - - public ANTLRException(string s) : base(s) - { - } - - public ANTLRException(string s, Exception inner) : base(s, inner) - { - } -} diff --git a/src/Spring/Spring.Core/Expressions/Parser/antlr/ANTLRPanicException.cs b/src/Spring/Spring.Core/Expressions/Parser/antlr/ANTLRPanicException.cs deleted file mode 100644 index 09a8082b0..000000000 --- a/src/Spring/Spring.Core/Expressions/Parser/antlr/ANTLRPanicException.cs +++ /dev/null @@ -1,33 +0,0 @@ -namespace Spring.Expressions.Parser.antlr; - -/*ANTLR Translator Generator - * Project led by Terence Parr at http://www.jGuru.com - * Software rights: http://www.antlr.org/license.html - * - * $Id:$ - */ - -// -// ANTLR C# Code Generator by Micheal Jordan -// Kunle Odutola : kunle UNDERSCORE odutola AT hotmail DOT com -// Anthony Oguntimehin -// -// With many thanks to Eric V. Smith from the ANTLR list. -// -using System; - -[Serializable] -public class ANTLRPanicException : ANTLRException -{ - public ANTLRPanicException() : base() - { - } - - public ANTLRPanicException(string s) : base(s) - { - } - - public ANTLRPanicException(string s, Exception inner) : base(s, inner) - { - } -} diff --git a/src/Spring/Spring.Core/Expressions/Parser/antlr/ASTFactory.cs b/src/Spring/Spring.Core/Expressions/Parser/antlr/ASTFactory.cs deleted file mode 100644 index 4986e6127..000000000 --- a/src/Spring/Spring.Core/Expressions/Parser/antlr/ASTFactory.cs +++ /dev/null @@ -1,717 +0,0 @@ -using System.Collections; -using Assembly = System.Reflection.Assembly; -using Debug = System.Diagnostics.Debug; -using AST = Spring.Expressions.Parser.antlr.collections.AST; -using ASTArray = Spring.Expressions.Parser.antlr.collections.impl.ASTArray; - -namespace Spring.Expressions.Parser.antlr; -/*ANTLR Translator Generator - * Project led by Terence Parr at http://www.jGuru.com - * Software rights: http://www.antlr.org/license.html - * - * $Id:$ - */ - -// -// ANTLR C# Code Generator by Micheal Jordan -// Kunle Odutola : kunle UNDERSCORE odutola AT hotmail DOT com -// Anthony Oguntimehin -// -// With many thanks to Eric V. Smith from the ANTLR list. -// - -// HISTORY: -// -// 19-Aug-2002 kunle Augmented the basic flexibility of the default ASTFactory with a map -// of TokenID-to-NodeTypeName. It's now a proper GoF-style Factory ;-) -// - -/// -/// AST Support code shared by TreeParser and Parser. -/// -/// -/// -/// We use delegation to share code (and have only one -/// bit of code to maintain) rather than subclassing -/// or superclassing (forces AST support code to be -/// loaded even when you don't want to do AST stuff). -/// -/// -/// Typically, is used to specify the -/// homogeneous type of node to create, but you can override -/// to make heterogeneous nodes etc... -/// -/// -public class ASTFactory -{ - //--------------------------------------------------------------------- - // CONSTRUCTORS - //--------------------------------------------------------------------- - - /// - /// Constructs an ASTFactory with the default AST node type of - /// . - /// - public ASTFactory() : this(typeof(antlr.CommonAST)) - { - } - - /// - /// Constructs an ASTFactory and use the specified AST node type - /// as the default. - /// - /// - /// Name of default AST node type for this factory. - /// - public ASTFactory(string nodeTypeName) - : this(loadNodeTypeObject(nodeTypeName)) - { - } - - /// - /// Constructs an ASTFactory and use the specified AST node type - /// as the default. - /// - /// - /// MetaType of default AST node type for this factory. - /// - public ASTFactory(Type nodeType) - { - heteroList_ = new FactoryEntry[Token.MIN_USER_TYPE + 1]; - defaultASTNodeTypeObject_ = nodeType; - defaultCreator_ = null; - typename2creator_ = new Hashtable(32, (float) 0.3); - typename2creator_[typeof(antlr.CommonAST).FullName] = CommonAST.Creator; - typename2creator_[typeof(antlr.CommonASTWithHiddenTokens).FullName] = CommonASTWithHiddenTokens.Creator; - } - - //--------------------------------------------------------------------- - // DATA MEMBERS - //--------------------------------------------------------------------- - - /// - /// Stores the Type of the default AST node class to be used during tree construction. - /// - protected Type defaultASTNodeTypeObject_; - - protected ASTNodeCreator defaultCreator_; - - /// - /// Stores the mapping between custom AST NodeTypes and their NodeTypeName/NodeTypeClass - /// and ASTNodeCreator. - /// - protected FactoryEntry[] heteroList_; - - /// - /// Stores the mapping between AST node typenames and their token ID. - /// - protected Hashtable typename2creator_; - - //--------------------------------------------------------------------- - // FUNCTION MEMBERS - //--------------------------------------------------------------------- - - /// - /// Specify an "override" for the type created for - /// the specified Token type. - /// - /// - /// This method is useful for situations that ANTLR cannot oridinarily deal - /// with (i.e., when you create a token based upon a nonliteral token symbol - /// like #[LT(1)]. This is a runtime value and ANTLR cannot determine the token - /// type (and hence the AST) statically. - /// - /// Token type to override. - /// - /// Fully qualified AST typename (or null to specify - /// the factory's default AST type). - /// - public void setTokenTypeASTNodeType(int tokenType, string NodeTypeName) - { - // check validity of arguments... - if (tokenType < Token.MIN_USER_TYPE) - throw new ANTLRException("Internal parser error: Cannot change AST Node Type for Token ID '" + tokenType + "'"); - - // resize up to and including 'type' and initialize any gaps to default - // factory. - if (tokenType > (heteroList_.Length + 1)) - setMaxNodeType(tokenType); - // And add new thing.. - if (heteroList_[tokenType] == null) - heteroList_[tokenType] = new FactoryEntry(loadNodeTypeObject(NodeTypeName)); - else - heteroList_[tokenType].NodeTypeObject = loadNodeTypeObject(NodeTypeName); - } - - /// - /// Register an AST Node Type for a given Token type ID. - /// - /// The Token type ID. - /// The AST Node Type to register. - [Obsolete("Replaced by setTokenTypeASTNodeType(int, string) since version 2.7.2.6", true)] - public void registerFactory(int NodeType, string NodeTypeName) - { - setTokenTypeASTNodeType(NodeType, NodeTypeName); - } - - /// - /// Register an ASTNodeCreator for a given Token type ID. - /// - /// The Token type ID. - /// The creater to register. - public void setTokenTypeASTNodeCreator(int NodeType, ASTNodeCreator creator) - { - // check validity of arguments... - if (NodeType < Token.MIN_USER_TYPE) - throw new ANTLRException("Internal parser error: Cannot change AST Node Type for Token ID '" + NodeType + "'"); - - // resize up to and including 'type' and initialize any gaps to default - // factory. - if (NodeType > (heteroList_.Length + 1)) - setMaxNodeType(NodeType); - // And add new thing.. - if (heteroList_[NodeType] == null) - heteroList_[NodeType] = new FactoryEntry(creator); - else - heteroList_[NodeType].Creator = creator; - - //typename2creator_[NodeType.ToString()] = creator; - typename2creator_[creator.ASTNodeTypeName] = creator; - } - - /// - /// Register an ASTNodeCreator to be used for creating node by default. - /// - /// The ASTNodeCreator. - public void setASTNodeCreator(ASTNodeCreator creator) - { - defaultCreator_ = creator; - } - - /// - /// Pre-expands the internal list of TokenTypeID-to-ASTNodeType mappings - /// to the specified size. - /// This is primarily a convenience method that can be used to prevent - /// unnecessary and costly re-org of the mappings list. - /// - /// Maximum Token Type ID. - public void setMaxNodeType(int NodeType) - { - //Debug.WriteLine(this, "NodeType = " + NodeType + " and NodeList.Length = " + nodeTypeList_.Length); - if (heteroList_ == null) - { - heteroList_ = new FactoryEntry[NodeType + 1]; - } - else - { - int length = heteroList_.Length; - - if (NodeType >= length) - { - FactoryEntry[] newList = new FactoryEntry[NodeType + 1]; - Array.Copy(heteroList_, 0, newList, 0, length); - heteroList_ = newList; - } - else if (NodeType < length) - { - FactoryEntry[] newList = new FactoryEntry[NodeType + 1]; - Array.Copy(heteroList_, 0, newList, 0, (NodeType + 1)); - heteroList_ = newList; - } - } - //Debug.WriteLine(this, "NodeType = " + NodeType + " and NodeList.Length = " + nodeTypeList_.Length); - } - - /// - /// Add a child to the current AST - /// - /// The AST to add a child to - /// The child AST to be added - public virtual void addASTChild(ref ASTPair currentAST, AST child) - { - if (child != null) - { - if (currentAST.root == null) - { - // Make new child the current root - currentAST.root = child; - } - else - { - if (currentAST.child == null) - { - // Add new child to current root - currentAST.root.setFirstChild(child); - } - else - { - currentAST.child.setNextSibling(child); - } - } - - // Make new child the current child - currentAST.child = child; - currentAST.advanceChildToEnd(); - } - } - - /// - /// Creates a new uninitialized AST node. Since a specific AST Node Type - /// wasn't indicated, the new AST node is created using the current default - /// AST Node type - - /// - /// An uninitialized AST node object. - public virtual AST create() - { - AST newNode; - - if (defaultCreator_ == null) - newNode = createFromNodeTypeObject(defaultASTNodeTypeObject_); - else - newNode = defaultCreator_.Create(); - - return newNode; - } - - /// - /// Creates and initializes a new AST node using the specified Token Type ID. - /// The used for creating this new AST node is - /// determined by the following: - /// - /// the current TokenTypeID-to-ASTNodeType mapping (if any) or, - /// the otherwise - /// - /// - /// Token type ID to be used to create new AST Node. - /// An initialized AST node object. - public virtual AST create(int type) - { - AST newNode = createFromNodeType(type); - newNode.initialize(type, ""); - return newNode; - } - - /// - /// Creates and initializes a new AST node using the specified Token Type ID. - /// The used for creating this new AST node is - /// determined by the following: - /// - /// the current TokenTypeID-to-ASTNodeType mapping (if any) or, - /// the otherwise - /// - /// - /// Token type ID to be used to create new AST Node. - /// Text for initializing the new AST Node. - /// An initialized AST node object. - public virtual AST create(int type, string txt) - { - AST newNode = createFromNodeType(type); - newNode.initialize(type, txt); - return newNode; - } - - /// - /// Creates a new AST node using the specified AST Node Type name. Once created, - /// the new AST node is initialized with the specified Token type ID and string. - /// The used for creating this new AST node is - /// determined solely by ASTNodeTypeName. - /// The AST Node type must have a default/parameterless constructor. - /// - /// Token type ID to be used to create new AST Node. - /// Text for initializing the new AST Node. - /// Fully qualified name of the Type to be used for creating the new AST Node. - /// An initialized AST node object. - public virtual AST create(int type, string txt, string ASTNodeTypeName) - { - AST newNode = createFromNodeName(ASTNodeTypeName); - newNode.initialize(type, txt); - return newNode; - } - - /// - /// Creates a new AST node using the specified AST Node Type name. - /// - /// Token instance to be used to initialize the new AST Node. - /// - /// Fully qualified name of the Type to be used for creating the new AST Node. - /// - /// A newly created and initialized AST node object. - /// - /// Once created, the new AST node is initialized with the specified Token - /// instance. The used for creating this new AST - /// node is determined solely by ASTNodeTypeName. - /// The AST Node type must have a default/parameterless constructor. - /// - public virtual AST create(IToken tok, string ASTNodeTypeName) - { - AST newNode = createFromNodeName(ASTNodeTypeName); - newNode.initialize(tok); - return newNode; - } - - /// - /// Creates and initializes a new AST node using the specified AST Node instance. - /// the new AST node is initialized with the specified Token type ID and string. - /// The used for creating this new AST node is - /// determined solely by aNode. - /// The AST Node type must have a default/parameterless constructor. - /// - /// AST Node instance to be used for creating the new AST Node. - /// An initialized AST node object. - public virtual AST create(AST aNode) - { - AST newNode; - - if (aNode == null) - newNode = null; - else - { - newNode = createFromAST(aNode); - newNode.initialize(aNode); - } - - return newNode; - } - - /// - /// Creates and initializes a new AST node using the specified Token instance. - /// The used for creating this new AST node is - /// determined by the following: - /// - /// the current TokenTypeID-to-ASTNodeType mapping (if any) or, - /// the otherwise - /// - /// - /// Token instance to be used to create new AST Node. - /// An initialized AST node object. - public virtual AST create(IToken tok) - { - AST newNode; - - if (tok == null) - newNode = null; - else - { - newNode = createFromNodeType(tok.Type); - newNode.initialize(tok); - } - - return newNode; - } - - /// - /// Returns a copy of the specified AST Node instance. The copy is obtained by - /// using the method Clone(). - /// - /// AST Node to copy. - /// An AST Node (or null if t is null). - public virtual AST dup(AST t) - { - // The Java version is implemented using code like this: - if (t == null) - return null; - - AST dup_edNode = createFromAST(t); - dup_edNode.initialize(t); - return dup_edNode; - } - - /// - /// Duplicate AST Node tree rooted at specified AST node and all of it's siblings. - /// - /// Root of AST Node tree. - /// Root node of new AST Node tree (or null if t is null). - public virtual AST dupList(AST t) - { - AST result = dupTree(t); // if t == null, then result==null - AST nt = result; - while (t != null) - { - // for each sibling of the root - t = t.getNextSibling(); - nt.setNextSibling(dupTree(t)); // dup each subtree, building new tree - nt = nt.getNextSibling(); - } - - return result; - } - - /// - /// Duplicate AST Node tree rooted at specified AST node. Ignore it's siblings. - /// - /// Root of AST Node tree. - /// Root node of new AST Node tree (or null if t is null). - public virtual AST dupTree(AST t) - { - AST result = dup(t); // make copy of root - // copy all children of root. - if (t != null) - { - result.setFirstChild(dupList(t.getFirstChild())); - } - - return result; - } - - /// - /// Make a tree from a list of nodes. The first element in the - /// array is the root. If the root is null, then the tree is - /// a simple list not a tree. Handles null children nodes correctly. - /// For example, build(a, b, null, c) yields tree (a b c). build(null,a,b) - /// yields tree (nil a b). - /// - /// List of Nodes. - /// AST Node tree. - public virtual AST make(params AST[] nodes) - { - if (nodes == null || nodes.Length == 0) - return null; - AST root = nodes[0]; - AST tail = null; - if (root != null) - { - root.setFirstChild(null); // don't leave any old pointers set - } - - // link in children; - for (int i = 1; i < nodes.Length; i++) - { - if (nodes[i] == null) - continue; - // ignore null nodes - if (root == null) - { - // Set the root and set it up for a flat list - root = (tail = nodes[i]); - } - else if (tail == null) - { - root.setFirstChild(nodes[i]); - tail = root.getFirstChild(); - } - else - { - tail.setNextSibling(nodes[i]); - tail = tail.getNextSibling(); - } - - // Chase tail to last sibling - while (tail.getNextSibling() != null) - { - tail = tail.getNextSibling(); - } - } - - return root; - } - - /// - /// Make a tree from a list of nodes, where the nodes are contained - /// in an ASTArray object. - /// - /// List of Nodes. - /// AST Node tree. - public virtual AST make(ASTArray nodes) - { - return make(nodes.array); - } - - /// - /// Make an AST the root of current AST. - /// - /// - /// - public virtual void makeASTRoot(ref ASTPair currentAST, AST root) - { - if (root != null) - { - // Add the current root as a child of new root - root.addChild(currentAST.root); - // The new current child is the last sibling of the old root - currentAST.child = currentAST.root; - currentAST.advanceChildToEnd(); - // Set the new root - currentAST.root = root; - } - } - - /// - /// Sets the global default AST Node Type for this ASTFactory instance. - /// This method also attempts to load the instance - /// for the specified typename. - /// - /// Fully qualified AST Node Type name. - public virtual void setASTNodeType(string t) - { - if (defaultCreator_ != null) - { - if (t != defaultCreator_.ASTNodeTypeName) - { - defaultCreator_ = null; - } - } - - defaultASTNodeTypeObject_ = loadNodeTypeObject(t); - } - - /// - /// To change where error messages go, can subclass/override this method - /// and then setASTFactory in Parser and TreeParser. This method removes - /// a prior dependency on class antlr.Tool. - /// - /// - public virtual void error(string e) - { - Console.Error.WriteLine(e); - } - - //--------------------------------------------------------------------- - // PRIVATE FUNCTION MEMBERS - //--------------------------------------------------------------------- - - private static Type loadNodeTypeObject(string nodeTypeName) - { - Type nodeTypeObject = null; - bool typeCreated = false; - - if (nodeTypeName != null) - { - foreach (Assembly assem in AppDomain.CurrentDomain.GetAssemblies()) - { - try - { - nodeTypeObject = assem.GetType(nodeTypeName); - if (nodeTypeObject != null) - { - typeCreated = true; - break; - } - } - catch - { - typeCreated = false; - } - } - } - - if (!typeCreated) - { - throw new TypeLoadException("Unable to load AST Node Type: '" + nodeTypeName + "'"); - } - - return nodeTypeObject; - } - - private AST createFromAST(AST node) - { - AST newNode = null; - Type nodeAsTypeObj = node.GetType(); - - ASTNodeCreator creator = (ASTNodeCreator) typename2creator_[nodeAsTypeObj.FullName]; - if (creator != null) - { - newNode = creator.Create(); - if (newNode == null) - { - throw new ArgumentException("Unable to create AST Node Type: '" + nodeAsTypeObj.FullName + "'"); - } - } - else - { - newNode = createFromNodeTypeObject(nodeAsTypeObj); - } - - return newNode; - } - - private AST createFromNodeName(string nodeTypeName) - { - AST newNode = null; - - ASTNodeCreator creator = (ASTNodeCreator) typename2creator_[nodeTypeName]; - if (creator != null) - { - newNode = creator.Create(); - if (newNode == null) - { - throw new ArgumentException("Unable to create AST Node Type: '" + nodeTypeName + "'"); - } - } - else - { - newNode = createFromNodeTypeObject(loadNodeTypeObject(nodeTypeName)); - } - - return newNode; - } - - private AST createFromNodeType(int nodeTypeIndex) - { - Debug.Assert((nodeTypeIndex >= 0) && (nodeTypeIndex <= heteroList_.Length), "Invalid AST node type!"); - AST newNode = null; - - FactoryEntry entry = heteroList_[nodeTypeIndex]; - if ((entry != null) && (entry.Creator != null)) - { - newNode = entry.Creator.Create(); - } - else - { - if ((entry == null) || (entry.NodeTypeObject == null)) - { - if (defaultCreator_ == null) - { - newNode = createFromNodeTypeObject(defaultASTNodeTypeObject_); - } - else - newNode = defaultCreator_.Create(); - } - else - newNode = createFromNodeTypeObject(entry.NodeTypeObject); - } - - return newNode; - } - - private AST createFromNodeTypeObject(Type nodeTypeObject) - { - AST newNode = null; - - try - { - newNode = (AST) Activator.CreateInstance(nodeTypeObject); - if (newNode == null) - { - throw new ArgumentException("Unable to create AST Node Type: '" + nodeTypeObject.FullName + "'"); - } - } - catch (Exception ex) - { - throw new ArgumentException("Unable to create AST Node Type: '" + nodeTypeObject.FullName + "'", ex); - } - - return newNode; - } - - protected class FactoryEntry - { - public FactoryEntry(Type typeObj, ASTNodeCreator creator) - { - NodeTypeObject = typeObj; - Creator = creator; - } - - public FactoryEntry(Type typeObj) - { - NodeTypeObject = typeObj; - } - - public FactoryEntry(ASTNodeCreator creator) - { - Creator = creator; - } - - public Type NodeTypeObject; - public ASTNodeCreator Creator; - } -} diff --git a/src/Spring/Spring.Core/Expressions/Parser/antlr/ASTNULLType.cs b/src/Spring/Spring.Core/Expressions/Parser/antlr/ASTNULLType.cs deleted file mode 100644 index 7b9767530..000000000 --- a/src/Spring/Spring.Core/Expressions/Parser/antlr/ASTNULLType.cs +++ /dev/null @@ -1,137 +0,0 @@ -using IEnumerator = System.Collections.IEnumerator; -using AST = Spring.Expressions.Parser.antlr.collections.AST; - -namespace Spring.Expressions.Parser.antlr; -/*ANTLR Translator Generator - * Project led by Terence Parr at http://www.jGuru.com - * Software rights: http://www.antlr.org/license.html - * - * $Id:$ - */ - -// -// ANTLR C# Code Generator by Micheal Jordan -// Kunle Odutola : kunle UNDERSCORE odutola AT hotmail DOT com -// Anthony Oguntimehin -// -// With many thanks to Eric V. Smith from the ANTLR list. -// - -/*There is only one instance of this class **/ -public class ASTNULLType : AST -{ - public virtual void addChild(AST c) { } - - public virtual bool Equals(AST t) - { - return false; - } - - public virtual bool EqualsList(AST t) - { - return false; - } - - public virtual bool EqualsListPartial(AST t) - { - return false; - } - - public virtual bool EqualsTree(AST t) - { - return false; - } - - public virtual bool EqualsTreePartial(AST t) - { - return false; - } - - public virtual IEnumerator findAll(AST tree) - { - return null; - } - - public virtual IEnumerator findAllPartial(AST subtree) - { - return null; - } - - public virtual AST getFirstChild() - { - return this; - } - - public virtual AST getNextSibling() - { - return this; - } - - public virtual string getText() - { - return ""; - } - - public virtual int Type - { - get { return Token.NULL_TREE_LOOKAHEAD; } - set { ; } - } - - public int getNumberOfChildren() - { - return 0; - } - - public virtual void initialize(int t, string txt) - { - } - - public virtual void initialize(AST t) - { - } - - public virtual void initialize(IToken t) - { - } - - public virtual void setFirstChild(AST c) - { - ; - } - - public virtual void setNextSibling(AST n) - { - ; - } - - public virtual void setText(string text) - { - ; - } - - public virtual void setType(int ttype) - { - this.Type = ttype; - } - - override public string ToString() - { - return getText(); - } - - public virtual string ToStringList() - { - return getText(); - } - - public virtual string ToStringTree() - { - return getText(); - } - - public object Clone() - { - return MemberwiseClone(); - } -} diff --git a/src/Spring/Spring.Core/Expressions/Parser/antlr/ASTNodeCreator.cs b/src/Spring/Spring.Core/Expressions/Parser/antlr/ASTNodeCreator.cs deleted file mode 100644 index 114853188..000000000 --- a/src/Spring/Spring.Core/Expressions/Parser/antlr/ASTNodeCreator.cs +++ /dev/null @@ -1,50 +0,0 @@ -namespace Spring.Expressions.Parser.antlr; - -using AST = antlr.collections.AST; - -/*ANTLR Translator Generator - * Project led by Terence Parr at http://www.jGuru.com - * Software rights: http://www.antlr.org/license.html - * - * $Id:$ - */ - -// -// ANTLR C# Code Generator by Micheal Jordan -// Kunle Odutola : kunle UNDERSCORE odutola AT hotmail DOT com -// Anthony Oguntimehin -// - -/// -/// A creator of AST node instances. -/// -/// -/// -/// This class and it's sub-classes exists primarily as an optimization -/// of the reflection-based mechanism(s) previously used exclusively to -/// create instances of AST node objects. -/// -/// -/// Parsers and TreeParsers already use the ASTFactory class in ANTLR whenever -/// they need to create an AST node objeect. What this class does is to support -/// performant extensibility of the basic ASTFactory. The ASTFactory can now be -/// extnded as run-time to support more new AST node types without using needing -/// to use reflection. -/// -/// -public abstract class ASTNodeCreator -{ - /// - /// Returns the fully qualified name of the AST type that this - /// class creates. - /// - public abstract string ASTNodeTypeName - { - get; - } - - /// - /// Constructs an instance. - /// - public abstract AST Create(); -} diff --git a/src/Spring/Spring.Core/Expressions/Parser/antlr/ASTPair.cs b/src/Spring/Spring.Core/Expressions/Parser/antlr/ASTPair.cs deleted file mode 100644 index 262ac6727..000000000 --- a/src/Spring/Spring.Core/Expressions/Parser/antlr/ASTPair.cs +++ /dev/null @@ -1,64 +0,0 @@ -namespace Spring.Expressions.Parser.antlr; - -using AST = antlr.collections.AST; - -/*ANTLR Translator Generator - * Project led by Terence Parr at http://www.jGuru.com - * Software rights: http://www.antlr.org/license.html - * - * $Id:$ - */ - -// -// ANTLR C# Code Generator by Micheal Jordan -// Kunle Odutola : kunle UNDERSCORE odutola AT hotmail DOT com -// Anthony Oguntimehin -// -// With many thanks to Eric V. Smith from the ANTLR list. -// - -/*ASTPair: utility class used for manipulating a pair of ASTs - * representing the current AST root and current AST sibling. - * This exists to compensate for the lack of pointers or 'var' - * arguments in Java. - */ - -public struct ASTPair -{ - public AST root; // current root of tree - public AST child; // current child to which siblings are added - - /*Make sure that child is the last sibling */ - public void advanceChildToEnd() - { - if (child != null) - { - while (child.getNextSibling() != null) - { - child = child.getNextSibling(); - } - } - } - - /*Copy an ASTPair. Don't call it clone() because we want type-safety */ - public ASTPair copy() - { - ASTPair tmp = new ASTPair(); - tmp.root = root; - tmp.child = child; - return tmp; - } - - private void reset() - { - root = null; - child = null; - } - - override public string ToString() - { - string r = (root == null) ? "null" : root.getText(); - string c = (child == null) ? "null" : child.getText(); - return "[" + r + "," + c + "]"; - } -} diff --git a/src/Spring/Spring.Core/Expressions/Parser/antlr/ASTVisitor.cs b/src/Spring/Spring.Core/Expressions/Parser/antlr/ASTVisitor.cs deleted file mode 100644 index b11220d5a..000000000 --- a/src/Spring/Spring.Core/Expressions/Parser/antlr/ASTVisitor.cs +++ /dev/null @@ -1,25 +0,0 @@ -using AST = Spring.Expressions.Parser.antlr.collections.AST; - -namespace Spring.Expressions.Parser.antlr; -/* ANTLR Translator Generator - * Project led by Terence Parr at http://www.jGuru.com - * Software rights: http://www.antlr.org/license.html - * - * $Id:$ - */ - -// -// ANTLR C# Code Generator by Micheal Jordan -// Kunle Odutola : kunle UNDERSCORE odutola AT hotmail DOT com -// Anthony Oguntimehin -// -// With many thanks to Eric V. Smith from the ANTLR list. -// - -/// -/// Summary description for ASTVisitor. -/// -public interface ASTVisitor -{ - void visit(AST node); -} diff --git a/src/Spring/Spring.Core/Expressions/Parser/antlr/BaseAST.cs b/src/Spring/Spring.Core/Expressions/Parser/antlr/BaseAST.cs deleted file mode 100644 index 2ffa6c15b..000000000 --- a/src/Spring/Spring.Core/Expressions/Parser/antlr/BaseAST.cs +++ /dev/null @@ -1,626 +0,0 @@ -using StringBuilder = System.Text.StringBuilder; -using TextWriter = System.IO.TextWriter; -using ArrayList = System.Collections.ArrayList; -using IEnumerator = System.Collections.IEnumerator; -using AST = Spring.Expressions.Parser.antlr.collections.AST; - -namespace Spring.Expressions.Parser.antlr; -/*ANTLR Translator Generator - * Project led by Terence Parr at http://www.jGuru.com - * Software rights: http://www.antlr.org/license.html - * - * $Id:$ - */ - -// -// ANTLR C# Code Generator by Micheal Jordan -// Kunle Odutola : kunle UNDERSCORE odutola AT hotmail DOT com -// Anthony Oguntimehin -// -// With many thanks to Eric V. Smith from the ANTLR list. -// - -/* - * A Child-Sibling Tree. - * - * A tree with PLUS at the root and with two children 3 and 4 is - * structured as: - * - * PLUS - * | - * 3 -- 4 - * - * and can be specified easily in LISP notation as - * - * (PLUS 3 4) - * - * where every '(' starts a new subtree. - * - * These trees are particular useful for translators because of - * the flexibility of the children lists. They are also very easy - * to walk automatically, whereas trees with specific children - * reference fields can't easily be walked automatically. - * - * This class contains the basic support for an AST. - * Most people will create ASTs that are subclasses of - * BaseAST or of CommonAST. - */ -[Serializable()] -public abstract class BaseAST : AST -{ - protected internal BaseAST down; - protected internal BaseAST right; - - private static bool verboseStringConversion = false; - private static string[] tokenNames = null; - - /*Add a node to the end of the child list for this node */ - public virtual void addChild(AST node) - { - if (node == null) - return; - BaseAST t = this.down; - if (t != null) - { - while (t.right != null) - { - t = t.right; - } - - t.right = (BaseAST) node; - } - else - { - this.down = (BaseAST) node; - } - } - - private void doWorkForFindAll(ArrayList v, AST target, bool partialMatch) - { - AST sibling; - - // Start walking sibling lists, looking for matches. -//siblingWalk: - for (sibling = this; sibling != null; sibling = sibling.getNextSibling()) - { - if ((partialMatch && sibling.EqualsTreePartial(target)) || (!partialMatch && sibling.EqualsTree(target))) - { - v.Add(sibling); - } - - // regardless of match or not, check any children for matches - if (sibling.getFirstChild() != null) - { - ((BaseAST) sibling.getFirstChild()).doWorkForFindAll(v, target, partialMatch); - } - } - } - - public override bool Equals(object obj) - { - if (obj == null) - return false; - if (this.GetType() != obj.GetType()) - return false; - return Equals((AST) obj); - } - - /*Is node t equal to this in terms of token type and text? */ - public virtual bool Equals(AST t) - { - if (t == null) - return false; - - return (Object.Equals(this.getText(), t.getText())) && - (this.Type == t.Type); - } - - /*Is t an exact structural and equals() match of this tree. The - * 'this' reference is considered the start of a sibling list. - */ - public virtual bool EqualsList(AST t) - { - AST sibling; - - // the empty tree is not a match of any non-null tree. - if (t == null) - { - return false; - } - - // Otherwise, start walking sibling lists. First mismatch, return false. - for (sibling = this; sibling != null && t != null; sibling = sibling.getNextSibling(), t = t.getNextSibling()) - { - // as a quick optimization, check roots first. - if (!sibling.Equals(t)) - { - return false; - } - - // if roots match, do full list match test on children. - if (sibling.getFirstChild() != null) - { - if (!sibling.getFirstChild().EqualsList(t.getFirstChild())) - { - return false; - } - } - else if (t.getFirstChild() != null) - { - return false; - } - } - - if (sibling == null && t == null) - { - return true; - } - - // one sibling list has more than the other - return false; - } - - /*Is 'sub' a subtree of this list? - * The siblings of the root are NOT ignored. - */ - public virtual bool EqualsListPartial(AST sub) - { - AST sibling; - - // the empty tree is always a subset of any tree. - if (sub == null) - { - return true; - } - - // Otherwise, start walking sibling lists. First mismatch, return false. - for (sibling = this; sibling != null && sub != null; sibling = sibling.getNextSibling(), sub = sub.getNextSibling()) - { - // as a quick optimization, check roots first. - if (!sibling.Equals(sub)) - return false; - // if roots match, do partial list match test on children. - if (sibling.getFirstChild() != null) - { - if (!sibling.getFirstChild().EqualsListPartial(sub.getFirstChild())) - return false; - } - } - - if (sibling == null && sub != null) - { - // nothing left to match in this tree, but subtree has more - return false; - } - - // either both are null or sibling has more, but subtree doesn't - return true; - } - - /*Is tree rooted at 'this' equal to 't'? The siblings - * of 'this' are ignored. - */ - public virtual bool EqualsTree(AST t) - { - // check roots first. - if (!this.Equals(t)) - return false; - // if roots match, do full list match test on children. - if (this.getFirstChild() != null) - { - if (!this.getFirstChild().EqualsList(t.getFirstChild())) - return false; - } - else if (t.getFirstChild() != null) - { - return false; - } - - return true; - } - - /*Is 't' a subtree of the tree rooted at 'this'? The siblings - * of 'this' are ignored. - */ - public virtual bool EqualsTreePartial(AST sub) - { - // the empty tree is always a subset of any tree. - if (sub == null) - { - return true; - } - - // check roots first. - if (!this.Equals(sub)) - return false; - // if roots match, do full list partial match test on children. - if (this.getFirstChild() != null) - { - if (!this.getFirstChild().EqualsListPartial(sub.getFirstChild())) - return false; - } - - return true; - } - - /*Walk the tree looking for all exact subtree matches. Return - * an IEnumerator that lets the caller walk the list - * of subtree roots found herein. - */ - public virtual IEnumerator findAll(AST target) - { - ArrayList roots = new ArrayList(10); - //AST sibling; - - // the empty tree cannot result in an enumeration - if (target == null) - { - return null; - } - - doWorkForFindAll(roots, target, false); // find all matches recursively - - return roots.GetEnumerator(); - } - - /*Walk the tree looking for all subtrees. Return - * an IEnumerator that lets the caller walk the list - * of subtree roots found herein. - */ - public virtual IEnumerator findAllPartial(AST sub) - { - ArrayList roots = new ArrayList(10); - //AST sibling; - - // the empty tree cannot result in an enumeration - if (sub == null) - { - return null; - } - - doWorkForFindAll(roots, sub, true); // find all matches recursively - - return roots.GetEnumerator(); - } - - /*Get the first child of this node; null if not children */ - public virtual AST getFirstChild() - { - return down; - } - - /*Get the next sibling in line after this one */ - public virtual AST getNextSibling() - { - return right; - } - - /*Get the token text for this node */ - public virtual string getText() - { - return ""; - } - - /*Get the token type for this node */ - public virtual int Type - { - get { return 0; } - set { ; } - } - - /// - /// Get number of children of this node; if leaf, returns 0 - /// - /// Number of children - public int getNumberOfChildren() - { - BaseAST t = this.down; - int n = 0; - if (t != null) - { - n = 1; - while (t.right != null) - { - t = t.right; - n++; - } - } - - return n; - } - - public abstract void initialize(int t, string txt); - - public abstract void initialize(AST t); - - public abstract void initialize(IToken t); - - /*Remove all children */ - public virtual void removeChildren() - { - down = null; - } - - public virtual void setFirstChild(AST c) - { - down = (BaseAST) c; - } - - public virtual void setNextSibling(AST n) - { - right = (BaseAST) n; - } - - /*Set the token text for this node */ - public virtual void setText(string text) - { - ; - } - - /*Set the token type for this node */ - public virtual void setType(int ttype) - { - this.Type = ttype; - } - - public static void setVerboseStringConversion(bool verbose, string[] names) - { - verboseStringConversion = verbose; - tokenNames = names; - } - - override public string ToString() - { - StringBuilder b = new StringBuilder(); - // if verbose and type name not same as text (keyword probably) - if (verboseStringConversion && - (0 != String.Compare(getText(), (tokenNames[Type]), true)) && - (0 != String.Compare(getText(), StringUtils.stripFrontBack(tokenNames[Type], @"""", @""""), true))) - { - b.Append('['); - b.Append(getText()); - b.Append(",<"); - b.Append(tokenNames[Type]); - b.Append(">]"); - return b.ToString(); - } - - return getText(); - } - - /*Print out a child-sibling tree in LISP notation */ - public virtual string ToStringList() - { - AST t = this; - string ts = ""; - if (t.getFirstChild() != null) - ts += " ("; - ts += " " + this.ToString(); - if (t.getFirstChild() != null) - { - ts += ((BaseAST) t.getFirstChild()).ToStringList(); - } - - if (t.getFirstChild() != null) - ts += " )"; - if (t.getNextSibling() != null) - { - ts += ((BaseAST) t.getNextSibling()).ToStringList(); - } - - return ts; - } - - public virtual string ToStringTree() - { - AST t = this; - string ts = ""; - if (t.getFirstChild() != null) - { - ts += " ("; - } - - ts += " " + this.ToString(); - if (t.getFirstChild() != null) - { - ts += ((BaseAST) t.getFirstChild()).ToStringList(); - } - - if (t.getFirstChild() != null) - { - ts += " )"; - } - - return ts; - } - - public virtual string ToTree() - { - return ToTree(string.Empty); - } - - public virtual string ToTree(string prefix) - { - StringBuilder sb = new StringBuilder(prefix); - - // Replace vertical bar if there is no next sibling. - if ((getNextSibling() == null)) - sb.Append("+--"); - else - sb.Append("|--"); - - sb.Append(ToString()); - sb.Append(Environment.NewLine); - - if (getFirstChild() != null) - { - // Replace vertical bar if there is no next sibling. - if (getNextSibling() == null) - sb.Append(((BaseAST) getFirstChild()).ToTree(prefix + " ")); - else - sb.Append(((BaseAST) getFirstChild()).ToTree(prefix + "| ")); - } - - if (getNextSibling() != null) - sb.Append(((BaseAST) getNextSibling()).ToTree(prefix)); - - return sb.ToString(); - } - - public static string decode(string text) - { - char c, c1, c2, c3, c4, c5; - StringBuilder n = new StringBuilder(); - for (int i = 0; i < text.Length; i++) - { - c = text[i]; - if (c == '&') - { - c1 = text[i + 1]; - c2 = text[i + 2]; - c3 = text[i + 3]; - c4 = text[i + 4]; - c5 = text[i + 5]; - - if (c1 == 'a' && c2 == 'm' && c3 == 'p' && c4 == ';') - { - n.Append("&"); - i += 5; - } - else if (c1 == 'l' && c2 == 't' && c3 == ';') - { - n.Append("<"); - i += 4; - } - else if (c1 == 'g' && c2 == 't' && c3 == ';') - { - n.Append(">"); - i += 4; - } - else if (c1 == 'q' && c2 == 'u' && c3 == 'o' && c4 == 't' && c5 == ';') - { - n.Append("\""); - i += 6; - } - else if (c1 == 'a' && c2 == 'p' && c3 == 'o' && c4 == 's' && c5 == ';') - { - n.Append("'"); - i += 6; - } - else - n.Append("&"); - } - else - n.Append(c); - } - - return n.ToString(); - } - - public static string encode(string text) - { - char c; - StringBuilder n = new StringBuilder(); - for (int i = 0; i < text.Length; i++) - { - c = text[i]; - switch (c) - { - case '&': - { - n.Append("&"); - break; - } - - case '<': - { - n.Append("<"); - break; - } - - case '>': - { - n.Append(">"); - break; - } - - case '"': - { - n.Append("""); - break; - } - - case '\'': - { - n.Append("'"); - break; - } - - default: - { - n.Append(c); - break; - } - } - } - - return n.ToString(); - } - - public virtual void xmlSerializeNode(TextWriter outWriter) - { - StringBuilder buf = new StringBuilder(100); - buf.Append("<"); - buf.Append(GetType().FullName + " "); - buf.Append("text=\"" + encode(getText()) + "\" type=\"" + Type + "\"/>"); - outWriter.Write(buf.ToString()); - } - - public virtual void xmlSerializeRootOpen(TextWriter outWriter) - { - StringBuilder buf = new StringBuilder(100); - buf.Append("<"); - buf.Append(GetType().FullName + " "); - buf.Append("text=\"" + encode(getText()) + "\" type=\"" + Type + "\">\n"); - outWriter.Write(buf.ToString()); - } - - public virtual void xmlSerializeRootClose(TextWriter outWriter) - { - outWriter.Write("\n"); - } - - public virtual void xmlSerialize(TextWriter outWriter) - { - // print out this node and all siblings - for (AST node = this; node != null; node = node.getNextSibling()) - { - if (node.getFirstChild() == null) - { - // print guts (class name, attributes) - ((BaseAST) node).xmlSerializeNode(outWriter); - } - else - { - ((BaseAST) node).xmlSerializeRootOpen(outWriter); - - // print children - ((BaseAST) node.getFirstChild()).xmlSerialize(outWriter); - - // print end tag - ((BaseAST) node).xmlSerializeRootClose(outWriter); - } - } - } - - [Obsolete("Deprecated since version 2.7.2. Use ASTFactory.dup() instead.", false)] - public virtual object Clone() - { - return MemberwiseClone(); - } - - public override Int32 GetHashCode() - { - return base.GetHashCode(); - } -} diff --git a/src/Spring/Spring.Core/Expressions/Parser/antlr/ByteBuffer.cs b/src/Spring/Spring.Core/Expressions/Parser/antlr/ByteBuffer.cs deleted file mode 100644 index c86a94f12..000000000 --- a/src/Spring/Spring.Core/Expressions/Parser/antlr/ByteBuffer.cs +++ /dev/null @@ -1,87 +0,0 @@ -using Stream = System.IO.Stream; - -namespace Spring.Expressions.Parser.antlr; -/*ANTLR Translator Generator - * Project led by Terence Parr at http://www.jGuru.com - * Software rights: http://www.antlr.org/license.html - * - * $Id:$ - */ - -// -// ANTLR C# Code Generator by Micheal Jordan -// Kunle Odutola : kunle UNDERSCORE odutola AT hotmail DOT com -// Anthony Oguntimehin -// -// With many thanks to Eric V. Smith from the ANTLR list. -// -/*A Stream of characters fed to the lexer from a InputStream that can - * be rewound via mark()/rewind() methods. - *

- * A dynamic array is used to buffer up all the input characters. Normally, - * "k" characters are stored in the buffer. More characters may be stored during - * guess mode (testing syntactic predicate), or when LT(i>k) is referenced. - * Consumption of characters is deferred. In other words, reading the next - * character is not done by conume(), but deferred until needed by LA or LT. - *

- */ - -// SAS: added this class to handle Binary input w/ FileInputStream - -public class ByteBuffer : InputBuffer -{ - // char source - [NonSerialized()] internal Stream input; - - private const int BUF_SIZE = 16; - - ///

- /// Small buffer used to avoid reading individual chars - /// - private byte[] buf = new byte[BUF_SIZE]; - - /*Create a character buffer */ - public ByteBuffer(Stream input_) : base() - { - input = input_; - } - - /*Ensure that the character buffer is sufficiently full */ - override public void fill(int amount) - { -// try -// { - syncConsume(); - // Fill the buffer sufficiently to hold needed characters - int bytesToRead = (amount + markerOffset) - queue.Count; - int c; - - while (bytesToRead > 0) - { - // Read a few characters - c = input.Read(buf, 0, BUF_SIZE); - for (int i = 0; i < c; i++) - { - // Append the next character - queue.Add(unchecked((char) buf[i])); - } - - if (c < BUF_SIZE) - { - while ((bytesToRead-- > 0) && (queue.Count < BUF_SIZE)) - { - queue.Add(CharScanner.EOF_CHAR); - } - - break; - } - - bytesToRead -= c; - } - // } -// catch (IOException io) -// { -// throw new CharStreamIOException(io); -// } - } -} diff --git a/src/Spring/Spring.Core/Expressions/Parser/antlr/CharBuffer.cs b/src/Spring/Spring.Core/Expressions/Parser/antlr/CharBuffer.cs deleted file mode 100644 index 5560c45bb..000000000 --- a/src/Spring/Spring.Core/Expressions/Parser/antlr/CharBuffer.cs +++ /dev/null @@ -1,88 +0,0 @@ -using TextReader = System.IO.TextReader; -using IOException = System.IO.IOException; - -namespace Spring.Expressions.Parser.antlr; -/*ANTLR Translator Generator - * Project led by Terence Parr at http://www.jGuru.com - * Software rights: http://www.antlr.org/license.html - * - * $Id:$ - */ - -// -// ANTLR C# Code Generator by Micheal Jordan -// Kunle Odutola : kunle UNDERSCORE odutola AT hotmail DOT com -// Anthony Oguntimehin -// -// With many thanks to Eric V. Smith from the ANTLR list. -// -/*A Stream of characters fed to the lexer from a InputStream that can - * be rewound via mark()/rewind() methods. - *

- * A dynamic array is used to buffer up all the input characters. Normally, - * "k" characters are stored in the buffer. More characters may be stored during - * guess mode (testing syntactic predicate), or when LT(i>k) is referenced. - * Consumption of characters is deferred. In other words, reading the next - * character is not done by conume(), but deferred until needed by LA or LT. - *

- */ - -// SAS: Move most functionality into InputBuffer -- just the file-specific -// stuff is in here -public class CharBuffer : InputBuffer -{ - // char source - [NonSerialized()] internal TextReader input; - - private const int BUF_SIZE = 16; - - ///

- /// Small buffer used to avoid reading individual chars - /// - private char[] buf = new char[BUF_SIZE]; - - /*Create a character buffer */ - public CharBuffer(TextReader input_) : base() - { - input = input_; - } - - /*Ensure that the character buffer is sufficiently full */ - override public void fill(int amount) - { - try - { - syncConsume(); - // Fill the buffer sufficiently to hold needed characters - int charsToRead = (amount + markerOffset) - queue.Count; - int c; - - while (charsToRead > 0) - { - // Read a few characters - c = input.Read(buf, 0, BUF_SIZE); - for (int i = 0; i < c; i++) - { - // Append the next character - queue.Add(buf[i]); - } - - if (c < BUF_SIZE) - { - while ((charsToRead-- > 0) && (queue.Count < BUF_SIZE)) - { - queue.Add(CharScanner.EOF_CHAR); - } - - break; - } - - charsToRead -= c; - } - } - catch (IOException io) - { - throw new CharStreamIOException(io); - } - } -} diff --git a/src/Spring/Spring.Core/Expressions/Parser/antlr/CharQueue.cs b/src/Spring/Spring.Core/Expressions/Parser/antlr/CharQueue.cs deleted file mode 100644 index 1a59e335b..000000000 --- a/src/Spring/Spring.Core/Expressions/Parser/antlr/CharQueue.cs +++ /dev/null @@ -1,124 +0,0 @@ -namespace Spring.Expressions.Parser.antlr; -/*ANTLR Translator Generator - * Project led by Terence Parr at http://www.jGuru.com - * Software rights: http://www.antlr.org/license.html - * - * $Id:$ - */ - -// -// ANTLR C# Code Generator by Micheal Jordan -// Kunle Odutola : kunle UNDERSCORE odutola AT hotmail DOT com -// Anthony Oguntimehin -// -// With many thanks to Eric V. Smith from the ANTLR list. -// - -/*A circular buffer object used by CharBuffer */ -public class CharQueue -{ - /*Physical circular buffer of tokens */ - protected internal char[] buffer; - - /*buffer.length-1 for quick modulos */ - private int sizeLessOne; - - /*physical index of front token */ - private int offset; - - /*number of tokens in the queue */ - protected internal int nbrEntries; - - public CharQueue(int minSize) - { - // Find first power of 2 >= to requested size - int size; - if (minSize < 0) - { - init(16); // pick some value for them - return; - } - - // check for overflow - if (minSize >= (Int32.MaxValue / 2)) - { - init(Int32.MaxValue); // wow that's big. - return; - } - - for (size = 2; size < minSize; size *= 2) - { - ; - } - - init(size); - } - - /*Add token to end of the queue - * @param tok The token to add - */ - public void append(char tok) - { - if (nbrEntries == buffer.Length) - { - expand(); - } - - buffer[(offset + nbrEntries) & sizeLessOne] = tok; - nbrEntries++; - } - - /*Fetch a token from the queue by index - * @param idx The index of the token to fetch, where zero is the token at the front of the queue - */ - public char elementAt(int idx) - { - return buffer[(offset + idx) & sizeLessOne]; - } - - /*Expand the token buffer by doubling its capacity */ - private void expand() - { - char[] newBuffer = new char[buffer.Length * 2]; - // Copy the contents to the new buffer - // Note that this will store the first logical item in the - // first physical array element. - for (int i = 0; i < buffer.Length; i++) - { - newBuffer[i] = elementAt(i); - } - - // Re-initialize with new contents, keep old nbrEntries - buffer = newBuffer; - sizeLessOne = buffer.Length - 1; - offset = 0; - } - - /*Initialize the queue. - * @param size The initial size of the queue - */ - public virtual void init(int size) - { - // Allocate buffer - buffer = new char[size]; - // Other initialization - sizeLessOne = size - 1; - offset = 0; - nbrEntries = 0; - } - - /*Clear the queue. Leaving the previous buffer alone. - */ - public void reset() - { - offset = 0; - nbrEntries = 0; - } - - /*Remove char from front of queue */ - public void removeFirst() - { - offset = (offset + 1) & sizeLessOne; - nbrEntries--; - } -} diff --git a/src/Spring/Spring.Core/Expressions/Parser/antlr/CharScanner.cs b/src/Spring/Spring.Core/Expressions/Parser/antlr/CharScanner.cs deleted file mode 100644 index bc207c961..000000000 --- a/src/Spring/Spring.Core/Expressions/Parser/antlr/CharScanner.cs +++ /dev/null @@ -1,822 +0,0 @@ -using Spring.Expressions.Parser.antlr.debug; -using Stream = System.IO.Stream; -using TextReader = System.IO.TextReader; -using StringBuilder = System.Text.StringBuilder; -using Hashtable = System.Collections.Hashtable; -using Assembly = System.Reflection.Assembly; -using EventHandlerList = System.ComponentModel.EventHandlerList; -using BitSet = Spring.Expressions.Parser.antlr.collections.impl.BitSet; - -namespace Spring.Expressions.Parser.antlr; -/*ANTLR Translator Generator - * Project led by Terence Parr at http://www.jGuru.com - * Software rights: http://www.antlr.org/license.html - * - * $Id:$ - */ - -// -// ANTLR C# Code Generator by Micheal Jordan -// Kunle Odutola : kunle UNDERSCORE odutola AT hotmail DOT com -// Anthony Oguntimehin -// -// With many thanks to Eric V. Smith from the ANTLR list. -// - -public abstract class CharScanner : TokenStream, ICharScannerDebugSubject -{ - internal const char NO_CHAR = (char) (0); - public static readonly char EOF_CHAR = Char.MaxValue; - - // Used to store event delegates - private EventHandlerList events_ = new EventHandlerList(); - - protected internal EventHandlerList Events - { - get { return events_; } - } - - // The unique keys for each event that CharScanner [objects] can generate - internal static readonly object EnterRuleEventKey = new object(); - internal static readonly object ExitRuleEventKey = new object(); - internal static readonly object DoneEventKey = new object(); - internal static readonly object ReportErrorEventKey = new object(); - internal static readonly object ReportWarningEventKey = new object(); - internal static readonly object NewLineEventKey = new object(); - internal static readonly object MatchEventKey = new object(); - internal static readonly object MatchNotEventKey = new object(); - internal static readonly object MisMatchEventKey = new object(); - internal static readonly object MisMatchNotEventKey = new object(); - internal static readonly object ConsumeEventKey = new object(); - internal static readonly object LAEventKey = new object(); - internal static readonly object SemPredEvaluatedEventKey = new object(); - internal static readonly object SynPredStartedEventKey = new object(); - internal static readonly object SynPredFailedEventKey = new object(); - internal static readonly object SynPredSucceededEventKey = new object(); - - protected internal StringBuilder text; // text of current token - - protected bool saveConsumedInput = true; // does consume() save characters? - - /// Used for creating Token instances. - protected TokenCreator tokenCreator; - - /// Used for caching lookahead characters. - protected char cached_LA1; - - protected char cached_LA2; - - protected bool caseSensitive = true; - protected bool caseSensitiveLiterals = true; - protected Hashtable literals; // set by subclass - - /*Tab chars are handled by tab() according to this value; override - * method to do anything weird with tabs. - */ - protected internal int tabsize = 8; - - protected internal IToken returnToken_ = null; // used to return tokens w/o using return val. - - protected internal LexerSharedInputState inputState; - - /*Used during filter mode to indicate that path is desired. - * A subsequent scan error will report an error as usual if - * acceptPath=true; - */ - protected internal bool commitToPath = false; - - /*Used to keep track of indentdepth for traceIn/Out */ - protected internal int traceDepth = 0; - - public CharScanner() - { - text = new StringBuilder(); - setTokenCreator(new CommonToken.CommonTokenCreator()); - } - - public CharScanner(InputBuffer cb) : this() - { - inputState = new LexerSharedInputState(cb); - cached_LA2 = inputState.input.LA(2); - cached_LA1 = inputState.input.LA(1); - } - - public CharScanner(LexerSharedInputState sharedState) : this() - { - inputState = sharedState; - if (inputState != null) - { - cached_LA2 = inputState.input.LA(2); - cached_LA1 = inputState.input.LA(1); - } - } - - public event TraceEventHandler EnterRule - { - add { Events.AddHandler(EnterRuleEventKey, value); } - remove { Events.RemoveHandler(EnterRuleEventKey, value); } - } - - public event TraceEventHandler ExitRule - { - add { Events.AddHandler(ExitRuleEventKey, value); } - remove { Events.RemoveHandler(ExitRuleEventKey, value); } - } - - public event TraceEventHandler Done - { - add { Events.AddHandler(DoneEventKey, value); } - remove { Events.RemoveHandler(DoneEventKey, value); } - } - - public event MessageEventHandler ErrorReported - { - add { Events.AddHandler(ReportErrorEventKey, value); } - remove { Events.RemoveHandler(ReportErrorEventKey, value); } - } - - public event MessageEventHandler WarningReported - { - add { Events.AddHandler(ReportWarningEventKey, value); } - remove { Events.RemoveHandler(ReportWarningEventKey, value); } - } - - public event NewLineEventHandler HitNewLine - { - add { Events.AddHandler(NewLineEventKey, value); } - remove { Events.RemoveHandler(NewLineEventKey, value); } - } - - public event MatchEventHandler MatchedChar - { - add { Events.AddHandler(MatchEventKey, value); } - remove { Events.RemoveHandler(MatchEventKey, value); } - } - - public event MatchEventHandler MatchedNotChar - { - add { Events.AddHandler(MatchNotEventKey, value); } - remove { Events.RemoveHandler(MatchNotEventKey, value); } - } - - public event MatchEventHandler MisMatchedChar - { - add { Events.AddHandler(MisMatchEventKey, value); } - remove { Events.RemoveHandler(MisMatchEventKey, value); } - } - - public event MatchEventHandler MisMatchedNotChar - { - add { Events.AddHandler(MisMatchNotEventKey, value); } - remove { Events.RemoveHandler(MisMatchNotEventKey, value); } - } - - public event TokenEventHandler ConsumedChar - { - add { Events.AddHandler(ConsumeEventKey, value); } - remove { Events.RemoveHandler(ConsumeEventKey, value); } - } - - public event TokenEventHandler CharLA - { - add { Events.AddHandler(LAEventKey, value); } - remove { Events.RemoveHandler(LAEventKey, value); } - } - - public event SemanticPredicateEventHandler SemPredEvaluated - { - add { Events.AddHandler(SemPredEvaluatedEventKey, value); } - remove { Events.RemoveHandler(SemPredEvaluatedEventKey, value); } - } - - public event SyntacticPredicateEventHandler SynPredStarted - { - add { Events.AddHandler(SynPredStartedEventKey, value); } - remove { Events.RemoveHandler(SynPredStartedEventKey, value); } - } - - public event SyntacticPredicateEventHandler SynPredFailed - { - add { Events.AddHandler(SynPredFailedEventKey, value); } - remove { Events.RemoveHandler(SynPredFailedEventKey, value); } - } - - public event SyntacticPredicateEventHandler SynPredSucceeded - { - add { Events.AddHandler(SynPredSucceededEventKey, value); } - remove { Events.RemoveHandler(SynPredSucceededEventKey, value); } - } - - // From interface TokenStream - public virtual IToken nextToken() { return null; } - - public virtual void append(char c) - { - if (saveConsumedInput) - { - text.Append(c); - } - } - - public virtual void append(string s) - { - if (saveConsumedInput) - { - text.Append(s); - } - } - - public virtual void commit() - { - inputState.input.commit(); - } - - public virtual void recover(RecognitionException ex, BitSet tokenSet) - { - consume(); - consumeUntil(tokenSet); - } - - public virtual void consume() - { - if (inputState.guessing == 0) - { - if (caseSensitive) - { - append(cached_LA1); - } - else - { - // use input.LA(), not LA(), to get original case - // CharScanner.LA() would toLower it. - append(inputState.input.LA(1)); - } - - if (cached_LA1 == '\t') - { - tab(); - } - else - { - inputState.column++; - } - } - - if (caseSensitive) - { - cached_LA1 = inputState.input.consume(); - cached_LA2 = inputState.input.LA(2); - } - else - { - cached_LA1 = toLower(inputState.input.consume()); - cached_LA2 = toLower(inputState.input.LA(2)); - } - } - - /*Consume chars until one matches the given char */ - public virtual void consumeUntil(int c) - { - while ((EOF_CHAR != cached_LA1) && (c != cached_LA1)) - { - consume(); - } - } - - /*Consume chars until one matches the given set */ - public virtual void consumeUntil(BitSet bset) - { - while (cached_LA1 != EOF_CHAR && !bset.member(cached_LA1)) - { - consume(); - } - } - - public virtual bool getCaseSensitive() - { - return caseSensitive; - } - - public bool getCaseSensitiveLiterals() - { - return caseSensitiveLiterals; - } - - public virtual int getColumn() - { - return inputState.column; - } - - public virtual void setColumn(int c) - { - inputState.column = c; - } - - public virtual bool getCommitToPath() - { - return commitToPath; - } - - public virtual string getFilename() - { - return inputState.filename; - } - - public virtual InputBuffer getInputBuffer() - { - return inputState.input; - } - - public virtual LexerSharedInputState getInputState() - { - return inputState; - } - - public virtual void setInputState(LexerSharedInputState state) - { - inputState = state; - } - - public virtual int getLine() - { - return inputState.line; - } - - /*return a copy of the current text buffer */ - public virtual string getText() - { - return text.ToString(); - } - - public virtual IToken getTokenObject() - { - return returnToken_; - } - - public virtual char LA(int i) - { - if (i == 1) - { - return cached_LA1; - } - - if (i == 2) - { - return cached_LA2; - } - - if (caseSensitive) - { - return inputState.input.LA(i); - } - else - { - return toLower(inputState.input.LA(i)); - } - } - - protected internal virtual IToken makeToken(int t) - { - IToken newToken = null; - bool typeCreated; - - try - { - newToken = tokenCreator.Create(); - if (newToken != null) - { - newToken.Type = t; - newToken.setColumn(inputState.tokenStartColumn); - newToken.setLine(inputState.tokenStartLine); - // tracking real start line now: newToken.setLine(inputState.line); - newToken.setFilename(inputState.filename); - } - - typeCreated = true; - } - catch - { - typeCreated = false; - } - - if (!typeCreated) - { - panic("Can't create Token object '" + tokenCreator.TokenTypeName + "'"); - newToken = Token.badToken; - } - - return newToken; - } - - public virtual int mark() - { - return inputState.input.mark(); - } - - public virtual void match(char c) - { - match((int) c); - } - - public virtual void match(int c) - { - if (cached_LA1 != c) - { - throw new MismatchedCharException(cached_LA1, Convert.ToChar(c), false, this); - } - - consume(); - } - - public virtual void match(BitSet b) - { - if (!b.member(cached_LA1)) - { - throw new MismatchedCharException(cached_LA1, b, false, this); - } - - consume(); - } - - public virtual void match(string s) - { - int len = s.Length; - for (int i = 0; i < len; i++) - { - if (cached_LA1 != s[i]) - { - throw new MismatchedCharException(cached_LA1, s[i], false, this); - } - - consume(); - } - } - - public virtual void matchNot(char c) - { - matchNot((int) c); - } - - public virtual void matchNot(int c) - { - if (cached_LA1 == c) - { - throw new MismatchedCharException(cached_LA1, Convert.ToChar(c), true, this); - } - - consume(); - } - - public virtual void matchRange(int c1, int c2) - { - if (cached_LA1 < c1 || cached_LA1 > c2) - { - throw new MismatchedCharException(cached_LA1, Convert.ToChar(c1), Convert.ToChar(c2), false, this); - } - - consume(); - } - - public virtual void matchRange(char c1, char c2) - { - matchRange((int) c1, (int) c2); - } - - public virtual void newline() - { - inputState.line++; - inputState.column = 1; - } - - /*advance the current column number by an appropriate amount - * according to tab size. This method is called from consume(). - */ - public virtual void tab() - { - int c = getColumn(); - int nc = (((c - 1) / tabsize) + 1) * tabsize + 1; // calculate tab stop - setColumn(nc); - } - - public virtual void setTabSize(int size) - { - tabsize = size; - } - - public virtual int getTabSize() - { - return tabsize; - } - - public virtual void panic() - { - //Console.Error.WriteLine("CharScanner: panic"); - //Environment.Exit(1); - panic(""); - } - - /// - /// This method is executed by ANTLR internally when it detected an illegal - /// state that cannot be recovered from. - /// The previous implementation of this method called - /// and writes directly to , which is usually not - /// appropriate when a translator is embedded into a larger application. - /// - /// Error message. - public virtual void panic(string s) - { - //Console.Error.WriteLine("CharScanner; panic: " + s); - //Environment.Exit(1); - throw new ANTLRPanicException("CharScanner::panic: " + s); - } - - /*Parser error-reporting function can be overridden in subclass */ - public virtual void reportError(RecognitionException ex) - { - Console.Error.WriteLine(ex); - } - - /*Parser error-reporting function can be overridden in subclass */ - public virtual void reportError(string s) - { - if (getFilename() == null) - { - Console.Error.WriteLine("error: " + s); - } - else - { - Console.Error.WriteLine(getFilename() + ": error: " + s); - } - } - - /*Parser warning-reporting function can be overridden in subclass */ - public virtual void reportWarning(string s) - { - if (getFilename() == null) - { - Console.Error.WriteLine("warning: " + s); - } - else - { - Console.Error.WriteLine(getFilename() + ": warning: " + s); - } - } - - public virtual void refresh() - { - if (caseSensitive) - { - cached_LA2 = inputState.input.LA(2); - cached_LA1 = inputState.input.LA(1); - } - else - { - cached_LA2 = toLower(inputState.input.LA(2)); - cached_LA1 = toLower(inputState.input.LA(1)); - } - } - - public virtual void resetState(InputBuffer ib) - { - text.Length = 0; - traceDepth = 0; - inputState.resetInput(ib); - refresh(); - } - - public void resetState(Stream s) - { - resetState(new ByteBuffer(s)); - } - - public void resetState(TextReader tr) - { - resetState(new CharBuffer(tr)); - } - - public virtual void resetText() - { - text.Length = 0; - inputState.tokenStartColumn = inputState.column; - inputState.tokenStartLine = inputState.line; - } - - public virtual void rewind(int pos) - { - inputState.input.rewind(pos); - //setColumn(inputState.tokenStartColumn); - if (caseSensitive) - { - cached_LA2 = inputState.input.LA(2); - cached_LA1 = inputState.input.LA(1); - } - else - { - cached_LA2 = toLower(inputState.input.LA(2)); - cached_LA1 = toLower(inputState.input.LA(1)); - } - } - - public virtual void setCaseSensitive(bool t) - { - caseSensitive = t; - if (caseSensitive) - { - cached_LA2 = inputState.input.LA(2); - cached_LA1 = inputState.input.LA(1); - } - else - { - cached_LA2 = toLower(inputState.input.LA(2)); - cached_LA1 = toLower(inputState.input.LA(1)); - } - } - - public virtual void setCommitToPath(bool commit) - { - commitToPath = commit; - } - - public virtual void setFilename(string f) - { - inputState.filename = f; - } - - public virtual void setLine(int line) - { - inputState.line = line; - } - - public virtual void setText(string s) - { - resetText(); - text.Append(s); - } - - public virtual void setTokenObjectClass(string cl) - { - this.tokenCreator = new ReflectionBasedTokenCreator(this, cl); - } - - public virtual void setTokenCreator(TokenCreator tokenCreator) - { - this.tokenCreator = tokenCreator; - } - - // Test the token text against the literals table - // Override this method to perform a different literals test - public virtual int testLiteralsTable(int ttype) - { - string tokenText = text.ToString(); - - if ((tokenText == null) || (tokenText == string.Empty)) - return ttype; - else - { - object typeAsObject = literals[tokenText]; - return (typeAsObject == null) ? ttype : ((int) typeAsObject); - } - } - - /*Test the text passed in against the literals table - * Override this method to perform a different literals test - * This is used primarily when you want to test a portion of - * a token. - */ - public virtual int testLiteralsTable(string someText, int ttype) - { - if ((someText == null) || (someText == string.Empty)) - return ttype; - else - { - object typeAsObject = literals[someText]; - return (typeAsObject == null) ? ttype : ((int) typeAsObject); - } - } - - // Override this method to get more specific case handling - public virtual char toLower(int c) - { - return Char.ToLower(Convert.ToChar(c), System.Globalization.CultureInfo.InvariantCulture); - } - - public virtual void traceIndent() - { - for (int i = 0; i < traceDepth; i++) - Console.Out.Write(" "); - } - - public virtual void traceIn(string rname) - { - traceDepth += 1; - traceIndent(); - Console.Out.WriteLine("> lexer " + rname + "; c==" + LA(1)); - } - - public virtual void traceOut(string rname) - { - traceIndent(); - Console.Out.WriteLine("< lexer " + rname + "; c==" + LA(1)); - traceDepth -= 1; - } - - /*This method is called by YourLexer.nextToken() when the lexer has - * hit EOF condition. EOF is NOT a character. - * This method is not called if EOF is reached during - * syntactic predicate evaluation or during evaluation - * of normal lexical rules, which presumably would be - * an IOException. This traps the "normal" EOF condition. - * - * uponEOF() is called after the complete evaluation of - * the previous token and only if your parser asks - * for another token beyond that last non-EOF token. - * - * You might want to throw token or char stream exceptions - * like: "Heh, premature eof" or a retry stream exception - * ("I found the end of this file, go back to referencing file"). - */ - public virtual void uponEOF() - { - } - - private class ReflectionBasedTokenCreator : TokenCreator - { - protected ReflectionBasedTokenCreator() { } - - public ReflectionBasedTokenCreator(CharScanner owner, string tokenTypeName) - { - this.owner = owner; - SetTokenType(tokenTypeName); - } - - private CharScanner owner; - - /// - /// The fully qualified name of the Token type to create. - /// - private string tokenTypeName; - - /// - /// Type object used as a template for creating tokens by reflection. - /// - private Type tokenTypeObject; - - /// - /// Returns the fully qualified name of the Token type that this - /// class creates. - /// - private void SetTokenType(string tokenTypeName) - { - this.tokenTypeName = tokenTypeName; - foreach (Assembly assem in AppDomain.CurrentDomain.GetAssemblies()) - { - try - { - tokenTypeObject = assem.GetType(tokenTypeName); - if (tokenTypeObject != null) - { - break; - } - } - catch - { - throw new TypeLoadException("Unable to load Type for Token class '" + tokenTypeName + "'"); - } - } - - if (tokenTypeObject == null) - throw new TypeLoadException("Unable to load Type for Token class '" + tokenTypeName + "'"); - } - - /// - /// Returns the fully qualified name of the Token type that this - /// class creates. - /// - public override string TokenTypeName - { - get - { - return tokenTypeName; - } - } - - /// - /// Constructs a instance. - /// - public override IToken Create() - { - IToken newToken = null; - - try - { - newToken = (Token) Activator.CreateInstance(tokenTypeObject); - } - catch - { - // supress exception - } - - return newToken; - } - } -} diff --git a/src/Spring/Spring.Core/Expressions/Parser/antlr/CharStreamException.cs b/src/Spring/Spring.Core/Expressions/Parser/antlr/CharStreamException.cs deleted file mode 100644 index 0404995b0..000000000 --- a/src/Spring/Spring.Core/Expressions/Parser/antlr/CharStreamException.cs +++ /dev/null @@ -1,29 +0,0 @@ -namespace Spring.Expressions.Parser.antlr; -/*ANTLR Translator Generator - * Project led by Terence Parr at http://www.jGuru.com - * Software rights: http://www.antlr.org/license.html - * - * $Id:$ - */ - -// -// ANTLR C# Code Generator by Micheal Jordan -// Kunle Odutola : kunle UNDERSCORE odutola AT hotmail DOT com -// Anthony Oguntimehin -// -// With many thanks to Eric V. Smith from the ANTLR list. -// -/* - * Anything that goes wrong while generating a stream of characters - */ - -[Serializable] -public class CharStreamException : ANTLRException -{ - /* - * CharStreamException constructor comment. - */ - public CharStreamException(string s) : base(s) - { - } -} diff --git a/src/Spring/Spring.Core/Expressions/Parser/antlr/CharStreamIOException.cs b/src/Spring/Spring.Core/Expressions/Parser/antlr/CharStreamIOException.cs deleted file mode 100644 index 6a4e8ebee..000000000 --- a/src/Spring/Spring.Core/Expressions/Parser/antlr/CharStreamIOException.cs +++ /dev/null @@ -1,31 +0,0 @@ -using IOException = System.IO.IOException; - -namespace Spring.Expressions.Parser.antlr; -/*ANTLR Translator Generator - * Project led by Terence Parr at http://www.jGuru.com - * Software rights: http://www.antlr.org/license.html - * - * $Id:$ - */ - -// -// ANTLR C# Code Generator by Micheal Jordan -// Kunle Odutola : kunle UNDERSCORE odutola AT hotmail DOT com -// Anthony Oguntimehin -// -// With many thanks to Eric V. Smith from the ANTLR list. -// - -/* - * Wrap an IOException in a CharStreamException - */ -[Serializable] -public class CharStreamIOException : CharStreamException -{ - public IOException io; - - public CharStreamIOException(IOException io) : base(io.Message) - { - this.io = io; - } -} diff --git a/src/Spring/Spring.Core/Expressions/Parser/antlr/CommonAST.cs b/src/Spring/Spring.Core/Expressions/Parser/antlr/CommonAST.cs deleted file mode 100644 index 5c23340b9..000000000 --- a/src/Spring/Spring.Core/Expressions/Parser/antlr/CommonAST.cs +++ /dev/null @@ -1,120 +0,0 @@ -using AST = Spring.Expressions.Parser.antlr.collections.AST; - -namespace Spring.Expressions.Parser.antlr; -/*ANTLR Translator Generator - * Project led by Terence Parr at http://www.jGuru.com - * Software rights: http://www.antlr.org/license.html - * - * $Id:$ - */ - -// -// ANTLR C# Code Generator by Micheal Jordan -// Kunle Odutola : kunle UNDERSCORE odutola AT hotmail DOT com -// Anthony Oguntimehin -// -// With many thanks to Eric V. Smith from the ANTLR list. -// - -/*Common AST node implementation */ -public class CommonAST : BaseAST -{ - public static readonly CommonAST.CommonASTCreator Creator = new CommonASTCreator(); - - internal int ttype = Token.INVALID_TYPE; - internal string text; - - [Obsolete("Deprecated since version 2.7.2. Use ASTFactory.dup() instead.", false)] - protected CommonAST(CommonAST another) - { - // don't include child/sibling pointers in Clone()/dup() - //down = another.down; - //right = another.right; - ttype = another.ttype; - text = (another.text == null) ? null : String.Copy(another.text); - } - - /*Get the token text for this node */ - override public string getText() - { - return text; - } - - /*Get the token type for this node */ - override public int Type - { - get { return ttype; } - set { ttype = value; } - } - - override public void initialize(int t, string txt) - { - Type = t; - setText(txt); - } - - override public void initialize(collections.AST t) - { - setText(t.getText()); - Type = t.Type; - } - - public CommonAST() - { - } - - public CommonAST(IToken tok) - { - initialize(tok); - } - - override public void initialize(IToken tok) - { - setText(tok.getText()); - Type = tok.Type; - } - - /*Set the token text for this node */ - override public void setText(string text_) - { - text = text_; - } - - /*Set the token type for this node */ - override public void setType(int ttype_) - { - this.Type = ttype_; - } - - [Obsolete("Deprecated since version 2.7.2. Use ASTFactory.dup() instead.", false)] - override public object Clone() - { - return new CommonAST(this); - } - - public class CommonASTCreator : ASTNodeCreator - { - public CommonASTCreator() { } - - /// - /// Returns the fully qualified name of the AST type that this - /// class creates. - /// - public override string ASTNodeTypeName - { - get - { - return typeof(antlr.CommonAST).FullName; - ; - } - } - - /// - /// Constructs a instance. - /// - public override AST Create() - { - return new CommonAST(); - } - } -} diff --git a/src/Spring/Spring.Core/Expressions/Parser/antlr/CommonASTWithHiddenTokens.cs b/src/Spring/Spring.Core/Expressions/Parser/antlr/CommonASTWithHiddenTokens.cs deleted file mode 100644 index b10ce219b..000000000 --- a/src/Spring/Spring.Core/Expressions/Parser/antlr/CommonASTWithHiddenTokens.cs +++ /dev/null @@ -1,99 +0,0 @@ -using AST = Spring.Expressions.Parser.antlr.collections.AST; - -namespace Spring.Expressions.Parser.antlr; -/*ANTLR Translator Generator - * Project led by Terence Parr at http://www.jGuru.com - * Software rights: http://www.antlr.org/license.html - * - * $Id:$ - */ - -// -// ANTLR C# Code Generator by Micheal Jordan -// Kunle Odutola : kunle UNDERSCORE odutola AT hotmail DOT com -// Anthony Oguntimehin -// -// With many thanks to Eric V. Smith from the ANTLR list. -// -/*A CommonAST whose initialization copies hidden token - * information from the Token used to create a node. - */ - -public class CommonASTWithHiddenTokens : CommonAST -{ - new public static readonly CommonASTWithHiddenTokens.CommonASTWithHiddenTokensCreator Creator = new CommonASTWithHiddenTokensCreator(); - - protected internal IHiddenStreamToken hiddenBefore, hiddenAfter; // references to hidden tokens - - public CommonASTWithHiddenTokens() : base() - { - } - - public CommonASTWithHiddenTokens(IToken tok) : base(tok) - { - } - - [Obsolete("Deprecated since version 2.7.2. Use ASTFactory.dup() instead.", false)] - protected CommonASTWithHiddenTokens(CommonASTWithHiddenTokens another) : base(another) - { - hiddenBefore = another.hiddenBefore; - hiddenAfter = another.hiddenAfter; - } - - public virtual IHiddenStreamToken getHiddenAfter() - { - return hiddenAfter; - } - - public virtual IHiddenStreamToken getHiddenBefore() - { - return hiddenBefore; - } - - override public void initialize(collections.AST t) - { - hiddenBefore = ((CommonASTWithHiddenTokens) t).getHiddenBefore(); - hiddenAfter = ((CommonASTWithHiddenTokens) t).getHiddenAfter(); - base.initialize(t); - } - - override public void initialize(IToken tok) - { - IHiddenStreamToken t = (IHiddenStreamToken) tok; - base.initialize(t); - hiddenBefore = t.getHiddenBefore(); - hiddenAfter = t.getHiddenAfter(); - } - - [Obsolete("Deprecated since version 2.7.2. Use ASTFactory.dup() instead.", false)] - override public object Clone() - { - return new CommonASTWithHiddenTokens(this); - } - - public class CommonASTWithHiddenTokensCreator : ASTNodeCreator - { - public CommonASTWithHiddenTokensCreator() { } - - /// - /// Returns the fully qualified name of the AST type that this - /// class creates. - /// - public override string ASTNodeTypeName - { - get - { - return typeof(antlr.CommonASTWithHiddenTokens).FullName; - ; - } - } - - /// - /// Constructs a instance. - /// - public override AST Create() - { - return new CommonASTWithHiddenTokens(); - } - } -} diff --git a/src/Spring/Spring.Core/Expressions/Parser/antlr/CommonHiddenStreamToken.cs b/src/Spring/Spring.Core/Expressions/Parser/antlr/CommonHiddenStreamToken.cs deleted file mode 100644 index 94e246e8c..000000000 --- a/src/Spring/Spring.Core/Expressions/Parser/antlr/CommonHiddenStreamToken.cs +++ /dev/null @@ -1,81 +0,0 @@ -namespace Spring.Expressions.Parser.antlr; -/*ANTLR Translator Generator - * Project led by Terence Parr at http://www.jGuru.com - * Software rights: http://www.antlr.org/license.html - * - * $Id:$ - */ - -// -// ANTLR C# Code Generator by Micheal Jordan -// Kunle Odutola : kunle UNDERSCORE odutola AT hotmail DOT com -// Anthony Oguntimehin -// -// With many thanks to Eric V. Smith from the ANTLR list. -// - -public class CommonHiddenStreamToken : CommonToken, IHiddenStreamToken -{ - new public static readonly CommonHiddenStreamToken.CommonHiddenStreamTokenCreator Creator = new CommonHiddenStreamTokenCreator(); - - protected internal IHiddenStreamToken hiddenBefore; - protected internal IHiddenStreamToken hiddenAfter; - - public CommonHiddenStreamToken() : base() - { - } - - public CommonHiddenStreamToken(int t, string txt) : base(t, txt) - { - } - - public CommonHiddenStreamToken(string s) : base(s) - { - } - - public virtual IHiddenStreamToken getHiddenAfter() - { - return hiddenAfter; - } - - public virtual IHiddenStreamToken getHiddenBefore() - { - return hiddenBefore; - } - - public virtual void setHiddenAfter(IHiddenStreamToken t) - { - hiddenAfter = t; - } - - public virtual void setHiddenBefore(IHiddenStreamToken t) - { - hiddenBefore = t; - } - - public class CommonHiddenStreamTokenCreator : TokenCreator - { - public CommonHiddenStreamTokenCreator() { } - - /// - /// Returns the fully qualified name of the Token type that this - /// class creates. - /// - public override string TokenTypeName - { - get - { - return typeof(antlr.CommonHiddenStreamToken).FullName; - ; - } - } - - /// - /// Constructs a instance. - /// - public override IToken Create() - { - return new CommonHiddenStreamToken(); - } - } -} diff --git a/src/Spring/Spring.Core/Expressions/Parser/antlr/CommonToken.cs b/src/Spring/Spring.Core/Expressions/Parser/antlr/CommonToken.cs deleted file mode 100644 index c5455d9e0..000000000 --- a/src/Spring/Spring.Core/Expressions/Parser/antlr/CommonToken.cs +++ /dev/null @@ -1,102 +0,0 @@ -namespace Spring.Expressions.Parser.antlr; -/*ANTLR Translator Generator - * Project led by Terence Parr at http://www.jGuru.com - * Software rights: http://www.antlr.org/license.html - * - * $Id:$ - */ - -// -// ANTLR C# Code Generator by Micheal Jordan -// Kunle Odutola : kunle UNDERSCORE odutola AT hotmail DOT com -// Anthony Oguntimehin -// -// With many thanks to Eric V. Smith from the ANTLR list. -// - -public class CommonToken : Token -{ - public static readonly CommonToken.CommonTokenCreator Creator = new CommonTokenCreator(); - - // most tokens will want line and text information - protected internal int line; - protected internal string text = null; - protected internal int col; - - public CommonToken() - { - } - - public CommonToken(int t, string txt) - { - type_ = t; - setText(txt); - } - - public CommonToken(string s) - { - text = s; - } - - override public int getLine() - { - return line; - } - - override public string getText() - { - return text; - } - - override public void setLine(int l) - { - line = l; - } - - override public void setText(string s) - { - text = s; - } - - override public string ToString() - { - return "[\"" + getText() + "\",<" + type_ + ">,line=" + line + ",col=" + col + "]"; - } - - /*Return token's start column */ - override public int getColumn() - { - return col; - } - - override public void setColumn(int c) - { - col = c; - } - - public class CommonTokenCreator : TokenCreator - { - public CommonTokenCreator() { } - - /// - /// Returns the fully qualified name of the Token type that this - /// class creates. - /// - public override string TokenTypeName - { - get - { - return typeof(antlr.CommonToken).FullName; - ; - } - } - - /// - /// Constructs a instance. - /// - public override IToken Create() - { - return new CommonToken(); - } - } -} diff --git a/src/Spring/Spring.Core/Expressions/Parser/antlr/DefaultFileLineFormatter.cs b/src/Spring/Spring.Core/Expressions/Parser/antlr/DefaultFileLineFormatter.cs deleted file mode 100644 index c717a532b..000000000 --- a/src/Spring/Spring.Core/Expressions/Parser/antlr/DefaultFileLineFormatter.cs +++ /dev/null @@ -1,45 +0,0 @@ -using StringBuilder = System.Text.StringBuilder; - -namespace Spring.Expressions.Parser.antlr; -/*ANTLR Translator Generator - * Project led by Terence Parr at http://www.jGuru.com - * Software rights: http://www.antlr.org/license.html - * - * $Id:$ - */ - -// -// ANTLR C# Code Generator by Micheal Jordan -// Kunle Odutola : kunle UNDERSCORE odutola AT hotmail DOT com -// Anthony Oguntimehin -// -// With many thanks to Eric V. Smith from the ANTLR list. -// - -public class DefaultFileLineFormatter : FileLineFormatter -{ - public override string getFormatString(string fileName, int line, int column) - { - StringBuilder buf = new StringBuilder(); - - if (fileName != null) - buf.Append(fileName + ":"); - - if (line != -1) - { - if (fileName == null) - buf.Append("line "); - - buf.Append(line); - - if (column != -1) - buf.Append(":" + column); - - buf.Append(":"); - } - - buf.Append(" "); - - return buf.ToString(); - } -} diff --git a/src/Spring/Spring.Core/Expressions/Parser/antlr/DumpASTVisitor.cs b/src/Spring/Spring.Core/Expressions/Parser/antlr/DumpASTVisitor.cs deleted file mode 100644 index e90fb1119..000000000 --- a/src/Spring/Spring.Core/Expressions/Parser/antlr/DumpASTVisitor.cs +++ /dev/null @@ -1,89 +0,0 @@ -using AST = Spring.Expressions.Parser.antlr.collections.AST; - -namespace Spring.Expressions.Parser.antlr; -/* ANTLR Translator Generator - * Project led by Terence Parr at http://www.jGuru.com - * Software rights: http://www.antlr.org/license.html - * - * $Id:$ - */ - -// -// ANTLR C# Code Generator by Micheal Jordan -// Kunle Odutola : kunle UNDERSCORE odutola AT hotmail DOT com -// Anthony Oguntimehin -// -// With many thanks to Eric V. Smith from the ANTLR list. -// - -/// -/// Summary description for DumpASTVisitor. -/// -/** Simple class to dump the contents of an AST to the output */ -public class DumpASTVisitor : ASTVisitor -{ - protected int level = 0; - - private void tabs() - { - for (int i = 0; i < level; i++) - { - Console.Out.Write(" "); - } - } - - public void visit(AST node) - { - // Flatten this level of the tree if it has no children - bool flatten = /*true*/ false; - AST node2; - for (node2 = node; node2 != null; node2 = node2.getNextSibling()) - { - if (node2.getFirstChild() != null) - { - flatten = false; - break; - } - } - - for (node2 = node; node2 != null; node2 = node2.getNextSibling()) - { - if (!flatten || node2 == node) - { - tabs(); - } - - if (node2.getText() == null) - { - Console.Out.Write("nil"); - } - else - { - Console.Out.Write(node2.getText()); - } - - Console.Out.Write(" [" + node2.Type + "] "); - - if (flatten) - { - Console.Out.Write(" "); - } - else - { - Console.Out.WriteLine(""); - } - - if (node2.getFirstChild() != null) - { - level++; - visit(node2.getFirstChild()); - level--; - } - } - - if (flatten) - { - Console.Out.WriteLine(""); - } - } -} diff --git a/src/Spring/Spring.Core/Expressions/Parser/antlr/FileLineFormatter.cs b/src/Spring/Spring.Core/Expressions/Parser/antlr/FileLineFormatter.cs deleted file mode 100644 index eeafb033c..000000000 --- a/src/Spring/Spring.Core/Expressions/Parser/antlr/FileLineFormatter.cs +++ /dev/null @@ -1,36 +0,0 @@ -namespace Spring.Expressions.Parser.antlr; -/*ANTLR Translator Generator - * Project led by Terence Parr at http://www.jGuru.com - * Software rights: http://www.antlr.org/license.html - * - * $Id:$ - */ - -// -// ANTLR C# Code Generator by Micheal Jordan -// Kunle Odutola : kunle UNDERSCORE odutola AT hotmail DOT com -// Anthony Oguntimehin -// -// With many thanks to Eric V. Smith from the ANTLR list. -// - -public abstract class FileLineFormatter -{ - private static FileLineFormatter formatter = new DefaultFileLineFormatter(); - - public static FileLineFormatter getFormatter() - { - return formatter; - } - - public static void setFormatter(FileLineFormatter f) - { - formatter = f; - } - - /*@param fileName the file that should appear in the prefix. (or null) - * @param line the line (or -1) - * @param column the column (or -1) - */ - public abstract string getFormatString(string fileName, int line, int column); -} diff --git a/src/Spring/Spring.Core/Expressions/Parser/antlr/IHiddenStreamToken.cs b/src/Spring/Spring.Core/Expressions/Parser/antlr/IHiddenStreamToken.cs deleted file mode 100644 index 5e6afde42..000000000 --- a/src/Spring/Spring.Core/Expressions/Parser/antlr/IHiddenStreamToken.cs +++ /dev/null @@ -1,24 +0,0 @@ -namespace Spring.Expressions.Parser.antlr; -/*ANTLR Translator Generator - * Project led by Terence Parr at http://www.jGuru.com - * Software rights: http://www.antlr.org/license.html - * - * $Id:$ - */ - -// -// ANTLR C# Code Generator by Micheal Jordan -// Kunle Odutola : kunle UNDERSCORE odutola AT hotmail DOT com -// Anthony Oguntimehin -// -// With many thanks to Eric V. Smith from the ANTLR list. -// - -public interface IHiddenStreamToken : IToken -{ - IHiddenStreamToken getHiddenAfter(); - void setHiddenAfter(IHiddenStreamToken t); - - IHiddenStreamToken getHiddenBefore(); - void setHiddenBefore(IHiddenStreamToken t); -} diff --git a/src/Spring/Spring.Core/Expressions/Parser/antlr/IToken.cs b/src/Spring/Spring.Core/Expressions/Parser/antlr/IToken.cs deleted file mode 100644 index 6b5364d1a..000000000 --- a/src/Spring/Spring.Core/Expressions/Parser/antlr/IToken.cs +++ /dev/null @@ -1,36 +0,0 @@ -namespace Spring.Expressions.Parser.antlr; -/*ANTLR Translator Generator - * Project led by Terence Parr at http://www.jGuru.com - * Software rights: http://www.antlr.org/license.html - * - * $Id:$ - */ - -// -// ANTLR C# Code Generator by Micheal Jordan -// Kunle Odutola : kunle UNDERSCORE odutola AT hotmail DOT com -// Anthony Oguntimehin -// -// With many thanks to Eric V. Smith from the ANTLR list. -// - -/// -/// A token is minimally a token type. Subclasses can add the text matched -/// for the token and line info. -/// -public interface IToken -{ - int getColumn(); - void setColumn(int c); - - int getLine(); - void setLine(int l); - - string getFilename(); - void setFilename(string name); - - string getText(); - void setText(string t); - - int Type { get; set; } -} diff --git a/src/Spring/Spring.Core/Expressions/Parser/antlr/InputBuffer.cs b/src/Spring/Spring.Core/Expressions/Parser/antlr/InputBuffer.cs deleted file mode 100644 index e738953c9..000000000 --- a/src/Spring/Spring.Core/Expressions/Parser/antlr/InputBuffer.cs +++ /dev/null @@ -1,169 +0,0 @@ -namespace Spring.Expressions.Parser.antlr; - -using ArrayList = System.Collections.ArrayList; -using StringBuilder = System.Text.StringBuilder; - -/*ANTLR Translator Generator - * Project led by Terence Parr at http://www.jGuru.com - * Software rights: http://www.antlr.org/license.html - */ - -// -// ANTLR C# Code Generator by Micheal Jordan -// Kunle Odutola : kunle UNDERSCORE odutola AT hotmail DOT com -// Anthony Oguntimehin -// -// With many thanks to Eric V. Smith from the ANTLR list. -// - -// SAS: Added this class to genericise the input buffers for scanners -// This allows a scanner to use a binary (FileInputStream) or -// text (FileReader) stream of data; the generated scanner -// subclass will define the input stream -// There are two subclasses to this: CharBuffer and ByteBuffer - -/// -/// Represents a stream of characters fed to the lexer from that can be rewound -/// via mark()/rewind() methods. -/// -/// -/// -/// A dynamic array is used to buffer up all the input characters. Normally, -/// "k" characters are stored in the buffer. More characters may be stored -/// during guess mode (testing syntactic predicate), or when LT(i>k) is referenced. -/// Consumption of characters is deferred. In other words, reading the next -/// character is not done by conume(), but deferred until needed by LA or LT. -/// -/// -public abstract class InputBuffer -{ - // Number of active markers - protected internal int nMarkers = 0; - - // Additional offset used when markers are active - protected internal int markerOffset = 0; - - // Number of calls to consume() since last LA() or LT() call - protected internal int numToConsume = 0; - - // Circular queue - protected ArrayList queue; - - /*Create an input buffer */ - public InputBuffer() - { - queue = new ArrayList(); - } - - /*This method updates the state of the input buffer so that - * the text matched since the most recent mark() is no longer - * held by the buffer. So, you either do a mark/rewind for - * failed predicate or mark/commit to keep on parsing without - * rewinding the input. - */ - public virtual void commit() - { - nMarkers--; - } - - /*Mark another character for deferred consumption */ - public virtual char consume() - { - numToConsume++; - return LA(1); - } - - /*Ensure that the input buffer is sufficiently full */ - public abstract void fill(int amount); - - public virtual string getLAChars() - { - StringBuilder la = new StringBuilder(); - - // copy buffer contents to array before looping thru contents (it's usually faster) - char[] fastBuf = new char[queue.Count - markerOffset]; - queue.CopyTo(fastBuf, markerOffset); - - la.Append(fastBuf); - return la.ToString(); - } - - public virtual string getMarkedChars() - { - StringBuilder marked = new StringBuilder(); - - // copy buffer contents to array before looping thru contents (it's usually faster) - char[] fastBuf = new char[queue.Count - markerOffset]; - queue.CopyTo(fastBuf, markerOffset); - - marked.Append(fastBuf); - return marked.ToString(); - } - - public virtual bool isMarked() - { - return (nMarkers != 0); - } - - /*Get a lookahead character */ - public virtual char LA(int i) - { - fill(i); - if ((this.markerOffset + i) <= this.queue.Count) - { - return (char) this.queue[(this.markerOffset + i) - 1]; - } - - return CharScanner.EOF_CHAR; - } - - /*Return an integer marker that can be used to rewind the buffer to - * its current state. - */ - public virtual int mark() - { - syncConsume(); - nMarkers++; - return markerOffset; - } - - /*Rewind the character buffer to a marker. - * @param mark Marker returned previously from mark() - */ - public virtual void rewind(int mark) - { - syncConsume(); - markerOffset = mark; - nMarkers--; - } - - /*Reset the input buffer - */ - public virtual void reset() - { - nMarkers = 0; - markerOffset = 0; - numToConsume = 0; - queue.Clear(); - } - - /*Sync up deferred consumption */ - protected internal virtual void syncConsume() - { - if (numToConsume > 0) - { - if (nMarkers > 0) - { - // guess mode -- leave leading characters and bump offset. - markerOffset += numToConsume; - } - else - { - // normal mode -- remove "consumed" characters from buffer - queue.RemoveRange(0, numToConsume); - } - - numToConsume = 0; - } - } -} diff --git a/src/Spring/Spring.Core/Expressions/Parser/antlr/LLkParser.cs b/src/Spring/Spring.Core/Expressions/Parser/antlr/LLkParser.cs deleted file mode 100644 index 29add71a8..000000000 --- a/src/Spring/Spring.Core/Expressions/Parser/antlr/LLkParser.cs +++ /dev/null @@ -1,108 +0,0 @@ -namespace Spring.Expressions.Parser.antlr; -/*ANTLR Translator Generator - * Project led by Terence Parr at http://www.jGuru.com - * Software rights: http://www.antlr.org/license.html - * - * $Id:$ - */ - -// -// ANTLR C# Code Generator by Micheal Jordan -// Kunle Odutola : kunle UNDERSCORE odutola AT hotmail DOT com -// Anthony Oguntimehin -// -// With many thanks to Eric V. Smith from the ANTLR list. -// - -/*An LL(k) parser. - * - * @see antlr.Token - * @see antlr.TokenBuffer - * @see antlr.LL1Parser - */ -public class LLkParser : Parser -{ - internal int k; - - public LLkParser(int k_) - { - k = k_; - } - - public LLkParser(ParserSharedInputState state, int k_) - { - k = k_; - inputState = state; - } - - public LLkParser(TokenBuffer tokenBuf, int k_) - { - k = k_; - setTokenBuffer(tokenBuf); - } - - public LLkParser(TokenStream lexer, int k_) - { - k = k_; - TokenBuffer tokenBuf = new TokenBuffer(lexer); - setTokenBuffer(tokenBuf); - } - - /*Consume another token from the input stream. Can only write sequentially! - * If you need 3 tokens ahead, you must consume() 3 times. - *

- * Note that it is possible to overwrite tokens that have not been matched. - * For example, calling consume() 3 times when k=2, means that the first token - * consumed will be overwritten with the 3rd. - */ - override public void consume() - { - inputState.input.consume(); - } - - override public int LA(int i) - { - return inputState.input.LA(i); - } - - override public IToken LT(int i) - { - return inputState.input.LT(i); - } - - private void trace(string ee, string rname) - { - traceIndent(); - Console.Out.Write(ee + rname + ((inputState.guessing > 0) ? "; [guessing]" : "; ")); - for (int i = 1; i <= k; i++) - { - if (i != 1) - { - Console.Out.Write(", "); - } - - if (LT(i) != null) - { - Console.Out.Write("LA(" + i + ")==" + LT(i).getText()); - } - else - { - Console.Out.Write("LA(" + i + ")==ull"); - } - } - - Console.Out.WriteLine(""); - } - - override public void traceIn(string rname) - { - traceDepth += 1; - trace("> ", rname); - } - - override public void traceOut(string rname) - { - trace("< ", rname); - traceDepth -= 1; - } -} diff --git a/src/Spring/Spring.Core/Expressions/Parser/antlr/LexerSharedInputState.cs b/src/Spring/Spring.Core/Expressions/Parser/antlr/LexerSharedInputState.cs deleted file mode 100644 index bd4d219db..000000000 --- a/src/Spring/Spring.Core/Expressions/Parser/antlr/LexerSharedInputState.cs +++ /dev/null @@ -1,85 +0,0 @@ -using Stream = System.IO.Stream; -using TextReader = System.IO.TextReader; - -namespace Spring.Expressions.Parser.antlr; -/*ANTLR Translator Generator - * Project led by Terence Parr at http://www.jGuru.com - * Software rights: http://www.antlr.org/license.html - * - * $Id:$ - */ - -// -// ANTLR C# Code Generator by Micheal Jordan -// Kunle Odutola : kunle UNDERSCORE odutola AT hotmail DOT com -// Anthony Oguntimehin -// -// With many thanks to Eric V. Smith from the ANTLR list. -// - -/*This object contains the data associated with an - * input stream of characters. Multiple lexers - * share a single LexerSharedInputState to lex - * the same input stream. - */ -public class LexerSharedInputState -{ - protected internal int column; - protected internal int line; - protected internal int tokenStartColumn; - protected internal int tokenStartLine; - protected internal InputBuffer input; - - /*What file (if known) caused the problem? */ - protected internal string filename; - - public int guessing; - - public LexerSharedInputState(InputBuffer inbuf) - { - initialize(); - input = inbuf; - } - - public LexerSharedInputState(Stream inStream) : this(new ByteBuffer(inStream)) - { - } - - public LexerSharedInputState(TextReader inReader) : this(new CharBuffer(inReader)) - { - } - - private void initialize() - { - column = 1; - line = 1; - tokenStartColumn = 1; - tokenStartLine = 1; - guessing = 0; - filename = null; - } - - public virtual void reset() - { - initialize(); - input.reset(); - } - - public virtual void resetInput(InputBuffer ib) - { - reset(); - input = ib; - } - - public virtual void resetInput(Stream s) - { - reset(); - input = new ByteBuffer(s); - } - - public virtual void resetInput(TextReader tr) - { - reset(); - input = new CharBuffer(tr); - } -} diff --git a/src/Spring/Spring.Core/Expressions/Parser/antlr/MismatchedCharException.cs b/src/Spring/Spring.Core/Expressions/Parser/antlr/MismatchedCharException.cs deleted file mode 100644 index 43f38b496..000000000 --- a/src/Spring/Spring.Core/Expressions/Parser/antlr/MismatchedCharException.cs +++ /dev/null @@ -1,179 +0,0 @@ -using StringBuilder = System.Text.StringBuilder; -using BitSet = Spring.Expressions.Parser.antlr.collections.impl.BitSet; - -namespace Spring.Expressions.Parser.antlr; -/*ANTLR Translator Generator - * Project led by Terence Parr at http://www.jGuru.com - * Software rights: http://www.antlr.org/license.html - * - * $Id:$ - */ - -// -// ANTLR C# Code Generator by Micheal Jordan -// Kunle Odutola : kunle UNDERSCORE odutola AT hotmail DOT com -// Anthony Oguntimehin -// -// With many thanks to Eric V. Smith from the ANTLR list. -// - -[Serializable] -public class MismatchedCharException : RecognitionException -{ - /* - * Returns a clean error message (no line number/column information) - */ - override public string Message - { - get - { - StringBuilder sb = new StringBuilder(); - - switch (mismatchType) - { - case CharTypeEnum.CharType: - sb.Append("expecting "); - appendCharName(sb, expecting); - sb.Append(", found "); - appendCharName(sb, foundChar); - break; - - case CharTypeEnum.NotCharType: - sb.Append("expecting anything but '"); - appendCharName(sb, expecting); - sb.Append("'; got it anyway"); - break; - - case CharTypeEnum.RangeType: - case CharTypeEnum.NotRangeType: - sb.Append("expecting token "); - if (mismatchType == CharTypeEnum.NotRangeType) - sb.Append("NOT "); - sb.Append("in range: "); - appendCharName(sb, expecting); - sb.Append(".."); - appendCharName(sb, upper); - sb.Append(", found "); - appendCharName(sb, foundChar); - break; - - case CharTypeEnum.SetType: - case CharTypeEnum.NotSetType: - sb.Append("expecting " + (mismatchType == CharTypeEnum.NotSetType ? "NOT " : "") + "one of ("); - int[] elems = bset.toArray(); - for (int i = 0; i < elems.Length; i++) - { - appendCharName(sb, elems[i]); - } - - sb.Append("), found "); - appendCharName(sb, foundChar); - break; - - default: - sb.Append(base.Message); - break; - } - - return sb.ToString(); - } - } - - // Types of chars - - public enum CharTypeEnum - { - CharType = 1, - NotCharType = 2, - RangeType = 3, - NotRangeType = 4, - SetType = 5, - NotSetType = 6 - } - - // One of the above - public CharTypeEnum mismatchType; - - // what was found on the input stream - public int foundChar; - - // For CHAR/NOT_CHAR and RANGE/NOT_RANGE - public int expecting; - - // For RANGE/NOT_RANGE (expecting is lower bound of range) - public int upper; - - // For SET/NOT_SET - public BitSet bset; - - // who knows...they may want to ask scanner questions - public CharScanner scanner; - - /* - * MismatchedCharException constructor comment. - */ - public MismatchedCharException() : base("Mismatched char") - { - } - - // Expected range / not range - public MismatchedCharException(char c, char lower, char upper_, bool matchNot, CharScanner scanner_) : - base("Mismatched char", scanner_.getFilename(), scanner_.getLine(), scanner_.getColumn()) - { - mismatchType = matchNot ? CharTypeEnum.NotRangeType : CharTypeEnum.RangeType; - foundChar = c; - expecting = lower; - upper = upper_; - scanner = scanner_; - } - - // Expected token / not token - public MismatchedCharException(char c, char expecting_, bool matchNot, CharScanner scanner_) : - base("Mismatched char", scanner_.getFilename(), scanner_.getLine(), scanner_.getColumn()) - { - mismatchType = matchNot ? CharTypeEnum.NotCharType : CharTypeEnum.CharType; - foundChar = c; - expecting = expecting_; - scanner = scanner_; - } - - // Expected BitSet / not BitSet - public MismatchedCharException(char c, BitSet set_, bool matchNot, CharScanner scanner_) : - base("Mismatched char", scanner_.getFilename(), scanner_.getLine(), scanner_.getColumn()) - { - mismatchType = matchNot ? CharTypeEnum.NotSetType : CharTypeEnum.SetType; - foundChar = c; - bset = set_; - scanner = scanner_; - } - - ///

- /// Append a char to the msg buffer. If special, then show escaped version - /// - /// Message buffer - /// Char to append - private void appendCharName(StringBuilder sb, int c) - { - switch (c) - { - case 65535: - // 65535 = (char) -1 = EOF - sb.Append("''"); - break; - case '\n': - sb.Append(@"'\n'"); - break; - case '\r': - sb.Append(@"'\r'"); - break; - case '\t': - sb.Append(@"'\t'"); - break; - default: - sb.Append('\''); - sb.Append((char) c); - sb.Append('\''); - break; - } - } -} diff --git a/src/Spring/Spring.Core/Expressions/Parser/antlr/MismatchedTokenException.cs b/src/Spring/Spring.Core/Expressions/Parser/antlr/MismatchedTokenException.cs deleted file mode 100644 index 37ada530c..000000000 --- a/src/Spring/Spring.Core/Expressions/Parser/antlr/MismatchedTokenException.cs +++ /dev/null @@ -1,219 +0,0 @@ -using StringBuilder = System.Text.StringBuilder; -using BitSet = Spring.Expressions.Parser.antlr.collections.impl.BitSet; -using AST = Spring.Expressions.Parser.antlr.collections.AST; - -namespace Spring.Expressions.Parser.antlr; -/*ANTLR Translator Generator - * Project led by Terence Parr at http://www.jGuru.com - * Software rights: http://www.antlr.org/license.html - * - * $Id:$ - */ - -// -// ANTLR C# Code Generator by Micheal Jordan -// Kunle Odutola : kunle UNDERSCORE odutola AT hotmail DOT com -// Anthony Oguntimehin -// -// With many thanks to Eric V. Smith from the ANTLR list. -// - -[Serializable] -public class MismatchedTokenException : RecognitionException -{ - // Token names array for formatting - internal string[] tokenNames; - - // The token that was encountered - public IToken token; - - // The offending AST node if tree walking - public AST node; - - internal string tokenText = null; // taken from node or token object - - // Types of tokens - public enum TokenTypeEnum - { - TokenType = 1, - NotTokenType = 2, - RangeType = 3, - NotRangeType = 4, - SetType = 5, - NotSetType = 6 - } - - // One of the above - public TokenTypeEnum mismatchType; - - // For TOKEN/NOT_TOKEN and RANGE/NOT_RANGE - public int expecting; - - // For RANGE/NOT_RANGE (expecting is lower bound of range) - public int upper; - - // For SET/NOT_SET - public BitSet bset; - - /*Looking for AST wildcard, didn't find it */ - public MismatchedTokenException() : base("Mismatched Token: expecting any AST node", "", -1, -1) - { - } - - // Expected range / not range - public MismatchedTokenException(string[] tokenNames_, AST node_, int lower, int upper_, bool matchNot) : - base("Mismatched Token", "", -1, -1) - { - tokenNames = tokenNames_; - node = node_; - if (node_ == null) - { - tokenText = ""; - } - else - { - tokenText = node_.ToString(); - } - - mismatchType = matchNot ? TokenTypeEnum.NotRangeType : TokenTypeEnum.RangeType; - expecting = lower; - upper = upper_; - } - - // Expected token / not token - public MismatchedTokenException(string[] tokenNames_, AST node_, int expecting_, bool matchNot) : - base("Mismatched Token", "", -1, -1) - { - tokenNames = tokenNames_; - node = node_; - if (node_ == null) - { - tokenText = ""; - } - else - { - tokenText = node_.ToString(); - } - - mismatchType = matchNot ? TokenTypeEnum.NotTokenType : TokenTypeEnum.TokenType; - expecting = expecting_; - } - - // Expected BitSet / not BitSet - public MismatchedTokenException(string[] tokenNames_, AST node_, BitSet set_, bool matchNot) : - base("Mismatched Token", "", -1, -1) - { - tokenNames = tokenNames_; - node = node_; - if (node_ == null) - { - tokenText = ""; - } - else - { - tokenText = node_.ToString(); - } - - mismatchType = matchNot ? TokenTypeEnum.NotSetType : TokenTypeEnum.SetType; - bset = set_; - } - - // Expected range / not range - public MismatchedTokenException(string[] tokenNames_, IToken token_, int lower, int upper_, bool matchNot, string fileName_) : - base("Mismatched Token", fileName_, token_.getLine(), token_.getColumn()) - { - tokenNames = tokenNames_; - token = token_; - tokenText = token_.getText(); - mismatchType = matchNot ? TokenTypeEnum.NotRangeType : TokenTypeEnum.RangeType; - expecting = lower; - upper = upper_; - } - - // Expected token / not token - public MismatchedTokenException(string[] tokenNames_, IToken token_, int expecting_, bool matchNot, string fileName_) : - base("Mismatched Token", fileName_, token_.getLine(), token_.getColumn()) - { - tokenNames = tokenNames_; - token = token_; - tokenText = token_.getText(); - mismatchType = matchNot ? TokenTypeEnum.NotTokenType : TokenTypeEnum.TokenType; - expecting = expecting_; - } - - // Expected BitSet / not BitSet - public MismatchedTokenException(string[] tokenNames_, IToken token_, BitSet set_, bool matchNot, string fileName_) : - base("Mismatched Token", fileName_, token_.getLine(), token_.getColumn()) - { - tokenNames = tokenNames_; - token = token_; - tokenText = token_.getText(); - mismatchType = matchNot ? TokenTypeEnum.NotSetType : TokenTypeEnum.SetType; - bset = set_; - } - - /* - * Returns a clean error message (no line number/column information) - */ - override public string Message - { - get - { - StringBuilder sb = new StringBuilder(); - - switch (mismatchType) - { - case TokenTypeEnum.TokenType: - sb.Append("expecting " + tokenName(expecting) + ", found '" + tokenText + "'"); - break; - - case TokenTypeEnum.NotTokenType: - sb.Append("expecting anything but " + tokenName(expecting) + "; got it anyway"); - break; - - case TokenTypeEnum.RangeType: - sb.Append("expecting token in range: " + tokenName(expecting) + ".." + tokenName(upper) + ", found '" + tokenText + "'"); - break; - - case TokenTypeEnum.NotRangeType: - sb.Append("expecting token NOT in range: " + tokenName(expecting) + ".." + tokenName(upper) + ", found '" + tokenText + "'"); - break; - - case TokenTypeEnum.SetType: - case TokenTypeEnum.NotSetType: - sb.Append("expecting " + (mismatchType == TokenTypeEnum.NotSetType ? "NOT " : "") + "one of ("); - int[] elems = bset.toArray(); - for (int i = 0; i < elems.Length; i++) - { - sb.Append(" "); - sb.Append(tokenName(elems[i])); - } - - sb.Append("), found '" + tokenText + "'"); - break; - - default: - sb.Append(base.Message); - break; - } - - return sb.ToString(); - } - } - - private string tokenName(int tokenType) - { - if (tokenType == Token.INVALID_TYPE) - { - return ""; - } - else if (tokenType < 0 || tokenType >= tokenNames.Length) - { - return "<" + tokenType.ToString() + ">"; - } - else - { - return tokenNames[tokenType]; - } - } -} diff --git a/src/Spring/Spring.Core/Expressions/Parser/antlr/NoViableAltException.cs b/src/Spring/Spring.Core/Expressions/Parser/antlr/NoViableAltException.cs deleted file mode 100644 index 594ae7116..000000000 --- a/src/Spring/Spring.Core/Expressions/Parser/antlr/NoViableAltException.cs +++ /dev/null @@ -1,58 +0,0 @@ -using AST = Spring.Expressions.Parser.antlr.collections.AST; - -namespace Spring.Expressions.Parser.antlr; -/*ANTLR Translator Generator - * Project led by Terence Parr at http://www.jGuru.com - * Software rights: http://www.antlr.org/license.html - * - * $Id:$ - */ - -// -// ANTLR C# Code Generator by Micheal Jordan -// Kunle Odutola : kunle UNDERSCORE odutola AT hotmail DOT com -// Anthony Oguntimehin -// -// With many thanks to Eric V. Smith from the ANTLR list. -// - -[Serializable] -public class NoViableAltException : RecognitionException -{ - public IToken token; - public AST node; // handles parsing and treeparsing - - public NoViableAltException(AST t) : base("NoViableAlt", "", -1, -1) - { - node = t; - } - - public NoViableAltException(IToken t, string fileName_) : - base("NoViableAlt", fileName_, t.getLine(), t.getColumn()) - { - token = t; - } - - /* - * Returns a clean error message (no line number/column information) - */ - override public string Message - { - get - { - if (token != null) - { - //return "unexpected token: " + token.getText(); - return "unexpected token: " + token.ToString(); - } - - // must a tree parser error if token==null - if ((node == null) || (node == TreeParser.ASTNULL)) - { - return "unexpected end of subtree"; - } - - return "unexpected AST node: " + node.ToString(); - } - } -} diff --git a/src/Spring/Spring.Core/Expressions/Parser/antlr/NoViableAltForCharException.cs b/src/Spring/Spring.Core/Expressions/Parser/antlr/NoViableAltForCharException.cs deleted file mode 100644 index ae661cd08..000000000 --- a/src/Spring/Spring.Core/Expressions/Parser/antlr/NoViableAltForCharException.cs +++ /dev/null @@ -1,64 +0,0 @@ -using StringBuilder = System.Text.StringBuilder; - -namespace Spring.Expressions.Parser.antlr; -/*ANTLR Translator Generator - * Project led by Terence Parr at http://www.jGuru.com - * Software rights: http://www.antlr.org/license.html - * - * $Id:$ - */ - -// -// ANTLR C# Code Generator by Micheal Jordan -// Kunle Odutola : kunle UNDERSCORE odutola AT hotmail DOT com -// Anthony Oguntimehin -// -// With many thanks to Eric V. Smith from the ANTLR list. -// - -[Serializable] -public class NoViableAltForCharException : RecognitionException -{ - public char foundChar; - - public NoViableAltForCharException(char c, CharScanner scanner) : - base("NoViableAlt", scanner.getFilename(), scanner.getLine(), scanner.getColumn()) - { - foundChar = c; - } - - public NoViableAltForCharException(char c, string fileName, int line, int column) : - base("NoViableAlt", fileName, line, column) - { - foundChar = c; - } - - /* - * Returns a clean error message (no line number/column information) - */ - override public string Message - { - get - { - StringBuilder mesg = new StringBuilder("unexpected char: "); - - // I'm trying to mirror a change in the C++ stuff. - // But java seems to lack something isprint-ish.. - // so we do it manually. This is probably too restrictive. - - if ((foundChar >= ' ') && (foundChar <= '~')) - { - mesg.Append('\''); - mesg.Append(foundChar); - mesg.Append('\''); - } - else - { - mesg.Append("0x"); - mesg.Append(((int) foundChar).ToString("X")); - } - - return mesg.ToString(); - } - } -} diff --git a/src/Spring/Spring.Core/Expressions/Parser/antlr/ParseTree.cs b/src/Spring/Spring.Core/Expressions/Parser/antlr/ParseTree.cs deleted file mode 100644 index 19d6133ad..000000000 --- a/src/Spring/Spring.Core/Expressions/Parser/antlr/ParseTree.cs +++ /dev/null @@ -1,74 +0,0 @@ -namespace Spring.Expressions.Parser.antlr; - -/* ANTLR Translator Generator - * Project led by Terence Parr at http://www.jGuru.com - * Software rights: http://www.antlr.org/license.html - */ - -// -// ANTLR C# Code Generator by Micheal Jordan -// Kunle Odutola : kunle UNDERSCORE odutola AT hotmail DOT com -// Anthony Oguntimehin -// -using StringBuilder = System.Text.StringBuilder; -using AST = antlr.collections.AST; - -public abstract class ParseTree : BaseAST -{ - /// - /// Walk parse tree and return requested number of derivation steps. - /// If steps less-than 0, return node text. If steps equals 1, return derivation - /// string at step. - /// - /// derivation steps - /// - public string getLeftmostDerivationStep(int step) - { - if (step <= 0) - { - return ToString(); - } - - StringBuilder buf = new StringBuilder(2000); - getLeftmostDerivation(buf, step); - return buf.ToString(); - } - - public string getLeftmostDerivation(int maxSteps) - { - StringBuilder buf = new StringBuilder(2000); - buf.Append(" " + this.ToString()); - buf.Append("\n"); - for (int d = 1; d < maxSteps; d++) - { - buf.Append(" =>"); - buf.Append(getLeftmostDerivationStep(d)); - buf.Append("\n"); - } - - return buf.ToString(); - } - - /// - /// Get derivation and return how many you did (less than requested for - /// subtree roots. - /// - /// string buffer - /// derivation steps - /// - protected internal abstract int getLeftmostDerivation(StringBuilder buf, int step); - - // just satisfy BaseAST interface; unused as we manually create nodes - - public override void initialize(int i, string s) - { - } - - public override void initialize(AST ast) - { - } - - public override void initialize(IToken token) - { - } -} diff --git a/src/Spring/Spring.Core/Expressions/Parser/antlr/ParseTreeRule.cs b/src/Spring/Spring.Core/Expressions/Parser/antlr/ParseTreeRule.cs deleted file mode 100644 index 43c8b5da7..000000000 --- a/src/Spring/Spring.Core/Expressions/Parser/antlr/ParseTreeRule.cs +++ /dev/null @@ -1,91 +0,0 @@ -namespace Spring.Expressions.Parser.antlr; - -/* ANTLR Translator Generator - * Project led by Terence Parr at http://www.jGuru.com - * Software rights: http://www.antlr.org/license.html - */ - -// -// ANTLR C# Code Generator by Micheal Jordan -// Kunle Odutola : kunle UNDERSCORE odutola AT hotmail DOT com -// Anthony Oguntimehin -// -using StringBuilder = System.Text.StringBuilder; -using AST = antlr.collections.AST; - -public class ParseTreeRule : ParseTree -{ - public const int INVALID_ALT = -1; - - protected string ruleName; - protected int altNumber; // unused until I modify antlr to record this - - public ParseTreeRule(string ruleName) : this(ruleName, INVALID_ALT) - { - } - - public ParseTreeRule(string ruleName, int altNumber) - { - this.ruleName = ruleName; - this.altNumber = altNumber; - } - - public string getRuleName() - { - return ruleName; - } - - /// - /// Do a step-first walk, building up a buffer of tokens until - /// you've reached a particular step and print out any rule subroots - /// insteads of descending. - /// - /// derivation buffer - /// derivation steps - /// - protected internal override int getLeftmostDerivation(StringBuilder buf, int step) - { - int numReplacements = 0; - if (step <= 0) - { - buf.Append(' '); - buf.Append(ToString()); - return numReplacements; - } - - AST child = getFirstChild(); - numReplacements = 1; - // walk child printing them out, descending into at most one - while (child != null) - { - if ((numReplacements >= step) || (child is ParseTreeToken)) - { - buf.Append(' '); - buf.Append(child.ToString()); - } - else - { - // descend for at least one more derivation; update count - int remainingReplacements = step - numReplacements; - int n = ((ParseTree) child).getLeftmostDerivation(buf, remainingReplacements); - numReplacements += n; - } - - child = child.getNextSibling(); - } - - return numReplacements; - } - - public override string ToString() - { - if (altNumber == INVALID_ALT) - { - return '<' + ruleName + '>'; - } - else - { - return '<' + ruleName + "[" + altNumber + "]>"; - } - } -} diff --git a/src/Spring/Spring.Core/Expressions/Parser/antlr/ParseTreeToken.cs b/src/Spring/Spring.Core/Expressions/Parser/antlr/ParseTreeToken.cs deleted file mode 100644 index 6601d5a18..000000000 --- a/src/Spring/Spring.Core/Expressions/Parser/antlr/ParseTreeToken.cs +++ /dev/null @@ -1,40 +0,0 @@ -namespace Spring.Expressions.Parser.antlr; - -/* ANTLR Translator Generator - * Project led by Terence Parr at http://www.jGuru.com - * Software rights: http://www.antlr.org/license.html - */ - -// -// ANTLR C# Code Generator by Micheal Jordan -// Kunle Odutola : kunle UNDERSCORE odutola AT hotmail DOT com -// Anthony Oguntimehin -// -using StringBuilder = System.Text.StringBuilder; - -public class ParseTreeToken : ParseTree -{ - protected IToken token; - - public ParseTreeToken(IToken token) - { - this.token = token; - } - - protected override internal int getLeftmostDerivation(StringBuilder buf, int step) - { - buf.Append(' '); - buf.Append(ToString()); - return step; // did on replacements - } - - public override string ToString() - { - if (token != null) - { - return token.getText(); - } - - return ""; - } -} diff --git a/src/Spring/Spring.Core/Expressions/Parser/antlr/Parser.cs b/src/Spring/Spring.Core/Expressions/Parser/antlr/Parser.cs deleted file mode 100644 index af308e47b..000000000 --- a/src/Spring/Spring.Core/Expressions/Parser/antlr/Parser.cs +++ /dev/null @@ -1,524 +0,0 @@ -using Spring.Expressions.Parser.antlr.debug; -using EventHandlerList = System.ComponentModel.EventHandlerList; -using BitSet = Spring.Expressions.Parser.antlr.collections.impl.BitSet; -using AST = Spring.Expressions.Parser.antlr.collections.AST; -using MessageListener = Spring.Expressions.Parser.antlr.debug.MessageListener; -using ParserListener = Spring.Expressions.Parser.antlr.debug.ParserListener; -using ParserMatchListener = Spring.Expressions.Parser.antlr.debug.ParserMatchListener; -using ParserTokenListener = Spring.Expressions.Parser.antlr.debug.ParserTokenListener; -using SemanticPredicateListener = Spring.Expressions.Parser.antlr.debug.SemanticPredicateListener; -using SyntacticPredicateListener = Spring.Expressions.Parser.antlr.debug.SyntacticPredicateListener; -using TraceListener = Spring.Expressions.Parser.antlr.debug.TraceListener; - -/* - private Vector messageListeners; - private Vector newLineListeners; - private Vector matchListeners; - private Vector tokenListeners; - private Vector semPredListeners; - private Vector synPredListeners; - private Vector traceListeners; -*/ - -namespace Spring.Expressions.Parser.antlr; -/*ANTLR Translator Generator - * Project led by Terence Parr at http://www.jGuru.com - * Software rights: http://www.antlr.org/license.html - * - * $Id:$ - */ - -// -// ANTLR C# Code Generator by Micheal Jordan -// Kunle Odutola : kunle UNDERSCORE odutola AT hotmail DOT com -// Anthony Oguntimehin -// -// With many thanks to Eric V. Smith from the ANTLR list. -// - -public abstract class Parser : IParserDebugSubject -{ - // Used to store event delegates - private EventHandlerList events_ = new EventHandlerList(); - - protected internal EventHandlerList Events - { - get { return events_; } - } - - // The unique keys for each event that Parser [objects] can generate - internal static readonly object EnterRuleEventKey = new object(); - internal static readonly object ExitRuleEventKey = new object(); - internal static readonly object DoneEventKey = new object(); - internal static readonly object ReportErrorEventKey = new object(); - internal static readonly object ReportWarningEventKey = new object(); - internal static readonly object NewLineEventKey = new object(); - internal static readonly object MatchEventKey = new object(); - internal static readonly object MatchNotEventKey = new object(); - internal static readonly object MisMatchEventKey = new object(); - internal static readonly object MisMatchNotEventKey = new object(); - internal static readonly object ConsumeEventKey = new object(); - internal static readonly object LAEventKey = new object(); - internal static readonly object SemPredEvaluatedEventKey = new object(); - internal static readonly object SynPredStartedEventKey = new object(); - internal static readonly object SynPredFailedEventKey = new object(); - internal static readonly object SynPredSucceededEventKey = new object(); - - protected internal ParserSharedInputState inputState; - - /*Nesting level of registered handlers */ - // protected int exceptionLevel = 0; - - /*Table of token type to token names */ - protected internal string[] tokenNames; - - /*AST return value for a rule is squirreled away here */ - protected internal AST returnAST; - - /*AST support code; parser and treeparser delegate to this object */ - protected internal ASTFactory astFactory = new ASTFactory(); - - private bool ignoreInvalidDebugCalls = false; - - /*Used to keep track of indentdepth for traceIn/Out */ - protected internal int traceDepth = 0; - - public Parser() - { - inputState = new ParserSharedInputState(); - } - - public Parser(ParserSharedInputState state) - { - inputState = state; - } - - /// - /// - /// - public event TraceEventHandler EnterRule - { - add { Events.AddHandler(EnterRuleEventKey, value); } - remove { Events.RemoveHandler(EnterRuleEventKey, value); } - } - - public event TraceEventHandler ExitRule - { - add { Events.AddHandler(ExitRuleEventKey, value); } - remove { Events.RemoveHandler(ExitRuleEventKey, value); } - } - - public event TraceEventHandler Done - { - add { Events.AddHandler(DoneEventKey, value); } - remove { Events.RemoveHandler(DoneEventKey, value); } - } - - public event MessageEventHandler ErrorReported - { - add { Events.AddHandler(ReportErrorEventKey, value); } - remove { Events.RemoveHandler(ReportErrorEventKey, value); } - } - - public event MessageEventHandler WarningReported - { - add { Events.AddHandler(ReportWarningEventKey, value); } - remove { Events.RemoveHandler(ReportWarningEventKey, value); } - } - - public event MatchEventHandler MatchedToken - { - add { Events.AddHandler(MatchEventKey, value); } - remove { Events.RemoveHandler(MatchEventKey, value); } - } - - public event MatchEventHandler MatchedNotToken - { - add { Events.AddHandler(MatchNotEventKey, value); } - remove { Events.RemoveHandler(MatchNotEventKey, value); } - } - - public event MatchEventHandler MisMatchedToken - { - add { Events.AddHandler(MisMatchEventKey, value); } - remove { Events.RemoveHandler(MisMatchEventKey, value); } - } - - public event MatchEventHandler MisMatchedNotToken - { - add { Events.AddHandler(MisMatchNotEventKey, value); } - remove { Events.RemoveHandler(MisMatchNotEventKey, value); } - } - - public event TokenEventHandler ConsumedToken - { - add { Events.AddHandler(ConsumeEventKey, value); } - remove { Events.RemoveHandler(ConsumeEventKey, value); } - } - - public event TokenEventHandler TokenLA - { - add { Events.AddHandler(LAEventKey, value); } - remove { Events.RemoveHandler(LAEventKey, value); } - } - - public event SemanticPredicateEventHandler SemPredEvaluated - { - add { Events.AddHandler(SemPredEvaluatedEventKey, value); } - remove { Events.RemoveHandler(SemPredEvaluatedEventKey, value); } - } - - public event SyntacticPredicateEventHandler SynPredStarted - { - add { Events.AddHandler(SynPredStartedEventKey, value); } - remove { Events.RemoveHandler(SynPredStartedEventKey, value); } - } - - public event SyntacticPredicateEventHandler SynPredFailed - { - add { Events.AddHandler(SynPredFailedEventKey, value); } - remove { Events.RemoveHandler(SynPredFailedEventKey, value); } - } - - public event SyntacticPredicateEventHandler SynPredSucceeded - { - add { Events.AddHandler(SynPredSucceededEventKey, value); } - remove { Events.RemoveHandler(SynPredSucceededEventKey, value); } - } - - public virtual void addMessageListener(MessageListener l) - { - if (!ignoreInvalidDebugCalls) - throw new System.ArgumentException("addMessageListener() is only valid if parser built for debugging"); - } - - public virtual void addParserListener(ParserListener l) - { - if (!ignoreInvalidDebugCalls) - throw new System.ArgumentException("addParserListener() is only valid if parser built for debugging"); - } - - public virtual void addParserMatchListener(ParserMatchListener l) - { - if (!ignoreInvalidDebugCalls) - throw new System.ArgumentException("addParserMatchListener() is only valid if parser built for debugging"); - } - - public virtual void addParserTokenListener(ParserTokenListener l) - { - if (!ignoreInvalidDebugCalls) - throw new System.ArgumentException("addParserTokenListener() is only valid if parser built for debugging"); - } - - public virtual void addSemanticPredicateListener(SemanticPredicateListener l) - { - if (!ignoreInvalidDebugCalls) - throw new System.ArgumentException("addSemanticPredicateListener() is only valid if parser built for debugging"); - } - - public virtual void addSyntacticPredicateListener(SyntacticPredicateListener l) - { - if (!ignoreInvalidDebugCalls) - throw new System.ArgumentException("addSyntacticPredicateListener() is only valid if parser built for debugging"); - } - - public virtual void addTraceListener(TraceListener l) - { - if (!ignoreInvalidDebugCalls) - throw new System.ArgumentException("addTraceListener() is only valid if parser built for debugging"); - } - - /*Get another token object from the token stream */ - public abstract void consume(); - - /*Consume tokens until one matches the given token */ - public virtual void consumeUntil(int tokenType) - { - while (LA(1) != Token.EOF_TYPE && LA(1) != tokenType) - { - consume(); - } - } - - /*Consume tokens until one matches the given token set */ - public virtual void consumeUntil(BitSet bset) - { - while (LA(1) != Token.EOF_TYPE && !bset.member(LA(1))) - { - consume(); - } - } - - protected internal virtual void defaultDebuggingSetup(TokenStream lexer, TokenBuffer tokBuf) - { - // by default, do nothing -- we're not debugging - } - - /*Get the AST return value squirreled away in the parser */ - public virtual AST getAST() - { - return returnAST; - } - - public virtual ASTFactory getASTFactory() - { - return astFactory; - } - - public virtual string getFilename() - { - return inputState.filename; - } - - public virtual ParserSharedInputState getInputState() - { - return inputState; - } - - public virtual void setInputState(ParserSharedInputState state) - { - inputState = state; - } - - public virtual void resetState() - { - traceDepth = 0; - inputState.reset(); - } - - public virtual string getTokenName(int num) - { - return tokenNames[num]; - } - - public virtual string[] getTokenNames() - { - return tokenNames; - } - - public virtual bool isDebugMode() - { - return false; - } - - /*Return the token type of the ith token of lookahead where i=1 - * is the current token being examined by the parser (i.e., it - * has not been matched yet). - */ - public abstract int LA(int i); - - /*Return the ith token of lookahead */ - public abstract IToken LT(int i); - - // Forwarded to TokenBuffer - public virtual int mark() - { - return inputState.input.mark(); - } - - /*Make sure current lookahead symbol matches token type t. - * Throw an exception upon mismatch, which is catch by either the - * error handler or by the syntactic predicate. - */ - public virtual void match(int t) - { - if (LA(1) != t) - throw new MismatchedTokenException(tokenNames, LT(1), t, false, getFilename()); - else - consume(); - } - - /*Make sure current lookahead symbol matches the given set - * Throw an exception upon mismatch, which is catch by either the - * error handler or by the syntactic predicate. - */ - public virtual void match(BitSet b) - { - if (!b.member(LA(1))) - throw new MismatchedTokenException(tokenNames, LT(1), b, false, getFilename()); - else - consume(); - } - - public virtual void matchNot(int t) - { - if (LA(1) == t) - throw new MismatchedTokenException(tokenNames, LT(1), t, true, getFilename()); - else - consume(); - } - - /// - /// @deprecated as of 2.7.2. This method calls System.exit() and writes - /// directly to stderr, which is usually not appropriate when - /// a parser is embedded into a larger application. Since the method is - /// static, it cannot be overridden to avoid these problems. - /// ANTLR no longer uses this method internally or in generated code. - /// - /// - [Obsolete("De-activated since version 2.7.2.6 as it cannot be overidden.", true)] - public static void panic() - { - System.Console.Error.WriteLine("Parser: panic"); - System.Environment.Exit(1); - } - - public virtual void removeMessageListener(MessageListener l) - { - if (!ignoreInvalidDebugCalls) - throw new System.SystemException("removeMessageListener() is only valid if parser built for debugging"); - } - - public virtual void removeParserListener(ParserListener l) - { - if (!ignoreInvalidDebugCalls) - throw new System.SystemException("removeParserListener() is only valid if parser built for debugging"); - } - - public virtual void removeParserMatchListener(ParserMatchListener l) - { - if (!ignoreInvalidDebugCalls) - throw new System.SystemException("removeParserMatchListener() is only valid if parser built for debugging"); - } - - public virtual void removeParserTokenListener(ParserTokenListener l) - { - if (!ignoreInvalidDebugCalls) - throw new System.SystemException("removeParserTokenListener() is only valid if parser built for debugging"); - } - - public virtual void removeSemanticPredicateListener(SemanticPredicateListener l) - { - if (!ignoreInvalidDebugCalls) - throw new System.ArgumentException("removeSemanticPredicateListener() is only valid if parser built for debugging"); - } - - public virtual void removeSyntacticPredicateListener(SyntacticPredicateListener l) - { - if (!ignoreInvalidDebugCalls) - throw new System.ArgumentException("removeSyntacticPredicateListener() is only valid if parser built for debugging"); - } - - public virtual void removeTraceListener(TraceListener l) - { - if (!ignoreInvalidDebugCalls) - throw new System.SystemException("removeTraceListener() is only valid if parser built for debugging"); - } - - /*Parser error-reporting function can be overridden in subclass */ - public virtual void reportError(RecognitionException ex) - { - Console.Error.WriteLine(ex); - } - - /*Parser error-reporting function can be overridden in subclass */ - public virtual void reportError(string s) - { - if (getFilename() == null) - { - Console.Error.WriteLine("error: " + s); - } - else - { - Console.Error.WriteLine(getFilename() + ": error: " + s); - } - } - - /*Parser warning-reporting function can be overridden in subclass */ - public virtual void reportWarning(string s) - { - if (getFilename() == null) - { - Console.Error.WriteLine("warning: " + s); - } - else - { - Console.Error.WriteLine(getFilename() + ": warning: " + s); - } - } - - public virtual void recover(RecognitionException ex, BitSet tokenSet) - { - consume(); - consumeUntil(tokenSet); - } - - public virtual void rewind(int pos) - { - inputState.input.rewind(pos); - } - - /// - /// Specify an object with support code (shared by Parser and TreeParser. - /// Normally, the programmer does not play with this, using - /// instead. - /// - /// - public virtual void setASTFactory(ASTFactory f) - { - astFactory = f; - } - - /// - /// Specify the type of node to create during tree building. - /// - /// Fully qualified AST Node type name. - public virtual void setASTNodeClass(string cl) - { - astFactory.setASTNodeType(cl); - } - - /// - /// Specify the type of node to create during tree building. - /// use now to be consistent with - /// Token Object Type accessor. - /// - /// Fully qualified AST Node type name. - [Obsolete("Replaced by setASTNodeClass(string) since version 2.7.1", true)] - public virtual void setASTNodeType(string nodeType) - { - setASTNodeClass(nodeType); - } - - public virtual void setDebugMode(bool debugMode) - { - if (!ignoreInvalidDebugCalls) - throw new System.SystemException("setDebugMode() only valid if parser built for debugging"); - } - - public virtual void setFilename(string f) - { - inputState.filename = f; - } - - public virtual void setIgnoreInvalidDebugCalls(bool Value) - { - ignoreInvalidDebugCalls = Value; - } - - /*Set or change the input token buffer */ - public virtual void setTokenBuffer(TokenBuffer t) - { - inputState.input = t; - } - - public virtual void traceIndent() - { - for (int i = 0; i < traceDepth; i++) - Console.Out.Write(" "); - } - - public virtual void traceIn(string rname) - { - traceDepth += 1; - traceIndent(); - Console.Out.WriteLine("> " + rname + "; LA(1)==" + LT(1).getText() + ((inputState.guessing > 0) ? " [guessing]" : "")); - } - - public virtual void traceOut(string rname) - { - traceIndent(); - Console.Out.WriteLine("< " + rname + "; LA(1)==" + LT(1).getText() + ((inputState.guessing > 0) ? " [guessing]" : "")); - traceDepth -= 1; - } -} diff --git a/src/Spring/Spring.Core/Expressions/Parser/antlr/ParserSharedInputState.cs b/src/Spring/Spring.Core/Expressions/Parser/antlr/ParserSharedInputState.cs deleted file mode 100644 index db00dae42..000000000 --- a/src/Spring/Spring.Core/Expressions/Parser/antlr/ParserSharedInputState.cs +++ /dev/null @@ -1,39 +0,0 @@ -namespace Spring.Expressions.Parser.antlr; -/*ANTLR Translator Generator - * Project led by Terence Parr at http://www.jGuru.com - * Software rights: http://www.antlr.org/license.html - * - * $Id:$ - */ - -// -// ANTLR C# Code Generator by Micheal Jordan -// Kunle Odutola : kunle UNDERSCORE odutola AT hotmail DOT com -// Anthony Oguntimehin -// -// With many thanks to Eric V. Smith from the ANTLR list. -// -/*This object contains the data associated with an - * input stream of tokens. Multiple parsers - * share a single ParserSharedInputState to parse - * the same stream of tokens. - */ - -public class ParserSharedInputState -{ - /*Where to get token objects */ - protected internal TokenBuffer input; - - /*Are we guessing (guessing>0)? */ - public int guessing = 0; - - /*What file (if known) caused the problem? */ - protected internal string filename; - - public virtual void reset() - { - guessing = 0; - filename = null; - input.reset(); - } -} \ No newline at end of file diff --git a/src/Spring/Spring.Core/Expressions/Parser/antlr/RecognitionException.cs b/src/Spring/Spring.Core/Expressions/Parser/antlr/RecognitionException.cs deleted file mode 100644 index 91447bb0c..000000000 --- a/src/Spring/Spring.Core/Expressions/Parser/antlr/RecognitionException.cs +++ /dev/null @@ -1,78 +0,0 @@ -namespace Spring.Expressions.Parser.antlr; -/*ANTLR Translator Generator - * Project led by Terence Parr at http://www.jGuru.com - * Software rights: http://www.antlr.org/license.html - * - * $Id:$ - */ - -// -// ANTLR C# Code Generator by Micheal Jordan -// Kunle Odutola : kunle UNDERSCORE odutola AT hotmail DOT com -// Anthony Oguntimehin -// -// With many thanks to Eric V. Smith from the ANTLR list. -// - -[Serializable] -public class RecognitionException : ANTLRException -{ - public string fileName; // not used by treeparsers - public int line; // not used by treeparsers - public int column; // not used by treeparsers - - public RecognitionException() : base("parsing error") - { - fileName = null; - line = -1; - column = -1; - } - - /* - * RecognitionException constructor comment. - * @param s java.lang.String - */ - public RecognitionException(string s) : base(s) - { - fileName = null; - line = -1; - column = -1; - } - - /* - * RecognitionException constructor comment. - * @param s java.lang.String - */ - public RecognitionException(string s, string fileName_, int line_, int column_) : base(s) - { - fileName = fileName_; - line = line_; - column = column_; - } - - public virtual string getFilename() - { - return fileName; - } - - public virtual int getLine() - { - return line; - } - - public virtual int getColumn() - { - return column; - } - - [Obsolete("Replaced by Message property since version 2.7.0", true)] - public virtual string getErrorMessage() - { - return Message; - } - - override public string ToString() - { - return FileLineFormatter.getFormatter().getFormatString(fileName, line, column) + Message; - } -} diff --git a/src/Spring/Spring.Core/Expressions/Parser/antlr/SemanticException.cs b/src/Spring/Spring.Core/Expressions/Parser/antlr/SemanticException.cs deleted file mode 100644 index 65e5b6bf8..000000000 --- a/src/Spring/Spring.Core/Expressions/Parser/antlr/SemanticException.cs +++ /dev/null @@ -1,34 +0,0 @@ -namespace Spring.Expressions.Parser.antlr; -/*ANTLR Translator Generator - * Project led by Terence Parr at http://www.jGuru.com - * Software rights: http://www.antlr.org/license.html - * - * $Id:$ - */ - -// -// ANTLR C# Code Generator by Micheal Jordan -// Kunle Odutola : kunle UNDERSCORE odutola AT hotmail DOT com -// Anthony Oguntimehin -// -// With many thanks to Eric V. Smith from the ANTLR list. -// - -[Serializable] -public class SemanticException : RecognitionException -{ - public SemanticException(string s) : base(s) - { - } - - [Obsolete("Replaced by SemanticException(string, string, int, int) since version 2.7.2.6", false)] - public SemanticException(String s, String fileName, int line) : - this(s, fileName, line, -1) - { - } - - public SemanticException(string s, string fileName, int line, int column) : - base(s, fileName, line, column) - { - } -} diff --git a/src/Spring/Spring.Core/Expressions/Parser/antlr/StringUtils.cs b/src/Spring/Spring.Core/Expressions/Parser/antlr/StringUtils.cs deleted file mode 100644 index 4a376c0ab..000000000 --- a/src/Spring/Spring.Core/Expressions/Parser/antlr/StringUtils.cs +++ /dev/null @@ -1,117 +0,0 @@ -namespace Spring.Expressions.Parser.antlr; -/* ANTLR Translator Generator - * Project led by Terence Parr at http://www.jGuru.com - * Software rights: http://www.antlr.org/license.html - * - * $Id:$ - */ -// -// ANTLR C# Code Generator by Micheal Jordan -// Kunle Odutola : kunle UNDERSCORE odutola AT hotmail DOT com -// Anthony Oguntimehin -// -// With many thanks to Eric V. Smith from the ANTLR list. -// - -public class StringUtils -{ - /*General-purpose utility function for removing - * characters from back of string - * @param s The string to process - * @param c The character to remove - * @return The resulting string - */ - static public string stripBack(string s, char c) - { - while (s.Length > 0 && s[s.Length - 1] == c) - { - s = s.Substring(0, (s.Length - 1) - (0)); - } - - return s; - } - - /*General-purpose utility function for removing - * characters from back of string - * @param s The string to process - * @param remove A string containing the set of characters to remove - * @return The resulting string - */ - static public string stripBack(string s, string remove) - { - bool changed; - do - { - changed = false; - for (int i = 0; i < remove.Length; i++) - { - char c = remove[i]; - while (s.Length > 0 && s[s.Length - 1] == c) - { - changed = true; - s = s.Substring(0, (s.Length - 1) - (0)); - } - } - } while (changed); - - return s; - } - - /*General-purpose utility function for removing - * characters from front of string - * @param s The string to process - * @param c The character to remove - * @return The resulting string - */ - static public string stripFront(string s, char c) - { - while (s.Length > 0 && s[0] == c) - { - s = s.Substring(1); - } - - return s; - } - - /*General-purpose utility function for removing - * characters from front of string - * @param s The string to process - * @param remove A string containing the set of characters to remove - * @return The resulting string - */ - static public string stripFront(string s, string remove) - { - bool changed; - do - { - changed = false; - for (int i = 0; i < remove.Length; i++) - { - char c = remove[i]; - while (s.Length > 0 && s[0] == c) - { - changed = true; - s = s.Substring(1); - } - } - } while (changed); - - return s; - } - - /*General-purpose utility function for removing - * characters from the front and back of string - * @param s The string to process - * @param head exact string to strip from head - * @param tail exact string to strip from tail - * @return The resulting string - */ - public static string stripFrontBack(string src, string head, string tail) - { - int h = src.IndexOf(head); - int t = src.LastIndexOf(tail); - if (h == -1 || t == -1) - return src; - return src.Substring(h + 1, (t) - (h + 1)); - } -} diff --git a/src/Spring/Spring.Core/Expressions/Parser/antlr/SupportClass.cs b/src/Spring/Spring.Core/Expressions/Parser/antlr/SupportClass.cs deleted file mode 100644 index ab9df1c3d..000000000 --- a/src/Spring/Spring.Core/Expressions/Parser/antlr/SupportClass.cs +++ /dev/null @@ -1,30 +0,0 @@ -namespace Spring.Expressions.Parser.antlr; - -internal class SupportClass -{ - public static int URShift(int number, int bits) - { - if (number >= 0) - return number >> bits; - else - return (number >> bits) + (2 << ~bits); - } - - public static int URShift(int number, long bits) - { - return URShift(number, (int) bits); - } - - public static long URShift(long number, int bits) - { - if (number >= 0) - return number >> bits; - else - return (number >> bits) + (2L << ~bits); - } - - public static long URShift(long number, long bits) - { - return URShift(number, (int) bits); - } -} diff --git a/src/Spring/Spring.Core/Expressions/Parser/antlr/Token.cs b/src/Spring/Spring.Core/Expressions/Parser/antlr/Token.cs deleted file mode 100644 index d004d894b..000000000 --- a/src/Spring/Spring.Core/Expressions/Parser/antlr/Token.cs +++ /dev/null @@ -1,102 +0,0 @@ -namespace Spring.Expressions.Parser.antlr; -/*ANTLR Translator Generator - * Project led by Terence Parr at http://www.jGuru.com - * Software rights: http://www.antlr.org/license.html - * - * $Id:$ - */ - -// -// ANTLR C# Code Generator by Micheal Jordan -// Kunle Odutola : kunle UNDERSCORE odutola AT hotmail DOT com -// Anthony Oguntimehin -// -// With many thanks to Eric V. Smith from the ANTLR list. -// -/*A token is minimally a token type. Subclasses can add the text matched - * for the token and line info. - */ - -public class Token : IToken //, ICloneable -{ - // constants - public const int MIN_USER_TYPE = 4; - public const int NULL_TREE_LOOKAHEAD = 3; - public const int INVALID_TYPE = 0; - public const int EOF_TYPE = 1; - public static readonly int SKIP = -1; - - // each Token has at least a token type - protected int type_; - - // the illegal token object - public static Token badToken = new Token(INVALID_TYPE, ""); - - public Token() - { - type_ = INVALID_TYPE; - } - - public Token(int t) - { - type_ = t; - } - - public Token(int t, string txt) - { - type_ = t; - setText(txt); - } - - public virtual int getColumn() - { - return 0; - } - - public virtual int getLine() - { - return 0; - } - - public virtual string getFilename() - { - return null; - } - - public virtual void setFilename(string name) - { - } - - public virtual string getText() - { - return ""; - } - - public int Type - { - get { return type_; } - set { type_ = value; } - } - - public virtual void setType(int newType) { this.Type = newType; } - - public virtual void setColumn(int c) - { - ; - } - - public virtual void setLine(int l) - { - ; - } - - public virtual void setText(string t) - { - ; - } - - override public string ToString() - { - return "[\"" + getText() + "\",<" + type_ + ">]"; - } -} diff --git a/src/Spring/Spring.Core/Expressions/Parser/antlr/TokenBuffer.cs b/src/Spring/Spring.Core/Expressions/Parser/antlr/TokenBuffer.cs deleted file mode 100644 index 4c3d543ea..000000000 --- a/src/Spring/Spring.Core/Expressions/Parser/antlr/TokenBuffer.cs +++ /dev/null @@ -1,141 +0,0 @@ -namespace Spring.Expressions.Parser.antlr; -/*ANTLR Translator Generator - * Project led by Terence Parr at http://www.jGuru.com - * Software rights: http://www.antlr.org/license.html - * - * $Id:$ - */ - -// -// ANTLR C# Code Generator by Micheal Jordan -// Kunle Odutola : kunle UNDERSCORE odutola AT hotmail DOT com -// Anthony Oguntimehin -// -// With many thanks to Eric V. Smith from the ANTLR list. -// -/*A Stream of Token objects fed to the parser from a Tokenizer that can - * be rewound via mark()/rewind() methods. - *

- * A dynamic array is used to buffer up all the input tokens. Normally, - * "k" tokens are stored in the buffer. More tokens may be stored during - * guess mode (testing syntactic predicate), or when LT(i>k) is referenced. - * Consumption of tokens is deferred. In other words, reading the next - * token is not done by conume(), but deferred until needed by LA or LT. - *

- * - * @see antlr.Token - * @see antlr.Tokenizer - * @see antlr.TokenQueue - */ - -public class TokenBuffer -{ - // Token source - protected internal TokenStream input; - - // Number of active markers - protected internal int nMarkers = 0; - - // Additional offset used when markers are active - protected internal int markerOffset = 0; - - // Number of calls to consume() since last LA() or LT() call - protected internal int numToConsume = 0; - - // Circular queue - internal TokenQueue queue; - - /*Create a token buffer */ - public TokenBuffer(TokenStream input_) - { - input = input_; - queue = new TokenQueue(1); - } - - /*Reset the input buffer to empty state */ - public virtual void reset() - { - nMarkers = 0; - markerOffset = 0; - numToConsume = 0; - queue.reset(); - } - - /*Mark another token for deferred consumption */ - public virtual void consume() - { - numToConsume++; - } - - /*Ensure that the token buffer is sufficiently full */ - protected virtual void fill(int amount) - { - syncConsume(); - // Fill the buffer sufficiently to hold needed tokens - while (queue.nbrEntries < (amount + markerOffset)) - { - // Append the next token - queue.append(input.nextToken()); - } - } - - /*return the Tokenizer (needed by ParseView) */ - public virtual TokenStream getInput() - { - return input; - } - - /*Get a lookahead token value */ - public virtual int LA(int i) - { - fill(i); - return queue.elementAt(markerOffset + i - 1).Type; - } - - /*Get a lookahead token */ - public virtual IToken LT(int i) - { - fill(i); - return queue.elementAt(markerOffset + i - 1); - } - - /*Return an integer marker that can be used to rewind the buffer to - * its current state. - */ - public virtual int mark() - { - syncConsume(); - nMarkers++; - return markerOffset; - } - - /*Rewind the token buffer to a marker. - * @param mark Marker returned previously from mark() - */ - public virtual void rewind(int mark) - { - syncConsume(); - markerOffset = mark; - nMarkers--; - } - - /*Sync up deferred consumption */ - protected virtual void syncConsume() - { - while (numToConsume > 0) - { - if (nMarkers > 0) - { - // guess mode -- leave leading tokens and bump offset. - markerOffset++; - } - else - { - // normal mode -- remove first token - queue.removeFirst(); - } - - numToConsume--; - } - } -} diff --git a/src/Spring/Spring.Core/Expressions/Parser/antlr/TokenCreator.cs b/src/Spring/Spring.Core/Expressions/Parser/antlr/TokenCreator.cs deleted file mode 100644 index 9de83db4b..000000000 --- a/src/Spring/Spring.Core/Expressions/Parser/antlr/TokenCreator.cs +++ /dev/null @@ -1,44 +0,0 @@ -namespace Spring.Expressions.Parser.antlr; -/*ANTLR Translator Generator - * Project led by Terence Parr at http://www.jGuru.com - * Software rights: http://www.antlr.org/license.html - * - * $Id:$ - */ - -// -// ANTLR C# Code Generator by Micheal Jordan -// Kunle Odutola : kunle UNDERSCORE odutola AT hotmail DOT com -// Anthony Oguntimehin -// - -///

-/// A creator of Token object instances. -/// -/// -/// -/// This class and it's sub-classes exists primarily as an optimization -/// of the reflection-based mechanism(s) previously used exclusively to -/// create instances of Token objects. -/// -/// -/// Since Lexers in ANTLR use a single Token type, each TokenCreator can -/// create one class of Token objects (that's why it's not called TokenFactory). -/// -/// -public abstract class TokenCreator -{ - /// - /// Returns the fully qualified name of the Token type that this - /// class creates. - /// - public abstract string TokenTypeName - { - get; - } - - /// - /// Constructs a instance. - /// - public abstract IToken Create(); -} diff --git a/src/Spring/Spring.Core/Expressions/Parser/antlr/TokenQueue.cs b/src/Spring/Spring.Core/Expressions/Parser/antlr/TokenQueue.cs deleted file mode 100644 index eb1156d0c..000000000 --- a/src/Spring/Spring.Core/Expressions/Parser/antlr/TokenQueue.cs +++ /dev/null @@ -1,124 +0,0 @@ -namespace Spring.Expressions.Parser.antlr; -/*ANTLR Translator Generator - * Project led by Terence Parr at http://www.jGuru.com - * Software rights: http://www.antlr.org/license.html - * - * $Id:$ - */ - -// -// ANTLR C# Code Generator by Micheal Jordan -// Kunle Odutola : kunle UNDERSCORE odutola AT hotmail DOT com -// Anthony Oguntimehin -// -// With many thanks to Eric V. Smith from the ANTLR list. -// -/*A private circular buffer object used by the token buffer */ - -class TokenQueue -{ - /*Physical circular buffer of tokens */ - private IToken[] buffer; - - /*buffer.length-1 for quick modulos */ - private int sizeLessOne; - - /*physical index of front token */ - private int offset; - - /*number of tokens in the queue */ - protected internal int nbrEntries; - - public TokenQueue(int minSize) - { - // Find first power of 2 >= to requested size - int size; - if (minSize < 0) - { - init(16); // pick some value for them - return; - } - - // check for overflow - if (minSize >= (int.MaxValue / 2)) - { - init(int.MaxValue); // wow that's big. - return; - } - - for (size = 2; size < minSize; size *= 2) - { - ; - } - - init(size); - } - - /*Add token to end of the queue - * @param tok The token to add - */ - public void append(IToken tok) - { - if (nbrEntries == buffer.Length) - { - expand(); - } - - buffer[(offset + nbrEntries) & sizeLessOne] = tok; - nbrEntries++; - } - - /*Fetch a token from the queue by index - * @param idx The index of the token to fetch, where zero is the token at the front of the queue - */ - public IToken elementAt(int idx) - { - return buffer[(offset + idx) & sizeLessOne]; - } - - /*Expand the token buffer by doubling its capacity */ - private void expand() - { - IToken[] newBuffer = new IToken[buffer.Length * 2]; - // Copy the contents to the new buffer - // Note that this will store the first logical item in the - // first physical array element. - for (int i = 0; i < buffer.Length; i++) - { - newBuffer[i] = elementAt(i); - } - - // Re-initialize with new contents, keep old nbrEntries - buffer = newBuffer; - sizeLessOne = buffer.Length - 1; - offset = 0; - } - - /*Initialize the queue. - * @param size The initial size of the queue - */ - private void init(int size) - { - // Allocate buffer - buffer = new IToken[size]; - // Other initialization - sizeLessOne = size - 1; - offset = 0; - nbrEntries = 0; - } - - /*Clear the queue. Leaving the previous buffer alone. - */ - public void reset() - { - offset = 0; - nbrEntries = 0; - } - - /*Remove token from front of queue */ - public void removeFirst() - { - offset = (offset + 1) & sizeLessOne; - nbrEntries--; - } -} diff --git a/src/Spring/Spring.Core/Expressions/Parser/antlr/TokenStream.cs b/src/Spring/Spring.Core/Expressions/Parser/antlr/TokenStream.cs deleted file mode 100644 index b4bb78991..000000000 --- a/src/Spring/Spring.Core/Expressions/Parser/antlr/TokenStream.cs +++ /dev/null @@ -1,20 +0,0 @@ -namespace Spring.Expressions.Parser.antlr; -/*ANTLR Translator Generator - * Project led by Terence Parr at http://www.jGuru.com - * Software rights: http://www.antlr.org/license.html - * - * $Id:$ - */ - -// -// ANTLR C# Code Generator by Micheal Jordan -// Kunle Odutola : kunle UNDERSCORE odutola AT hotmail DOT com -// Anthony Oguntimehin -// -// With many thanks to Eric V. Smith from the ANTLR list. -// - -public interface TokenStream -{ - IToken nextToken(); -} diff --git a/src/Spring/Spring.Core/Expressions/Parser/antlr/TokenStreamBasicFilter.cs b/src/Spring/Spring.Core/Expressions/Parser/antlr/TokenStreamBasicFilter.cs deleted file mode 100644 index daa1a536e..000000000 --- a/src/Spring/Spring.Core/Expressions/Parser/antlr/TokenStreamBasicFilter.cs +++ /dev/null @@ -1,57 +0,0 @@ -using BitSet = Spring.Expressions.Parser.antlr.collections.impl.BitSet; - -namespace Spring.Expressions.Parser.antlr; -/*ANTLR Translator Generator - * Project led by Terence Parr at http://www.jGuru.com - * Software rights: http://www.antlr.org/license.html - * - * $Id:$ - */ - -// -// ANTLR C# Code Generator by Micheal Jordan -// Kunle Odutola : kunle UNDERSCORE odutola AT hotmail DOT com -// Anthony Oguntimehin -// -// With many thanks to Eric V. Smith from the ANTLR list. -// - -/*This object is a TokenStream that passes through all - * tokens except for those that you tell it to discard. - * There is no buffering of the tokens. - */ -public class TokenStreamBasicFilter : TokenStream -{ - /*The set of token types to discard */ - protected internal BitSet discardMask; - - /*The input stream */ - protected internal TokenStream input; - - public TokenStreamBasicFilter(TokenStream input) - { - this.input = input; - discardMask = new BitSet(); - } - - public virtual void discard(int ttype) - { - discardMask.add(ttype); - } - - public virtual void discard(BitSet mask) - { - discardMask = mask; - } - - public virtual IToken nextToken() - { - IToken tok = input.nextToken(); - while (tok != null && discardMask.member(tok.Type)) - { - tok = input.nextToken(); - } - - return tok; - } -} diff --git a/src/Spring/Spring.Core/Expressions/Parser/antlr/TokenStreamException.cs b/src/Spring/Spring.Core/Expressions/Parser/antlr/TokenStreamException.cs deleted file mode 100644 index c5c1403f6..000000000 --- a/src/Spring/Spring.Core/Expressions/Parser/antlr/TokenStreamException.cs +++ /dev/null @@ -1,30 +0,0 @@ -namespace Spring.Expressions.Parser.antlr; -/*ANTLR Translator Generator - * Project led by Terence Parr at http://www.jGuru.com - * Software rights: http://www.antlr.org/license.html - * - * $Id:$ - */ - -// -// ANTLR C# Code Generator by Micheal Jordan -// Kunle Odutola : kunle UNDERSCORE odutola AT hotmail DOT com -// Anthony Oguntimehin -// -// With many thanks to Eric V. Smith from the ANTLR list. -// -/* - * Anything that goes wrong while generating a stream of tokens. - */ - -[Serializable] -public class TokenStreamException : ANTLRException -{ - public TokenStreamException() - { - } - - public TokenStreamException(string s) : base(s) - { - } -} diff --git a/src/Spring/Spring.Core/Expressions/Parser/antlr/TokenStreamHiddenTokenFilter.cs b/src/Spring/Spring.Core/Expressions/Parser/antlr/TokenStreamHiddenTokenFilter.cs deleted file mode 100644 index a5d66a29b..000000000 --- a/src/Spring/Spring.Core/Expressions/Parser/antlr/TokenStreamHiddenTokenFilter.cs +++ /dev/null @@ -1,193 +0,0 @@ -using BitSet = Spring.Expressions.Parser.antlr.collections.impl.BitSet; - -namespace Spring.Expressions.Parser.antlr; -/*ANTLR Translator Generator - * Project led by Terence Parr at http://www.jGuru.com - * Software rights: http://www.antlr.org/license.html - * - * $Id:$ - */ - -// -// ANTLR C# Code Generator by Micheal Jordan -// Kunle Odutola : kunle UNDERSCORE odutola AT hotmail DOT com -// Anthony Oguntimehin -// -// With many thanks to Eric V. Smith from the ANTLR list. -// - -/*This object filters a token stream coming from a lexer - * or another TokenStream so that only certain token channels - * get transmitted to the parser. - * - * Any of the channels can be filtered off as "hidden" channels whose - * tokens can be accessed from the parser. - */ -public class TokenStreamHiddenTokenFilter : TokenStreamBasicFilter, TokenStream -{ - // protected BitSet discardMask; - protected internal BitSet hideMask; - - private IHiddenStreamToken nextMonitoredToken; - - /*track tail of hidden list emanating from previous - * monitored token - */ - protected internal IHiddenStreamToken lastHiddenToken; - - protected internal IHiddenStreamToken firstHidden = null; - - public TokenStreamHiddenTokenFilter(TokenStream input) : base(input) - { - hideMask = new BitSet(); - } - - protected internal virtual void consume() - { - nextMonitoredToken = (IHiddenStreamToken) input.nextToken(); - } - - private void consumeFirst() - { - consume(); // get first token of input stream - - // Handle situation where hidden or discarded tokens - // appear first in input stream - IHiddenStreamToken p = null; - // while hidden or discarded scarf tokens - while (hideMask.member(LA(1).Type) || discardMask.member(LA(1).Type)) - { - if (hideMask.member(LA(1).Type)) - { - if (p == null) - { - p = LA(1); - } - else - { - p.setHiddenAfter(LA(1)); - LA(1).setHiddenBefore(p); // double-link - p = LA(1); - } - - lastHiddenToken = p; - if (firstHidden == null) - { - firstHidden = p; // record hidden token if first - } - } - - consume(); - } - } - - public virtual BitSet getDiscardMask() - { - return discardMask; - } - - /*Return a ptr to the hidden token appearing immediately after - * token t in the input stream. - */ - public virtual IHiddenStreamToken getHiddenAfter(IHiddenStreamToken t) - { - return t.getHiddenAfter(); - } - - /*Return a ptr to the hidden token appearing immediately before - * token t in the input stream. - */ - public virtual IHiddenStreamToken getHiddenBefore(IHiddenStreamToken t) - { - return t.getHiddenBefore(); - } - - public virtual BitSet getHideMask() - { - return hideMask; - } - - /*Return the first hidden token if one appears - * before any monitored token. - */ - public virtual IHiddenStreamToken getInitialHiddenToken() - { - return firstHidden; - } - - public virtual void hide(int m) - { - hideMask.add(m); - } - - public virtual void hide(BitSet mask) - { - hideMask = mask; - } - - protected internal virtual IHiddenStreamToken LA(int i) - { - return nextMonitoredToken; - } - - /*Return the next monitored token. - * Test the token following the monitored token. - * If following is another monitored token, save it - * for the next invocation of nextToken (like a single - * lookahead token) and return it then. - * If following is unmonitored, nondiscarded (hidden) - * channel token, add it to the monitored token. - * - * Note: EOF must be a monitored Token. - */ - override public IToken nextToken() - { - // handle an initial condition; don't want to get lookahead - // token of this splitter until first call to nextToken - if (LA(1) == null) - { - consumeFirst(); - } - - // we always consume hidden tokens after monitored, thus, - // upon entry LA(1) is a monitored token. - IHiddenStreamToken monitored = LA(1); - // point to hidden tokens found during last invocation - monitored.setHiddenBefore(lastHiddenToken); - lastHiddenToken = null; - - // Look for hidden tokens, hook them into list emanating - // from the monitored tokens. - consume(); - IHiddenStreamToken p = monitored; - // while hidden or discarded scarf tokens - while (hideMask.member(LA(1).Type) || discardMask.member(LA(1).Type)) - { - if (hideMask.member(LA(1).Type)) - { - // attach the hidden token to the monitored in a chain - // link forwards - p.setHiddenAfter(LA(1)); - // link backwards - if (p != monitored) - { - //hidden cannot point to monitored tokens - LA(1).setHiddenBefore(p); - } - - p = (lastHiddenToken = LA(1)); - } - - consume(); - } - - return monitored; - } - - public virtual void resetState() - { - firstHidden = null; - lastHiddenToken = null; - nextMonitoredToken = null; - } -} \ No newline at end of file diff --git a/src/Spring/Spring.Core/Expressions/Parser/antlr/TokenStreamIOException.cs b/src/Spring/Spring.Core/Expressions/Parser/antlr/TokenStreamIOException.cs deleted file mode 100644 index 5e42b7eb0..000000000 --- a/src/Spring/Spring.Core/Expressions/Parser/antlr/TokenStreamIOException.cs +++ /dev/null @@ -1,35 +0,0 @@ -using IOException = System.IO.IOException; - -namespace Spring.Expressions.Parser.antlr; -/*ANTLR Translator Generator - * Project led by Terence Parr at http://www.jGuru.com - * Software rights: http://www.antlr.org/license.html - * - * $Id:$ - */ - -// -// ANTLR C# Code Generator by Micheal Jordan -// Kunle Odutola : kunle UNDERSCORE odutola AT hotmail DOT com -// Anthony Oguntimehin -// -// With many thanks to Eric V. Smith from the ANTLR list. -// - -/* - * Wraps an IOException in a TokenStreamException - */ -[Serializable] -public class TokenStreamIOException : TokenStreamException -{ - public IOException io; - - /* - * TokenStreamIOException constructor comment. - * @param s java.lang.String - */ - public TokenStreamIOException(IOException io) : base(io.Message) - { - this.io = io; - } -} \ No newline at end of file diff --git a/src/Spring/Spring.Core/Expressions/Parser/antlr/TokenStreamRecognitionException.cs b/src/Spring/Spring.Core/Expressions/Parser/antlr/TokenStreamRecognitionException.cs deleted file mode 100644 index 4af2233ed..000000000 --- a/src/Spring/Spring.Core/Expressions/Parser/antlr/TokenStreamRecognitionException.cs +++ /dev/null @@ -1,36 +0,0 @@ -namespace Spring.Expressions.Parser.antlr; -/*ANTLR Translator Generator - * Project led by Terence Parr at http://www.jGuru.com - * Software rights: http://www.antlr.org/license.html - * - * $Id:$ - */ - -// -// ANTLR C# Code Generator by Micheal Jordan -// Kunle Odutola : kunle UNDERSCORE odutola AT hotmail DOT com -// Anthony Oguntimehin -// -// With many thanks to Eric V. Smith from the ANTLR list. -// -/* - * Wraps a RecognitionException in a TokenStreamException so you - * can pass it along. - */ - -[Serializable] -public class TokenStreamRecognitionException : TokenStreamException -{ - public RecognitionException recog; - - public TokenStreamRecognitionException(RecognitionException re) : - base(re.Message) - { - this.recog = re; - } - - override public string ToString() - { - return recog.ToString(); - } -} diff --git a/src/Spring/Spring.Core/Expressions/Parser/antlr/TokenStreamRetryException.cs b/src/Spring/Spring.Core/Expressions/Parser/antlr/TokenStreamRetryException.cs deleted file mode 100644 index 9796d759a..000000000 --- a/src/Spring/Spring.Core/Expressions/Parser/antlr/TokenStreamRetryException.cs +++ /dev/null @@ -1,26 +0,0 @@ -namespace Spring.Expressions.Parser.antlr; -/*ANTLR Translator Generator - * Project led by Terence Parr at http://www.jGuru.com - * Software rights: http://www.antlr.org/license.html - * - * $Id:$ - */ - -// -// ANTLR C# Code Generator by Micheal Jordan -// Kunle Odutola : kunle UNDERSCORE odutola AT hotmail DOT com -// Anthony Oguntimehin -// -// With many thanks to Eric V. Smith from the ANTLR list. -// -/* - * Aborted recognition of current token. Try to get one again. - * Used by TokenStreamSelector.retry() to force nextToken() - * of stream to re-enter and retry. - */ - -[Serializable] -public class TokenStreamRetryException : TokenStreamException -{ - public TokenStreamRetryException() { } -} diff --git a/src/Spring/Spring.Core/Expressions/Parser/antlr/TokenStreamRewriteEngine.cs b/src/Spring/Spring.Core/Expressions/Parser/antlr/TokenStreamRewriteEngine.cs deleted file mode 100644 index cee7551b4..000000000 --- a/src/Spring/Spring.Core/Expressions/Parser/antlr/TokenStreamRewriteEngine.cs +++ /dev/null @@ -1,559 +0,0 @@ -namespace Spring.Expressions.Parser.antlr; - -/* ANTLR Translator Generator - * Project led by Terence Parr at http://www.jGuru.com - * Software rights: http://www.antlr.org/license.html - */ - -// -// ANTLR C# Code Generator by Micheal Jordan -// Kunle Odutola : kunle UNDERSCORE odutola AT hotmail DOT com -// Anthony Oguntimehin -// -using IList = System.Collections.IList; -using IDictionary = System.Collections.IDictionary; -using ArrayList = System.Collections.ArrayList; -using Hashtable = System.Collections.Hashtable; -using IComparer = System.Collections.IComparer; -using StringBuilder = System.Text.StringBuilder; -using BitSet = antlr.collections.impl.BitSet; - -/// -/// This token stream tracks the *entire* token stream coming from -/// a lexer, but does not pass on the whitespace (or whatever else -/// you want to discard) to the parser. -/// -/// -/// -/// This class can then be asked for the ith token in the input stream. -/// Useful for dumping out the input stream exactly after doing some -/// augmentation or other manipulations. Tokens are index from 0..n-1 -/// -/// -/// You can insert stuff, replace, and delete chunks. Note that the -/// operations are done lazily--only if you convert the buffer to a -/// string. This is very efficient because you are not moving data around -/// all the time. As the buffer of tokens is converted to strings, the -/// toString() method(s) check to see if there is an operation at the -/// current index. If so, the operation is done and then normal string -/// rendering continues on the buffer. This is like having multiple Turing -/// machine instruction streams (programs) operating on a single input tape. :) -/// -/// -/// Since the operations are done lazily at toString-time, operations do not -/// screw up the token index values. That is, an insert operation at token -/// index i does not change the index values for tokens i+1..n-1. -/// -/// -/// Because operations never actually alter the buffer, you may always get -/// the original token stream back without undoing anything. Since -/// the instructions are queued up, you can easily simulate transactions and -/// roll back any changes if there is an error just by removing instructions. -/// For example, -/// -/// For example: -/// -/// TokenStreamRewriteEngine rewriteEngine = new TokenStreamRewriteEngine(lexer); -/// JavaRecognizer parser = new JavaRecognizer(rewriteEngine); -/// ... -/// rewriteEngine.insertAfter("pass1", t, "foobar");} -/// rewriteEngine.insertAfter("pass2", u, "start");} -/// System.Console.Out.WriteLine(rewriteEngine.ToString("pass1")); -/// System.Console.Out.WriteLine(rewriteEngine.ToString("pass2")); -/// -/// -/// -/// You can also have multiple "instruction streams" and get multiple -/// rewrites from a single pass over the input. Just name the instruction -/// streams and use that name again when printing the buffer. This could be -/// useful for generating a C file and also its header file--all from the -/// same buffer. -/// -/// -/// If you don't use named rewrite streams, a "default" stream is used. -/// -/// -/// Terence Parr, parrt@cs.usfca.edu -/// University of San Francisco -/// February 2004 -/// -/// -public class TokenStreamRewriteEngine : TokenStream -{ - public const int MIN_TOKEN_INDEX = 0; - - protected class RewriteOperation - { - protected internal int index; - protected internal string text; - - protected RewriteOperation(int index, string text) - { - this.index = index; - this.text = text; - } - - /// - /// Execute the rewrite operation by possibly adding to the buffer. - /// - /// rewrite buffer - /// The index of the next token to operate on. - public virtual int execute(StringBuilder buf) - { - return index; - } - } - - protected class InsertBeforeOp : RewriteOperation - { - public InsertBeforeOp(int index, string text) : base(index, text) - { - } - - public override int execute(StringBuilder buf) - { - buf.Append(text); - return index; - } - } - - protected class ReplaceOp : RewriteOperation - { - protected int lastIndex; - - public ReplaceOp(int from, int to, string text) : base(from, text) - { - lastIndex = to; - } - - public override int execute(StringBuilder buf) - { - if (text != null) - { - buf.Append(text); - } - - return lastIndex + 1; - } - } - - protected class DeleteOp : ReplaceOp - { - public DeleteOp(int from, int to) : base(from, to, null) - { - } - } - - public const string DEFAULT_PROGRAM_NAME = "default"; - public const int PROGRAM_INIT_SIZE = 100; - - /// - /// Track the incoming list of tokens - /// - protected IList tokens; - - /// - /// You may have multiple, named streams of rewrite operations. - /// I'm calling these things "programs." - /// Maps string (name) -> rewrite (List) - /// - protected IDictionary programs = null; - - /// - /// Map string (program name) -> Integer index - /// - protected IDictionary lastRewriteTokenIndexes = null; - - /// - /// track index of tokens - /// - protected int index = MIN_TOKEN_INDEX; - - /// - /// Who do we suck tokens from? - /// - protected TokenStream stream; - - /// - /// Which (whitespace) token(s) to throw out - /// - protected BitSet discardMask = new BitSet(); - - public TokenStreamRewriteEngine(TokenStream upstream) : this(upstream, 1000) - { - } - - public TokenStreamRewriteEngine(TokenStream upstream, int initialSize) - { - stream = upstream; - tokens = new ArrayList(initialSize); - programs = new Hashtable(); - programs[DEFAULT_PROGRAM_NAME] = new ArrayList(PROGRAM_INIT_SIZE); - lastRewriteTokenIndexes = new Hashtable(); - } - - public IToken nextToken() // throws TokenStreamException - { - TokenWithIndex t; - - // suck tokens until end of stream or we find a non-discarded token - do - { - t = (TokenWithIndex) stream.nextToken(); - if (t != null) - { - t.setIndex(index); // what is t's index in list? - if (t.Type != Token.EOF_TYPE) - { - tokens.Add(t); // track all tokens except EOF - } - - index++; // move to next position - } - } while ((t != null) && (discardMask.member(t.Type))); - - return t; - } - - public void rollback(int instructionIndex) - { - rollback(DEFAULT_PROGRAM_NAME, instructionIndex); - } - - /// - /// Rollback the instruction stream for a program so that - /// the indicated instruction (via instructionIndex) is no - /// longer in the stream. - /// - /// - /// UNTESTED! - /// - /// - /// - public void rollback(string programName, int instructionIndex) - { - ArrayList il = (ArrayList) programs[programName]; - if (il != null) - { - programs[programName] = il.GetRange(MIN_TOKEN_INDEX, (instructionIndex - MIN_TOKEN_INDEX)); - } - } - - public void deleteProgram() - { - deleteProgram(DEFAULT_PROGRAM_NAME); - } - - /// - /// Reset the program so that no instructions exist - /// - /// - public void deleteProgram(string programName) - { - rollback(programName, MIN_TOKEN_INDEX); - } - - /// - /// If op.index > lastRewriteTokenIndexes, just add to the end. - /// Otherwise, do linear - /// - /// - protected void addToSortedRewriteList(RewriteOperation op) - { - addToSortedRewriteList(DEFAULT_PROGRAM_NAME, op); - } - - protected void addToSortedRewriteList(string programName, RewriteOperation op) - { - ArrayList rewrites = (ArrayList) getProgram(programName); - // if at or beyond last op's index, just append - if (op.index >= getLastRewriteTokenIndex(programName)) - { - rewrites.Add(op); // append to list of operations - // record the index of this operation for next time through - setLastRewriteTokenIndex(programName, op.index); - return; - } - - // not after the last one, so must insert to ordered list - int pos = rewrites.BinarySearch(op, RewriteOperationComparer.Default); - if (pos < 0) - { - rewrites.Insert(-pos - 1, op); - } - } - - public void insertAfter(IToken t, string text) - { - insertAfter(DEFAULT_PROGRAM_NAME, t, text); - } - - public void insertAfter(int index, string text) - { - insertAfter(DEFAULT_PROGRAM_NAME, index, text); - } - - public void insertAfter(string programName, IToken t, string text) - { - insertAfter(programName, ((TokenWithIndex) t).getIndex(), text); - } - - public void insertAfter(string programName, int index, string text) - { - // to insert after, just insert before next index (even if past end) - insertBefore(programName, index + 1, text); - } - - public void insertBefore(IToken t, string text) - { - insertBefore(DEFAULT_PROGRAM_NAME, t, text); - } - - public void insertBefore(int index, string text) - { - insertBefore(DEFAULT_PROGRAM_NAME, index, text); - } - - public void insertBefore(string programName, IToken t, string text) - { - insertBefore(programName, ((TokenWithIndex) t).getIndex(), text); - } - - public void insertBefore(string programName, int index, string text) - { - addToSortedRewriteList(programName, new InsertBeforeOp(index, text)); - } - - public void replace(int index, string text) - { - replace(DEFAULT_PROGRAM_NAME, index, index, text); - } - - public void replace(int from, int to, string text) - { - replace(DEFAULT_PROGRAM_NAME, from, to, text); - } - - public void replace(IToken indexT, string text) - { - replace(DEFAULT_PROGRAM_NAME, indexT, indexT, text); - } - - public void replace(IToken from, IToken to, string text) - { - replace(DEFAULT_PROGRAM_NAME, from, to, text); - } - - public void replace(string programName, int from, int to, string text) - { - addToSortedRewriteList(new ReplaceOp(from, to, text)); - } - - public void replace(string programName, IToken from, IToken to, string text) - { - replace(programName, - ((TokenWithIndex) from).getIndex(), - ((TokenWithIndex) to).getIndex(), - text); - } - - public void delete(int index) - { - delete(DEFAULT_PROGRAM_NAME, index, index); - } - - public void delete(int from, int to) - { - delete(DEFAULT_PROGRAM_NAME, from, to); - } - - public void delete(IToken indexT) - { - delete(DEFAULT_PROGRAM_NAME, indexT, indexT); - } - - public void delete(IToken from, IToken to) - { - delete(DEFAULT_PROGRAM_NAME, from, to); - } - - public void delete(string programName, int from, int to) - { - replace(programName, from, to, null); - } - - public void delete(string programName, IToken from, IToken to) - { - replace(programName, from, to, null); - } - - public void discard(int ttype) - { - discardMask.add(ttype); - } - - public TokenWithIndex getToken(int i) - { - return (TokenWithIndex) tokens[i]; - } - - public int getTokenStreamSize() - { - return tokens.Count; - } - - public string ToOriginalString() - { - return ToOriginalString(MIN_TOKEN_INDEX, getTokenStreamSize() - 1); - } - - public string ToOriginalString(int start, int end) - { - StringBuilder buf = new StringBuilder(); - for (int i = start; (i >= MIN_TOKEN_INDEX) && (i <= end) && (i < tokens.Count); i++) - { - buf.Append(getToken(i).getText()); - } - - return buf.ToString(); - } - - public override string ToString() - { - return ToString(MIN_TOKEN_INDEX, getTokenStreamSize()); - } - - public string ToString(string programName) - { - return ToString(programName, MIN_TOKEN_INDEX, getTokenStreamSize()); - } - - public string ToString(int start, int end) - { - return ToString(DEFAULT_PROGRAM_NAME, start, end); - } - - public string ToString(string programName, int start, int end) - { - IList rewrites = (IList) programs[programName]; - if (rewrites == null) - { - return null; // invalid program - } - - StringBuilder buf = new StringBuilder(); - - // Index of first rewrite we have not done - int rewriteOpIndex = 0; - - int tokenCursor = start; - while ((tokenCursor >= MIN_TOKEN_INDEX) && - (tokenCursor <= end) && - (tokenCursor < tokens.Count)) - { - if (rewriteOpIndex < rewrites.Count) - { - RewriteOperation op = (RewriteOperation) rewrites[rewriteOpIndex]; - while ((tokenCursor == op.index) && (rewriteOpIndex < rewrites.Count)) - { - /* - Console.Out.WriteLine("execute op "+rewriteOpIndex+ - " (type "+op.GetType().FullName+")" - +" at index "+op.index); - */ - tokenCursor = op.execute(buf); - rewriteOpIndex++; - if (rewriteOpIndex < rewrites.Count) - { - op = (RewriteOperation) rewrites[rewriteOpIndex]; - } - } - } - - if (tokenCursor < end) - { - buf.Append(getToken(tokenCursor).getText()); - tokenCursor++; - } - } - - // now see if there are operations (append) beyond last token index - for (int opi = rewriteOpIndex; opi < rewrites.Count; opi++) - { - RewriteOperation op = (RewriteOperation) rewrites[opi]; - op.execute(buf); // must be insertions if after last token - } - - return buf.ToString(); - } - - public string ToDebugString() - { - return ToDebugString(MIN_TOKEN_INDEX, getTokenStreamSize()); - } - - public string ToDebugString(int start, int end) - { - StringBuilder buf = new StringBuilder(); - for (int i = start; (i >= MIN_TOKEN_INDEX) && (i <= end) && (i < tokens.Count); i++) - { - buf.Append(getToken(i)); - } - - return buf.ToString(); - } - - public int getLastRewriteTokenIndex() - { - return getLastRewriteTokenIndex(DEFAULT_PROGRAM_NAME); - } - - protected int getLastRewriteTokenIndex(string programName) - { - object i = lastRewriteTokenIndexes[programName]; - if (i == null) - { - return -1; - } - - return (int) i; - } - - protected void setLastRewriteTokenIndex(string programName, int i) - { - lastRewriteTokenIndexes[programName] = (object) i; - } - - protected IList getProgram(string name) - { - IList il = (IList) programs[name]; - if (il == null) - { - il = initializeProgram(name); - } - - return il; - } - - private IList initializeProgram(string name) - { - IList il = new ArrayList(PROGRAM_INIT_SIZE); - programs[name] = il; - return il; - } - - public class RewriteOperationComparer : IComparer - { - public static readonly RewriteOperationComparer Default = new RewriteOperationComparer(); - - public virtual int Compare(object o1, object o2) - { - RewriteOperation rop1 = (RewriteOperation) o1; - RewriteOperation rop2 = (RewriteOperation) o2; - - if (rop1.index < rop2.index) return -1; - if (rop1.index > rop2.index) return 1; - return 0; - } - } -} diff --git a/src/Spring/Spring.Core/Expressions/Parser/antlr/TokenStreamSelector.cs b/src/Spring/Spring.Core/Expressions/Parser/antlr/TokenStreamSelector.cs deleted file mode 100644 index 808cb77f2..000000000 --- a/src/Spring/Spring.Core/Expressions/Parser/antlr/TokenStreamSelector.cs +++ /dev/null @@ -1,134 +0,0 @@ -using Hashtable = System.Collections.Hashtable; -using Stack = System.Collections.Stack; - -namespace Spring.Expressions.Parser.antlr; -/*ANTLR Translator Generator - * Project led by Terence Parr at http://www.jGuru.com - * Software rights: http://www.antlr.org/license.html - * - * $Id:$ - */ - -// -// ANTLR C# Code Generator by Micheal Jordan -// Kunle Odutola : kunle UNDERSCORE odutola AT hotmail DOT com -// Anthony Oguntimehin -// -// With many thanks to Eric V. Smith from the ANTLR list. -// - -/*A token stream MUX (multiplexor) knows about n token streams - * and can multiplex them onto the same channel for use by token - * stream consumer like a parser. This is a way to have multiple - * lexers break up the same input stream for a single parser. - * Or, you can have multiple instances of the same lexer handle - * multiple input streams; this works great for includes. - */ -public class TokenStreamSelector : TokenStream -{ - /*The set of inputs to the MUX */ - protected internal Hashtable inputStreamNames; - - /*The currently-selected token stream input */ - protected internal TokenStream input; - - /*Used to track stack of input streams */ - protected internal Stack streamStack = new Stack(); - - public TokenStreamSelector() : base() - { - inputStreamNames = new Hashtable(); - } - - public virtual void addInputStream(TokenStream stream, string key) - { - inputStreamNames[key] = stream; - } - - /*Return the stream from tokens are being pulled at - * the moment. - */ - public virtual TokenStream getCurrentStream() - { - return input; - } - - public virtual TokenStream getStream(string sname) - { - TokenStream stream = (TokenStream) inputStreamNames[sname]; - if (stream == null) - { - throw new System.ArgumentException("TokenStream " + sname + " not found"); - } - - return stream; - } - - public virtual IToken nextToken() - { - // return input.nextToken(); - // keep looking for a token until you don't - // get a retry exception. - for (;;) - { - try - { - return input.nextToken(); - } - catch (TokenStreamRetryException) - { - // just retry "forever" - } - } - } - - public virtual TokenStream pop() - { - TokenStream stream = (TokenStream) streamStack.Pop(); - select(stream); - return stream; - } - - public virtual void push(TokenStream stream) - { - streamStack.Push(input); // save current stream - select(stream); - } - - public virtual void push(string sname) - { - streamStack.Push(input); - select(sname); - } - - /*Abort recognition of current Token and try again. - * A stream can push a new stream (for include files - * for example, and then retry(), which will cause - * the current stream to abort back to this.nextToken(). - * this.nextToken() then asks for a token from the - * current stream, which is the new "substream." - */ - public virtual void retry() - { - throw new TokenStreamRetryException(); - } - - /*Set the stream without pushing old stream */ - public virtual void select(TokenStream stream) - { - input = stream; - if (input is CharScanner) - { - ((CharScanner) input).refresh(); - } - } - - public virtual void select(string sname) - { - input = getStream(sname); - if (input is CharScanner) - { - ((CharScanner) input).refresh(); - } - } -} diff --git a/src/Spring/Spring.Core/Expressions/Parser/antlr/TokenWithIndex.cs b/src/Spring/Spring.Core/Expressions/Parser/antlr/TokenWithIndex.cs deleted file mode 100644 index 5a2094487..000000000 --- a/src/Spring/Spring.Core/Expressions/Parser/antlr/TokenWithIndex.cs +++ /dev/null @@ -1,47 +0,0 @@ -namespace Spring.Expressions.Parser.antlr; -/* ANTLR Translator Generator - * Project led by Terence Parr at http://www.jGuru.com - * Software rights: http://www.antlr.org/license.html - */ - -// -// ANTLR C# Code Generator by Micheal Jordan -// Kunle Odutola : kunle UNDERSCORE odutola AT hotmail DOT com -// Anthony Oguntimehin -// - -/// -/// This token tracks it's own index 0..n-1 relative to the beginning -/// of the stream. It is designed to work with -/// in TokenStreamRewriteEngine.cs -/// -public class TokenWithIndex : CommonToken -{ - /// - /// Index into token array indicating position in input stream - /// - int index; - - public TokenWithIndex() : base() - { - } - - public TokenWithIndex(int i, string t) : base(i, t) - { - } - - public void setIndex(int i) - { - index = i; - } - - public int getIndex() - { - return index; - } - - public override string ToString() - { - return "[" + index + ":\"" + getText() + "\",<" + Type + ">,line=" + line + ",col=" + col + "]\n"; - } -} diff --git a/src/Spring/Spring.Core/Expressions/Parser/antlr/TreeParser.cs b/src/Spring/Spring.Core/Expressions/Parser/antlr/TreeParser.cs deleted file mode 100644 index 9d2b991f1..000000000 --- a/src/Spring/Spring.Core/Expressions/Parser/antlr/TreeParser.cs +++ /dev/null @@ -1,189 +0,0 @@ -using AST = Spring.Expressions.Parser.antlr.collections.AST; -using BitSet = Spring.Expressions.Parser.antlr.collections.impl.BitSet; - -namespace Spring.Expressions.Parser.antlr; -/*ANTLR Translator Generator - * Project led by Terence Parr at http://www.jGuru.com - * Software rights: http://www.antlr.org/license.html - * - * $Id:$ - */ - -// -// ANTLR C# Code Generator by Micheal Jordan -// Kunle Odutola : kunle UNDERSCORE odutola AT hotmail DOT com -// Anthony Oguntimehin -// -// With many thanks to Eric V. Smith from the ANTLR list. -// - -public class TreeParser -{ - /*The AST Null object; the parsing cursor is set to this when - * it is found to be null. This way, we can test the - * token type of a node without having to have tests for null - * everywhere. - */ - public static ASTNULLType ASTNULL = new ASTNULLType(); - - /*Where did this rule leave off parsing; avoids a return parameter */ - protected internal AST retTree_; - - /*guessing nesting level; guessing==0 implies not guessing */ - // protected int guessing = 0; - - /*Nesting level of registered handlers */ - // protected int exceptionLevel = 0; - - protected internal TreeParserSharedInputState inputState; - - /*Table of token type to token names */ - protected internal string[] tokenNames; - - /*AST return value for a rule is squirreled away here */ - protected internal AST returnAST; - - /*AST support code; parser and treeparser delegate to this object */ - protected internal ASTFactory astFactory = new ASTFactory(); - - /*Used to keep track of indentdepth for traceIn/Out */ - protected internal int traceDepth = 0; - - public TreeParser() - { - inputState = new TreeParserSharedInputState(); - } - - /*Get the AST return value squirreled away in the parser */ - public virtual AST getAST() - { - return returnAST; - } - - public virtual ASTFactory getASTFactory() - { - return astFactory; - } - - public virtual void resetState() - { - traceDepth = 0; - returnAST = null; - retTree_ = null; - inputState.reset(); - } - - public virtual string getTokenName(int num) - { - return tokenNames[num]; - } - - public virtual string[] getTokenNames() - { - return tokenNames; - } - - protected internal virtual void match(AST t, int ttype) - { - //System.out.println("match("+ttype+"); cursor is "+t); - if (t == null || t == ASTNULL || t.Type != ttype) - { - throw new MismatchedTokenException(getTokenNames(), t, ttype, false); - } - } - - /*Make sure current lookahead symbol matches the given set - * Throw an exception upon mismatch, which is catch by either the - * error handler or by the syntactic predicate. - */ - public virtual void match(AST t, BitSet b) - { - if (t == null || t == ASTNULL || !b.member(t.Type)) - { - throw new MismatchedTokenException(getTokenNames(), t, b, false); - } - } - - protected internal virtual void matchNot(AST t, int ttype) - { - //System.out.println("match("+ttype+"); cursor is "+t); - if (t == null || t == ASTNULL || t.Type == ttype) - { - throw new MismatchedTokenException(getTokenNames(), t, ttype, true); - } - } - - /// - /// @deprecated as of 2.7.2. This method calls System.exit() and writes - /// directly to stderr, which is usually not appropriate when - /// a parser is embedded into a larger application. Since the method is - /// static, it cannot be overridden to avoid these problems. - /// ANTLR no longer uses this method internally or in generated code. - /// - /// - [Obsolete("De-activated since version 2.7.2.6 as it cannot be overidden.", true)] - public static void panic() - { - Console.Error.WriteLine("TreeWalker: panic"); - System.Environment.Exit(1); - } - - /*Parser error-reporting function can be overridden in subclass */ - public virtual void reportError(RecognitionException ex) - { - Console.Error.WriteLine(ex.ToString()); - } - - /*Parser error-reporting function can be overridden in subclass */ - public virtual void reportError(string s) - { - Console.Error.WriteLine("error: " + s); - } - - /*Parser warning-reporting function can be overridden in subclass */ - public virtual void reportWarning(string s) - { - Console.Error.WriteLine("warning: " + s); - } - - /*Specify an object with support code (shared by - * Parser and TreeParser. Normally, the programmer - * does not play with this, using setASTNodeType instead. - */ - public virtual void setASTFactory(ASTFactory f) - { - astFactory = f; - } - - /*Specify the type of node to create during tree building */ - public virtual void setASTNodeType(string nodeType) - { - setASTNodeClass(nodeType); - } - - /*Specify the type of node to create during tree building */ - public virtual void setASTNodeClass(string nodeType) - { - astFactory.setASTNodeType(nodeType); - } - - public virtual void traceIndent() - { - for (int i = 0; i < traceDepth; i++) - Console.Out.Write(" "); - } - - public virtual void traceIn(string rname, AST t) - { - traceDepth += 1; - traceIndent(); - Console.Out.WriteLine("> " + rname + "(" + ((t != null) ? t.ToString() : "null") + ")" + ((inputState.guessing > 0) ? " [guessing]" : "")); - } - - public virtual void traceOut(string rname, AST t) - { - traceIndent(); - Console.Out.WriteLine("< " + rname + "(" + ((t != null) ? t.ToString() : "null") + ")" + ((inputState.guessing > 0) ? " [guessing]" : "")); - traceDepth--; - } -} diff --git a/src/Spring/Spring.Core/Expressions/Parser/antlr/TreeParserSharedInputState.cs b/src/Spring/Spring.Core/Expressions/Parser/antlr/TreeParserSharedInputState.cs deleted file mode 100644 index 32287d41c..000000000 --- a/src/Spring/Spring.Core/Expressions/Parser/antlr/TreeParserSharedInputState.cs +++ /dev/null @@ -1,32 +0,0 @@ -namespace Spring.Expressions.Parser.antlr; -/*ANTLR Translator Generator - * Project led by Terence Parr at http://www.jGuru.com - * Software rights: http://www.antlr.org/license.html - * - * $Id:$ - */ - -// -// ANTLR C# Code Generator by Micheal Jordan -// Kunle Odutola : kunle UNDERSCORE odutola AT hotmail DOT com -// Anthony Oguntimehin -// -// With many thanks to Eric V. Smith from the ANTLR list. -// -/*This object contains the data associated with an - * input AST. Multiple parsers - * share a single TreeParserSharedInputState to parse - * the same tree or to have the parser walk multiple - * trees. - */ - -public class TreeParserSharedInputState -{ - /*Are we guessing (guessing>0)? */ - public int guessing = 0; - - public virtual void reset() - { - guessing = 0; - } -} diff --git a/src/Spring/Spring.Core/Expressions/Parser/antlr/collections/AST.cs b/src/Spring/Spring.Core/Expressions/Parser/antlr/collections/AST.cs deleted file mode 100644 index 87bb4f4cd..000000000 --- a/src/Spring/Spring.Core/Expressions/Parser/antlr/collections/AST.cs +++ /dev/null @@ -1,96 +0,0 @@ -using IEnumerator = System.Collections.IEnumerator; - -namespace Spring.Expressions.Parser.antlr.collections; -/*ANTLR Translator Generator - * Project led by Terence Parr at http://www.jGuru.com - * Software rights: http://www.antlr.org/license.html - * - * $Id:$ - */ - -// -// ANTLR C# Code Generator by Micheal Jordan -// Kunle Odutola : kunle UNDERSCORE odutola AT hotmail DOT com -// Anthony Oguntimehin -// -// With many thanks to Eric V. Smith from the ANTLR list. -// - -/// -/// Minimal AST node interface used by ANTLR AST generation and tree-walker. -/// -public interface AST : ICloneable -{ - /// - /// Add a (rightmost) child to this node - /// - /// - void addChild(AST c); - - bool Equals(AST t); - bool EqualsList(AST t); - bool EqualsListPartial(AST t); - bool EqualsTree(AST t); - bool EqualsTreePartial(AST t); - IEnumerator findAll(AST tree); - IEnumerator findAllPartial(AST subtree); - - /// - /// Get the first child of this node; null if no children - /// - AST getFirstChild(); - - /// - /// Get the next sibling in line after this one - /// - AST getNextSibling(); - - /// - /// Get the token text for this node - /// - /// - string getText(); - - /// - /// Get the token type for this node - /// - int Type { get; set; } - - /// - /// Get number of children of this node; if leaf, returns 0 - /// - /// Number of children - int getNumberOfChildren(); - - void initialize(int t, string txt); - void initialize(AST t); - void initialize(IToken t); - - /// - /// Set the first child of a node. - /// - /// - void setFirstChild(AST c); - - /// - /// Set the next sibling after this one. - /// - /// - void setNextSibling(AST n); - - /// - /// Set the token text for this node - /// - /// - void setText(string text); - - /// - /// Set the token type for this node - /// - /// - void setType(int ttype); - - string ToString(); - string ToStringList(); - string ToStringTree(); -} diff --git a/src/Spring/Spring.Core/Expressions/Parser/antlr/collections/impl/ASTArray.cs b/src/Spring/Spring.Core/Expressions/Parser/antlr/collections/impl/ASTArray.cs deleted file mode 100644 index c6a062958..000000000 --- a/src/Spring/Spring.Core/Expressions/Parser/antlr/collections/impl/ASTArray.cs +++ /dev/null @@ -1,37 +0,0 @@ -namespace Spring.Expressions.Parser.antlr.collections.impl; -/*ANTLR Translator Generator - * Project led by Terence Parr at http://www.jGuru.com - * Software rights: http://www.antlr.org/license.html - * - * $Id:$ - */ - -// -// ANTLR C# Code Generator by Micheal Jordan -// Kunle Odutola : kunle UNDERSCORE odutola AT hotmail DOT com -// Anthony Oguntimehin -// -// With many thanks to Eric V. Smith from the ANTLR list. -// - -/*ASTArray is a class that allows ANTLR to - * generate code that can create and initialize an array - * in one expression, like: - * (new ASTArray(3)).add(x).add(y).add(z) - */ -public class ASTArray -{ - public int size = 0; - public AST[] array; - - public ASTArray(int capacity) - { - array = new AST[capacity]; - } - - public virtual ASTArray add(AST node) - { - array[size++] = node; - return this; - } -} diff --git a/src/Spring/Spring.Core/Expressions/Parser/antlr/collections/impl/BitSet.cs b/src/Spring/Spring.Core/Expressions/Parser/antlr/collections/impl/BitSet.cs deleted file mode 100644 index 3b7cba9d0..000000000 --- a/src/Spring/Spring.Core/Expressions/Parser/antlr/collections/impl/BitSet.cs +++ /dev/null @@ -1,554 +0,0 @@ -using ArrayList = System.Collections.ArrayList; - -//using CharFormatter = antlr.CharFormatter; - -namespace Spring.Expressions.Parser.antlr.collections.impl; -/*ANTLR Translator Generator - * Project led by Terence Parr at http://www.jGuru.com - * Software rights: http://www.antlr.org/license.html - * - * $Id:$ - */ - -// -// ANTLR C# Code Generator by Micheal Jordan -// Kunle Odutola : kunle UNDERSCORE odutola AT hotmail DOT com -// Anthony Oguntimehin -// -// With many thanks to Eric V. Smith from the ANTLR list. -// -/*A BitSet to replace java.util.BitSet. - * Primary differences are that most set operators return new sets - * as opposed to oring and anding "in place". Further, a number of - * operations were added. I cannot contain a BitSet because there - * is no way to access the internal bits (which I need for speed) - * and, because it is final, I cannot subclass to add functionality. - * Consider defining set degree. Without access to the bits, I must - * call a method n times to test the ith bit...ack! - * - * Also seems like or() from util is wrong when size of incoming set is bigger - * than this.bits.length. - * - * @author Terence Parr - * @author
Pete Wells - */ - -public class BitSet : ICloneable -{ - protected internal const int BITS = 64; // number of bits / long - protected internal const int NIBBLE = 4; - protected internal const int LOG_BITS = 6; // 2^6 == 64 - - /*We will often need to do a mod operator (i mod nbits). Its - * turns out that, for powers of two, this mod operation is - * same as (i & (nbits-1)). Since mod is slow, we use a - * precomputed mod mask to do the mod instead. - */ - protected internal static readonly int MOD_MASK = BITS - 1; - - /*The actual data bits */ - protected internal long[] dataBits; - - /*Construct a bitset of size one word (64 bits) */ - public BitSet() : this(BITS) - { - } - - /*Construction from a static array of longs */ - public BitSet(long[] bits_) - { - dataBits = bits_; - } - - /*Construct a bitset given the size - * @param nbits The size of the bitset in bits - */ - public BitSet(int nbits) - { - dataBits = new long[((nbits - 1) >> LOG_BITS) + 1]; - } - - /*or this element into this set (grow as necessary to accommodate) */ - public virtual void add(int el) - { - int n = wordNumber(el); - if (n >= dataBits.Length) - { - growToInclude(el); - } - - dataBits[n] |= bitMask(el); - } - - public virtual BitSet and(BitSet a) - { - BitSet s = (BitSet) this.Clone(); - s.andInPlace(a); - return s; - } - - public virtual void andInPlace(BitSet a) - { - int min = (int) (Math.Min(dataBits.Length, a.dataBits.Length)); - for (int i = min - 1; i >= 0; i--) - { - dataBits[i] &= a.dataBits[i]; - } - - // clear all bits in this not present in a (if this bigger than a). - for (int i = min; i < dataBits.Length; i++) - { - dataBits[i] = 0; - } - } - - private static long bitMask(int bitNumber) - { - int bitPosition = bitNumber & MOD_MASK; // bitNumber mod BITS - return 1L << bitPosition; - } - - public virtual void clear() - { - for (int i = dataBits.Length - 1; i >= 0; i--) - { - dataBits[i] = 0; - } - } - - public virtual void clear(int el) - { - int n = wordNumber(el); - if (n >= dataBits.Length) - { - // grow as necessary to accommodate - growToInclude(el); - } - - dataBits[n] &= ~ bitMask(el); - } - - public virtual object Clone() - { - BitSet s; - try - { - s = new BitSet(); - s.dataBits = new long[dataBits.Length]; - Array.Copy(dataBits, 0, s.dataBits, 0, dataBits.Length); - } - catch //(System.Exception e) - { - throw new System.ApplicationException(); - } - - return s; - } - - public virtual int degree() - { - int deg = 0; - for (int i = dataBits.Length - 1; i >= 0; i--) - { - long word = dataBits[i]; - if (word != 0L) - { - for (int bit = BITS - 1; bit >= 0; bit--) - { - if ((word & (1L << bit)) != 0) - { - deg++; - } - } - } - } - - return deg; - } - - override public int GetHashCode() - { - return dataBits.GetHashCode(); - } - - /*code "inherited" from java.util.BitSet */ - override public bool Equals(object obj) - { - if ((obj != null) && (obj is BitSet)) - { - BitSet bset = (BitSet) obj; - - int n = (int) (System.Math.Min(dataBits.Length, bset.dataBits.Length)); - for (int i = n; i-- > 0;) - { - if (dataBits[i] != bset.dataBits[i]) - { - return false; - } - } - - if (dataBits.Length > n) - { - for (int i = (int) (dataBits.Length); i-- > n;) - { - if (dataBits[i] != 0) - { - return false; - } - } - } - else if (bset.dataBits.Length > n) - { - for (int i = (int) (bset.dataBits.Length); i-- > n;) - { - if (bset.dataBits[i] != 0) - { - return false; - } - } - } - - return true; - } - - return false; - } - - /* - * Grows the set to a larger number of bits. - * @param bit element that must fit in set - */ - public virtual void growToInclude(int bit) - { - int newSize = (int) (System.Math.Max(dataBits.Length << 1, numWordsToHold(bit))); - long[] newbits = new long[newSize]; - Array.Copy(dataBits, 0, newbits, 0, dataBits.Length); - dataBits = newbits; - } - - public virtual bool member(int el) - { - int n = wordNumber(el); - if (n >= dataBits.Length) - return false; - return (dataBits[n] & bitMask(el)) != 0; - } - - public virtual bool nil() - { - for (int i = dataBits.Length - 1; i >= 0; i--) - { - if (dataBits[i] != 0) - return false; - } - - return true; - } - - public virtual BitSet not() - { - BitSet s = (BitSet) this.Clone(); - s.notInPlace(); - return s; - } - - public virtual void notInPlace() - { - for (int i = dataBits.Length - 1; i >= 0; i--) - { - dataBits[i] = ~ dataBits[i]; - } - } - - /*complement bits in the range 0..maxBit. */ - public virtual void notInPlace(int maxBit) - { - notInPlace(0, maxBit); - } - - /*complement bits in the range minBit..maxBit.*/ - public virtual void notInPlace(int minBit, int maxBit) - { - // make sure that we have room for maxBit - growToInclude(maxBit); - for (int i = minBit; i <= maxBit; i++) - { - int n = wordNumber(i); - dataBits[n] ^= bitMask(i); - } - } - - private int numWordsToHold(int el) - { - return (el >> LOG_BITS) + 1; - } - - public static BitSet of(int el) - { - BitSet s = new BitSet(el + 1); - s.add(el); - return s; - } - - /*return this | a in a new set */ - public virtual BitSet or(BitSet a) - { - BitSet s = (BitSet) this.Clone(); - s.orInPlace(a); - return s; - } - - public virtual void orInPlace(BitSet a) - { - // If this is smaller than a, grow this first - if (a.dataBits.Length > dataBits.Length) - { - setSize((int) (a.dataBits.Length)); - } - - int min = (int) (System.Math.Min(dataBits.Length, a.dataBits.Length)); - for (int i = min - 1; i >= 0; i--) - { - dataBits[i] |= a.dataBits[i]; - } - } - - // remove this element from this set - public virtual void remove(int el) - { - int n = wordNumber(el); - if (n >= dataBits.Length) - { - growToInclude(el); - } - - dataBits[n] &= ~ bitMask(el); - } - - /* - * Sets the size of a set. - * @param nwords how many words the new set should be - */ - private void setSize(int nwords) - { - long[] newbits = new long[nwords]; - int n = (int) (System.Math.Min(nwords, dataBits.Length)); - Array.Copy(dataBits, 0, newbits, 0, n); - dataBits = newbits; - } - - public virtual int size() - { - return dataBits.Length << LOG_BITS; // num words * bits per word - } - - /*return how much space is being used by the dataBits array not - * how many actually have member bits on. - */ - public virtual int lengthInLongWords() - { - return dataBits.Length; - } - - /*Is this contained within a? */ - public virtual bool subset(BitSet a) - { - if (a == null) //(a == null || !(a is BitSet)) - return false; - return this.and(a).Equals(this); - } - - /*Subtract the elements of 'a' from 'this' in-place. - * Basically, just turn off all bits of 'this' that are in 'a'. - */ - public virtual void subtractInPlace(BitSet a) - { - if (a == null) - return; - // for all words of 'a', turn off corresponding bits of 'this' - for (int i = 0; i < dataBits.Length && i < a.dataBits.Length; i++) - { - dataBits[i] &= ~ a.dataBits[i]; - } - } - - public virtual int[] toArray() - { - int[] elems = new int[degree()]; - int en = 0; - for (int i = 0; i < (dataBits.Length << LOG_BITS); i++) - { - if (member(i)) - { - elems[en++] = i; - } - } - - return elems; - } - - public virtual long[] toPackedArray() - { - return dataBits; - } - - override public string ToString() - { - return ToString(","); - } - - /*Transform a bit set into a string by formatting each element as an integer - * @separator The string to put in between elements - * @return A commma-separated list of values - */ - public virtual string ToString(string separator) - { - string str = ""; - for (int i = 0; i < (dataBits.Length << LOG_BITS); i++) - { - if (member(i)) - { - if (str.Length > 0) - { - str += separator; - } - - str = str + i; - } - } - - return str; - } - - /*Create a string representation where instead of integer elements, the - * ith element of vocabulary is displayed instead. Vocabulary is a Vector - * of Strings. - * @separator The string to put in between elements - * @return A commma-separated list of character constants. - */ - public virtual string ToString(string separator, ArrayList vocabulary) - { - if (vocabulary == null) - { - return ToString(separator); - } - - string str = ""; - for (int i = 0; i < (dataBits.Length << LOG_BITS); i++) - { - if (member(i)) - { - if (str.Length > 0) - { - str += separator; - } - - if (i >= vocabulary.Count) - { - str += ""; - } - else if (vocabulary[i] == null) - { - str += "<" + i + ">"; - } - else - { - str += (string) vocabulary[i]; - } - } - } - - return str; - } - - /* - * Dump a comma-separated list of the words making up the bit set. - * Split each 64 bit number into two more manageable 32 bit numbers. - * This generates a comma-separated list of C++-like unsigned long constants. - */ - public virtual string toStringOfHalfWords() - { - string s = new string("".ToCharArray()); - for (int i = 0; i < dataBits.Length; i++) - { - if (i != 0) - s += ", "; - long tmp = dataBits[i]; - tmp &= 0xFFFFFFFFL; - s += (tmp + "UL"); - s += ", "; - tmp = SupportClass.URShift(dataBits[i], 32); - tmp &= 0xFFFFFFFFL; - s += (tmp + "UL"); - } - - return s; - } - - /* - * Dump a comma-separated list of the words making up the bit set. - * This generates a comma-separated list of Java-like long int constants. - */ - public virtual string toStringOfWords() - { - string s = new string("".ToCharArray()); - for (int i = 0; i < dataBits.Length; i++) - { - if (i != 0) - s += ", "; - s += (dataBits[i] + "L"); - } - - return s; - } - - /*Print out the bit set but collapse char ranges. */ -/* public virtual string toStringWithRanges(string separator, CharFormatter formatter) - { - string str = ""; - int[] elems = this.toArray(); - if (elems.Length == 0) - { - return ""; - } - // look for ranges - int i = 0; - while (i < elems.Length) - { - int lastInRange; - lastInRange = 0; - for (int j = i + 1; j < elems.Length; j++) - { - if (elems[j] != elems[j - 1] + 1) - { - break; - } - lastInRange = j; - } - // found a range - if (str.Length > 0) - { - str += separator; - } - if (lastInRange - i >= 2) - { - str += formatter.literalChar(elems[i]); - str += ".."; - str += formatter.literalChar(elems[lastInRange]); - i = lastInRange; // skip past end of range for next range - } - else - { - // no range, just print current char and move on - str += formatter.literalChar(elems[i]); - } - i++; - } - return str; - } -*/ - private static int wordNumber(int bit) - { - return bit >> LOG_BITS; // bit / BITS - } -} \ No newline at end of file diff --git a/src/Spring/Spring.Core/Expressions/Parser/antlr/debug/ANTLREventArgs.cs b/src/Spring/Spring.Core/Expressions/Parser/antlr/debug/ANTLREventArgs.cs deleted file mode 100644 index 1f322e69a..000000000 --- a/src/Spring/Spring.Core/Expressions/Parser/antlr/debug/ANTLREventArgs.cs +++ /dev/null @@ -1,37 +0,0 @@ -namespace Spring.Expressions.Parser.antlr.debug; - -using System; - -public abstract class ANTLREventArgs : EventArgs -{ - public ANTLREventArgs() - { - } - - public ANTLREventArgs(int type) - { - this.Type = type; - } - - public virtual int Type - { - get - { - return this.type_; - } - set - { - this.type_ = value; - } - } - - internal void setValues(int type) - { - this.Type = type; - } - - /// - /// Event type. - /// - private int type_; -} diff --git a/src/Spring/Spring.Core/Expressions/Parser/antlr/debug/DebuggingCharScanner.cs b/src/Spring/Spring.Core/Expressions/Parser/antlr/debug/DebuggingCharScanner.cs deleted file mode 100644 index 7595a0815..000000000 --- a/src/Spring/Spring.Core/Expressions/Parser/antlr/debug/DebuggingCharScanner.cs +++ /dev/null @@ -1,358 +0,0 @@ -namespace Spring.Expressions.Parser.antlr.debug; - -using System; -using System.Threading; -using antlr; -using BitSet = antlr.collections.impl.BitSet; - -public abstract class DebuggingCharScanner : CharScanner, DebuggingParser -{ - private void InitBlock() - { - eventSupport = new ScannerEventSupport(this); - } - - public virtual void setDebugMode(bool mode) - { - _notDebugMode = !mode; - } - - private ScannerEventSupport eventSupport; - private bool _notDebugMode = false; - protected internal string[] ruleNames; - protected internal string[] semPredNames; - - public DebuggingCharScanner(InputBuffer cb) : base(cb) - { - InitBlock(); - } - - public DebuggingCharScanner(LexerSharedInputState state) : base(state) - { - InitBlock(); - } - - public virtual void addMessageListener(MessageListener l) - { - eventSupport.addMessageListener(l); - } - - public virtual void addNewLineListener(NewLineListener l) - { - eventSupport.addNewLineListener(l); - } - - public virtual void addParserListener(ParserListener l) - { - eventSupport.addParserListener(l); - } - - public virtual void addParserMatchListener(ParserMatchListener l) - { - eventSupport.addParserMatchListener(l); - } - - public virtual void addParserTokenListener(ParserTokenListener l) - { - eventSupport.addParserTokenListener(l); - } - - public virtual void addSemanticPredicateListener(SemanticPredicateListener l) - { - eventSupport.addSemanticPredicateListener(l); - } - - public virtual void addSyntacticPredicateListener(SyntacticPredicateListener l) - { - eventSupport.addSyntacticPredicateListener(l); - } - - public virtual void addTraceListener(TraceListener l) - { - eventSupport.addTraceListener(l); - } - - public override void consume() - { - int la_1 = -99; - try - { - la_1 = LA(1); - } - catch (CharStreamException) - { - } - - base.consume(); - eventSupport.fireConsume(la_1); - } - - protected internal virtual void fireEnterRule(int num, int data) - { - if (isDebugMode()) - eventSupport.fireEnterRule(num, inputState.guessing, data); - } - - protected internal virtual void fireExitRule(int num, int ttype) - { - if (isDebugMode()) - eventSupport.fireExitRule(num, inputState.guessing, ttype); - } - - protected internal virtual bool fireSemanticPredicateEvaluated(int type, int num, bool condition) - { - if (isDebugMode()) - return eventSupport.fireSemanticPredicateEvaluated(type, num, condition, inputState.guessing); - else - return condition; - } - - protected internal virtual void fireSyntacticPredicateFailed() - { - if (isDebugMode()) - eventSupport.fireSyntacticPredicateFailed(inputState.guessing); - } - - protected internal virtual void fireSyntacticPredicateStarted() - { - if (isDebugMode()) - eventSupport.fireSyntacticPredicateStarted(inputState.guessing); - } - - protected internal virtual void fireSyntacticPredicateSucceeded() - { - if (isDebugMode()) - eventSupport.fireSyntacticPredicateSucceeded(inputState.guessing); - } - - public virtual string getRuleName(int num) - { - return ruleNames[num]; - } - - public virtual string getSemPredName(int num) - { - return semPredNames[num]; - } - - public virtual void goToSleep() - { - lock (this) - { - try - { - Monitor.Wait(this); - } - catch (System.Threading.ThreadInterruptedException) - { - } - } - } - - public virtual bool isDebugMode() - { - return !_notDebugMode; - } - - public override char LA(int i) - { - char la = base.LA(i); - eventSupport.fireLA(i, la); - return la; - } - - protected internal override IToken makeToken(int t) - { - // do something with char buffer??? - // try { - // IToken tok = (Token)tokenObjectClass.newInstance(); - // tok.setType(t); - // // tok.setText(getText()); done in generated lexer now - // tok.setLine(line); - // return tok; - // } - // catch (InstantiationException ie) { - // panic("can't instantiate a Token"); - // } - // catch (IllegalAccessException iae) { - // panic("Token class is not accessible"); - // } - return base.makeToken(t); - } - - public override void match(int c) - { - char la_1 = LA(1); - try - { - base.match(c); - eventSupport.fireMatch(Convert.ToChar(c), inputState.guessing); - } - catch (MismatchedCharException e) - { - if (inputState.guessing == 0) - eventSupport.fireMismatch(la_1, Convert.ToChar(c), inputState.guessing); - throw e; - } - } - - public override void match(BitSet b) - { - string text = this.text.ToString(); - char la_1 = LA(1); - try - { - base.match(b); - eventSupport.fireMatch(la_1, b, text, inputState.guessing); - } - catch (MismatchedCharException e) - { - if (inputState.guessing == 0) - eventSupport.fireMismatch(la_1, b, text, inputState.guessing); - throw e; - } - } - - public override void match(string s) - { - System.Text.StringBuilder la_s = new System.Text.StringBuilder(""); - int len = s.Length; - // peek at the next len worth of characters - try - { - for (int i = 1; i <= len; i++) - { - la_s.Append(base.LA(i)); - } - } - catch (System.Exception) - { - } - - try - { - base.match(s); - eventSupport.fireMatch(s, inputState.guessing); - } - catch (MismatchedCharException e) - { - if (inputState.guessing == 0) - eventSupport.fireMismatch(la_s.ToString(), s, inputState.guessing); - throw e; - } - } - - public override void matchNot(int c) - { - char la_1 = LA(1); - try - { - base.matchNot(c); - eventSupport.fireMatchNot(la_1, Convert.ToChar(c), inputState.guessing); - } - catch (MismatchedCharException e) - { - if (inputState.guessing == 0) - eventSupport.fireMismatchNot(la_1, Convert.ToChar(c), inputState.guessing); - throw e; - } - } - - public override void matchRange(int c1, int c2) - { - char la_1 = LA(1); - try - { - base.matchRange(c1, c2); - eventSupport.fireMatch(la_1, "" + c1 + c2, inputState.guessing); - } - catch (MismatchedCharException e) - { - if (inputState.guessing == 0) - eventSupport.fireMismatch(la_1, "" + c1 + c2, inputState.guessing); - throw e; - } - } - - public override void newline() - { - base.newline(); - eventSupport.fireNewLine(getLine()); - } - - public virtual void removeMessageListener(MessageListener l) - { - eventSupport.removeMessageListener(l); - } - - public virtual void removeNewLineListener(NewLineListener l) - { - eventSupport.removeNewLineListener(l); - } - - public virtual void removeParserListener(ParserListener l) - { - eventSupport.removeParserListener(l); - } - - public virtual void removeParserMatchListener(ParserMatchListener l) - { - eventSupport.removeParserMatchListener(l); - } - - public virtual void removeParserTokenListener(ParserTokenListener l) - { - eventSupport.removeParserTokenListener(l); - } - - public virtual void removeSemanticPredicateListener(SemanticPredicateListener l) - { - eventSupport.removeSemanticPredicateListener(l); - } - - public virtual void removeSyntacticPredicateListener(SyntacticPredicateListener l) - { - eventSupport.removeSyntacticPredicateListener(l); - } - - public virtual void removeTraceListener(TraceListener l) - { - eventSupport.removeTraceListener(l); - } - - /// Report exception errors caught in nextToken() - /// - public virtual void reportError(MismatchedCharException e) - { - eventSupport.fireReportError(e); - base.reportError(e); - } - - /// Parser error-reporting function can be overridden in subclass - /// - public override void reportError(string s) - { - eventSupport.fireReportError(s); - base.reportError(s); - } - - /// Parser warning-reporting function can be overridden in subclass - /// - public override void reportWarning(string s) - { - eventSupport.fireReportWarning(s); - base.reportWarning(s); - } - - public virtual void setupDebugging() - { - } - - public virtual void wakeUp() - { - lock (this) - { - Monitor.Pulse(this); - } - } -} diff --git a/src/Spring/Spring.Core/Expressions/Parser/antlr/debug/DebuggingInputBuffer.cs b/src/Spring/Spring.Core/Expressions/Parser/antlr/debug/DebuggingInputBuffer.cs deleted file mode 100644 index ccef8268c..000000000 --- a/src/Spring/Spring.Core/Expressions/Parser/antlr/debug/DebuggingInputBuffer.cs +++ /dev/null @@ -1,90 +0,0 @@ -namespace Spring.Expressions.Parser.antlr.debug; - -using ArrayList = System.Collections.ArrayList; - -public class DebuggingInputBuffer : InputBuffer -{ - public virtual ArrayList InputBufferListeners - { - get { return inputBufferEventSupport.InputBufferListeners; } - } - - public virtual bool DebugMode - { - set { debugMode = value; } - } - - private InputBuffer buffer; - private InputBufferEventSupport inputBufferEventSupport; - private bool debugMode = true; - - public DebuggingInputBuffer(InputBuffer buffer) - { - this.buffer = buffer; - inputBufferEventSupport = new InputBufferEventSupport(this); - } - - public virtual void addInputBufferListener(InputBufferListener l) - { - inputBufferEventSupport.addInputBufferListener(l); - } - - public override char consume() - { - char la = ' '; - try - { - la = buffer.LA(1); - } - catch (CharStreamException) - { - } // vaporize it... - - buffer.consume(); - if (debugMode) - inputBufferEventSupport.fireConsume(la); - return la; - } - - public override void fill(int a) - { - buffer.fill(a); - } - - public virtual bool isDebugMode() - { - return debugMode; - } - - public override bool isMarked() - { - return buffer.isMarked(); - } - - public override char LA(int i) - { - char la = buffer.LA(i); - if (debugMode) - inputBufferEventSupport.fireLA(la, i); - return la; - } - - public override int mark() - { - int m = buffer.mark(); - inputBufferEventSupport.fireMark(m); - return m; - } - - public virtual void removeInputBufferListener(InputBufferListener l) - { - if (inputBufferEventSupport != null) - inputBufferEventSupport.removeInputBufferListener(l); - } - - public override void rewind(int mark) - { - buffer.rewind(mark); - inputBufferEventSupport.fireRewind(mark); - } -} diff --git a/src/Spring/Spring.Core/Expressions/Parser/antlr/debug/DebuggingParser.cs b/src/Spring/Spring.Core/Expressions/Parser/antlr/debug/DebuggingParser.cs deleted file mode 100644 index 57aeb4560..000000000 --- a/src/Spring/Spring.Core/Expressions/Parser/antlr/debug/DebuggingParser.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace Spring.Expressions.Parser.antlr.debug; - -/// This type was created in VisualAge. -/// -public interface DebuggingParser -{ - string getRuleName(int n); - string getSemPredName(int n); -} diff --git a/src/Spring/Spring.Core/Expressions/Parser/antlr/debug/GuessingEventArgs.cs b/src/Spring/Spring.Core/Expressions/Parser/antlr/debug/GuessingEventArgs.cs deleted file mode 100644 index 5c6614122..000000000 --- a/src/Spring/Spring.Core/Expressions/Parser/antlr/debug/GuessingEventArgs.cs +++ /dev/null @@ -1,28 +0,0 @@ -namespace Spring.Expressions.Parser.antlr.debug; - -public abstract class GuessingEventArgs : ANTLREventArgs -{ - public GuessingEventArgs() - { - } - - public GuessingEventArgs(int type) : base(type) - { - } - - public virtual int Guessing - { - get { return guessing_; } - set { this.guessing_ = value; } - } - - private int guessing_; - - /// This should NOT be called from anyone other than ParserEventSupport! - /// - public virtual void setValues(int type, int guessing) - { - setValues(type); - this.Guessing = guessing; - } -} diff --git a/src/Spring/Spring.Core/Expressions/Parser/antlr/debug/ICharScannerDebugSubject.cs b/src/Spring/Spring.Core/Expressions/Parser/antlr/debug/ICharScannerDebugSubject.cs deleted file mode 100644 index 69dc95bdb..000000000 --- a/src/Spring/Spring.Core/Expressions/Parser/antlr/debug/ICharScannerDebugSubject.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace Spring.Expressions.Parser.antlr.debug; - -public interface ICharScannerDebugSubject : IDebugSubject -{ - event NewLineEventHandler HitNewLine; - event MatchEventHandler MatchedChar; - event MatchEventHandler MatchedNotChar; - event MatchEventHandler MisMatchedChar; - event MatchEventHandler MisMatchedNotChar; - event TokenEventHandler ConsumedChar; - event TokenEventHandler CharLA; -} diff --git a/src/Spring/Spring.Core/Expressions/Parser/antlr/debug/IDebugSubject.cs b/src/Spring/Spring.Core/Expressions/Parser/antlr/debug/IDebugSubject.cs deleted file mode 100644 index ee4f99865..000000000 --- a/src/Spring/Spring.Core/Expressions/Parser/antlr/debug/IDebugSubject.cs +++ /dev/null @@ -1,20 +0,0 @@ -namespace Spring.Expressions.Parser.antlr.debug; -//using EventHandlerList = System.ComponentModel.EventHandlerList; - -public interface IDebugSubject -{ - /* EventHandlerList Events - { - get; - } -*/ - event TraceEventHandler EnterRule; - event TraceEventHandler ExitRule; - event TraceEventHandler Done; - event MessageEventHandler ErrorReported; - event MessageEventHandler WarningReported; - event SemanticPredicateEventHandler SemPredEvaluated; - event SyntacticPredicateEventHandler SynPredStarted; - event SyntacticPredicateEventHandler SynPredFailed; - event SyntacticPredicateEventHandler SynPredSucceeded; -} diff --git a/src/Spring/Spring.Core/Expressions/Parser/antlr/debug/IParserDebugSubject.cs b/src/Spring/Spring.Core/Expressions/Parser/antlr/debug/IParserDebugSubject.cs deleted file mode 100644 index 5ccd49b25..000000000 --- a/src/Spring/Spring.Core/Expressions/Parser/antlr/debug/IParserDebugSubject.cs +++ /dev/null @@ -1,11 +0,0 @@ -namespace Spring.Expressions.Parser.antlr.debug; - -public interface IParserDebugSubject : IDebugSubject -{ - event MatchEventHandler MatchedToken; - event MatchEventHandler MatchedNotToken; - event MatchEventHandler MisMatchedToken; - event MatchEventHandler MisMatchedNotToken; - event TokenEventHandler ConsumedToken; - event TokenEventHandler TokenLA; -} diff --git a/src/Spring/Spring.Core/Expressions/Parser/antlr/debug/InputBufferEventArgs.cs b/src/Spring/Spring.Core/Expressions/Parser/antlr/debug/InputBufferEventArgs.cs deleted file mode 100644 index 59d04c9c4..000000000 --- a/src/Spring/Spring.Core/Expressions/Parser/antlr/debug/InputBufferEventArgs.cs +++ /dev/null @@ -1,47 +0,0 @@ -namespace Spring.Expressions.Parser.antlr.debug; - -public class InputBufferEventArgs : ANTLREventArgs -{ - public InputBufferEventArgs() - { - } - - public InputBufferEventArgs(int type, char c, int lookaheadAmount) - { - setValues(type, c, lookaheadAmount); - } - - public virtual char Char - { - get { return this.c_; } - set { this.c_ = value; } - } - - public virtual int LookaheadAmount - { - get { return this.lookaheadAmount_; } - set { this.lookaheadAmount_ = value; } - } - - internal char c_; - internal int lookaheadAmount_; // amount of lookahead - - public const int CONSUME = 0; - public const int LA = 1; - public const int MARK = 2; - public const int REWIND = 3; - - /// This should NOT be called from anyone other than ParserEventSupport! - /// - internal void setValues(int type, char c, int la) - { - setValues(type); - this.Char = c; - this.LookaheadAmount = la; - } - - public override string ToString() - { - return "CharBufferEvent [" + (Type == CONSUME ? "CONSUME, " : "LA, ") + Char + "," + LookaheadAmount + "]"; - } -} diff --git a/src/Spring/Spring.Core/Expressions/Parser/antlr/debug/InputBufferEventSupport.cs b/src/Spring/Spring.Core/Expressions/Parser/antlr/debug/InputBufferEventSupport.cs deleted file mode 100644 index a8470904d..000000000 --- a/src/Spring/Spring.Core/Expressions/Parser/antlr/debug/InputBufferEventSupport.cs +++ /dev/null @@ -1,131 +0,0 @@ -namespace Spring.Expressions.Parser.antlr.debug; - -using ArrayList = System.Collections.ArrayList; - -public class InputBufferEventSupport -{ - public virtual ArrayList InputBufferListeners - { - get - { - return inputBufferListeners; - } - } - - private object source; - private ArrayList inputBufferListeners; - private InputBufferEventArgs inputBufferEvent; - protected internal const int CONSUME = 0; - protected internal const int LA = 1; - protected internal const int MARK = 2; - protected internal const int REWIND = 3; - - public InputBufferEventSupport(object source) - { - inputBufferEvent = new InputBufferEventArgs(); - this.source = source; - } - - public virtual void addInputBufferListener(InputBufferListener l) - { - if (inputBufferListeners == null) - inputBufferListeners = new ArrayList(); - inputBufferListeners.Add(l); - } - - public virtual void fireConsume(char c) - { - inputBufferEvent.setValues(InputBufferEventArgs.CONSUME, c, 0); - fireEvents(CONSUME, inputBufferListeners); - } - - public virtual void fireEvent(int type, Listener l) - { - switch (type) - { - case CONSUME: - ((InputBufferListener) l).inputBufferConsume(source, inputBufferEvent); break; - - case LA: - ((InputBufferListener) l).inputBufferLA(source, inputBufferEvent); break; - - case MARK: - ((InputBufferListener) l).inputBufferMark(source, inputBufferEvent); break; - - case REWIND: - ((InputBufferListener) l).inputBufferRewind(source, inputBufferEvent); break; - - default: - throw new System.ArgumentException("bad type " + type + " for fireEvent()"); - } - } - - public virtual void fireEvents(int type, ArrayList listeners) - { - ArrayList targets = null; - Listener l = null; - - lock (this) - { - if (listeners == null) - return; - targets = (ArrayList) listeners.Clone(); - } - - if (targets != null) - for (int i = 0; i < targets.Count; i++) - { - l = (Listener) targets[i]; - fireEvent(type, l); - } - } - - public virtual void fireLA(char c, int la) - { - inputBufferEvent.setValues(InputBufferEventArgs.LA, c, la); - fireEvents(LA, inputBufferListeners); - } - - public virtual void fireMark(int pos) - { - inputBufferEvent.setValues(InputBufferEventArgs.MARK, ' ', pos); - fireEvents(MARK, inputBufferListeners); - } - - public virtual void fireRewind(int pos) - { - inputBufferEvent.setValues(InputBufferEventArgs.REWIND, ' ', pos); - fireEvents(REWIND, inputBufferListeners); - } - - protected internal virtual void refresh(ArrayList listeners) - { - ArrayList v; - lock (listeners) - { - v = (ArrayList) listeners.Clone(); - } - - if (v != null) - for (int i = 0; i < v.Count; i++) - ((Listener) v[i]).refresh(); - } - - public virtual void refreshListeners() - { - refresh(inputBufferListeners); - } - - public virtual void removeInputBufferListener(InputBufferListener l) - { - if (inputBufferListeners != null) - { - ArrayList temp_arraylist; - object temp_object; - temp_arraylist = inputBufferListeners; - temp_object = l; - temp_arraylist.Contains(temp_object); - temp_arraylist.Remove(temp_object); - } - } -} diff --git a/src/Spring/Spring.Core/Expressions/Parser/antlr/debug/InputBufferListener.cs b/src/Spring/Spring.Core/Expressions/Parser/antlr/debug/InputBufferListener.cs deleted file mode 100644 index 6f7268f24..000000000 --- a/src/Spring/Spring.Core/Expressions/Parser/antlr/debug/InputBufferListener.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace Spring.Expressions.Parser.antlr.debug; - -public interface InputBufferListener : Listener -{ - void inputBufferConsume(object source, InputBufferEventArgs e); - void inputBufferLA(object source, InputBufferEventArgs e); - void inputBufferMark(object source, InputBufferEventArgs e); - void inputBufferRewind(object source, InputBufferEventArgs e); -} diff --git a/src/Spring/Spring.Core/Expressions/Parser/antlr/debug/InputBufferListenerBase.cs b/src/Spring/Spring.Core/Expressions/Parser/antlr/debug/InputBufferListenerBase.cs deleted file mode 100644 index 18c7079bf..000000000 --- a/src/Spring/Spring.Core/Expressions/Parser/antlr/debug/InputBufferListenerBase.cs +++ /dev/null @@ -1,62 +0,0 @@ -namespace Spring.Expressions.Parser.antlr.debug; - -/// -/// Provides an abstract base for implementing subclasses. -/// -/// -/// -/// This abstract class is provided to make it easier to create s. -/// You should extend this base class rather than creating your own. -/// -/// -public abstract class InputBufferListenerBase : InputBufferListener -{ - /// - /// Handle the "Done" event. - /// - /// Event source object - /// Event data object - public virtual void doneParsing(object source, TraceEventArgs e) - { - } - - /// - /// Handle the "CharConsumed" event. - /// - /// Event source object - /// Event data object - public virtual void inputBufferConsume(object source, InputBufferEventArgs e) - { - } - - /// - /// Handle the "CharLA" event. - /// - /// Event source object - /// Event data object - public virtual void inputBufferLA(object source, InputBufferEventArgs e) - { - } - - /// - /// Handle the "Mark" event. - /// - /// Event source object - /// Event data object - public virtual void inputBufferMark(object source, InputBufferEventArgs e) - { - } - - /// - /// Handle the "Rewind" event. - /// - /// Event source object - /// Event data object - public virtual void inputBufferRewind(object source, InputBufferEventArgs e) - { - } - - public virtual void refresh() - { - } -} diff --git a/src/Spring/Spring.Core/Expressions/Parser/antlr/debug/InputBufferReporter.cs b/src/Spring/Spring.Core/Expressions/Parser/antlr/debug/InputBufferReporter.cs deleted file mode 100644 index a3f66bd26..000000000 --- a/src/Spring/Spring.Core/Expressions/Parser/antlr/debug/InputBufferReporter.cs +++ /dev/null @@ -1,33 +0,0 @@ -namespace Spring.Expressions.Parser.antlr.debug; - -public class InputBufferReporter : InputBufferListenerBase, InputBufferListener -{ - public virtual void inputBufferChanged(object source, InputBufferEventArgs e) - { - System.Console.Out.WriteLine(e); - } - - /// charBufferConsume method comment. - /// - public override void inputBufferConsume(object source, InputBufferEventArgs e) - { - System.Console.Out.WriteLine(e); - } - - /// charBufferLA method comment. - /// - public override void inputBufferLA(object source, InputBufferEventArgs e) - { - System.Console.Out.WriteLine(e); - } - - public override void inputBufferMark(object source, InputBufferEventArgs e) - { - System.Console.Out.WriteLine(e); - } - - public override void inputBufferRewind(object source, InputBufferEventArgs e) - { - System.Console.Out.WriteLine(e); - } -} \ No newline at end of file diff --git a/src/Spring/Spring.Core/Expressions/Parser/antlr/debug/LLkDebuggingParser.cs b/src/Spring/Spring.Core/Expressions/Parser/antlr/debug/LLkDebuggingParser.cs deleted file mode 100644 index 6eb4be2a9..000000000 --- a/src/Spring/Spring.Core/Expressions/Parser/antlr/debug/LLkDebuggingParser.cs +++ /dev/null @@ -1,336 +0,0 @@ -namespace Spring.Expressions.Parser.antlr.debug; - -using System.Threading; -using antlr.collections.impl; - -public class LLkDebuggingParser : LLkParser, DebuggingParser -{ - private void InitBlock() - { - parserEventSupport = new ParserEventSupport(this); - } - - public override void setDebugMode(bool mode) - { - _notDebugMode = !mode; - } - - protected internal ParserEventSupport parserEventSupport; - - private bool _notDebugMode = false; - protected internal string[] ruleNames; - protected internal string[] semPredNames; - - public LLkDebuggingParser(int k_) : base(k_) - { - InitBlock(); - } - - public LLkDebuggingParser(ParserSharedInputState state, int k_) : base(state, k_) - { - InitBlock(); - } - - public LLkDebuggingParser(TokenBuffer tokenBuf, int k_) : base(tokenBuf, k_) - { - InitBlock(); - } - - public LLkDebuggingParser(TokenStream lexer, int k_) : base(lexer, k_) - { - InitBlock(); - } - - public override void addMessageListener(MessageListener l) - { - parserEventSupport.addMessageListener(l); - } - - public override void addParserListener(ParserListener l) - { - parserEventSupport.addParserListener(l); - } - - public override void addParserMatchListener(ParserMatchListener l) - { - parserEventSupport.addParserMatchListener(l); - } - - public override void addParserTokenListener(ParserTokenListener l) - { - parserEventSupport.addParserTokenListener(l); - } - - public override void addSemanticPredicateListener(SemanticPredicateListener l) - { - parserEventSupport.addSemanticPredicateListener(l); - } - - public override void addSyntacticPredicateListener(SyntacticPredicateListener l) - { - parserEventSupport.addSyntacticPredicateListener(l); - } - - public override void addTraceListener(TraceListener l) - { - parserEventSupport.addTraceListener(l); - } - - /// Get another token object from the token stream - /// - public override void consume() - { - int la_1 = -99; - la_1 = LA(1); - base.consume(); - parserEventSupport.fireConsume(la_1); - } - - protected internal virtual void fireEnterRule(int num, int data) - { - if (isDebugMode()) - parserEventSupport.fireEnterRule(num, inputState.guessing, data); - } - - protected internal virtual void fireExitRule(int num, int data) - { - if (isDebugMode()) - parserEventSupport.fireExitRule(num, inputState.guessing, data); - } - - protected internal virtual bool fireSemanticPredicateEvaluated(int type, int num, bool condition) - { - if (isDebugMode()) - return parserEventSupport.fireSemanticPredicateEvaluated(type, num, condition, inputState.guessing); - else - return condition; - } - - protected internal virtual void fireSyntacticPredicateFailed() - { - if (isDebugMode()) - parserEventSupport.fireSyntacticPredicateFailed(inputState.guessing); - } - - protected internal virtual void fireSyntacticPredicateStarted() - { - if (isDebugMode()) - parserEventSupport.fireSyntacticPredicateStarted(inputState.guessing); - } - - protected internal virtual void fireSyntacticPredicateSucceeded() - { - if (isDebugMode()) - parserEventSupport.fireSyntacticPredicateSucceeded(inputState.guessing); - } - - public virtual string getRuleName(int num) - { - return ruleNames[num]; - } - - public virtual string getSemPredName(int num) - { - return semPredNames[num]; - } - - public virtual void goToSleep() - { - lock (this) - { - try - { - Monitor.Wait(this); - } - catch (System.Threading.ThreadInterruptedException) - { - } - } - } - - public override bool isDebugMode() - { - return !_notDebugMode; - } - - public virtual bool isGuessing() - { - return inputState.guessing > 0; - } - - /// Return the token type of the ith token of lookahead where i=1 - /// is the current token being examined by the parser (i.e., it - /// has not been matched yet). - /// - public override int LA(int i) - { - int la = base.LA(i); - parserEventSupport.fireLA(i, la); - return la; - } - - /// Make sure current lookahead symbol matches token type t. - /// Throw an exception upon mismatch, which is catch by either the - /// error handler or by the syntactic predicate. - /// - public override void match(int t) - { - string text = LT(1).getText(); - int la_1 = LA(1); - try - { - base.match(t); - parserEventSupport.fireMatch(t, text, inputState.guessing); - } - catch (MismatchedTokenException e) - { - if (inputState.guessing == 0) - parserEventSupport.fireMismatch(la_1, t, text, inputState.guessing); - throw e; - } - } - - /// Make sure current lookahead symbol matches the given set - /// Throw an exception upon mismatch, which is catch by either the - /// error handler or by the syntactic predicate. - /// - public override void match(BitSet b) - { - string text = LT(1).getText(); - int la_1 = LA(1); - try - { - base.match(b); - parserEventSupport.fireMatch(la_1, b, text, inputState.guessing); - } - catch (MismatchedTokenException e) - { - if (inputState.guessing == 0) - parserEventSupport.fireMismatch(la_1, b, text, inputState.guessing); - throw e; - } - } - - public override void matchNot(int t) - { - string text = LT(1).getText(); - int la_1 = LA(1); - try - { - base.matchNot(t); - parserEventSupport.fireMatchNot(la_1, t, text, inputState.guessing); - } - catch (MismatchedTokenException e) - { - if (inputState.guessing == 0) - parserEventSupport.fireMismatchNot(la_1, t, text, inputState.guessing); - throw e; - } - } - - public override void removeMessageListener(MessageListener l) - { - parserEventSupport.removeMessageListener(l); - } - - public override void removeParserListener(ParserListener l) - { - parserEventSupport.removeParserListener(l); - } - - public override void removeParserMatchListener(ParserMatchListener l) - { - parserEventSupport.removeParserMatchListener(l); - } - - public override void removeParserTokenListener(ParserTokenListener l) - { - parserEventSupport.removeParserTokenListener(l); - } - - public override void removeSemanticPredicateListener(SemanticPredicateListener l) - { - parserEventSupport.removeSemanticPredicateListener(l); - } - - public override void removeSyntacticPredicateListener(SyntacticPredicateListener l) - { - parserEventSupport.removeSyntacticPredicateListener(l); - } - - public override void removeTraceListener(TraceListener l) - { - parserEventSupport.removeTraceListener(l); - } - - /// Parser error-reporting function can be overridden in subclass - /// - public override void reportError(RecognitionException ex) - { - parserEventSupport.fireReportError(ex); - base.reportError(ex); - } - - /// Parser error-reporting function can be overridden in subclass - /// - public override void reportError(string s) - { - parserEventSupport.fireReportError(s); - base.reportError(s); - } - - /// Parser warning-reporting function can be overridden in subclass - /// - public override void reportWarning(string s) - { - parserEventSupport.fireReportWarning(s); - base.reportWarning(s); - } - - public virtual void setupDebugging(TokenBuffer tokenBuf) - { - setupDebugging(null, tokenBuf); - } - - public virtual void setupDebugging(TokenStream lexer) - { - setupDebugging(lexer, null); - } - - /// User can override to do their own debugging - /// - protected internal virtual void setupDebugging(TokenStream lexer, TokenBuffer tokenBuf) - { - setDebugMode(true); - // default parser debug setup is ParseView - try - { -// try -// { -// System.Type.GetType("javax.swing.JButton"); -// } -// catch (System.Exception) -// { -// System.Console.Error.WriteLine("Swing is required to use ParseView, but is not present in your CLASSPATH"); -// System.Environment.Exit(1); -// } - System.Type c = System.Type.GetType("antlr.parseview.ParseView"); - System.Reflection.ConstructorInfo constructor = c.GetConstructor(new System.Type[] { typeof(LLkDebuggingParser), typeof(TokenStream), typeof(TokenBuffer) }); - constructor.Invoke(new object[] { this, lexer, tokenBuf }); - } - catch (System.Exception e) - { - System.Console.Error.WriteLine("Error initializing ParseView: " + e); - System.Console.Error.WriteLine("Please report this to Scott Stanchfield, thetick@magelang.com"); - System.Environment.Exit(1); - } - } - - public virtual void wakeUp() - { - lock (this) - { - Monitor.Pulse(this); - } - } -} diff --git a/src/Spring/Spring.Core/Expressions/Parser/antlr/debug/Listener.cs b/src/Spring/Spring.Core/Expressions/Parser/antlr/debug/Listener.cs deleted file mode 100644 index 14e02e9cb..000000000 --- a/src/Spring/Spring.Core/Expressions/Parser/antlr/debug/Listener.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace Spring.Expressions.Parser.antlr.debug; - -public interface Listener -{ - void doneParsing(object source, TraceEventArgs e); - void refresh(); -} diff --git a/src/Spring/Spring.Core/Expressions/Parser/antlr/debug/MessageEventArgs.cs b/src/Spring/Spring.Core/Expressions/Parser/antlr/debug/MessageEventArgs.cs deleted file mode 100644 index a4a1993c2..000000000 --- a/src/Spring/Spring.Core/Expressions/Parser/antlr/debug/MessageEventArgs.cs +++ /dev/null @@ -1,37 +0,0 @@ -namespace Spring.Expressions.Parser.antlr.debug; - -public class MessageEventArgs : ANTLREventArgs -{ - public MessageEventArgs() - { - } - - public MessageEventArgs(int type, string text) - { - setValues(type, text); - } - - public virtual string Text - { - get { return text_; } - set { this.text_ = value; } - } - - private string text_; - - public static int WARNING = 0; - public static int ERROR = 1; - - /// This should NOT be called from anyone other than ParserEventSupport! - /// - internal void setValues(int type, string text) - { - setValues(type); - this.Text = text; - } - - public override string ToString() - { - return "ParserMessageEvent [" + (Type == WARNING ? "warning," : "error,") + Text + "]"; - } -} diff --git a/src/Spring/Spring.Core/Expressions/Parser/antlr/debug/MessageListener.cs b/src/Spring/Spring.Core/Expressions/Parser/antlr/debug/MessageListener.cs deleted file mode 100644 index b5f7e3ab9..000000000 --- a/src/Spring/Spring.Core/Expressions/Parser/antlr/debug/MessageListener.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace Spring.Expressions.Parser.antlr.debug; - -public interface MessageListener : Listener -{ - void reportError(object source, MessageEventArgs e); - void reportWarning(object source, MessageEventArgs e); -} diff --git a/src/Spring/Spring.Core/Expressions/Parser/antlr/debug/MessageListenerBase.cs b/src/Spring/Spring.Core/Expressions/Parser/antlr/debug/MessageListenerBase.cs deleted file mode 100644 index e107cd856..000000000 --- a/src/Spring/Spring.Core/Expressions/Parser/antlr/debug/MessageListenerBase.cs +++ /dev/null @@ -1,44 +0,0 @@ -namespace Spring.Expressions.Parser.antlr.debug; - -/// -/// Provides an abstract base for implementing subclasses. -/// -/// -/// -/// This abstract class is provided to make it easier to create s. -/// You should extend this base class rather than creating your own. -/// -/// -public class MessageListenerBase : MessageListener -{ - /// - /// Handle the "Done" event. - /// - /// Event source object - /// Event data object - public virtual void doneParsing(object source, TraceEventArgs e) - { - } - - public virtual void refresh() - { - } - - /// - /// Handle the "ReportError" event. - /// - /// Event source object - /// Event data object - public virtual void reportError(object source, MessageEventArgs e) - { - } - - /// - /// Handle the "ReportWarning" event. - /// - /// Event source object - /// Event data object - public virtual void reportWarning(object source, MessageEventArgs e) - { - } -} diff --git a/src/Spring/Spring.Core/Expressions/Parser/antlr/debug/NewLineEventArgs.cs b/src/Spring/Spring.Core/Expressions/Parser/antlr/debug/NewLineEventArgs.cs deleted file mode 100644 index f35d844f0..000000000 --- a/src/Spring/Spring.Core/Expressions/Parser/antlr/debug/NewLineEventArgs.cs +++ /dev/null @@ -1,28 +0,0 @@ -namespace Spring.Expressions.Parser.antlr.debug; - -public class NewLineEventArgs : ANTLREventArgs -{ - public NewLineEventArgs() - { - } - - public NewLineEventArgs(int line) - { - Line = line; - } - - public virtual int Line - { - get { return this.line_; } - set { this.line_ = value; } - } - - private int line_; - - /// This should NOT be called from anyone other than ParserEventSupport! - /// - public override string ToString() - { - return "NewLineEvent [" + line_ + "]"; - } -} diff --git a/src/Spring/Spring.Core/Expressions/Parser/antlr/debug/NewLineListener.cs b/src/Spring/Spring.Core/Expressions/Parser/antlr/debug/NewLineListener.cs deleted file mode 100644 index 912ee701a..000000000 --- a/src/Spring/Spring.Core/Expressions/Parser/antlr/debug/NewLineListener.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace Spring.Expressions.Parser.antlr.debug; - -public interface NewLineListener : Listener -{ - void hitNewLine(object source, NewLineEventArgs e); -} diff --git a/src/Spring/Spring.Core/Expressions/Parser/antlr/debug/ParseTreeDebugParser.cs b/src/Spring/Spring.Core/Expressions/Parser/antlr/debug/ParseTreeDebugParser.cs deleted file mode 100644 index 29598fc4f..000000000 --- a/src/Spring/Spring.Core/Expressions/Parser/antlr/debug/ParseTreeDebugParser.cs +++ /dev/null @@ -1,163 +0,0 @@ -namespace Spring.Expressions.Parser.antlr.debug; - -/* ANTLR Translator Generator - * Project led by Terence Parr at http://www.jGuru.com - * Software rights: http://www.antlr.org/license.html - */ - -// -// ANTLR C# Code Generator by Micheal Jordan -// Kunle Odutola : kunle UNDERSCORE odutola AT hotmail DOT com -// Anthony Oguntimehin -// -using Stack = System.Collections.Stack; -using antlr; -using BitSet = antlr.collections.impl.BitSet; - -/// -/// Specifies the behaviour required (i.e. parser modifications) -/// specifically to support parse tree debugging and derivation. -/// -/// -/// -/// Override the standard matching and rule entry/exit routines -/// to build parse trees. This class is useful for 2.7.3 where -/// you can specify a superclass like -/// -/// -/// class TinyCParser extends Parser(ParseTreeDebugParser); -/// -/// -public class ParseTreeDebugParser : LLkParser -{ - /// - /// Each new rule invocation must have it's own subtree. Tokens are - /// added to the current root so we must have a stack of subtree roots. - /// - protected Stack currentParseTreeRoot = new Stack(); - - /// - /// Track most recently created parse subtree so that when parsing - /// is finished, we can get to the root. - /// - protected ParseTreeRule mostRecentParseTreeRoot = null; - - /// - /// For every rule replacement with a production, we bump up count. - /// - protected int numberOfDerivationSteps = 1; // n replacements plus step 0 - - public ParseTreeDebugParser(int k_) : base(k_) - { - } - - public ParseTreeDebugParser(ParserSharedInputState state, int k_) : base(state, k_) - { - } - - public ParseTreeDebugParser(TokenBuffer tokenBuf, int k_) : base(tokenBuf, k_) - { - } - - public ParseTreeDebugParser(TokenStream lexer, int k_) : base(lexer, k_) - { - } - - public ParseTree getParseTree() - { - return mostRecentParseTreeRoot; - } - - public int getNumberOfDerivationSteps() - { - return numberOfDerivationSteps; - } - - public override void match(int i) // throws MismatchedTokenException, TokenStreamException - { - addCurrentTokenToParseTree(); - base.match(i); - } - - public override void match(BitSet bitSet) // throws MismatchedTokenException, TokenStreamException - { - addCurrentTokenToParseTree(); - base.match(bitSet); - } - - public override void matchNot(int i) // throws MismatchedTokenException, TokenStreamException - { - addCurrentTokenToParseTree(); - base.matchNot(i); - } - - /// - /// Adds LT(1) to the current parse subtree. - /// - /// - /// - /// Note that the match() routines add the node before checking for - /// correct match. This means that, upon mismatched token, there - /// will a token node in the tree corresponding to where that token - /// was expected. For no viable alternative errors, no node will - /// be in the tree as nothing was matched() (the lookahead failed - /// to predict an alternative). - /// - /// - protected void addCurrentTokenToParseTree() // throws TokenStreamException - { - if (inputState.guessing > 0) - { - return; - } - - ParseTreeRule root = (ParseTreeRule) currentParseTreeRoot.Peek(); - ParseTreeToken tokenNode = null; - if (LA(1) == Token.EOF_TYPE) - { - tokenNode = new ParseTreeToken(new antlr.CommonToken("EOF")); - } - else - { - tokenNode = new ParseTreeToken(LT(1)); - } - - root.addChild(tokenNode); - } - - /// - /// Create a rule node, add to current tree, and make it current root - /// - /// - public override void traceIn(string s) // throws TokenStreamException - { - if (inputState.guessing > 0) - { - return; - } - - ParseTreeRule subRoot = new ParseTreeRule(s); - if (currentParseTreeRoot.Count > 0) - { - ParseTreeRule oldRoot = (ParseTreeRule) currentParseTreeRoot.Peek(); - oldRoot.addChild(subRoot); - } - - currentParseTreeRoot.Push(subRoot); - numberOfDerivationSteps++; - } - - /// - /// Pop current root; back to adding to old root - /// - /// - public override void traceOut(string s) // throws TokenStreamException - { - if (inputState.guessing > 0) - { - return; - } - - mostRecentParseTreeRoot = (ParseTreeRule) currentParseTreeRoot.Pop(); - } -} diff --git a/src/Spring/Spring.Core/Expressions/Parser/antlr/debug/ParserController.cs b/src/Spring/Spring.Core/Expressions/Parser/antlr/debug/ParserController.cs deleted file mode 100644 index f0ba1a73a..000000000 --- a/src/Spring/Spring.Core/Expressions/Parser/antlr/debug/ParserController.cs +++ /dev/null @@ -1,11 +0,0 @@ -namespace Spring.Expressions.Parser.antlr.debug; - -public interface ParserController : ParserListener -{ - ParserEventSupport ParserEventSupport - { - set; - } - - void checkBreak(); -} diff --git a/src/Spring/Spring.Core/Expressions/Parser/antlr/debug/ParserEventSupport.cs b/src/Spring/Spring.Core/Expressions/Parser/antlr/debug/ParserEventSupport.cs deleted file mode 100644 index 726c4f290..000000000 --- a/src/Spring/Spring.Core/Expressions/Parser/antlr/debug/ParserEventSupport.cs +++ /dev/null @@ -1,562 +0,0 @@ -namespace Spring.Expressions.Parser.antlr.debug; - -using Hashtable = System.Collections.Hashtable; -using DictionaryEntry = System.Collections.DictionaryEntry; -using antlr.collections.impl; - -public delegate void MessageEventHandler(object sender, MessageEventArgs e); - -public delegate void NewLineEventHandler(object sender, NewLineEventArgs e); - -public delegate void MatchEventHandler(object sender, MatchEventArgs e); - -public delegate void TokenEventHandler(object sender, TokenEventArgs e); - -public delegate void SemanticPredicateEventHandler(object sender, SemanticPredicateEventArgs e); - -public delegate void SyntacticPredicateEventHandler(object sender, SyntacticPredicateEventArgs e); - -public delegate void TraceEventHandler(object sender, TraceEventArgs e); - -/// A class to assist in firing parser events -/// NOTE: I intentionally _did_not_ synchronize the event firing and -/// add/remove listener methods. This is because the add/remove should -/// _only_ be called by the parser at its start/end, and the _same_thread_ -/// should be performing the parsing. This should help performance a tad... -/// -public class ParserEventSupport -{ - private object source; - private Hashtable listeners; - - private MatchEventArgs matchEvent; - private MessageEventArgs messageEvent; - private TokenEventArgs tokenEvent; - private SemanticPredicateEventArgs semPredEvent; - private SyntacticPredicateEventArgs synPredEvent; - private TraceEventArgs traceEvent; - private NewLineEventArgs newLineEvent; - - private ParserController controller; - - private int ruleDepth = 0; - - public ParserEventSupport(object source) - { - matchEvent = new MatchEventArgs(); - messageEvent = new MessageEventArgs(); - tokenEvent = new TokenEventArgs(); - traceEvent = new TraceEventArgs(); - semPredEvent = new SemanticPredicateEventArgs(); - synPredEvent = new SyntacticPredicateEventArgs(); - newLineEvent = new NewLineEventArgs(); - listeners = new Hashtable(); - this.source = source; - } - - public virtual void checkController() - { - if (controller != null) - controller.checkBreak(); - } - - public virtual void addDoneListener(Listener l) - { - ((Parser) source).Done += new TraceEventHandler(l.doneParsing); - listeners[l] = l; - } - - public virtual void addMessageListener(MessageListener l) - { - ((Parser) source).ErrorReported += new MessageEventHandler(l.reportError); - ((Parser) source).WarningReported += new MessageEventHandler(l.reportWarning); - //messageListeners.Add(l); - addDoneListener(l); - } - - public virtual void addParserListener(ParserListener l) - { - if (l is ParserController) - { - ((ParserController) l).ParserEventSupport = this; - controller = (ParserController) l; - } - - addParserMatchListener(l); - addParserTokenListener(l); - - addMessageListener(l); - addTraceListener(l); - addSemanticPredicateListener(l); - addSyntacticPredicateListener(l); - } - - public virtual void addParserMatchListener(ParserMatchListener l) - { - ((Parser) source).MatchedToken += new MatchEventHandler(l.parserMatch); - ((Parser) source).MatchedNotToken += new MatchEventHandler(l.parserMatchNot); - ((Parser) source).MisMatchedToken += new MatchEventHandler(l.parserMismatch); - ((Parser) source).MisMatchedNotToken += new MatchEventHandler(l.parserMismatchNot); - //matchListeners.Add(l); - addDoneListener(l); - } - - public virtual void addParserTokenListener(ParserTokenListener l) - { - ((Parser) source).ConsumedToken += new TokenEventHandler(l.parserConsume); - ((Parser) source).TokenLA += new TokenEventHandler(l.parserLA); - //tokenListeners.Add(l); - addDoneListener(l); - } - - public virtual void addSemanticPredicateListener(SemanticPredicateListener l) - { - ((Parser) source).SemPredEvaluated += new SemanticPredicateEventHandler(l.semanticPredicateEvaluated); - //semPredListeners.Add(l); - addDoneListener(l); - } - - public virtual void addSyntacticPredicateListener(SyntacticPredicateListener l) - { - ((Parser) source).SynPredStarted += new SyntacticPredicateEventHandler(l.syntacticPredicateStarted); - ((Parser) source).SynPredFailed += new SyntacticPredicateEventHandler(l.syntacticPredicateFailed); - ((Parser) source).SynPredSucceeded += new SyntacticPredicateEventHandler(l.syntacticPredicateSucceeded); - //synPredListeners.Add(l); - addDoneListener(l); - } - - public virtual void addTraceListener(TraceListener l) - { - ((Parser) source).EnterRule += new TraceEventHandler(l.enterRule); - ((Parser) source).ExitRule += new TraceEventHandler(l.exitRule); - //traceListeners.Add(l); - addDoneListener(l); - } - - public virtual void fireConsume(int c) - { - TokenEventHandler eventDelegate = (TokenEventHandler) ((Parser) source).Events[Parser.LAEventKey]; - if (eventDelegate != null) - { - tokenEvent.setValues(TokenEventArgs.CONSUME, 1, c); - eventDelegate(source, tokenEvent); - } - - checkController(); - } - - public virtual void fireDoneParsing() - { - TraceEventHandler eventDelegate = (TraceEventHandler) ((Parser) source).Events[Parser.DoneEventKey]; - if (eventDelegate != null) - { - traceEvent.setValues(TraceEventArgs.DONE_PARSING, 0, 0, 0); - eventDelegate(source, traceEvent); - } - - checkController(); - } - - public virtual void fireEnterRule(int ruleNum, int guessing, int data) - { - ruleDepth++; - TraceEventHandler eventDelegate = (TraceEventHandler) ((Parser) source).Events[Parser.EnterRuleEventKey]; - if (eventDelegate != null) - { - traceEvent.setValues(TraceEventArgs.ENTER, ruleNum, guessing, data); - eventDelegate(source, traceEvent); - } - - checkController(); - } - - public virtual void fireExitRule(int ruleNum, int guessing, int data) - { - TraceEventHandler eventDelegate = (TraceEventHandler) ((Parser) source).Events[Parser.ExitRuleEventKey]; - if (eventDelegate != null) - { - traceEvent.setValues(TraceEventArgs.EXIT, ruleNum, guessing, data); - eventDelegate(source, traceEvent); - } - - checkController(); - - ruleDepth--; - if (ruleDepth == 0) - fireDoneParsing(); - } - - public virtual void fireLA(int k, int la) - { - TokenEventHandler eventDelegate = (TokenEventHandler) ((Parser) source).Events[Parser.LAEventKey]; - if (eventDelegate != null) - { - tokenEvent.setValues(TokenEventArgs.LA, k, la); - eventDelegate(source, tokenEvent); - } - - checkController(); - } - - public virtual void fireMatch(char c, int guessing) - { - MatchEventHandler eventDelegate = (MatchEventHandler) ((Parser) source).Events[Parser.MatchEventKey]; - if (eventDelegate != null) - { - matchEvent.setValues(MatchEventArgs.CHAR, c, c, null, guessing, false, true); - eventDelegate(source, matchEvent); - } - - checkController(); - } - - public virtual void fireMatch(char c, BitSet b, int guessing) - { - MatchEventHandler eventDelegate = (MatchEventHandler) ((Parser) source).Events[Parser.MatchEventKey]; - if (eventDelegate != null) - { - matchEvent.setValues(MatchEventArgs.CHAR_BITSET, c, b, null, guessing, false, true); - eventDelegate(source, matchEvent); - } - - checkController(); - } - - public virtual void fireMatch(char c, string target, int guessing) - { - MatchEventHandler eventDelegate = (MatchEventHandler) ((Parser) source).Events[Parser.MatchEventKey]; - if (eventDelegate != null) - { - matchEvent.setValues(MatchEventArgs.CHAR_RANGE, c, target, null, guessing, false, true); - eventDelegate(source, matchEvent); - } - - checkController(); - } - - public virtual void fireMatch(int c, BitSet b, string text, int guessing) - { - MatchEventHandler eventDelegate = (MatchEventHandler) ((Parser) source).Events[Parser.MatchEventKey]; - if (eventDelegate != null) - { - matchEvent.setValues(MatchEventArgs.BITSET, c, b, text, guessing, false, true); - eventDelegate(source, matchEvent); - } - - checkController(); - } - - public virtual void fireMatch(int n, string text, int guessing) - { - MatchEventHandler eventDelegate = (MatchEventHandler) ((Parser) source).Events[Parser.MatchEventKey]; - if (eventDelegate != null) - { - matchEvent.setValues(MatchEventArgs.TOKEN, n, n, text, guessing, false, true); - eventDelegate(source, matchEvent); - } - - checkController(); - } - - public virtual void fireMatch(string s, int guessing) - { - MatchEventHandler eventDelegate = (MatchEventHandler) ((Parser) source).Events[Parser.MatchEventKey]; - if (eventDelegate != null) - { - matchEvent.setValues(MatchEventArgs.STRING, 0, s, null, guessing, false, true); - eventDelegate(source, matchEvent); - } - - checkController(); - } - - public virtual void fireMatchNot(char c, char n, int guessing) - { - MatchEventHandler eventDelegate = (MatchEventHandler) ((Parser) source).Events[Parser.MatchNotEventKey]; - if (eventDelegate != null) - { - matchEvent.setValues(MatchEventArgs.CHAR, c, n, null, guessing, true, true); - eventDelegate(source, matchEvent); - } - - checkController(); - } - - public virtual void fireMatchNot(int c, int n, string text, int guessing) - { - MatchEventHandler eventDelegate = (MatchEventHandler) ((Parser) source).Events[Parser.MatchNotEventKey]; - if (eventDelegate != null) - { - matchEvent.setValues(MatchEventArgs.TOKEN, c, n, text, guessing, true, true); - eventDelegate(source, matchEvent); - } - - checkController(); - } - - public virtual void fireMismatch(char c, char n, int guessing) - { - MatchEventHandler eventDelegate = (MatchEventHandler) ((Parser) source).Events[Parser.MisMatchEventKey]; - if (eventDelegate != null) - { - matchEvent.setValues(MatchEventArgs.CHAR, c, n, null, guessing, false, false); - eventDelegate(source, matchEvent); - } - - checkController(); - } - - public virtual void fireMismatch(char c, BitSet b, int guessing) - { - MatchEventHandler eventDelegate = (MatchEventHandler) ((Parser) source).Events[Parser.MisMatchEventKey]; - if (eventDelegate != null) - { - matchEvent.setValues(MatchEventArgs.CHAR_BITSET, c, b, null, guessing, false, true); - eventDelegate(source, matchEvent); - } - - checkController(); - } - - public virtual void fireMismatch(char c, string target, int guessing) - { - MatchEventHandler eventDelegate = (MatchEventHandler) ((Parser) source).Events[Parser.MisMatchEventKey]; - if (eventDelegate != null) - { - matchEvent.setValues(MatchEventArgs.CHAR_RANGE, c, target, null, guessing, false, true); - eventDelegate(source, matchEvent); - } - - checkController(); - } - - public virtual void fireMismatch(int i, int n, string text, int guessing) - { - MatchEventHandler eventDelegate = (MatchEventHandler) ((Parser) source).Events[Parser.MisMatchEventKey]; - if (eventDelegate != null) - { - matchEvent.setValues(MatchEventArgs.TOKEN, i, n, text, guessing, false, false); - eventDelegate(source, matchEvent); - } - - checkController(); - } - - public virtual void fireMismatch(int i, BitSet b, string text, int guessing) - { - MatchEventHandler eventDelegate = (MatchEventHandler) ((Parser) source).Events[Parser.MisMatchEventKey]; - if (eventDelegate != null) - { - matchEvent.setValues(MatchEventArgs.BITSET, i, b, text, guessing, false, true); - eventDelegate(source, matchEvent); - } - - checkController(); - } - - public virtual void fireMismatch(string s, string text, int guessing) - { - MatchEventHandler eventDelegate = (MatchEventHandler) ((Parser) source).Events[Parser.MisMatchEventKey]; - if (eventDelegate != null) - { - matchEvent.setValues(MatchEventArgs.STRING, 0, text, s, guessing, false, true); - eventDelegate(source, matchEvent); - } - - checkController(); - } - - public virtual void fireMismatchNot(char v, char c, int guessing) - { - MatchEventHandler eventDelegate = (MatchEventHandler) ((Parser) source).Events[Parser.MisMatchNotEventKey]; - if (eventDelegate != null) - { - matchEvent.setValues(MatchEventArgs.CHAR, v, c, null, guessing, true, true); - eventDelegate(source, matchEvent); - } - - checkController(); - } - - public virtual void fireMismatchNot(int i, int n, string text, int guessing) - { - MatchEventHandler eventDelegate = (MatchEventHandler) ((Parser) source).Events[Parser.MisMatchNotEventKey]; - if (eventDelegate != null) - { - matchEvent.setValues(MatchEventArgs.TOKEN, i, n, text, guessing, true, true); - eventDelegate(source, matchEvent); - } - - checkController(); - } - - public virtual void fireReportError(System.Exception e) - { - MessageEventHandler eventDelegate = (MessageEventHandler) ((Parser) source).Events[Parser.ReportErrorEventKey]; - if (eventDelegate != null) - { - messageEvent.setValues(MessageEventArgs.ERROR, e.ToString()); - eventDelegate(source, messageEvent); - } - - checkController(); - } - - public virtual void fireReportError(string s) - { - MessageEventHandler eventDelegate = (MessageEventHandler) ((Parser) source).Events[Parser.ReportErrorEventKey]; - if (eventDelegate != null) - { - messageEvent.setValues(MessageEventArgs.ERROR, s); - eventDelegate(source, messageEvent); - } - - checkController(); - } - - public virtual void fireReportWarning(string s) - { - MessageEventHandler eventDelegate = (MessageEventHandler) ((Parser) source).Events[Parser.ReportWarningEventKey]; - if (eventDelegate != null) - { - messageEvent.setValues(MessageEventArgs.WARNING, s); - eventDelegate(source, messageEvent); - } - - checkController(); - } - - public virtual bool fireSemanticPredicateEvaluated(int type, int condition, bool result, int guessing) - { - SemanticPredicateEventHandler eventDelegate = (SemanticPredicateEventHandler) ((Parser) source).Events[Parser.SemPredEvaluatedEventKey]; - if (eventDelegate != null) - { - semPredEvent.setValues(type, condition, result, guessing); - eventDelegate(source, semPredEvent); - } - - checkController(); - - return result; - } - - public virtual void fireSyntacticPredicateFailed(int guessing) - { - SyntacticPredicateEventHandler eventDelegate = (SyntacticPredicateEventHandler) ((Parser) source).Events[Parser.SynPredFailedEventKey]; - if (eventDelegate != null) - { - synPredEvent.setValues(0, guessing); - eventDelegate(source, synPredEvent); - } - - checkController(); - } - - public virtual void fireSyntacticPredicateStarted(int guessing) - { - SyntacticPredicateEventHandler eventDelegate = (SyntacticPredicateEventHandler) ((Parser) source).Events[Parser.SynPredStartedEventKey]; - if (eventDelegate != null) - { - synPredEvent.setValues(0, guessing); - eventDelegate(source, synPredEvent); - } - - checkController(); - } - - public virtual void fireSyntacticPredicateSucceeded(int guessing) - { - SyntacticPredicateEventHandler eventDelegate = (SyntacticPredicateEventHandler) ((Parser) source).Events[Parser.SynPredSucceededEventKey]; - if (eventDelegate != null) - { - synPredEvent.setValues(0, guessing); - eventDelegate(source, synPredEvent); - } - - checkController(); - } - - public virtual void refreshListeners() - { - Hashtable clonedTable; - - lock (listeners.SyncRoot) - { - clonedTable = (Hashtable) listeners.Clone(); - } - - foreach (DictionaryEntry entry in clonedTable) - { - if (entry.Value != null) - { - ((Listener) entry.Value).refresh(); - } - } - } - - public virtual void removeDoneListener(Listener l) - { - ((Parser) source).Done -= new TraceEventHandler(l.doneParsing); - listeners.Remove(l); - } - - public virtual void removeMessageListener(MessageListener l) - { - ((Parser) source).ErrorReported -= new MessageEventHandler(l.reportError); - ((Parser) source).WarningReported -= new MessageEventHandler(l.reportWarning); - //messageListeners.Remove(l); - removeDoneListener(l); - } - - public virtual void removeParserListener(ParserListener l) - { - removeParserMatchListener(l); - removeMessageListener(l); - removeParserTokenListener(l); - removeTraceListener(l); - removeSemanticPredicateListener(l); - removeSyntacticPredicateListener(l); - } - - public virtual void removeParserMatchListener(ParserMatchListener l) - { - ((Parser) source).MatchedToken -= new MatchEventHandler(l.parserMatch); - ((Parser) source).MatchedNotToken -= new MatchEventHandler(l.parserMatchNot); - ((Parser) source).MisMatchedToken -= new MatchEventHandler(l.parserMismatch); - ((Parser) source).MisMatchedNotToken -= new MatchEventHandler(l.parserMismatchNot); - //matchListeners.Remove(l); - removeDoneListener(l); - } - - public virtual void removeParserTokenListener(ParserTokenListener l) - { - ((Parser) source).ConsumedToken -= new TokenEventHandler(l.parserConsume); - ((Parser) source).TokenLA -= new TokenEventHandler(l.parserLA); - //tokenListeners.Remove(l); - removeDoneListener(l); - } - - public virtual void removeSemanticPredicateListener(SemanticPredicateListener l) - { - ((Parser) source).SemPredEvaluated -= new SemanticPredicateEventHandler(l.semanticPredicateEvaluated); - //semPredListeners.Remove(l); - removeDoneListener(l); - } - - public virtual void removeSyntacticPredicateListener(SyntacticPredicateListener l) - { - ((Parser) source).SynPredStarted -= new SyntacticPredicateEventHandler(l.syntacticPredicateStarted); - ((Parser) source).SynPredFailed -= new SyntacticPredicateEventHandler(l.syntacticPredicateFailed); - ((Parser) source).SynPredSucceeded -= new SyntacticPredicateEventHandler(l.syntacticPredicateSucceeded); - //synPredListeners.Remove(l); - removeDoneListener(l); - } - - public virtual void removeTraceListener(TraceListener l) - { - ((Parser) source).EnterRule -= new TraceEventHandler(l.enterRule); - ((Parser) source).ExitRule -= new TraceEventHandler(l.exitRule); - //traceListeners.Remove(l); - removeDoneListener(l); - } -} diff --git a/src/Spring/Spring.Core/Expressions/Parser/antlr/debug/ParserListener.cs b/src/Spring/Spring.Core/Expressions/Parser/antlr/debug/ParserListener.cs deleted file mode 100644 index aaa5b07b9..000000000 --- a/src/Spring/Spring.Core/Expressions/Parser/antlr/debug/ParserListener.cs +++ /dev/null @@ -1,5 +0,0 @@ -namespace Spring.Expressions.Parser.antlr.debug; - -public interface ParserListener : SemanticPredicateListener, ParserMatchListener, MessageListener, ParserTokenListener, TraceListener, SyntacticPredicateListener -{ -} diff --git a/src/Spring/Spring.Core/Expressions/Parser/antlr/debug/ParserListenerBase.cs b/src/Spring/Spring.Core/Expressions/Parser/antlr/debug/ParserListenerBase.cs deleted file mode 100644 index 67a9368ca..000000000 --- a/src/Spring/Spring.Core/Expressions/Parser/antlr/debug/ParserListenerBase.cs +++ /dev/null @@ -1,152 +0,0 @@ -namespace Spring.Expressions.Parser.antlr.debug; - -/// -/// Provides an abstract base for implementing subclasses. -/// -/// -/// -/// This abstract class is provided to make it easier to create s. -/// You should extend this base class rather than creating your own. -/// -/// -public class ParserListenerBase : ParserListener -{ - /// - /// Handle the "Done" event. - /// - /// Event source object - /// Event data object - public virtual void doneParsing(object source, TraceEventArgs e) - { - } - - /// - /// Handle the "EnterRule" event - /// - /// Event source object - /// Event data object - public virtual void enterRule(object source, TraceEventArgs e) - { - } - - /// - /// Handle the "ExitRule" event - /// - /// Event source object - /// Event data object - public virtual void exitRule(object source, TraceEventArgs e) - { - } - - /// - /// Handle the "Consume" event. - /// - /// Event source object - /// Event data object - public virtual void parserConsume(object source, TokenEventArgs e) - { - } - - /// - /// Handle the "ParserLA" event. - /// - /// Event source object - /// Event data object - public virtual void parserLA(object source, TokenEventArgs e) - { - } - - /// - /// Handle the "Match" event. - /// - /// Event source object - /// Event data object - public virtual void parserMatch(object source, MatchEventArgs e) - { - } - - /// - /// Handle the "MatchNot" event. - /// - /// Event source object - /// Event data object - public virtual void parserMatchNot(object source, MatchEventArgs e) - { - } - - /// - /// Handle the "MisMatch" event. - /// - /// Event source object - /// Event data object - public virtual void parserMismatch(object source, MatchEventArgs e) - { - } - - /// - /// Handle the "MisMatchNot" event. - /// - /// Event source object - /// Event data object - public virtual void parserMismatchNot(object source, MatchEventArgs e) - { - } - - /// - /// Handle the "ReportError" event. - /// - /// Event source object - /// Event data object - public virtual void reportError(object source, MessageEventArgs e) - { - } - - /// - /// Handle the "ReportWarning" event. - /// - /// Event source object - /// Event data object - public virtual void reportWarning(object source, MessageEventArgs e) - { - } - - /// - /// Handle the "SemPreEvaluated" event. - /// - /// Event source object - /// Event data object - public virtual void semanticPredicateEvaluated(object source, SemanticPredicateEventArgs e) - { - } - - /// - /// Handle the "SynPredFailed" event. - /// - /// Event source object - /// Event data object - public virtual void syntacticPredicateFailed(object source, SyntacticPredicateEventArgs e) - { - } - - /// - /// Handle the "SynPredStarted" event. - /// - /// Event source object - /// Event data object - public virtual void syntacticPredicateStarted(object source, SyntacticPredicateEventArgs e) - { - } - - /// - /// Handle the "SynPredSucceeded" event. - /// - /// Event source object - /// Event data object - public virtual void syntacticPredicateSucceeded(object source, SyntacticPredicateEventArgs e) - { - } - - public virtual void refresh() - { - } -} diff --git a/src/Spring/Spring.Core/Expressions/Parser/antlr/debug/ParserMatchEventArgs.cs b/src/Spring/Spring.Core/Expressions/Parser/antlr/debug/ParserMatchEventArgs.cs deleted file mode 100644 index c7cc46d32..000000000 --- a/src/Spring/Spring.Core/Expressions/Parser/antlr/debug/ParserMatchEventArgs.cs +++ /dev/null @@ -1,93 +0,0 @@ -namespace Spring.Expressions.Parser.antlr.debug; - -public class MatchEventArgs : GuessingEventArgs -{ - public MatchEventArgs() - { - } - - public MatchEventArgs(int type, int val, object target, string text, int guessing, bool inverse, bool matched) - { - setValues(type, val, target, text, guessing, inverse, matched); - } - - public virtual object Target - { - get { return this.target_; } - set { this.target_ = value; } - } - - public virtual string Text - { - get { return this.text_; } - set { this.text_ = value; } - } - - public virtual int Value - { - get { return this.val_; } - set { this.val_ = value; } - } - - internal bool Inverse - { - set { this.inverse_ = value; } - } - - internal bool Matched - { - set { this.matched_ = value; } - } - - // NOTE: for a mismatch on type STRING, the "text" is used as the lookahead - // value. Normally "value" is this - public enum ParserMatchEnums - { - TOKEN = 0, - BITSET = 1, - CHAR = 2, - CHAR_BITSET = 3, - STRING = 4, - CHAR_RANGE = 5, - } - - public static int TOKEN = 0; - public static int BITSET = 1; - public static int CHAR = 2; - public static int CHAR_BITSET = 3; - public static int STRING = 4; - public static int CHAR_RANGE = 5; - - private bool inverse_; - private bool matched_; - private object target_; - private int val_; - private string text_; - - public virtual bool isInverse() - { - return inverse_; - } - - public virtual bool isMatched() - { - return matched_; - } - - /// This should NOT be called from anyone other than ParserEventSupport! - /// - internal void setValues(int type, int val, object target, string text, int guessing, bool inverse, bool matched) - { - base.setValues(type, guessing); - this.Value = val; - this.Target = target; - this.Inverse = inverse; - this.Matched = matched; - this.Text = text; - } - - public override string ToString() - { - return "ParserMatchEvent [" + (isMatched() ? "ok," : "bad,") + (isInverse() ? "NOT " : "") + (Type == TOKEN ? "token," : "bitset,") + Value + "," + Target + "," + Guessing + "]"; - } -} diff --git a/src/Spring/Spring.Core/Expressions/Parser/antlr/debug/ParserMatchListener.cs b/src/Spring/Spring.Core/Expressions/Parser/antlr/debug/ParserMatchListener.cs deleted file mode 100644 index ebfcf6e50..000000000 --- a/src/Spring/Spring.Core/Expressions/Parser/antlr/debug/ParserMatchListener.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace Spring.Expressions.Parser.antlr.debug; - -public interface ParserMatchListener : Listener -{ - void parserMatch(object source, MatchEventArgs e); - void parserMatchNot(object source, MatchEventArgs e); - void parserMismatch(object source, MatchEventArgs e); - void parserMismatchNot(object source, MatchEventArgs e); -} diff --git a/src/Spring/Spring.Core/Expressions/Parser/antlr/debug/ParserMatchListenerBase.cs b/src/Spring/Spring.Core/Expressions/Parser/antlr/debug/ParserMatchListenerBase.cs deleted file mode 100644 index 5569e5c3e..000000000 --- a/src/Spring/Spring.Core/Expressions/Parser/antlr/debug/ParserMatchListenerBase.cs +++ /dev/null @@ -1,62 +0,0 @@ -namespace Spring.Expressions.Parser.antlr.debug; - -/// -/// Provides an abstract base for implementing subclasses. -/// -/// -/// -/// This abstract class is provided to make it easier to create s. -/// You should extend this base class rather than creating your own. -/// -/// -public abstract class ParserMatchListenerBase : ParserMatchListener -{ - /// - /// Handle the "Done" event. - /// - /// Event source object - /// Event data object - public virtual void doneParsing(object source, TraceEventArgs e) - { - } - - /// - /// Handle the "Match" event. - /// - /// Event source object - /// Event data object - public virtual void parserMatch(object source, MatchEventArgs e) - { - } - - /// - /// Handle the "MatchNot" event. - /// - /// Event source object - /// Event data object - public virtual void parserMatchNot(object source, MatchEventArgs e) - { - } - - /// - /// Handle the "MisMatch" event. - /// - /// Event source object - /// Event data object - public virtual void parserMismatch(object source, MatchEventArgs e) - { - } - - /// - /// Handle the "MisMatchNot" event. - /// - /// Event source object - /// Event data object - public virtual void parserMismatchNot(object source, MatchEventArgs e) - { - } - - public virtual void refresh() - { - } -} diff --git a/src/Spring/Spring.Core/Expressions/Parser/antlr/debug/ParserReporter.cs b/src/Spring/Spring.Core/Expressions/Parser/antlr/debug/ParserReporter.cs deleted file mode 100644 index 1296f8c6b..000000000 --- a/src/Spring/Spring.Core/Expressions/Parser/antlr/debug/ParserReporter.cs +++ /dev/null @@ -1,64 +0,0 @@ -namespace Spring.Expressions.Parser.antlr.debug; - -public class ParserReporter : Tracer, ParserListener -{ - public virtual void parserConsume(object source, TokenEventArgs e) - { - System.Console.Out.WriteLine(indentString + e); - } - - public virtual void parserLA(object source, TokenEventArgs e) - { - System.Console.Out.WriteLine(indentString + e); - } - - public virtual void parserMatch(object source, MatchEventArgs e) - { - System.Console.Out.WriteLine(indentString + e); - } - - public virtual void parserMatchNot(object source, MatchEventArgs e) - { - System.Console.Out.WriteLine(indentString + e); - } - - public virtual void parserMismatch(object source, MatchEventArgs e) - { - System.Console.Out.WriteLine(indentString + e); - } - - public virtual void parserMismatchNot(object source, MatchEventArgs e) - { - System.Console.Out.WriteLine(indentString + e); - } - - public virtual void reportError(object source, MessageEventArgs e) - { - System.Console.Out.WriteLine(indentString + e); - } - - public virtual void reportWarning(object source, MessageEventArgs e) - { - System.Console.Out.WriteLine(indentString + e); - } - - public virtual void semanticPredicateEvaluated(object source, SemanticPredicateEventArgs e) - { - System.Console.Out.WriteLine(indentString + e); - } - - public virtual void syntacticPredicateFailed(object source, SyntacticPredicateEventArgs e) - { - System.Console.Out.WriteLine(indentString + e); - } - - public virtual void syntacticPredicateStarted(object source, SyntacticPredicateEventArgs e) - { - System.Console.Out.WriteLine(indentString + e); - } - - public virtual void syntacticPredicateSucceeded(object source, SyntacticPredicateEventArgs e) - { - System.Console.Out.WriteLine(indentString + e); - } -} diff --git a/src/Spring/Spring.Core/Expressions/Parser/antlr/debug/ParserTokenEventArgs.cs b/src/Spring/Spring.Core/Expressions/Parser/antlr/debug/ParserTokenEventArgs.cs deleted file mode 100644 index 64dbe7ec0..000000000 --- a/src/Spring/Spring.Core/Expressions/Parser/antlr/debug/ParserTokenEventArgs.cs +++ /dev/null @@ -1,48 +0,0 @@ -namespace Spring.Expressions.Parser.antlr.debug; - -public class TokenEventArgs : ANTLREventArgs -{ - public TokenEventArgs() - { - } - - public TokenEventArgs(int type, int amount, int val) - { - setValues(type, amount, val); - } - - public virtual int Amount - { - get { return amount; } - set { this.amount = value; } - } - - public virtual int Value - { - get { return this.value_; } - set { this.value_ = value; } - } - - private int value_; - private int amount; - - public static int LA = 0; - public static int CONSUME = 1; - - /// This should NOT be called from anyone other than ParserEventSupport! - /// - internal void setValues(int type, int amount, int val) - { - base.setValues(type); - this.Amount = amount; - this.Value = val; - } - - public override string ToString() - { - if (Type == LA) - return "ParserTokenEvent [LA," + Amount + "," + Value + "]"; - else - return "ParserTokenEvent [consume,1," + Value + "]"; - } -} diff --git a/src/Spring/Spring.Core/Expressions/Parser/antlr/debug/ParserTokenListener.cs b/src/Spring/Spring.Core/Expressions/Parser/antlr/debug/ParserTokenListener.cs deleted file mode 100644 index 70e424034..000000000 --- a/src/Spring/Spring.Core/Expressions/Parser/antlr/debug/ParserTokenListener.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace Spring.Expressions.Parser.antlr.debug; - -public interface ParserTokenListener : Listener -{ - void parserConsume(object source, TokenEventArgs e); - void parserLA(object source, TokenEventArgs e); -} diff --git a/src/Spring/Spring.Core/Expressions/Parser/antlr/debug/ParserTokenListenerBase.cs b/src/Spring/Spring.Core/Expressions/Parser/antlr/debug/ParserTokenListenerBase.cs deleted file mode 100644 index 3eb8f5115..000000000 --- a/src/Spring/Spring.Core/Expressions/Parser/antlr/debug/ParserTokenListenerBase.cs +++ /dev/null @@ -1,44 +0,0 @@ -namespace Spring.Expressions.Parser.antlr.debug; - -/// -/// Provides an abstract base for implementing subclasses. -/// -/// -/// -/// This abstract class is provided to make it easier to create s. -/// You should extend this base class rather than creating your own. -/// -/// -public abstract class ParserTokenListenerBase : ParserTokenListener -{ - /// - /// Handle the "Done" event. - /// - /// Event source object - /// Event data object - public virtual void doneParsing(object source, TraceEventArgs e) - { - } - - public virtual void refresh() - { - } - - /// - /// Handle the "Consume" event. - /// - /// Event source object - /// Event data object - public virtual void parserConsume(object source, TokenEventArgs e) - { - } - - /// - /// Handle the "ParserLA" event. - /// - /// Event source object - /// Event data object - public virtual void parserLA(object source, TokenEventArgs e) - { - } -} diff --git a/src/Spring/Spring.Core/Expressions/Parser/antlr/debug/ScannerEventSupport.cs b/src/Spring/Spring.Core/Expressions/Parser/antlr/debug/ScannerEventSupport.cs deleted file mode 100644 index 3d647607a..000000000 --- a/src/Spring/Spring.Core/Expressions/Parser/antlr/debug/ScannerEventSupport.cs +++ /dev/null @@ -1,554 +0,0 @@ -namespace Spring.Expressions.Parser.antlr.debug; - -using Hashtable = System.Collections.Hashtable; -using antlr.collections.impl; - -/// A class to assist in firing parser events -/// NOTE: I intentionally _did_not_ synchronize the event firing and -/// add/remove listener methods. This is because the add/remove should -/// _only_ be called by the parser at its start/end, and the _same_thread_ -/// should be performing the parsing. This should help performance a tad... -/// -public class ScannerEventSupport -{ - private object source; - private Hashtable listeners; - private MatchEventArgs matchEvent; - private MessageEventArgs messageEvent; - private TokenEventArgs tokenEvent; - private SemanticPredicateEventArgs semPredEvent; - private SyntacticPredicateEventArgs synPredEvent; - private TraceEventArgs traceEvent; - private NewLineEventArgs newLineEvent; - //private ParserController controller; - - private int ruleDepth = 0; - - public ScannerEventSupport(object source) - { - matchEvent = new MatchEventArgs(); - messageEvent = new MessageEventArgs(); - tokenEvent = new TokenEventArgs(); - traceEvent = new TraceEventArgs(); - semPredEvent = new SemanticPredicateEventArgs(); - synPredEvent = new SyntacticPredicateEventArgs(); - newLineEvent = new NewLineEventArgs(); - listeners = new Hashtable(); - this.source = source; - } - - public virtual void checkController() - { - //if (controller != null) - // controller.checkBreak(); - } - - public virtual void addDoneListener(Listener l) - { - ((CharScanner) source).Done += new TraceEventHandler(l.doneParsing); - listeners[l] = l; - } - - public virtual void addMessageListener(MessageListener l) - { - ((CharScanner) source).ErrorReported += new MessageEventHandler(l.reportError); - ((CharScanner) source).WarningReported += new MessageEventHandler(l.reportWarning); - addDoneListener(l); - } - - public virtual void addNewLineListener(NewLineListener l) - { - ((CharScanner) source).HitNewLine += new NewLineEventHandler(l.hitNewLine); - addDoneListener(l); - } - - public virtual void addParserListener(ParserListener l) - { - if (l is ParserController) - { - //((ParserController) l).ParserEventSupport = this; - //controller = (ParserController) l; - } - - addParserMatchListener(l); - addParserTokenListener(l); - - addMessageListener(l); - addTraceListener(l); - addSemanticPredicateListener(l); - addSyntacticPredicateListener(l); - } - - public virtual void addParserMatchListener(ParserMatchListener l) - { - ((CharScanner) source).MatchedChar += new MatchEventHandler(l.parserMatch); - ((CharScanner) source).MatchedNotChar += new MatchEventHandler(l.parserMatchNot); - ((CharScanner) source).MisMatchedChar += new MatchEventHandler(l.parserMismatch); - ((CharScanner) source).MisMatchedNotChar += new MatchEventHandler(l.parserMismatchNot); - addDoneListener(l); - } - - public virtual void addParserTokenListener(ParserTokenListener l) - { - ((CharScanner) source).ConsumedChar += new TokenEventHandler(l.parserConsume); - ((CharScanner) source).CharLA += new TokenEventHandler(l.parserLA); - addDoneListener(l); - } - - public virtual void addSemanticPredicateListener(SemanticPredicateListener l) - { - ((CharScanner) source).SemPredEvaluated += new SemanticPredicateEventHandler(l.semanticPredicateEvaluated); - addDoneListener(l); - } - - public virtual void addSyntacticPredicateListener(SyntacticPredicateListener l) - { - ((CharScanner) source).SynPredStarted += new SyntacticPredicateEventHandler(l.syntacticPredicateStarted); - ((CharScanner) source).SynPredFailed += new SyntacticPredicateEventHandler(l.syntacticPredicateFailed); - ((CharScanner) source).SynPredSucceeded += new SyntacticPredicateEventHandler(l.syntacticPredicateSucceeded); - addDoneListener(l); - } - - public virtual void addTraceListener(TraceListener l) - { - ((CharScanner) source).EnterRule += new TraceEventHandler(l.enterRule); - ((CharScanner) source).ExitRule += new TraceEventHandler(l.exitRule); - addDoneListener(l); - } - - public virtual void fireConsume(int c) - { - TokenEventHandler eventDelegate = (TokenEventHandler) ((CharScanner) source).Events[Parser.LAEventKey]; - if (eventDelegate != null) - { - tokenEvent.setValues(TokenEventArgs.CONSUME, 1, c); - eventDelegate(source, tokenEvent); - } - - checkController(); - } - - public virtual void fireDoneParsing() - { - TraceEventHandler eventDelegate = (TraceEventHandler) ((CharScanner) source).Events[Parser.DoneEventKey]; - if (eventDelegate != null) - { - traceEvent.setValues(TraceEventArgs.DONE_PARSING, 0, 0, 0); - eventDelegate(source, traceEvent); - } - - checkController(); - } - - public virtual void fireEnterRule(int ruleNum, int guessing, int data) - { - ruleDepth++; - TraceEventHandler eventDelegate = (TraceEventHandler) ((CharScanner) source).Events[Parser.EnterRuleEventKey]; - if (eventDelegate != null) - { - traceEvent.setValues(TraceEventArgs.ENTER, ruleNum, guessing, data); - eventDelegate(source, traceEvent); - } - - checkController(); - } - - public virtual void fireExitRule(int ruleNum, int guessing, int data) - { - TraceEventHandler eventDelegate = (TraceEventHandler) ((CharScanner) source).Events[Parser.ExitRuleEventKey]; - if (eventDelegate != null) - { - traceEvent.setValues(TraceEventArgs.EXIT, ruleNum, guessing, data); - eventDelegate(source, traceEvent); - } - - checkController(); - - ruleDepth--; - if (ruleDepth == 0) - fireDoneParsing(); - } - - public virtual void fireLA(int k, int la) - { - TokenEventHandler eventDelegate = (TokenEventHandler) ((CharScanner) source).Events[Parser.LAEventKey]; - if (eventDelegate != null) - { - tokenEvent.setValues(TokenEventArgs.LA, k, la); - eventDelegate(source, tokenEvent); - } - - checkController(); - } - - public virtual void fireMatch(char c, int guessing) - { - MatchEventHandler eventDelegate = (MatchEventHandler) ((CharScanner) source).Events[Parser.MatchEventKey]; - if (eventDelegate != null) - { - matchEvent.setValues(MatchEventArgs.CHAR, c, c, null, guessing, false, true); - eventDelegate(source, matchEvent); - } - - checkController(); - } - - public virtual void fireMatch(char c, BitSet b, int guessing) - { - MatchEventHandler eventDelegate = (MatchEventHandler) ((CharScanner) source).Events[Parser.MatchEventKey]; - if (eventDelegate != null) - { - matchEvent.setValues(MatchEventArgs.CHAR_BITSET, c, b, null, guessing, false, true); - eventDelegate(source, matchEvent); - } - - checkController(); - } - - public virtual void fireMatch(char c, string target, int guessing) - { - MatchEventHandler eventDelegate = (MatchEventHandler) ((CharScanner) source).Events[Parser.MatchEventKey]; - if (eventDelegate != null) - { - matchEvent.setValues(MatchEventArgs.CHAR_RANGE, c, target, null, guessing, false, true); - eventDelegate(source, matchEvent); - } - - checkController(); - } - - public virtual void fireMatch(int c, BitSet b, string text, int guessing) - { - MatchEventHandler eventDelegate = (MatchEventHandler) ((CharScanner) source).Events[Parser.MatchEventKey]; - if (eventDelegate != null) - { - matchEvent.setValues(MatchEventArgs.BITSET, c, b, text, guessing, false, true); - eventDelegate(source, matchEvent); - } - - checkController(); - } - - public virtual void fireMatch(int n, string text, int guessing) - { - MatchEventHandler eventDelegate = (MatchEventHandler) ((CharScanner) source).Events[Parser.MatchEventKey]; - if (eventDelegate != null) - { - matchEvent.setValues(MatchEventArgs.TOKEN, n, n, text, guessing, false, true); - eventDelegate(source, matchEvent); - } - - checkController(); - } - - public virtual void fireMatch(string s, int guessing) - { - MatchEventHandler eventDelegate = (MatchEventHandler) ((CharScanner) source).Events[Parser.MatchEventKey]; - if (eventDelegate != null) - { - matchEvent.setValues(MatchEventArgs.STRING, 0, s, null, guessing, false, true); - eventDelegate(source, matchEvent); - } - - checkController(); - } - - public virtual void fireMatchNot(char c, char n, int guessing) - { - MatchEventHandler eventDelegate = (MatchEventHandler) ((CharScanner) source).Events[Parser.MatchNotEventKey]; - if (eventDelegate != null) - { - matchEvent.setValues(MatchEventArgs.CHAR, c, n, null, guessing, true, true); - eventDelegate(source, matchEvent); - } - - checkController(); - } - - public virtual void fireMatchNot(int c, int n, string text, int guessing) - { - MatchEventHandler eventDelegate = (MatchEventHandler) ((CharScanner) source).Events[Parser.MatchNotEventKey]; - if (eventDelegate != null) - { - matchEvent.setValues(MatchEventArgs.TOKEN, c, n, text, guessing, true, true); - eventDelegate(source, matchEvent); - } - - checkController(); - } - - public virtual void fireMismatch(char c, char n, int guessing) - { - MatchEventHandler eventDelegate = (MatchEventHandler) ((CharScanner) source).Events[Parser.MisMatchEventKey]; - if (eventDelegate != null) - { - matchEvent.setValues(MatchEventArgs.CHAR, c, n, null, guessing, false, false); - eventDelegate(source, matchEvent); - } - - checkController(); - } - - public virtual void fireMismatch(char c, BitSet b, int guessing) - { - MatchEventHandler eventDelegate = (MatchEventHandler) ((CharScanner) source).Events[Parser.MisMatchEventKey]; - if (eventDelegate != null) - { - matchEvent.setValues(MatchEventArgs.CHAR_BITSET, c, b, null, guessing, false, true); - eventDelegate(source, matchEvent); - } - - checkController(); - } - - public virtual void fireMismatch(char c, string target, int guessing) - { - MatchEventHandler eventDelegate = (MatchEventHandler) ((CharScanner) source).Events[Parser.MisMatchEventKey]; - if (eventDelegate != null) - { - matchEvent.setValues(MatchEventArgs.CHAR_RANGE, c, target, null, guessing, false, true); - eventDelegate(source, matchEvent); - } - - checkController(); - } - - public virtual void fireMismatch(int i, int n, string text, int guessing) - { - MatchEventHandler eventDelegate = (MatchEventHandler) ((CharScanner) source).Events[Parser.MisMatchEventKey]; - if (eventDelegate != null) - { - matchEvent.setValues(MatchEventArgs.TOKEN, i, n, text, guessing, false, false); - eventDelegate(source, matchEvent); - } - - checkController(); - } - - public virtual void fireMismatch(int i, BitSet b, string text, int guessing) - { - MatchEventHandler eventDelegate = (MatchEventHandler) ((CharScanner) source).Events[Parser.MisMatchEventKey]; - if (eventDelegate != null) - { - matchEvent.setValues(MatchEventArgs.BITSET, i, b, text, guessing, false, true); - eventDelegate(source, matchEvent); - } - - checkController(); - } - - public virtual void fireMismatch(string s, string text, int guessing) - { - MatchEventHandler eventDelegate = (MatchEventHandler) ((CharScanner) source).Events[Parser.MisMatchEventKey]; - if (eventDelegate != null) - { - matchEvent.setValues(MatchEventArgs.STRING, 0, text, s, guessing, false, true); - eventDelegate(source, matchEvent); - } - - checkController(); - } - - public virtual void fireMismatchNot(char v, char c, int guessing) - { - MatchEventHandler eventDelegate = (MatchEventHandler) ((CharScanner) source).Events[Parser.MisMatchNotEventKey]; - if (eventDelegate != null) - { - matchEvent.setValues(MatchEventArgs.CHAR, v, c, null, guessing, true, true); - eventDelegate(source, matchEvent); - } - - checkController(); - } - - public virtual void fireMismatchNot(int i, int n, string text, int guessing) - { - MatchEventHandler eventDelegate = (MatchEventHandler) ((CharScanner) source).Events[Parser.MisMatchNotEventKey]; - if (eventDelegate != null) - { - matchEvent.setValues(MatchEventArgs.TOKEN, i, n, text, guessing, true, true); - eventDelegate(source, matchEvent); - } - - checkController(); - } - - public virtual void fireNewLine(int line) - { - NewLineEventHandler eventDelegate = (NewLineEventHandler) ((CharScanner) source).Events[Parser.NewLineEventKey]; - if (eventDelegate != null) - { - newLineEvent.Line = line; - eventDelegate(source, newLineEvent); - } - - checkController(); - } - - public virtual void fireReportError(System.Exception e) - { - MessageEventHandler eventDelegate = (MessageEventHandler) ((CharScanner) source).Events[Parser.ReportErrorEventKey]; - if (eventDelegate != null) - { - messageEvent.setValues(MessageEventArgs.ERROR, e.ToString()); - eventDelegate(source, messageEvent); - } - - checkController(); - } - - public virtual void fireReportError(string s) - { - MessageEventHandler eventDelegate = (MessageEventHandler) ((CharScanner) source).Events[Parser.ReportErrorEventKey]; - if (eventDelegate != null) - { - messageEvent.setValues(MessageEventArgs.ERROR, s); - eventDelegate(source, messageEvent); - } - - checkController(); - } - - public virtual void fireReportWarning(string s) - { - MessageEventHandler eventDelegate = (MessageEventHandler) ((CharScanner) source).Events[Parser.ReportWarningEventKey]; - if (eventDelegate != null) - { - messageEvent.setValues(MessageEventArgs.WARNING, s); - eventDelegate(source, messageEvent); - } - - checkController(); - } - - public virtual bool fireSemanticPredicateEvaluated(int type, int condition, bool result, int guessing) - { - SemanticPredicateEventHandler eventDelegate = (SemanticPredicateEventHandler) ((CharScanner) source).Events[Parser.SemPredEvaluatedEventKey]; - if (eventDelegate != null) - { - semPredEvent.setValues(type, condition, result, guessing); - eventDelegate(source, semPredEvent); - } - - checkController(); - - return result; - } - - public virtual void fireSyntacticPredicateFailed(int guessing) - { - SyntacticPredicateEventHandler eventDelegate = (SyntacticPredicateEventHandler) ((CharScanner) source).Events[Parser.SynPredFailedEventKey]; - if (eventDelegate != null) - { - synPredEvent.setValues(0, guessing); - eventDelegate(source, synPredEvent); - } - - checkController(); - } - - public virtual void fireSyntacticPredicateStarted(int guessing) - { - SyntacticPredicateEventHandler eventDelegate = (SyntacticPredicateEventHandler) ((CharScanner) source).Events[Parser.SynPredStartedEventKey]; - if (eventDelegate != null) - { - synPredEvent.setValues(0, guessing); - eventDelegate(source, synPredEvent); - } - - checkController(); - } - - public virtual void fireSyntacticPredicateSucceeded(int guessing) - { - SyntacticPredicateEventHandler eventDelegate = (SyntacticPredicateEventHandler) ((CharScanner) source).Events[Parser.SynPredSucceededEventKey]; - if (eventDelegate != null) - { - synPredEvent.setValues(0, guessing); - eventDelegate(source, synPredEvent); - } - - checkController(); - } - - public virtual void refreshListeners() - { - Hashtable clonedTable; - - lock (listeners.SyncRoot) - { - clonedTable = (Hashtable) listeners.Clone(); - } - - foreach (Listener l in clonedTable) - { - l.refresh(); - } - } - - public virtual void removeDoneListener(Listener l) - { - ((CharScanner) source).Done -= new TraceEventHandler(l.doneParsing); - listeners.Remove(l); - } - - public virtual void removeMessageListener(MessageListener l) - { - ((CharScanner) source).ErrorReported -= new MessageEventHandler(l.reportError); - ((CharScanner) source).WarningReported -= new MessageEventHandler(l.reportWarning); - removeDoneListener(l); - } - - public virtual void removeNewLineListener(NewLineListener l) - { - ((CharScanner) source).HitNewLine -= new NewLineEventHandler(l.hitNewLine); - removeDoneListener(l); - } - - public virtual void removeParserListener(ParserListener l) - { - removeParserMatchListener(l); - removeMessageListener(l); - removeParserTokenListener(l); - removeTraceListener(l); - removeSemanticPredicateListener(l); - removeSyntacticPredicateListener(l); - } - - public virtual void removeParserMatchListener(ParserMatchListener l) - { - ((CharScanner) source).MatchedChar -= new MatchEventHandler(l.parserMatch); - ((CharScanner) source).MatchedNotChar -= new MatchEventHandler(l.parserMatchNot); - ((CharScanner) source).MisMatchedChar -= new MatchEventHandler(l.parserMismatch); - ((CharScanner) source).MisMatchedNotChar -= new MatchEventHandler(l.parserMismatchNot); - removeDoneListener(l); - } - - public virtual void removeParserTokenListener(ParserTokenListener l) - { - ((CharScanner) source).ConsumedChar -= new TokenEventHandler(l.parserConsume); - ((CharScanner) source).CharLA -= new TokenEventHandler(l.parserLA); - removeDoneListener(l); - } - - public virtual void removeSemanticPredicateListener(SemanticPredicateListener l) - { - ((CharScanner) source).SemPredEvaluated -= new SemanticPredicateEventHandler(l.semanticPredicateEvaluated); - removeDoneListener(l); - } - - public virtual void removeSyntacticPredicateListener(SyntacticPredicateListener l) - { - ((CharScanner) source).SynPredStarted -= new SyntacticPredicateEventHandler(l.syntacticPredicateStarted); - ((CharScanner) source).SynPredFailed -= new SyntacticPredicateEventHandler(l.syntacticPredicateFailed); - ((CharScanner) source).SynPredSucceeded -= new SyntacticPredicateEventHandler(l.syntacticPredicateSucceeded); - removeDoneListener(l); - } - - public virtual void removeTraceListener(TraceListener l) - { - ((CharScanner) source).EnterRule -= new TraceEventHandler(l.enterRule); - ((CharScanner) source).ExitRule -= new TraceEventHandler(l.exitRule); - removeDoneListener(l); - } -} \ No newline at end of file diff --git a/src/Spring/Spring.Core/Expressions/Parser/antlr/debug/SemanticPredicateEventArgs.cs b/src/Spring/Spring.Core/Expressions/Parser/antlr/debug/SemanticPredicateEventArgs.cs deleted file mode 100644 index 2ce8fc544..000000000 --- a/src/Spring/Spring.Core/Expressions/Parser/antlr/debug/SemanticPredicateEventArgs.cs +++ /dev/null @@ -1,44 +0,0 @@ -namespace Spring.Expressions.Parser.antlr.debug; - -public class SemanticPredicateEventArgs : GuessingEventArgs -{ - public SemanticPredicateEventArgs() - { - } - - public SemanticPredicateEventArgs(int type) : base(type) - { - } - - public virtual int Condition - { - get { return this.condition_; } - set { this.condition_ = value; } - } - - public virtual bool Result - { - get { return this.result_; } - set { this.result_ = value; } - } - - public const int VALIDATING = 0; - public const int PREDICTING = 1; - - private int condition_; - private bool result_; - - /// This should NOT be called from anyone other than ParserEventSupport! - /// - internal void setValues(int type, int condition, bool result, int guessing) - { - base.setValues(type, guessing); - this.Condition = condition; - this.Result = result; - } - - public override string ToString() - { - return "SemanticPredicateEvent [" + Condition + "," + Result + "," + Guessing + "]"; - } -} diff --git a/src/Spring/Spring.Core/Expressions/Parser/antlr/debug/SemanticPredicateListener.cs b/src/Spring/Spring.Core/Expressions/Parser/antlr/debug/SemanticPredicateListener.cs deleted file mode 100644 index 30f38551a..000000000 --- a/src/Spring/Spring.Core/Expressions/Parser/antlr/debug/SemanticPredicateListener.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace Spring.Expressions.Parser.antlr.debug; - -public interface SemanticPredicateListener : Listener -{ - void semanticPredicateEvaluated(object source, SemanticPredicateEventArgs e); -} diff --git a/src/Spring/Spring.Core/Expressions/Parser/antlr/debug/SemanticPredicateListenerBase.cs b/src/Spring/Spring.Core/Expressions/Parser/antlr/debug/SemanticPredicateListenerBase.cs deleted file mode 100644 index 9a7248287..000000000 --- a/src/Spring/Spring.Core/Expressions/Parser/antlr/debug/SemanticPredicateListenerBase.cs +++ /dev/null @@ -1,35 +0,0 @@ -namespace Spring.Expressions.Parser.antlr.debug; - -/// -/// Provides an abstract base for implementing subclasses. -/// -/// -/// -/// This abstract class is provided to make it easier to create s. -/// You should extend this base class rather than creating your own. -/// -/// -public class SemanticPredicateListenerBase : SemanticPredicateListener -{ - /// - /// Handle the "Done" event. - /// - /// Event source object - /// Event data object - public virtual void doneParsing(object source, TraceEventArgs e) - { - } - - public virtual void refresh() - { - } - - /// - /// Handle the "SemPreEvaluated" event. - /// - /// Event source object - /// Event data object - public virtual void semanticPredicateEvaluated(object source, SemanticPredicateEventArgs e) - { - } -} \ No newline at end of file diff --git a/src/Spring/Spring.Core/Expressions/Parser/antlr/debug/SyntacticPredicateEventArgs.cs b/src/Spring/Spring.Core/Expressions/Parser/antlr/debug/SyntacticPredicateEventArgs.cs deleted file mode 100644 index b3e8f09af..000000000 --- a/src/Spring/Spring.Core/Expressions/Parser/antlr/debug/SyntacticPredicateEventArgs.cs +++ /dev/null @@ -1,17 +0,0 @@ -namespace Spring.Expressions.Parser.antlr.debug; - -public class SyntacticPredicateEventArgs : GuessingEventArgs -{ - public SyntacticPredicateEventArgs() - { - } - - public SyntacticPredicateEventArgs(int type) : base(type) - { - } - - public override string ToString() - { - return "SyntacticPredicateEvent [" + Guessing + "]"; - } -} diff --git a/src/Spring/Spring.Core/Expressions/Parser/antlr/debug/SyntacticPredicateListener.cs b/src/Spring/Spring.Core/Expressions/Parser/antlr/debug/SyntacticPredicateListener.cs deleted file mode 100644 index 89d770701..000000000 --- a/src/Spring/Spring.Core/Expressions/Parser/antlr/debug/SyntacticPredicateListener.cs +++ /dev/null @@ -1,8 +0,0 @@ -namespace Spring.Expressions.Parser.antlr.debug; - -public interface SyntacticPredicateListener : Listener -{ - void syntacticPredicateFailed(object source, SyntacticPredicateEventArgs e); - void syntacticPredicateStarted(object source, SyntacticPredicateEventArgs e); - void syntacticPredicateSucceeded(object source, SyntacticPredicateEventArgs e); -} diff --git a/src/Spring/Spring.Core/Expressions/Parser/antlr/debug/SyntacticPredicateListenerBase.cs b/src/Spring/Spring.Core/Expressions/Parser/antlr/debug/SyntacticPredicateListenerBase.cs deleted file mode 100644 index 2e7bc7ba4..000000000 --- a/src/Spring/Spring.Core/Expressions/Parser/antlr/debug/SyntacticPredicateListenerBase.cs +++ /dev/null @@ -1,53 +0,0 @@ -namespace Spring.Expressions.Parser.antlr.debug; - -/// -/// Provides an abstract base for implementing subclasses. -/// -/// -/// -/// This abstract class is provided to make it easier to create s. -/// You should extend this base class rather than creating your own. -/// -/// -public abstract class SyntacticPredicateListenerBase : SyntacticPredicateListener -{ - /// - /// Handle the "Done" event. - /// - /// Event source object - /// Event data object - public virtual void doneParsing(object source, TraceEventArgs e) - { - } - - public virtual void refresh() - { - } - - /// - /// Handle the "SynPredFailed" event. - /// - /// Event source object - /// Event data object - public virtual void syntacticPredicateFailed(object source, SyntacticPredicateEventArgs e) - { - } - - /// - /// Handle the "SynPredStarted" event. - /// - /// Event source object - /// Event data object - public virtual void syntacticPredicateStarted(object source, SyntacticPredicateEventArgs e) - { - } - - /// - /// Handle the "SynPredSucceeded" event. - /// - /// Event source object - /// Event data object - public virtual void syntacticPredicateSucceeded(object source, SyntacticPredicateEventArgs e) - { - } -} diff --git a/src/Spring/Spring.Core/Expressions/Parser/antlr/debug/TraceEventArgs.cs b/src/Spring/Spring.Core/Expressions/Parser/antlr/debug/TraceEventArgs.cs deleted file mode 100644 index a94aa54bb..000000000 --- a/src/Spring/Spring.Core/Expressions/Parser/antlr/debug/TraceEventArgs.cs +++ /dev/null @@ -1,46 +0,0 @@ -namespace Spring.Expressions.Parser.antlr.debug; - -public class TraceEventArgs : GuessingEventArgs -{ - public TraceEventArgs() - { - } - - public TraceEventArgs(int type, int ruleNum, int guessing, int data) - { - setValues(type, ruleNum, guessing, data); - } - - public virtual int Data - { - get { return this.data_; } - set { this.data_ = value; } - } - - public virtual int RuleNum - { - get { return this.ruleNum_; } - set { this.ruleNum_ = value; } - } - - private int ruleNum_; - private int data_; - - public static int ENTER = 0; - public static int EXIT = 1; - public static int DONE_PARSING = 2; - - /// This should NOT be called from anyone other than ParserEventSupport! - /// - internal void setValues(int type, int ruleNum, int guessing, int data) - { - base.setValues(type, guessing); - RuleNum = ruleNum; - Data = data; - } - - public override string ToString() - { - return "ParserTraceEvent [" + (Type == ENTER ? "enter," : "exit,") + RuleNum + "," + Guessing + "]"; - } -} diff --git a/src/Spring/Spring.Core/Expressions/Parser/antlr/debug/TraceListener.cs b/src/Spring/Spring.Core/Expressions/Parser/antlr/debug/TraceListener.cs deleted file mode 100644 index 828445081..000000000 --- a/src/Spring/Spring.Core/Expressions/Parser/antlr/debug/TraceListener.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace Spring.Expressions.Parser.antlr.debug; - -public interface TraceListener : Listener -{ - void enterRule(object source, TraceEventArgs e); - void exitRule(object source, TraceEventArgs e); -} diff --git a/src/Spring/Spring.Core/Expressions/Parser/antlr/debug/TraceListenerBase.cs b/src/Spring/Spring.Core/Expressions/Parser/antlr/debug/TraceListenerBase.cs deleted file mode 100644 index b1c6048a5..000000000 --- a/src/Spring/Spring.Core/Expressions/Parser/antlr/debug/TraceListenerBase.cs +++ /dev/null @@ -1,44 +0,0 @@ -namespace Spring.Expressions.Parser.antlr.debug; - -/// -/// Provides an abstract base for implementing subclasses. -/// -/// -/// -/// This abstract class is provided to make it easier to create s. -/// You should extend this base class rather than creating your own. -/// -/// -public abstract class TraceListenerBase : TraceListener -{ - /// - /// Handle the "Done" event. - /// - /// Event source object - /// Event data object - public virtual void doneParsing(object source, TraceEventArgs e) - { - } - - /// - /// Handle the "EnterRule" event - /// - /// Event source object - /// Event data object - public virtual void enterRule(object source, TraceEventArgs e) - { - } - - /// - /// Handle the "ExitRule" event - /// - /// Event source object - /// Event data object - public virtual void exitRule(object source, TraceEventArgs e) - { - } - - public virtual void refresh() - { - } -} diff --git a/src/Spring/Spring.Core/Expressions/Parser/antlr/debug/Tracer.cs b/src/Spring/Spring.Core/Expressions/Parser/antlr/debug/Tracer.cs deleted file mode 100644 index 671d7ba89..000000000 --- a/src/Spring/Spring.Core/Expressions/Parser/antlr/debug/Tracer.cs +++ /dev/null @@ -1,32 +0,0 @@ -namespace Spring.Expressions.Parser.antlr.debug; - -public class Tracer : TraceListenerBase, TraceListener -{ - protected string indentString = ""; - // TBD: should be StringBuffer - - protected internal virtual void dedent() - { - if (indentString.Length < 2) - indentString = ""; - else - indentString = indentString.Substring(2); - } - - public override void enterRule(object source, TraceEventArgs e) - { - System.Console.Out.WriteLine(indentString + e); - indent(); - } - - public override void exitRule(object source, TraceEventArgs e) - { - dedent(); - System.Console.Out.WriteLine(indentString + e); - } - - protected internal virtual void indent() - { - indentString += " "; - } -} diff --git a/src/Spring/Spring.Core/Expressions/QualifiedIdentifier.cs b/src/Spring/Spring.Core/Expressions/QualifiedIdentifier.cs index 15c6e225e..53ad7bad4 100644 --- a/src/Spring/Spring.Core/Expressions/QualifiedIdentifier.cs +++ b/src/Spring/Spring.Core/Expressions/QualifiedIdentifier.cs @@ -15,7 +15,6 @@ */ using System.Runtime.Serialization; -using Spring.Expressions.Parser.antlr.collections; namespace Spring.Expressions; @@ -83,7 +82,7 @@ public override string getText() // { // tmp = tmp.Replace(ESCAPE_CHAR, ""); // remove all occurrences of escape char // } - AST node = this.getFirstChild(); + SpringAST node = this.getFirstChild(); while (node != null) { tmp = string.Concat(tmp, node.getText()); diff --git a/src/Spring/Spring.Core/Expressions/README.md b/src/Spring/Spring.Core/Expressions/README.md new file mode 100644 index 000000000..85f49088e --- /dev/null +++ b/src/Spring/Spring.Core/Expressions/README.md @@ -0,0 +1,39 @@ +# Expression parser + +`ExpressionGrammar.parlot.cs` is the grammar, a build-only file that the `Parlot.SourceGenerator` analyzer turns into code of +`Spring.Core`. `ExpressionGrammar.cs` has the tokens, the construction of the nodes and the syntax errors. The language is the +one of the former ANTLR 2 grammar, and `ExpressionGrammarTests` holds the trees and errors that parser gave for its quirks in +`ExpressionGrammarGolden.json`. + +## Quirks kept on purpose + +These decide what is accepted, so they stay: + +- A dot between nodes is optional: `a b` is `a.b`, and `1 .a` and `a.` parse. +- `T(` is one token only without a space, and `T(...)` reads any token up to `)`. +- A real number with a fraction has to have a valid exponent after `e`, while an integer doesn't: `1.5ex` fails, `1ex` is `1` + then `ex`. +- `Ul` is not an integer suffix but `lU` is. +- Keywords can't be property names. +- The relational and power operators don't chain. +- The line of an error is always 1, and its column counts a tab as moving to the next multiple of 8. + +## PEG vs LL(2) + +A PEG choice can backtrack where ANTLR committed to an alternative after looking at two tokens. These keep the same language: + +- Tokens are scanned as ANTLR's lexer did: `^` doesn't match the start of `^{`, `{` doesn't match `{|`, `.` doesn't match `.5`. + Otherwise `a^{b,c}`, an error, would be read again as `a ^ {b,c}`. +- A name followed by `(` can only be a call, so `a(b;c)` isn't read again as a property followed by an expression list. This is + `Not(lparen)` in the grammar. +- A name followed by `=` in arguments can only be a named argument: `Not(id.AndSkip(assign))` on the other alternative. Without + it, nested `new a(b=` takes exponential time. +- `Parse` needs the end of the input, so a failed alternative can't be accepted. `ParsePrimary` doesn't, and checks what follows + with the follow sets of the ANTLR grammar (`CanFollowPrimary`). + +## Layout of the grammar + +`Operators()` handles the unary and the left-associative levels. The relational and power levels don't chain, and the third +operand of `?:` is a whole expression, which a table can't express, so these are sequences. `Parse`, `ParsePrimary` and +`ParseLambda` share one generated parser through a configuration parameter and `If`, as generating one each would triple the +code. `ParseProperty` is a scan by hand. diff --git a/src/Spring/Spring.Core/Expressions/SpringAST.cs b/src/Spring/Spring.Core/Expressions/SpringAST.cs index 18fbc3563..2db531b32 100644 --- a/src/Spring/Spring.Core/Expressions/SpringAST.cs +++ b/src/Spring/Spring.Core/Expressions/SpringAST.cs @@ -1,6 +1,5 @@ using System.Runtime.Serialization; -using Spring.Expressions.Parser.antlr; -using Spring.Expressions.Parser.antlr.collections; +using System.Text; namespace Spring.Expressions; @@ -8,34 +7,17 @@ namespace Spring.Expressions; /// For internal purposes only. Use for expression node implementations. ///
/// -/// This class is only required to enable serialization of parsed Spring expressions since antlr.CommonAST -/// unfortunately is not marked as [Serializable].
+/// A node of a parsed expression: its first child, its next sibling, a token type and a text.
///
/// Note:Since SpringAST implements , deriving classes /// have to explicitely override if they need to persist additional /// data during serialization. ///
[Serializable] -public class SpringAST : Parser.antlr.BaseAST, ISerializable +public class SpringAST : ISerializable { - internal class SpringASTCreator : Parser.antlr.ASTNodeCreator - { - public override Parser.antlr.collections.AST Create() - { - return new SpringAST(); - } - - public override string ASTNodeTypeName - { - get { return typeof(SpringAST).FullName; } - } - } - - /// - /// The global SpringAST node factory - /// - internal static readonly SpringASTCreator Creator = new SpringASTCreator(); - + private SpringAST down; + private SpringAST right; private string text; private int ttype; @@ -46,36 +28,19 @@ public SpringAST() { } - /// - /// Create an instance from a token - /// - public SpringAST(IToken token) - { - initialize(token); - } - /// /// initialize this instance from an AST /// - public override void initialize(AST t) + public virtual void initialize(SpringAST t) { this.setText(t.getText()); this.Type = t.Type; } - /// - /// initialize this instance from an IToken - /// - public override void initialize(IToken tok) - { - this.setText(tok.getText()); - this.Type = tok.Type; - } - /// /// initialize this instance from a token type number and a text /// - public override void initialize(int t, string txt) + public virtual void initialize(int t, string txt) { this.Type = t; this.setText(txt); @@ -84,12 +49,20 @@ public override void initialize(int t, string txt) /// /// gets or sets the token type of this node /// - public override int Type + public virtual int Type { get { return this.ttype; } set { this.ttype = value; } } + /// + /// sets the token type of this node + /// + public virtual void setType(int ttype) + { + this.Type = ttype; + } + /// /// gets or sets the text of this node /// @@ -102,7 +75,7 @@ public string Text /// /// sets the text of this node /// - public override void setText(string txt) + public virtual void setText(string txt) { this.text = txt; } @@ -110,11 +83,144 @@ public override void setText(string txt) /// /// gets the text of this node /// - public override string getText() + public virtual string getText() { return this.text; } + /// + /// adds a node to the end of the children of this node + /// + public virtual void addChild(SpringAST node) + { + if (node == null) + { + return; + } + + var t = this.down; + if (t == null) + { + this.down = node; + return; + } + + while (t.right != null) + { + t = t.right; + } + + t.right = node; + } + + /// + /// gets the first child of this node + /// + public virtual SpringAST getFirstChild() + { + return this.down; + } + + /// + /// sets the first child of this node + /// + public virtual void setFirstChild(SpringAST c) + { + this.down = c; + } + + /// + /// gets the next sibling of this node + /// + public virtual SpringAST getNextSibling() + { + return this.right; + } + + /// + /// sets the next sibling of this node + /// + public virtual void setNextSibling(SpringAST n) + { + this.right = n; + } + + /// + /// removes the children of this node + /// + public virtual void removeChildren() + { + this.down = null; + } + + /// + /// gets the number of children of this node, 0 for a leaf + /// + public int getNumberOfChildren() + { + var n = 0; + for (var t = this.down; t != null; t = t.right) + { + n++; + } + + return n; + } + + /// + /// whether is a node of the same class, token type and text, whatever its children + /// + public override bool Equals(object obj) + { + return obj != null && this.GetType() == obj.GetType() && Equals((SpringAST) obj); + } + + /// + /// whether has the same token type and text, whatever its children + /// + public virtual bool Equals(SpringAST t) + { + return t != null && object.Equals(this.getText(), t.getText()) && this.Type == t.Type; + } + + /// + public override int GetHashCode() + { + return base.GetHashCode(); + } + + /// + /// returns the text of this node + /// + public override string ToString() + { + return getText(); + } + + /// + /// prints this node, its children and its next siblings in LISP notation + /// + public virtual string ToStringList() + { + var builder = new StringBuilder(); + for (var t = this; t != null; t = t.right) + { + builder.Append(t.ToStringTree()); + } + + return builder.ToString(); + } + + /// + /// prints this node and its children in LISP notation + /// + public virtual string ToStringTree() + { + return this.down == null + ? " " + ToString() + : " ( " + ToString() + this.down.ToStringList() + " )"; + } + /// /// Create a new instance from SerializationInfo /// @@ -123,8 +229,8 @@ public override string getText() #endif protected SpringAST(SerializationInfo info, StreamingContext context) { - base.down = (BaseAST) info.GetValue("down", typeof(BaseAST)); - base.right = (BaseAST) info.GetValue("right", typeof(BaseAST)); + this.down = (SpringAST) info.GetValue("down", typeof(SpringAST)); + this.right = (SpringAST) info.GetValue("right", typeof(SpringAST)); this.ttype = info.GetInt32("ttype"); this.text = info.GetString("text"); } @@ -137,8 +243,8 @@ protected SpringAST(SerializationInfo info, StreamingContext context) #endif public virtual void GetObjectData(SerializationInfo info, StreamingContext context) { - info.AddValue("down", base.down, typeof(SpringAST)); - info.AddValue("right", base.right, typeof(SpringAST)); + info.AddValue("down", this.down, typeof(SpringAST)); + info.AddValue("right", this.right, typeof(SpringAST)); info.AddValue("ttype", this.Type, typeof(int)); info.AddValue("text", this.Text, typeof(string)); } diff --git a/src/Spring/Spring.Core/Expressions/SyntaxErrorException.cs b/src/Spring/Spring.Core/Expressions/SyntaxErrorException.cs index 516cad047..c3187c22e 100644 --- a/src/Spring/Spring.Core/Expressions/SyntaxErrorException.cs +++ b/src/Spring/Spring.Core/Expressions/SyntaxErrorException.cs @@ -15,31 +15,35 @@ */ using System.Runtime.Serialization; -using Spring.Expressions.Parser.antlr; namespace Spring.Expressions; /// -/// Exception thrown when detecting invalid SpEL syntax +/// Exception thrown by when detecting invalid SpEL syntax, including +/// an expression nested too deeply to be parsed. /// /// Erich Eichinger [Serializable] -internal class SyntaxErrorException : RecognitionException, ISerializable +public class SyntaxErrorException : Exception, ISerializable { private readonly string _expression; + private readonly int _line; + private readonly int _column; /// + /// The line of the error, which is always 1: the columns are those of the whole expression /// public int Line { - get { return line; } + get { return _line; } } /// + /// The column of the error in the expression, from 1, a tab moving it to the next multiple of 8 plus 1 /// public int Column { - get { return column; } + get { return _column; } } /// @@ -62,43 +66,46 @@ public string Expression } /// - /// TODO + /// Creates a new instance. /// + /// The text of the error, without its position. + /// The line of the error. + /// The column of the error. + /// The expression that caused the error. public SyntaxErrorException(string message, int line, int column, string expression) - : base(message, null, line, column) + : base(message) { + _line = line; + _column = column; _expression = expression; } /// - /// TODO + /// Creates a new instance from SerializationInfo. /// #if NET [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] #endif - protected SyntaxErrorException(SerializationInfo info, StreamingContext context) : base(info.GetString("Message")) + protected SyntaxErrorException(SerializationInfo info, StreamingContext context) : base(info, context) { - base.line = info.GetInt32("Line"); - base.column = info.GetInt32("Column"); - this._expression = info.GetString("Expression"); + _line = info.GetInt32("Line"); + _column = info.GetInt32("Column"); + _expression = info.GetString("Expression"); } /// - /// + /// Populates SerializationInfo from this instance. /// - /// - /// + /// The object to populate. + /// The destination of this serialization. #if NET [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] #endif public override void GetObjectData(SerializationInfo info, StreamingContext context) { - // since RecognitionException does not implement .ctor(SerializationInfo info, StreamingContext context) - // we need to do the serialization on our own... #�$% - //base.GetObjectData( info, context ); - info.AddValue("Line", base.line); - info.AddValue("Column", base.column); - info.AddValue("Message", base.Message); - info.AddValue("Expression", this._expression); + base.GetObjectData(info, context); + info.AddValue("Line", _line); + info.AddValue("Column", _column); + info.AddValue("Expression", _expression); } } diff --git a/src/Spring/Spring.Core/Expressions/TernaryNode.cs b/src/Spring/Spring.Core/Expressions/TernaryNode.cs index d9baa717c..a59e80cc9 100644 --- a/src/Spring/Spring.Core/Expressions/TernaryNode.cs +++ b/src/Spring/Spring.Core/Expressions/TernaryNode.cs @@ -15,7 +15,6 @@ */ using System.Runtime.Serialization; -using Spring.Expressions.Parser.antlr.collections; namespace Spring.Expressions; @@ -63,7 +62,7 @@ protected override object Get(object context, EvaluationContext evalContext) { if (!initialized) { - AST node = this.getFirstChild(); + SpringAST node = this.getFirstChild(); condition = (BaseNode) node; node = node.getNextSibling(); trueExp = (BaseNode) node; diff --git a/src/Spring/Spring.Core/Expressions/TypeNode.cs b/src/Spring/Spring.Core/Expressions/TypeNode.cs index b3bf0fe14..9c966fbd7 100644 --- a/src/Spring/Spring.Core/Expressions/TypeNode.cs +++ b/src/Spring/Spring.Core/Expressions/TypeNode.cs @@ -16,7 +16,6 @@ using System.Runtime.Serialization; using Spring.Core.TypeResolution; -using Spring.Expressions.Parser.antlr.collections; namespace Spring.Expressions; @@ -85,7 +84,7 @@ public override string getText() // tmp = type.AssemblyQualifiedName; // } // } - AST node = this.getFirstChild(); + SpringAST node = this.getFirstChild(); while (node != null) { tmp += node.getText(); diff --git a/src/Spring/Spring.Core/Objects/ObjectWrapper.cs b/src/Spring/Spring.Core/Objects/ObjectWrapper.cs index a3beb2f45..f81f649fd 100644 --- a/src/Spring/Spring.Core/Objects/ObjectWrapper.cs +++ b/src/Spring/Spring.Core/Objects/ObjectWrapper.cs @@ -20,7 +20,6 @@ using Microsoft.Extensions.Logging; using Spring.Core; using Spring.Expressions; -using Spring.Expressions.Parser.antlr; using Spring.Util; using StringUtils = Spring.Util.StringUtils; @@ -170,11 +169,7 @@ public virtual object GetPropertyValue(string propertyName) IExpression propertyExpression = GetPropertyExpression(propertyName); return GetPropertyValue(propertyExpression); } - catch (RecognitionException e) - { - throw new InvalidPropertyException("Failed to parse property name '" + propertyName + "'.", e); - } - catch (TokenStreamRecognitionException e) + catch (SyntaxErrorException e) { throw new InvalidPropertyException("Failed to parse property name '" + propertyName + "'.", e); } @@ -215,11 +210,7 @@ public virtual void SetPropertyValue(string propertyName, object val) IExpression propertyExpression = GetPropertyExpression(propertyName); SetPropertyValue(propertyExpression, val); } - catch (RecognitionException e) - { - throw new InvalidPropertyException("Failed to parse property name '" + propertyName + "'.", e); - } - catch (TokenStreamRecognitionException e) + catch (SyntaxErrorException e) { throw new InvalidPropertyException("Failed to parse property name '" + propertyName + "'.", e); } @@ -418,11 +409,7 @@ private MemberInfo GetPropertyOrFieldInfo(string propertyOrFieldName) throw new FatalObjectException($"'{propertyOrFieldName}' is not a valid property or field expression."); } - catch (RecognitionException e) - { - throw new FatalObjectException($"Failed to parse property or field name '{propertyOrFieldName}'.", e); - } - catch (TokenStreamRecognitionException e) + catch (SyntaxErrorException e) { throw new FatalObjectException($"Failed to parse property or field name '{propertyOrFieldName}'.", e); } diff --git a/src/Spring/Spring.Core/Objects/PropertyValue.cs b/src/Spring/Spring.Core/Objects/PropertyValue.cs index bb35d65ab..1cd210719 100644 --- a/src/Spring/Spring.Core/Objects/PropertyValue.cs +++ b/src/Spring/Spring.Core/Objects/PropertyValue.cs @@ -17,7 +17,6 @@ using System.Globalization; using Spring.Core; using Spring.Expressions; -using Spring.Expressions.Parser.antlr; using Spring.Util; namespace Spring.Objects; @@ -110,11 +109,7 @@ public IExpression Expression { propertyExpression = ObjectWrapper.GetPropertyExpression(propertyName); } - catch (RecognitionException e) - { - throw new InvalidPropertyException("Failed to parse property name '" + propertyName + "'.", e); - } - catch (TokenStreamRecognitionException e) + catch (SyntaxErrorException e) { throw new InvalidPropertyException("Failed to parse property name '" + propertyName + "'.", e); } diff --git a/src/Spring/Spring.Core/README_ANTLR.txt b/src/Spring/Spring.Core/README_ANTLR.txt deleted file mode 100644 index 676861fcf..000000000 --- a/src/Spring/Spring.Core/README_ANTLR.txt +++ /dev/null @@ -1,20 +0,0 @@ -Notes on code merge into Spring.Core: - - -28-07-2009 ----------- - -*) Added codebase version 2.7.7 of antlr -*) had to move ::SupportClass to namespace "antlr" -*) Replaced Method antlr.InputBuffer.LA(int i) with - - public virtual char LA(int i) - { - fill(i); - if ((this.markerOffset + i) <= this.queue.Count) - { - return (char)this.queue[(this.markerOffset + i) - 1]; - } - return CharScanner.EOF_CHAR; - } -*) renamed namespaces "antlr.*" to "Spring.Expressions.Parser.antrl.*" diff --git a/src/Spring/Spring.Core/Spring.Core.csproj b/src/Spring/Spring.Core/Spring.Core.csproj index 4cae4ee4c..16854a7d3 100644 --- a/src/Spring/Spring.Core/Spring.Core.csproj +++ b/src/Spring/Spring.Core/Spring.Core.csproj @@ -19,6 +19,14 @@ + + + + + + + diff --git a/test/Spring/Spring.Benchmark/ContainerBenchmark.cs b/test/Spring/Spring.Benchmark/ContainerBenchmark.cs index 94b5dd2bc..d2b5e330a 100644 --- a/test/Spring/Spring.Benchmark/ContainerBenchmark.cs +++ b/test/Spring/Spring.Benchmark/ContainerBenchmark.cs @@ -20,7 +20,7 @@ namespace Spring.Benchmark; -[ClrJob, CoreJob] +[Config(typeof(FrameworkAndCoreConfig))] [MemoryDiagnoser] public class ContainerBenchmark { diff --git a/test/Spring/Spring.Benchmark/ExpressionBenchmark.cs b/test/Spring/Spring.Benchmark/ExpressionBenchmark.cs new file mode 100644 index 000000000..fefcf1072 --- /dev/null +++ b/test/Spring/Spring.Benchmark/ExpressionBenchmark.cs @@ -0,0 +1,123 @@ +using System.Collections; +using BenchmarkDotNet.Attributes; +using Spring.Expressions; +using Spring.Objects; + +namespace Spring.Benchmark; + +/// +/// The expression language, from parsing alone to the layers above it. Only uses the public API, so that the same file +/// builds against any version of Spring.Core, to compare two of them. +/// +[MemoryDiagnoser] +public class ExpressionBenchmark +{ + private const string Small = "Name.Length + 1"; + + private const string Medium = + "(Age >= 18 and Name like 'A*') ? Address.City.ToUpper() + ', ' + Address.Zip : 'minor'"; + + private const string Large = + "Friends.?{Age > 20 and Address.City != 'Paris' or Name matches '^B.*$'}" + + ".!{Name + ' (' + Age + ')'}.Count" + + " + {1, 2, 3, 0x10, 5}.!{#this * 2 % 7}.Count" + + " + #{'a' : 1, 'b' : 2.5e0}.Count" + + " + (Friends.^{Age >= 30}.Name.Length ^ 2) - -Friends.${Age < 100}.Age" + + " + (T(System.Math).Max(Age, 10) / 2 between {1, 100} ? new System.Text.StringBuilder('abc').Length : 0)" + + " + (Address.Zip in {'75001', '75002'} and !(Name == null) xor Friends[0].Name is T(string) ? 1 : 2)" + + " + (#sum = {|a, b| $a + $b}; #sum(1, 2))"; + + private readonly Person root = new() + { + Name = "Alice", + Age = 34, + Address = new Address { City = "Lyon", Zip = "69001" }, + Friends = new ArrayList + { + new Person { Name = "Bob", Age = 41, Address = new Address { City = "Paris", Zip = "75001" } }, + new Person { Name = "Carol", Age = 19, Address = new Address { City = "Nice", Zip = "06000" } }, + new Person { Name = "Dan", Age = 28, Address = new Address { City = "Lille", Zip = "59000" } }, + }, + }; + + private readonly Dictionary variables = new(); + private string expression; + private IExpression prepared; + + [Params("Small", "Medium", "Large")] + public string Size { get; set; } + + [GlobalSetup] + public void Setup() + { + expression = Size switch + { + "Small" => Small, + "Medium" => Medium, + _ => Large, + }; + + prepared = Expression.Parse(expression); + } + + /// Parsing alone. + [Benchmark] + public object Parse() => Expression.Parse(expression); + + /// parses its expression on each call, without a cache. + [Benchmark] + public object GetValueUncached() => ExpressionEvaluator.GetValue(root, expression, variables); + + /// What the documentation recommends: parse once, evaluate many times. + [Benchmark] + public object ParseThenGetValue100() + { + var parsed = Expression.Parse(expression); + object value = null; + for (var i = 0; i < 100; i++) + { + value = parsed.GetValue(root, variables); + } + + return value; + } + + /// The evaluation alone, which doesn't depend on the parser. + [Benchmark] + public object GetValuePrepared() => prepared.GetValue(root, variables); +} + +/// +/// parses the name of a property each time it is asked for it. +/// +[MemoryDiagnoser] +public class ObjectWrapperBenchmark +{ + private readonly ObjectWrapper wrapper = new(new Person + { + Name = "Alice", + Friends = new ArrayList { new Person(), new Person { Address = new Address { City = "Nice" } } }, + }); + + /// Only reads a name, without the parser. + [Benchmark] + public object SimpleProperty() => wrapper.GetPropertyValue("Name"); + + /// Takes the primary expression parsing path. + [Benchmark] + public object PropertyPath() => wrapper.GetPropertyValue("Friends[1].Address.City"); +} + +public class Person +{ + public string Name { get; set; } + public int Age { get; set; } + public Address Address { get; set; } + public IList Friends { get; set; } +} + +public class Address +{ + public string City { get; set; } + public string Zip { get; set; } +} diff --git a/test/Spring/Spring.Benchmark/FrameworkAndCoreConfig.cs b/test/Spring/Spring.Benchmark/FrameworkAndCoreConfig.cs new file mode 100644 index 000000000..ed2771c27 --- /dev/null +++ b/test/Spring/Spring.Benchmark/FrameworkAndCoreConfig.cs @@ -0,0 +1,20 @@ +using System.Runtime.InteropServices; +using BenchmarkDotNet.Configs; +using BenchmarkDotNet.Environments; +using BenchmarkDotNet.Jobs; + +namespace Spring.Benchmark; + +/// Compares .NET with .NET Framework where there is one. +public class FrameworkAndCoreConfig : ManualConfig +{ + public FrameworkAndCoreConfig() + { + AddJob(Job.Default.WithRuntime(CoreRuntime.Core10_0)); + + if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + { + AddJob(Job.Default.WithRuntime(ClrRuntime.Net472)); + } + } +} diff --git a/test/Spring/Spring.Benchmark/HybridSetBenchmark.cs b/test/Spring/Spring.Benchmark/HybridSetBenchmark.cs index e55e468be..190aea880 100644 --- a/test/Spring/Spring.Benchmark/HybridSetBenchmark.cs +++ b/test/Spring/Spring.Benchmark/HybridSetBenchmark.cs @@ -20,7 +20,7 @@ namespace Spring.Benchmark; -[ClrJob, CoreJob] +[Config(typeof(FrameworkAndCoreConfig))] [MemoryDiagnoser] public class HybridSetBenchmark { diff --git a/test/Spring/Spring.Core.Tests/ExceptionsTest.cs b/test/Spring/Spring.Core.Tests/ExceptionsTest.cs index d209fba01..7fd3cb82f 100644 --- a/test/Spring/Spring.Core.Tests/ExceptionsTest.cs +++ b/test/Spring/Spring.Core.Tests/ExceptionsTest.cs @@ -39,7 +39,7 @@ public abstract class ExceptionsTest : StandardsComplianceTest // sorry folks, but this is really a special case - default ctor policy doesn't apply here private bool ExcludeFromConstructorPolicyCheck(Type t) { - //TODO: uncomment when making SyntaxErrorException public: + // Only the parser creates it, always with a position and an expression, which the standard constructors don't have: if (t.FullName == "Spring.Expressions.SyntaxErrorException") return true; return false; } diff --git a/test/Spring/Spring.Core.Tests/Expressions/ExpressionEvaluatorTests.cs b/test/Spring/Spring.Core.Tests/Expressions/ExpressionEvaluatorTests.cs index 5d2edbebe..d0710ea05 100644 --- a/test/Spring/Spring.Core.Tests/Expressions/ExpressionEvaluatorTests.cs +++ b/test/Spring/Spring.Core.Tests/Expressions/ExpressionEvaluatorTests.cs @@ -31,8 +31,6 @@ using Spring.Context.Support; using Spring.Core; using Spring.Core.TypeResolution; -using Spring.Expressions.Parser.antlr; -using Spring.Expressions.Parser.antlr.collections; using Spring.Expressions.Processors; using Spring.Objects; using Spring.Objects.Factory; @@ -186,8 +184,6 @@ public void MembersDontGetSerializedByDefault() /// /// /// date() is parsed into DateLiteralNode( down:<default node type> ). - /// Normally antlr.CommonAST is the default node used by antlr. To enable serialization, Spring - /// uses a custom ASTFactory in /// [Test] public void ExpressionDateLiteralNodeMaintainsStateAfterSerialization() @@ -326,7 +322,7 @@ public void ThrowsSyntaxErrorException() ExpressionEvaluator.GetValue(null, "'date"); // unclose string literal Assert.Fail(); } - catch (RecognitionException ex) + catch (SyntaxErrorException ex) { Assert.That(ex.Message, Is.EqualTo("Syntax Error on line 1, column 6: expecting ''', found '' in expression" + Environment.NewLine + "''date'")); } @@ -2842,14 +2838,14 @@ public void TestStaticInheritedMethodInvocation() Assert.That(ExpressionEvaluator.GetValue(null, string.Format("T({0}).ShadowedStaticMethod()", typeof(DerivedSingleMethodTestClass).FullName)), Is.EqualTo("DerivedSingleMethodTestClass.ShadowedStaticMethod")); } - private static void DumpNode(AST rootNode, int level) + private static void DumpNode(SpringAST rootNode, int level) { Trace.WriteLine(new string(' ', level) + rootNode.ToString()); int numberOfChildren = rootNode.getNumberOfChildren(); if (numberOfChildren > 0) { - AST node = rootNode.getFirstChild(); + SpringAST node = rootNode.getFirstChild(); while (node != null) { DumpNode(node, level + 2); diff --git a/test/Spring/Spring.Core.Tests/Expressions/ExpressionGrammarGolden.json b/test/Spring/Spring.Core.Tests/Expressions/ExpressionGrammarGolden.json new file mode 100644 index 000000000..1bf6ded94 --- /dev/null +++ b/test/Spring/Spring.Core.Tests/Expressions/ExpressionGrammarGolden.json @@ -0,0 +1,1204 @@ +[ + [ + "a b c", + "(Expression|4|expression (PropertyOrFieldNode|33|a) (PropertyOrFieldNode|33|b) (PropertyOrFieldNode|33|c))", + "(Expression|4|expression (PropertyOrFieldNode|33|a) (PropertyOrFieldNode|33|b) (PropertyOrFieldNode|33|c))" + ], + [ + "a..b", + "(Expression|4|expression (PropertyOrFieldNode|33|a) (PropertyOrFieldNode|33|b))", + "(Expression|4|expression (PropertyOrFieldNode|33|a) (PropertyOrFieldNode|33|b))" + ], + [ + "a.", + "(Expression|4|expression (PropertyOrFieldNode|33|a))", + "(Expression|4|expression (PropertyOrFieldNode|33|a))" + ], + [ + "1 .a", + "(Expression|4|expression (IntLiteralNode|51|1) (PropertyOrFieldNode|33|a))", + "(Expression|4|expression (IntLiteralNode|51|1) (PropertyOrFieldNode|33|a))" + ], + [ + "(a)", + "(Expression|4|expression (Expression|4|expression (PropertyOrFieldNode|33|a)))", + "(Expression|4|expression (Expression|4|expression (PropertyOrFieldNode|33|a)))" + ], + [ + "((a))", + "(Expression|4|expression (Expression|4|expression (Expression|4|expression (PropertyOrFieldNode|33|a))))", + "(Expression|4|expression (Expression|4|expression (Expression|4|expression (PropertyOrFieldNode|33|a))))" + ], + [ + "(a;b)", + "(Expression|4|expression (ExpressionListNode|4|expressionList (Expression|4|expression (PropertyOrFieldNode|33|a)) (Expression|4|expression (PropertyOrFieldNode|33|b))))", + "(Expression|4|expression (ExpressionListNode|4|expressionList (Expression|4|expression (PropertyOrFieldNode|33|a)) (Expression|4|expression (PropertyOrFieldNode|33|b))))" + ], + [ + "(a;b).c", + "(Expression|4|expression (ExpressionListNode|4|expressionList (Expression|4|expression (PropertyOrFieldNode|33|a)) (Expression|4|expression (PropertyOrFieldNode|33|b))) (PropertyOrFieldNode|33|c))", + "(Expression|4|expression (ExpressionListNode|4|expressionList (Expression|4|expression (PropertyOrFieldNode|33|a)) (Expression|4|expression (PropertyOrFieldNode|33|b))) (PropertyOrFieldNode|33|c))" + ], + [ + "a[0](b;c)", + "(Expression|4|expression (PropertyOrFieldNode|33|a) (IndexerNode|37|[ (Expression|4|expression (IntLiteralNode|51|0))) (ExpressionListNode|4|expressionList (Expression|4|expression (PropertyOrFieldNode|33|b)) (Expression|4|expression (PropertyOrFieldNode|33|c))))", + "(Expression|4|expression (PropertyOrFieldNode|33|a) (IndexerNode|37|[ (Expression|4|expression (IntLiteralNode|51|0))) (ExpressionListNode|4|expressionList (Expression|4|expression (PropertyOrFieldNode|33|b)) (Expression|4|expression (PropertyOrFieldNode|33|c))))" + ], + [ + "T(a)", + "(Expression|4|expression (TypeNode|4|a))", + "(Expression|4|expression (TypeNode|4|a))" + ], + [ + "T( a . b )", + "(Expression|4|expression (TypeNode|4|a.b))", + "(Expression|4|expression (TypeNode|4|a.b))" + ], + [ + "T(a'b'c)", + "(Expression|4|expression (TypeNode|4|abc))", + "(Expression|4|expression (TypeNode|4|abc))" + ], + [ + "T(a,b=1.2.3)", + "(Expression|4|expression (TypeNode|4|a,b=1.2.3))", + "(Expression|4|expression (TypeNode|4|a,b=1.2.3))" + ], + [ + "T(a)", + "(Expression|4|expression (TypeNode|4|a))", + "(Expression|4|expression (TypeNode|4|a))" + ], + [ + "T(int[])", + "(Expression|4|expression (TypeNode|4|int[]))", + "(Expression|4|expression (TypeNode|4|int[]))" + ], + [ + "@(a)", + "(Expression|4|expression (ReferenceNode|4|ref (QualifiedIdentifier|33|a)))", + "(Expression|4|expression (ReferenceNode|4|ref (QualifiedIdentifier|33|a)))" + ], + [ + "@(a:b)", + "(Expression|4|expression (ReferenceNode|4|ref (QualifiedIdentifier|33|a) (QualifiedIdentifier|33|b)))", + "(Expression|4|expression (ReferenceNode|4|ref (QualifiedIdentifier|33|a) (QualifiedIdentifier|33|b)))" + ], + [ + "@('a b':'c d')", + "(Expression|4|expression (ReferenceNode|4|ref (QualifiedIdentifier|46|a b) (QualifiedIdentifier|46|c d)))", + "(Expression|4|expression (ReferenceNode|4|ref (QualifiedIdentifier|46|a b) (QualifiedIdentifier|46|c d)))" + ], + [ + "@(a.b:c.d)", + "(Expression|4|expression (ReferenceNode|4|ref (QualifiedIdentifier|33|a.b) (QualifiedIdentifier|33|c.d)))", + "(Expression|4|expression (ReferenceNode|4|ref (QualifiedIdentifier|33|a.b) (QualifiedIdentifier|33|c.d)))" + ], + [ + "@[a.b]", + "(Expression|4|expression (AttributeNode|4|a.b))", + "(Expression|4|expression (AttributeNode|4|a.b))" + ], + [ + "@[a(1,x=2)]", + "(Expression|4|expression (AttributeNode|4|a (Expression|4|expression (IntLiteralNode|51|1)) (NamedArgumentNode|33|x (Expression|4|expression (IntLiteralNode|51|2)))))", + "(Expression|4|expression (AttributeNode|4|a (Expression|4|expression (IntLiteralNode|51|1)) (NamedArgumentNode|33|x (Expression|4|expression (IntLiteralNode|51|2)))))" + ], + [ + "new a.b(1,x=2)", + "(Expression|4|expression (ConstructorNode|4|a.b (Expression|4|expression (IntLiteralNode|51|1)) (NamedArgumentNode|33|x (Expression|4|expression (IntLiteralNode|51|2)))))", + "(Expression|4|expression (ConstructorNode|4|a.b (Expression|4|expression (IntLiteralNode|51|1)) (NamedArgumentNode|33|x (Expression|4|expression (IntLiteralNode|51|2)))))" + ], + [ + "new a[1]", + "(Expression|4|expression (ArrayConstructorNode|4|a (SpringAST|37|[ (Expression|4|expression (IntLiteralNode|51|1)))))", + "(Expression|4|expression (ArrayConstructorNode|4|a (SpringAST|37|[ (Expression|4|expression (IntLiteralNode|51|1)))))" + ], + [ + "new a[1,2]{1,2}", + "(Expression|4|expression (ArrayConstructorNode|4|a (SpringAST|37|[ (Expression|4|expression (IntLiteralNode|51|1)) (Expression|4|expression (IntLiteralNode|51|2))) (ListInitializerNode|50|{ (Expression|4|expression (IntLiteralNode|51|1)) (Expression|4|expression (IntLiteralNode|51|2)))))", + "(Expression|4|expression (ArrayConstructorNode|4|a (SpringAST|37|[ (Expression|4|expression (IntLiteralNode|51|1)) (Expression|4|expression (IntLiteralNode|51|2))) (ListInitializerNode|50|{ (Expression|4|expression (IntLiteralNode|51|1)) (Expression|4|expression (IntLiteralNode|51|2)))))" + ], + [ + "new a[]{1}", + "(Expression|4|expression (ArrayConstructorNode|4|a (SpringAST|37|[) (ListInitializerNode|50|{ (Expression|4|expression (IntLiteralNode|51|1)))))", + "(Expression|4|expression (ArrayConstructorNode|4|a (SpringAST|37|[) (ListInitializerNode|50|{ (Expression|4|expression (IntLiteralNode|51|1)))))" + ], + [ + "new a[](b)", + "ERROR 10 Syntax Error on line 1, column 10: unexpected token: [\")\",<19>,line=1,col=10]", + "ERROR 10 Syntax Error on line 1, column 10: unexpected token: [\")\",<19>,line=1,col=10]" + ], + [ + "#a", + "(Expression|4|expression (VariableNode|33|a))", + "(Expression|4|expression (VariableNode|33|a))" + ], + [ + "#a(1)", + "(Expression|4|expression (FunctionNode|33|a (Expression|4|expression (IntLiteralNode|51|1))))", + "(Expression|4|expression (FunctionNode|33|a (Expression|4|expression (IntLiteralNode|51|1))))" + ], + [ + "# a", + "(Expression|4|expression (VariableNode|33|a))", + "(Expression|4|expression (VariableNode|33|a))" + ], + [ + "$a", + "(Expression|4|expression (LocalVariableNode|33|a))", + "(Expression|4|expression (LocalVariableNode|33|a))" + ], + [ + "$a(1)", + "(Expression|4|expression (LocalFunctionNode|33|a (Expression|4|expression (IntLiteralNode|51|1))))", + "(Expression|4|expression (LocalFunctionNode|33|a (Expression|4|expression (IntLiteralNode|51|1))))" + ], + [ + "#{a:1,b:2}", + "(Expression|4|expression (MapInitializerNode|50|{ (MapEntryNode|4|entry (Expression|4|expression (PropertyOrFieldNode|33|a)) (Expression|4|expression (IntLiteralNode|51|1))) (MapEntryNode|4|entry (Expression|4|expression (PropertyOrFieldNode|33|b)) (Expression|4|expression (IntLiteralNode|51|2)))))", + "(Expression|4|expression (MapInitializerNode|50|{ (MapEntryNode|4|entry (Expression|4|expression (PropertyOrFieldNode|33|a)) (Expression|4|expression (IntLiteralNode|51|1))) (MapEntryNode|4|entry (Expression|4|expression (PropertyOrFieldNode|33|b)) (Expression|4|expression (IntLiteralNode|51|2)))))" + ], + [ + "{1,2}", + "(Expression|4|expression (ListInitializerNode|50|{ (Expression|4|expression (IntLiteralNode|51|1)) (Expression|4|expression (IntLiteralNode|51|2))))", + "(Expression|4|expression (ListInitializerNode|50|{ (Expression|4|expression (IntLiteralNode|51|1)) (Expression|4|expression (IntLiteralNode|51|2))))" + ], + [ + "{|a,b|a}", + "(Expression|4|expression (LambdaExpressionNode|4|lambda (SpringAST|4|args (SpringAST|33|a) (SpringAST|33|b)) (Expression|4|expression (PropertyOrFieldNode|33|a))))", + "(Expression|4|expression (LambdaExpressionNode|4|lambda (SpringAST|4|args (SpringAST|33|a) (SpringAST|33|b)) (Expression|4|expression (PropertyOrFieldNode|33|a))))" + ], + [ + "{|x|x}", + "(Expression|4|expression (LambdaExpressionNode|4|lambda (SpringAST|4|args (SpringAST|33|x)) (Expression|4|expression (PropertyOrFieldNode|33|x))))", + "(Expression|4|expression (LambdaExpressionNode|4|lambda (SpringAST|4|args (SpringAST|33|x)) (Expression|4|expression (PropertyOrFieldNode|33|x))))" + ], + [ + "{||1}", + "(Expression|4|expression (LambdaExpressionNode|4|lambda (Expression|4|expression (IntLiteralNode|51|1))))", + "(Expression|4|expression (LambdaExpressionNode|4|lambda (Expression|4|expression (IntLiteralNode|51|1))))" + ], + [ + "!{a}", + "(Expression|4|expression (ProjectionNode|39|!{ (Expression|4|expression (PropertyOrFieldNode|33|a))))", + "(Expression|4|expression (ProjectionNode|39|!{ (Expression|4|expression (PropertyOrFieldNode|33|a))))" + ], + [ + "?{a,b}", + "(Expression|4|expression (SelectionNode|41|?{ (Expression|4|expression (PropertyOrFieldNode|33|a)) (Expression|4|expression (PropertyOrFieldNode|33|b))))", + "(Expression|4|expression (SelectionNode|41|?{ (Expression|4|expression (PropertyOrFieldNode|33|a)) (Expression|4|expression (PropertyOrFieldNode|33|b))))" + ], + [ + "^{a}", + "(Expression|4|expression (SelectionFirstNode|42|^{ (Expression|4|expression (PropertyOrFieldNode|33|a))))", + "(Expression|4|expression (SelectionFirstNode|42|^{ (Expression|4|expression (PropertyOrFieldNode|33|a))))" + ], + [ + "${a}", + "(Expression|4|expression (SelectionLastNode|43|${ (Expression|4|expression (PropertyOrFieldNode|33|a))))", + "(Expression|4|expression (SelectionLastNode|43|${ (Expression|4|expression (PropertyOrFieldNode|33|a))))" + ], + [ + "a!{b}?{c}^{d}${e}", + "(Expression|4|expression (PropertyOrFieldNode|33|a) (ProjectionNode|39|!{ (Expression|4|expression (PropertyOrFieldNode|33|b))) (SelectionNode|41|?{ (Expression|4|expression (PropertyOrFieldNode|33|c))) (SelectionFirstNode|42|^{ (Expression|4|expression (PropertyOrFieldNode|33|d))) (SelectionLastNode|43|${ (Expression|4|expression (PropertyOrFieldNode|33|e))))", + "(Expression|4|expression (PropertyOrFieldNode|33|a) (ProjectionNode|39|!{ (Expression|4|expression (PropertyOrFieldNode|33|b))) (SelectionNode|41|?{ (Expression|4|expression (PropertyOrFieldNode|33|c))) (SelectionFirstNode|42|^{ (Expression|4|expression (PropertyOrFieldNode|33|d))) (SelectionLastNode|43|${ (Expression|4|expression (PropertyOrFieldNode|33|e))))" + ], + [ + "a^b", + "(OpPOWER|29|^ (Expression|4|expression (PropertyOrFieldNode|33|a)) (Expression|4|expression (PropertyOrFieldNode|33|b)))", + "(Expression|4|expression (PropertyOrFieldNode|33|a))" + ], + [ + "a^{b}", + "(Expression|4|expression (PropertyOrFieldNode|33|a) (SelectionFirstNode|42|^{ (Expression|4|expression (PropertyOrFieldNode|33|b))))", + "(Expression|4|expression (PropertyOrFieldNode|33|a) (SelectionFirstNode|42|^{ (Expression|4|expression (PropertyOrFieldNode|33|b))))" + ], + [ + "a ^ {b}", + "(OpPOWER|29|^ (Expression|4|expression (PropertyOrFieldNode|33|a)) (Expression|4|expression (ListInitializerNode|50|{ (Expression|4|expression (PropertyOrFieldNode|33|b)))))", + "(Expression|4|expression (PropertyOrFieldNode|33|a))" + ], + [ + "a^{b,c}", + "ERROR 5 Syntax Error on line 1, column 5: unexpected token: [\",\",<35>,line=1,col=5]", + "ERROR 5 Syntax Error on line 1, column 5: unexpected token: [\",\",<35>,line=1,col=5]", + "ERROR 5 Syntax Error on line 1, column 5: expecting \"RCURLY\", found ','", + "ERROR 5 Syntax Error on line 1, column 5: expecting \"RCURLY\", found ','" + ], + [ + "a^b^c", + "ERROR 4 Syntax Error on line 1, column 4: expecting \"EOF\", found '^'", + "(Expression|4|expression (PropertyOrFieldNode|33|a))", + "ERROR 4 Syntax Error on line 1, column 4: unexpected token: [\"^\",<29>,line=1,col=4]", + "(Expression|4|expression (PropertyOrFieldNode|33|a))" + ], + [ + "-a^b", + "(OpPOWER|29|^ (OpUnaryMinus|25|- (Expression|4|expression (PropertyOrFieldNode|33|a))) (Expression|4|expression (PropertyOrFieldNode|33|b)))", + "ERROR 1 Syntax Error on line 1, column 1: unexpected token: [\"-\",<25>,line=1,col=1]" + ], + [ + "2^-3", + "(OpPOWER|29|^ (Expression|4|expression (IntLiteralNode|51|2)) (OpUnaryMinus|25|- (Expression|4|expression (IntLiteralNode|51|3))))", + "(Expression|4|expression (IntLiteralNode|51|2))" + ], + [ + "a==b", + "(OpEqual|4|== (Expression|4|expression (PropertyOrFieldNode|33|a)) (Expression|4|expression (PropertyOrFieldNode|33|b)))", + "(Expression|4|expression (PropertyOrFieldNode|33|a))" + ], + [ + "a==b==c", + "ERROR 5 Syntax Error on line 1, column 5: expecting \"EOF\", found '=='", + "(Expression|4|expression (PropertyOrFieldNode|33|a))", + "ERROR 5 Syntax Error on line 1, column 5: unexpected token: [\"==\",<54>,line=1,col=5]", + "(Expression|4|expression (PropertyOrFieldNode|33|a))" + ], + [ + "a<=b", + "(OpLessOrEqual|4|<= (Expression|4|expression (PropertyOrFieldNode|33|a)) (Expression|4|expression (PropertyOrFieldNode|33|b)))", + "(Expression|4|expression (PropertyOrFieldNode|33|a))" + ], + [ + "a,line=1,col=4]", + "(Expression|4|expression (PropertyOrFieldNode|33|a))" + ], + [ + "a in b", + "(OpIn|4|in (Expression|4|expression (PropertyOrFieldNode|33|a)) (Expression|4|expression (PropertyOrFieldNode|33|b)))", + "(Expression|4|expression (PropertyOrFieldNode|33|a))" + ], + [ + "a is b", + "(OpIs|4|is (Expression|4|expression (PropertyOrFieldNode|33|a)) (Expression|4|expression (PropertyOrFieldNode|33|b)))", + "(Expression|4|expression (PropertyOrFieldNode|33|a))" + ], + [ + "a between b", + "(OpBetween|4|between (Expression|4|expression (PropertyOrFieldNode|33|a)) (Expression|4|expression (PropertyOrFieldNode|33|b)))", + "(Expression|4|expression (PropertyOrFieldNode|33|a))" + ], + [ + "a like b", + "(OpLike|4|like (Expression|4|expression (PropertyOrFieldNode|33|a)) (Expression|4|expression (PropertyOrFieldNode|33|b)))", + "(Expression|4|expression (PropertyOrFieldNode|33|a))" + ], + [ + "a matches b", + "(OpMatches|4|matches (Expression|4|expression (PropertyOrFieldNode|33|a)) (Expression|4|expression (PropertyOrFieldNode|33|b)))", + "(Expression|4|expression (PropertyOrFieldNode|33|a))" + ], + [ + "a and b or c xor d", + "(OpOR|9|or (OpAND|8|and (Expression|4|expression (PropertyOrFieldNode|33|a)) (Expression|4|expression (PropertyOrFieldNode|33|b))) (OpXOR|10|xor (Expression|4|expression (PropertyOrFieldNode|33|c)) (Expression|4|expression (PropertyOrFieldNode|33|d))))", + "(Expression|4|expression (PropertyOrFieldNode|33|a))" + ], + [ + "a or b and c", + "(OpOR|9|or (Expression|4|expression (PropertyOrFieldNode|33|a)) (OpAND|8|and (Expression|4|expression (PropertyOrFieldNode|33|b)) (Expression|4|expression (PropertyOrFieldNode|33|c))))", + "(Expression|4|expression (PropertyOrFieldNode|33|a))" + ], + [ + "a=b", + "(AssignNode|20|= (Expression|4|expression (PropertyOrFieldNode|33|a)) (Expression|4|expression (PropertyOrFieldNode|33|b)))", + "(Expression|4|expression (PropertyOrFieldNode|33|a))" + ], + [ + "a=b=c", + "ERROR 4 Syntax Error on line 1, column 4: expecting \"EOF\", found '='", + "(Expression|4|expression (PropertyOrFieldNode|33|a))" + ], + [ + "a??b", + "(DefaultNode|21|?? (Expression|4|expression (PropertyOrFieldNode|33|a)) (Expression|4|expression (PropertyOrFieldNode|33|b)))", + "(Expression|4|expression (PropertyOrFieldNode|33|a))" + ], + [ + "a??b??c", + "ERROR 5 Syntax Error on line 1, column 5: expecting \"EOF\", found '??'", + "(Expression|4|expression (PropertyOrFieldNode|33|a))" + ], + [ + "a?b:c", + "(TernaryNode|22|? (Expression|4|expression (PropertyOrFieldNode|33|a)) (Expression|4|expression (PropertyOrFieldNode|33|b)) (Expression|4|expression (PropertyOrFieldNode|33|c)))", + "(Expression|4|expression (PropertyOrFieldNode|33|a))" + ], + [ + "a?b:c?d:e", + "(TernaryNode|22|? (Expression|4|expression (PropertyOrFieldNode|33|a)) (Expression|4|expression (PropertyOrFieldNode|33|b)) (TernaryNode|22|? (Expression|4|expression (PropertyOrFieldNode|33|c)) (Expression|4|expression (PropertyOrFieldNode|33|d)) (Expression|4|expression (PropertyOrFieldNode|33|e))))", + "(Expression|4|expression (PropertyOrFieldNode|33|a))" + ], + [ + "a?b:c=d", + "(TernaryNode|22|? (Expression|4|expression (PropertyOrFieldNode|33|a)) (Expression|4|expression (PropertyOrFieldNode|33|b)) (AssignNode|20|= (Expression|4|expression (PropertyOrFieldNode|33|c)) (Expression|4|expression (PropertyOrFieldNode|33|d))))", + "(Expression|4|expression (PropertyOrFieldNode|33|a))" + ], + [ + "a?b", + "ERROR 4 Syntax Error on line 1, column 4: unexpected end of expression", + "(Expression|4|expression (PropertyOrFieldNode|33|a))", + "ERROR 4 Syntax Error on line 1, column 4: expecting \"COLON\", found ''", + "(Expression|4|expression (PropertyOrFieldNode|33|a))" + ], + [ + "a+b*c", + "(OpADD|24|+ (Expression|4|expression (PropertyOrFieldNode|33|a)) (OpMULTIPLY|26|* (Expression|4|expression (PropertyOrFieldNode|33|b)) (Expression|4|expression (PropertyOrFieldNode|33|c))))", + "(Expression|4|expression (PropertyOrFieldNode|33|a))" + ], + [ + "a*b+c", + "(OpADD|24|+ (OpMULTIPLY|26|* (Expression|4|expression (PropertyOrFieldNode|33|a)) (Expression|4|expression (PropertyOrFieldNode|33|b))) (Expression|4|expression (PropertyOrFieldNode|33|c)))", + "(Expression|4|expression (PropertyOrFieldNode|33|a))" + ], + [ + "(a+b)*c", + "(OpMULTIPLY|26|* (Expression|4|expression (OpADD|24|+ (Expression|4|expression (PropertyOrFieldNode|33|a)) (Expression|4|expression (PropertyOrFieldNode|33|b)))) (Expression|4|expression (PropertyOrFieldNode|33|c)))", + "(Expression|4|expression (OpADD|24|+ (Expression|4|expression (PropertyOrFieldNode|33|a)) (Expression|4|expression (PropertyOrFieldNode|33|b))))" + ], + [ + "a-b-c", + "(OpSUBTRACT|25|- (OpSUBTRACT|25|- (Expression|4|expression (PropertyOrFieldNode|33|a)) (Expression|4|expression (PropertyOrFieldNode|33|b))) (Expression|4|expression (PropertyOrFieldNode|33|c)))", + "(Expression|4|expression (PropertyOrFieldNode|33|a))" + ], + [ + "a%b/c", + "(OpDIVIDE|27|/ (OpMODULUS|28|% (Expression|4|expression (PropertyOrFieldNode|33|a)) (Expression|4|expression (PropertyOrFieldNode|33|b))) (Expression|4|expression (PropertyOrFieldNode|33|c)))", + "(Expression|4|expression (PropertyOrFieldNode|33|a))" + ], + [ + "1", + "(Expression|4|expression (IntLiteralNode|51|1))", + "(Expression|4|expression (IntLiteralNode|51|1))" + ], + [ + "1.5", + "(Expression|4|expression (RealLiteralNode|53|1.5))", + "(Expression|4|expression (RealLiteralNode|53|1.5))" + ], + [ + "1e5", + "(Expression|4|expression (RealLiteralNode|53|1e5))", + "(Expression|4|expression (RealLiteralNode|53|1e5))" + ], + [ + "1e+5", + "(Expression|4|expression (RealLiteralNode|53|1e+5))", + "(Expression|4|expression (RealLiteralNode|53|1e+5))" + ], + [ + "1e", + "(Expression|4|expression (IntLiteralNode|51|1) (PropertyOrFieldNode|33|e))", + "(Expression|4|expression (IntLiteralNode|51|1) (PropertyOrFieldNode|33|e))" + ], + [ + "1.", + "(Expression|4|expression (IntLiteralNode|51|1))", + "(Expression|4|expression (IntLiteralNode|51|1))" + ], + [ + "1.a", + "(Expression|4|expression (IntLiteralNode|51|1) (PropertyOrFieldNode|33|a))", + "(Expression|4|expression (IntLiteralNode|51|1) (PropertyOrFieldNode|33|a))" + ], + [ + ".5", + "(Expression|4|expression (RealLiteralNode|53|.5))", + "(Expression|4|expression (RealLiteralNode|53|.5))" + ], + [ + "a.5", + "ERROR 2 Syntax Error on line 1, column 2: expecting \"EOF\", found '.5'", + "ERROR 2 Syntax Error on line 1, column 2: unexpected token: [\".5\",<53>,line=1,col=2]", + "ERROR 1 Syntax Error on line 1, column 1: unexpected token: [\"a\",<33>,line=1,col=1]", + "ERROR 1 Syntax Error on line 1, column 1: unexpected token: [\"a\",<33>,line=1,col=1]" + ], + [ + "0x1F", + "(Expression|4|expression (HexLiteralNode|52|0x1F))", + "(Expression|4|expression (HexLiteralNode|52|0x1F))" + ], + [ + "0x", + "ERROR 3 Syntax Error on line 1, column 3: unexpected end of expression", + "ERROR 3 Syntax Error on line 1, column 3: unexpected end of expression", + "ERROR 3 Syntax Error on line 1, column 3: unexpected char: 0xFFFF", + "ERROR 3 Syntax Error on line 1, column 3: unexpected char: 0xFFFF" + ], + [ + "0xg", + "ERROR 3 Syntax Error on line 1, column 3: unexpected char: 'g'", + "ERROR 3 Syntax Error on line 1, column 3: unexpected char: 'g'" + ], + [ + "0x1Fu", + "(Expression|4|expression (HexLiteralNode|52|0x1Fu))", + "(Expression|4|expression (HexLiteralNode|52|0x1Fu))" + ], + [ + "0X1", + "(Expression|4|expression (IntLiteralNode|51|0) (PropertyOrFieldNode|33|X1))", + "(Expression|4|expression (IntLiteralNode|51|0) (PropertyOrFieldNode|33|X1))" + ], + [ + "1L", + "(Expression|4|expression (IntLiteralNode|51|1L))", + "(Expression|4|expression (IntLiteralNode|51|1L))" + ], + [ + "1UL", + "(Expression|4|expression (IntLiteralNode|51|1UL))", + "(Expression|4|expression (IntLiteralNode|51|1UL))" + ], + [ + "1Ul", + "(Expression|4|expression (IntLiteralNode|51|1U) (PropertyOrFieldNode|33|l))", + "(Expression|4|expression (IntLiteralNode|51|1U) (PropertyOrFieldNode|33|l))" + ], + [ + "1f", + "(Expression|4|expression (RealLiteralNode|53|1f))", + "(Expression|4|expression (RealLiteralNode|53|1f))" + ], + [ + "1d", + "(Expression|4|expression (RealLiteralNode|53|1d))", + "(Expression|4|expression (RealLiteralNode|53|1d))" + ], + [ + "1m", + "(Expression|4|expression (RealLiteralNode|53|1m))", + "(Expression|4|expression (RealLiteralNode|53|1m))" + ], + [ + "1.5f", + "(Expression|4|expression (RealLiteralNode|53|1.5f))", + "(Expression|4|expression (RealLiteralNode|53|1.5f))" + ], + [ + "1.5L", + "(Expression|4|expression (RealLiteralNode|53|1.5) (PropertyOrFieldNode|33|L))", + "(Expression|4|expression (RealLiteralNode|53|1.5) (PropertyOrFieldNode|33|L))" + ], + [ + "1.5e", + "ERROR 5 Syntax Error on line 1, column 5: unexpected end of expression", + "ERROR 5 Syntax Error on line 1, column 5: unexpected end of expression", + "ERROR 5 Syntax Error on line 1, column 5: unexpected char: 0xFFFF", + "ERROR 5 Syntax Error on line 1, column 5: unexpected char: 0xFFFF" + ], + [ + "1.5e+", + "ERROR 6 Syntax Error on line 1, column 6: unexpected end of expression", + "ERROR 6 Syntax Error on line 1, column 6: unexpected end of expression", + "ERROR 6 Syntax Error on line 1, column 6: unexpected char: 0xFFFF", + "ERROR 6 Syntax Error on line 1, column 6: unexpected char: 0xFFFF" + ], + [ + "1.5ex", + "ERROR 5 Syntax Error on line 1, column 5: unexpected char: 'x'", + "ERROR 5 Syntax Error on line 1, column 5: unexpected char: 'x'" + ], + [ + "'a'", + "(Expression|4|expression (StringLiteralNode|46|a))", + "(Expression|4|expression (StringLiteralNode|46|a))" + ], + [ + "''", + "(Expression|4|expression (StringLiteralNode|46|))", + "(Expression|4|expression (StringLiteralNode|46|))" + ], + [ + "'a''b'", + "(Expression|4|expression (StringLiteralNode|46|a'b))", + "(Expression|4|expression (StringLiteralNode|46|a'b))" + ], + [ + "'", + "ERROR 1 Syntax Error on line 1, column 1: unexpected token: [\"'\",<45>,line=1,col=1]", + "ERROR 1 Syntax Error on line 1, column 1: unexpected token: [\"'\",<45>,line=1,col=1]" + ], + [ + "'a", + "ERROR 3 Syntax Error on line 1, column 3: expecting ''', found ''", + "ERROR 3 Syntax Error on line 1, column 3: expecting ''', found ''" + ], + [ + "true", + "(Expression|4|expression (BooleanLiteralNode|7|true))", + "(Expression|4|expression (BooleanLiteralNode|7|true))" + ], + [ + "false", + "(Expression|4|expression (BooleanLiteralNode|6|false))", + "(Expression|4|expression (BooleanLiteralNode|6|false))" + ], + [ + "null", + "(Expression|4|expression (NullLiteralNode|16|null))", + "(Expression|4|expression (NullLiteralNode|16|null))" + ], + [ + "new", + "ERROR 4 Syntax Error on line 1, column 4: unexpected end of expression", + "ERROR 4 Syntax Error on line 1, column 4: unexpected end of expression", + "ERROR 1 Syntax Error on line 1, column 1: unexpected token: [\"new\",<49>,line=1,col=1]", + "ERROR 1 Syntax Error on line 1, column 1: unexpected token: [\"new\",<49>,line=1,col=1]" + ], + [ + "in", + "ERROR 1 Syntax Error on line 1, column 1: unexpected token: [\"in\",<11>,line=1,col=1]", + "ERROR 1 Syntax Error on line 1, column 1: unexpected token: [\"in\",<11>,line=1,col=1]" + ], + [ + "T", + "(Expression|4|expression (PropertyOrFieldNode|33|T))", + "(Expression|4|expression (PropertyOrFieldNode|33|T))" + ], + [ + "T (a)", + "(Expression|4|expression (MethodNode|33|T (Expression|4|expression (PropertyOrFieldNode|33|a))))", + "(Expression|4|expression (MethodNode|33|T (Expression|4|expression (PropertyOrFieldNode|33|a))))" + ], + [ + "T(", + "ERROR 3 Syntax Error on line 1, column 3: unexpected end of expression", + "ERROR 3 Syntax Error on line 1, column 3: unexpected end of expression", + "ERROR 3 Syntax Error on line 1, column 3: expecting \"ID\", found ''", + "ERROR 3 Syntax Error on line 1, column 3: expecting \"ID\", found ''" + ], + [ + "1 2", + "ERROR 3 Syntax Error on line 1, column 3: expecting \"EOF\", found '2'", + "ERROR 3 Syntax Error on line 1, column 3: unexpected token: [\"2\",<51>,line=1,col=3]", + "ERROR 3 Syntax Error on line 1, column 3: unexpected token: [\"2\",<51>,line=1,col=3]", + "ERROR 3 Syntax Error on line 1, column 3: unexpected token: [\"2\",<51>,line=1,col=3]" + ], + [ + "a 'b'", + "ERROR 3 Syntax Error on line 1, column 3: expecting \"EOF\", found 'b'", + "ERROR 3 Syntax Error on line 1, column 3: unexpected token: [\"b\",<46>,line=1,col=3]", + "ERROR 1 Syntax Error on line 1, column 1: unexpected token: [\"a\",<33>,line=1,col=1]", + "ERROR 1 Syntax Error on line 1, column 1: unexpected token: [\"a\",<33>,line=1,col=1]" + ], + [ + "a ~", + "ERROR 3 Syntax Error on line 1, column 3: unexpected char: '~'", + "ERROR 3 Syntax Error on line 1, column 3: unexpected char: '~'" + ], + [ + "~", + "ERROR 1 Syntax Error on line 1, column 1: unexpected char: '~'", + "ERROR 1 Syntax Error on line 1, column 1: unexpected char: '~'" + ], + [ + "a \t b ~", + "ERROR 12 Syntax Error on line 1, column 12: unexpected char: '~'", + "ERROR 12 Syntax Error on line 1, column 12: unexpected char: '~'" + ], + [ + "a\n b ~", + "ERROR 6 Syntax Error on line 1, column 6: unexpected char: '~'", + "ERROR 6 Syntax Error on line 1, column 6: unexpected char: '~'" + ], + [ + "a\tb\t~", + "ERROR 17 Syntax Error on line 1, column 17: unexpected char: '~'", + "ERROR 17 Syntax Error on line 1, column 17: unexpected char: '~'" + ], + [ + "\\", + "ERROR 1 Syntax Error on line 1, column 1: unexpected token: [\"\\\",<62>,line=1,col=1]", + "ERROR 1 Syntax Error on line 1, column 1: unexpected token: [\"\\\",<62>,line=1,col=1]" + ], + [ + "\\.", + "ERROR 1 Syntax Error on line 1, column 1: unexpected token: [\"\\.\",<63>,line=1,col=1]", + "ERROR 1 Syntax Error on line 1, column 1: unexpected token: [\"\\.\",<63>,line=1,col=1]" + ], + [ + "`", + "ERROR 1 Syntax Error on line 1, column 1: unexpected token: [\"`\",<61>,line=1,col=1]", + "ERROR 1 Syntax Error on line 1, column 1: unexpected token: [\"`\",<61>,line=1,col=1]" + ], + [ + "a|b", + "ERROR 2 Syntax Error on line 1, column 2: expecting \"EOF\", found '|'", + "ERROR 2 Syntax Error on line 1, column 2: unexpected token: [\"|\",<48>,line=1,col=2]", + "ERROR 1 Syntax Error on line 1, column 1: unexpected token: [\"a\",<33>,line=1,col=1]", + "ERROR 1 Syntax Error on line 1, column 1: unexpected token: [\"a\",<33>,line=1,col=1]" + ], + [ + "a,b", + "ERROR 2 Syntax Error on line 1, column 2: expecting \"EOF\", found ','", + "(Expression|4|expression (PropertyOrFieldNode|33|a))" + ], + [ + "a;b", + "ERROR 2 Syntax Error on line 1, column 2: expecting \"EOF\", found ';'", + "(Expression|4|expression (PropertyOrFieldNode|33|a))" + ], + [ + ";", + "ERROR 1 Syntax Error on line 1, column 1: unexpected token: [\";\",<18>,line=1,col=1]", + "ERROR 1 Syntax Error on line 1, column 1: unexpected token: [\";\",<18>,line=1,col=1]" + ], + [ + ":", + "ERROR 1 Syntax Error on line 1, column 1: unexpected token: [\":\",<23>,line=1,col=1]", + "ERROR 1 Syntax Error on line 1, column 1: unexpected token: [\":\",<23>,line=1,col=1]" + ], + [ + "a)", + "ERROR 2 Syntax Error on line 1, column 2: expecting \"EOF\", found ')'", + "(Expression|4|expression (PropertyOrFieldNode|33|a))" + ], + [ + "(a", + "ERROR 3 Syntax Error on line 1, column 3: unexpected end of expression", + "ERROR 3 Syntax Error on line 1, column 3: unexpected end of expression", + "ERROR 3 Syntax Error on line 1, column 3: expecting \"RPAREN\", found ''", + "ERROR 3 Syntax Error on line 1, column 3: expecting \"RPAREN\", found ''" + ], + [ + "[a]", + "(Expression|4|expression (IndexerNode|37|[ (Expression|4|expression (PropertyOrFieldNode|33|a))))", + "(Expression|4|expression (IndexerNode|37|[ (Expression|4|expression (PropertyOrFieldNode|33|a))))" + ], + [ + "[a,b]", + "(Expression|4|expression (IndexerNode|37|[ (Expression|4|expression (PropertyOrFieldNode|33|a)) (Expression|4|expression (PropertyOrFieldNode|33|b))))", + "(Expression|4|expression (IndexerNode|37|[ (Expression|4|expression (PropertyOrFieldNode|33|a)) (Expression|4|expression (PropertyOrFieldNode|33|b))))" + ], + [ + "a[b,c]", + "(Expression|4|expression (PropertyOrFieldNode|33|a) (IndexerNode|37|[ (Expression|4|expression (PropertyOrFieldNode|33|b)) (Expression|4|expression (PropertyOrFieldNode|33|c))))", + "(Expression|4|expression (PropertyOrFieldNode|33|a) (IndexerNode|37|[ (Expression|4|expression (PropertyOrFieldNode|33|b)) (Expression|4|expression (PropertyOrFieldNode|33|c))))" + ], + [ + "a[]", + "ERROR 3 Syntax Error on line 1, column 3: unexpected token: [\"]\",<38>,line=1,col=3]", + "ERROR 3 Syntax Error on line 1, column 3: unexpected token: [\"]\",<38>,line=1,col=3]" + ], + [ + "a()", + "(Expression|4|expression (MethodNode|33|a))", + "(Expression|4|expression (MethodNode|33|a))" + ], + [ + "a(b,c)", + "(Expression|4|expression (MethodNode|33|a (Expression|4|expression (PropertyOrFieldNode|33|b)) (Expression|4|expression (PropertyOrFieldNode|33|c))))", + "(Expression|4|expression (MethodNode|33|a (Expression|4|expression (PropertyOrFieldNode|33|b)) (Expression|4|expression (PropertyOrFieldNode|33|c))))" + ], + [ + "a(b;c)", + "ERROR 4 Syntax Error on line 1, column 4: unexpected token: [\";\",<18>,line=1,col=4]", + "ERROR 4 Syntax Error on line 1, column 4: unexpected token: [\";\",<18>,line=1,col=4]", + "ERROR 4 Syntax Error on line 1, column 4: expecting \"RPAREN\", found ';'", + "ERROR 4 Syntax Error on line 1, column 4: expecting \"RPAREN\", found ';'" + ], + [ + "#a(b;c)", + "ERROR 5 Syntax Error on line 1, column 5: unexpected token: [\";\",<18>,line=1,col=5]", + "ERROR 5 Syntax Error on line 1, column 5: unexpected token: [\";\",<18>,line=1,col=5]", + "ERROR 5 Syntax Error on line 1, column 5: expecting \"RPAREN\", found ';'", + "ERROR 5 Syntax Error on line 1, column 5: expecting \"RPAREN\", found ';'" + ], + [ + "$a(b;c)", + "ERROR 5 Syntax Error on line 1, column 5: unexpected token: [\";\",<18>,line=1,col=5]", + "ERROR 5 Syntax Error on line 1, column 5: unexpected token: [\";\",<18>,line=1,col=5]", + "ERROR 5 Syntax Error on line 1, column 5: expecting \"RPAREN\", found ';'", + "ERROR 5 Syntax Error on line 1, column 5: expecting \"RPAREN\", found ';'" + ], + [ + "a.b(c)(d;e)", + "(Expression|4|expression (PropertyOrFieldNode|33|a) (MethodNode|33|b (Expression|4|expression (PropertyOrFieldNode|33|c))) (ExpressionListNode|4|expressionList (Expression|4|expression (PropertyOrFieldNode|33|d)) (Expression|4|expression (PropertyOrFieldNode|33|e))))", + "(Expression|4|expression (PropertyOrFieldNode|33|a) (MethodNode|33|b (Expression|4|expression (PropertyOrFieldNode|33|c))) (ExpressionListNode|4|expressionList (Expression|4|expression (PropertyOrFieldNode|33|d)) (Expression|4|expression (PropertyOrFieldNode|33|e))))" + ], + [ + "(a;b)(c;d)", + "(Expression|4|expression (ExpressionListNode|4|expressionList (Expression|4|expression (PropertyOrFieldNode|33|a)) (Expression|4|expression (PropertyOrFieldNode|33|b))) (ExpressionListNode|4|expressionList (Expression|4|expression (PropertyOrFieldNode|33|c)) (Expression|4|expression (PropertyOrFieldNode|33|d))))", + "(Expression|4|expression (ExpressionListNode|4|expressionList (Expression|4|expression (PropertyOrFieldNode|33|a)) (Expression|4|expression (PropertyOrFieldNode|33|b))) (ExpressionListNode|4|expressionList (Expression|4|expression (PropertyOrFieldNode|33|c)) (Expression|4|expression (PropertyOrFieldNode|33|d))))" + ], + [ + "{a}", + "(Expression|4|expression (ListInitializerNode|50|{ (Expression|4|expression (PropertyOrFieldNode|33|a))))", + "(Expression|4|expression (ListInitializerNode|50|{ (Expression|4|expression (PropertyOrFieldNode|33|a))))" + ], + [ + "{}", + "ERROR 2 Syntax Error on line 1, column 2: unexpected token: [\"}\",<40>,line=1,col=2]", + "ERROR 2 Syntax Error on line 1, column 2: unexpected token: [\"}\",<40>,line=1,col=2]" + ], + [ + "#{}", + "ERROR 3 Syntax Error on line 1, column 3: unexpected token: [\"}\",<40>,line=1,col=3]", + "ERROR 3 Syntax Error on line 1, column 3: unexpected token: [\"}\",<40>,line=1,col=3]" + ], + [ + "{|", + "ERROR 3 Syntax Error on line 1, column 3: unexpected end of expression", + "ERROR 3 Syntax Error on line 1, column 3: unexpected end of expression", + "ERROR 3 Syntax Error on line 1, column 3: unexpected token: [\"\",<1>,line=1,col=3]", + "ERROR 3 Syntax Error on line 1, column 3: unexpected token: [\"\",<1>,line=1,col=3]" + ], + [ + "{|a", + "ERROR 4 Syntax Error on line 1, column 4: unexpected end of expression", + "ERROR 4 Syntax Error on line 1, column 4: unexpected end of expression", + "ERROR 4 Syntax Error on line 1, column 4: expecting \"PIPE\", found ''", + "ERROR 4 Syntax Error on line 1, column 4: expecting \"PIPE\", found ''" + ], + [ + "{|a|", + "ERROR 5 Syntax Error on line 1, column 5: unexpected end of expression", + "ERROR 5 Syntax Error on line 1, column 5: unexpected end of expression", + "ERROR 5 Syntax Error on line 1, column 5: unexpected token: [\"\",<1>,line=1,col=5]", + "ERROR 5 Syntax Error on line 1, column 5: unexpected token: [\"\",<1>,line=1,col=5]" + ], + [ + "{|a|b", + "ERROR 6 Syntax Error on line 1, column 6: unexpected end of expression", + "ERROR 6 Syntax Error on line 1, column 6: unexpected end of expression", + "ERROR 6 Syntax Error on line 1, column 6: expecting \"RCURLY\", found ''", + "ERROR 6 Syntax Error on line 1, column 6: expecting \"RCURLY\", found ''" + ], + [ + "a=1", + "(AssignNode|20|= (Expression|4|expression (PropertyOrFieldNode|33|a)) (Expression|4|expression (IntLiteralNode|51|1)))", + "(Expression|4|expression (PropertyOrFieldNode|33|a))" + ], + [ + "(a=1)", + "(Expression|4|expression (AssignNode|20|= (Expression|4|expression (PropertyOrFieldNode|33|a)) (Expression|4|expression (IntLiteralNode|51|1))))", + "(Expression|4|expression (AssignNode|20|= (Expression|4|expression (PropertyOrFieldNode|33|a)) (Expression|4|expression (IntLiteralNode|51|1))))" + ], + [ + "(#x=1;#x+1)", + "(Expression|4|expression (ExpressionListNode|4|expressionList (AssignNode|20|= (Expression|4|expression (VariableNode|33|x)) (Expression|4|expression (IntLiteralNode|51|1))) (OpADD|24|+ (Expression|4|expression (VariableNode|33|x)) (Expression|4|expression (IntLiteralNode|51|1)))))", + "(Expression|4|expression (ExpressionListNode|4|expressionList (AssignNode|20|= (Expression|4|expression (VariableNode|33|x)) (Expression|4|expression (IntLiteralNode|51|1))) (OpADD|24|+ (Expression|4|expression (VariableNode|33|x)) (Expression|4|expression (IntLiteralNode|51|1)))))" + ], + [ + "new a(x=1,y=2)", + "(Expression|4|expression (ConstructorNode|4|a (NamedArgumentNode|33|x (Expression|4|expression (IntLiteralNode|51|1))) (NamedArgumentNode|33|y (Expression|4|expression (IntLiteralNode|51|2)))))", + "(Expression|4|expression (ConstructorNode|4|a (NamedArgumentNode|33|x (Expression|4|expression (IntLiteralNode|51|1))) (NamedArgumentNode|33|y (Expression|4|expression (IntLiteralNode|51|2)))))" + ], + [ + "new a(x=1 ?2:3)", + "(Expression|4|expression (ConstructorNode|4|a (NamedArgumentNode|33|x (TernaryNode|22|? (Expression|4|expression (IntLiteralNode|51|1)) (Expression|4|expression (IntLiteralNode|51|2)) (Expression|4|expression (IntLiteralNode|51|3))))))", + "(Expression|4|expression (ConstructorNode|4|a (NamedArgumentNode|33|x (TernaryNode|22|? (Expression|4|expression (IntLiteralNode|51|1)) (Expression|4|expression (IntLiteralNode|51|2)) (Expression|4|expression (IntLiteralNode|51|3))))))" + ], + [ + "new a(x==1)", + "(Expression|4|expression (ConstructorNode|4|a (OpEqual|4|== (Expression|4|expression (PropertyOrFieldNode|33|x)) (Expression|4|expression (IntLiteralNode|51|1)))))", + "(Expression|4|expression (ConstructorNode|4|a (OpEqual|4|== (Expression|4|expression (PropertyOrFieldNode|33|x)) (Expression|4|expression (IntLiteralNode|51|1)))))" + ], + [ + "@(a", + "ERROR 4 Syntax Error on line 1, column 4: unexpected end of expression", + "ERROR 4 Syntax Error on line 1, column 4: unexpected end of expression", + "ERROR 4 Syntax Error on line 1, column 4: expecting \"RPAREN\", found ''", + "ERROR 4 Syntax Error on line 1, column 4: expecting \"RPAREN\", found ''" + ], + [ + "@(a:", + "ERROR 5 Syntax Error on line 1, column 5: unexpected end of expression", + "ERROR 5 Syntax Error on line 1, column 5: unexpected end of expression", + "ERROR 5 Syntax Error on line 1, column 5: unexpected token: [\"\",<1>,line=1,col=5]", + "ERROR 5 Syntax Error on line 1, column 5: unexpected token: [\"\",<1>,line=1,col=5]" + ], + [ + "@(a:b", + "ERROR 6 Syntax Error on line 1, column 6: unexpected end of expression", + "ERROR 6 Syntax Error on line 1, column 6: unexpected end of expression", + "ERROR 6 Syntax Error on line 1, column 6: expecting \"RPAREN\", found ''", + "ERROR 6 Syntax Error on line 1, column 6: expecting \"RPAREN\", found ''" + ], + [ + "@[", + "ERROR 3 Syntax Error on line 1, column 3: unexpected end of expression", + "ERROR 3 Syntax Error on line 1, column 3: unexpected end of expression", + "ERROR 3 Syntax Error on line 1, column 3: expecting \"ID\", found ''", + "ERROR 3 Syntax Error on line 1, column 3: expecting \"ID\", found ''" + ], + [ + "@[a", + "ERROR 4 Syntax Error on line 1, column 4: unexpected end of expression", + "ERROR 4 Syntax Error on line 1, column 4: unexpected end of expression", + "ERROR 4 Syntax Error on line 1, column 4: unexpected token: [\"\",<1>,line=1,col=4]", + "ERROR 4 Syntax Error on line 1, column 4: unexpected token: [\"\",<1>,line=1,col=4]" + ], + [ + "@[a(", + "ERROR 5 Syntax Error on line 1, column 5: unexpected end of expression", + "ERROR 5 Syntax Error on line 1, column 5: unexpected end of expression", + "ERROR 5 Syntax Error on line 1, column 5: unexpected token: [\"\",<1>,line=1,col=5]", + "ERROR 5 Syntax Error on line 1, column 5: unexpected token: [\"\",<1>,line=1,col=5]" + ], + [ + "@", + "ERROR 2 Syntax Error on line 1, column 2: unexpected end of expression", + "ERROR 2 Syntax Error on line 1, column 2: unexpected end of expression", + "ERROR 1 Syntax Error on line 1, column 1: unexpected token: [\"@\",<36>,line=1,col=1]", + "ERROR 1 Syntax Error on line 1, column 1: unexpected token: [\"@\",<36>,line=1,col=1]" + ], + [ + "@ (a)", + "(Expression|4|expression (ReferenceNode|4|ref (QualifiedIdentifier|33|a)))", + "(Expression|4|expression (ReferenceNode|4|ref (QualifiedIdentifier|33|a)))" + ], + [ + "@ [a]", + "(Expression|4|expression (AttributeNode|4|a))", + "(Expression|4|expression (AttributeNode|4|a))" + ], + [ + "#", + "ERROR 2 Syntax Error on line 1, column 2: unexpected end of expression", + "ERROR 2 Syntax Error on line 1, column 2: unexpected end of expression", + "ERROR 1 Syntax Error on line 1, column 1: unexpected token: [\"#\",<32>,line=1,col=1]", + "ERROR 1 Syntax Error on line 1, column 1: unexpected token: [\"#\",<32>,line=1,col=1]" + ], + [ + "$", + "ERROR 2 Syntax Error on line 1, column 2: unexpected end of expression", + "ERROR 2 Syntax Error on line 1, column 2: unexpected end of expression", + "ERROR 1 Syntax Error on line 1, column 1: unexpected token: [\"$\",<34>,line=1,col=1]", + "ERROR 1 Syntax Error on line 1, column 1: unexpected token: [\"$\",<34>,line=1,col=1]" + ], + [ + "#{|", + "ERROR 2 Syntax Error on line 1, column 2: unexpected token: [\"{|\",<47>,line=1,col=2]", + "ERROR 2 Syntax Error on line 1, column 2: unexpected token: [\"{|\",<47>,line=1,col=2]", + "ERROR 1 Syntax Error on line 1, column 1: unexpected token: [\"#\",<32>,line=1,col=1]", + "ERROR 1 Syntax Error on line 1, column 1: unexpected token: [\"#\",<32>,line=1,col=1]" + ], + [ + "#{a}", + "ERROR 4 Syntax Error on line 1, column 4: unexpected token: [\"}\",<40>,line=1,col=4]", + "ERROR 4 Syntax Error on line 1, column 4: unexpected token: [\"}\",<40>,line=1,col=4]", + "ERROR 4 Syntax Error on line 1, column 4: expecting \"COLON\", found '}'", + "ERROR 4 Syntax Error on line 1, column 4: expecting \"COLON\", found '}'" + ], + [ + "#{a:1", + "ERROR 6 Syntax Error on line 1, column 6: unexpected end of expression", + "ERROR 6 Syntax Error on line 1, column 6: unexpected end of expression", + "ERROR 6 Syntax Error on line 1, column 6: expecting \"RCURLY\", found ''", + "ERROR 6 Syntax Error on line 1, column 6: expecting \"RCURLY\", found ''" + ], + [ + "${", + "ERROR 3 Syntax Error on line 1, column 3: unexpected end of expression", + "ERROR 3 Syntax Error on line 1, column 3: unexpected end of expression", + "ERROR 3 Syntax Error on line 1, column 3: unexpected token: [\"\",<1>,line=1,col=3]", + "ERROR 3 Syntax Error on line 1, column 3: unexpected token: [\"\",<1>,line=1,col=3]" + ], + [ + "$ {a}", + "ERROR 3 Syntax Error on line 1, column 3: unexpected token: [\"{\",<50>,line=1,col=3]", + "ERROR 3 Syntax Error on line 1, column 3: unexpected token: [\"{\",<50>,line=1,col=3]", + "ERROR 1 Syntax Error on line 1, column 1: unexpected token: [\"$\",<34>,line=1,col=1]", + "ERROR 1 Syntax Error on line 1, column 1: unexpected token: [\"$\",<34>,line=1,col=1]" + ], + [ + "^{", + "ERROR 3 Syntax Error on line 1, column 3: unexpected end of expression", + "ERROR 3 Syntax Error on line 1, column 3: unexpected end of expression", + "ERROR 3 Syntax Error on line 1, column 3: unexpected token: [\"\",<1>,line=1,col=3]", + "ERROR 3 Syntax Error on line 1, column 3: unexpected token: [\"\",<1>,line=1,col=3]" + ], + [ + "a?{b", + "ERROR 5 Syntax Error on line 1, column 5: unexpected end of expression", + "ERROR 5 Syntax Error on line 1, column 5: unexpected end of expression", + "ERROR 5 Syntax Error on line 1, column 5: expecting \"RCURLY\", found ''", + "ERROR 5 Syntax Error on line 1, column 5: expecting \"RCURLY\", found ''" + ], + [ + "a?", + "ERROR 3 Syntax Error on line 1, column 3: unexpected end of expression", + "(Expression|4|expression (PropertyOrFieldNode|33|a))", + "ERROR 3 Syntax Error on line 1, column 3: unexpected token: [\"\",<1>,line=1,col=3]", + "(Expression|4|expression (PropertyOrFieldNode|33|a))" + ], + [ + "!{", + "ERROR 3 Syntax Error on line 1, column 3: unexpected end of expression", + "ERROR 3 Syntax Error on line 1, column 3: unexpected end of expression", + "ERROR 3 Syntax Error on line 1, column 3: unexpected token: [\"\",<1>,line=1,col=3]", + "ERROR 3 Syntax Error on line 1, column 3: unexpected token: [\"\",<1>,line=1,col=3]" + ], + [ + "!", + "ERROR 2 Syntax Error on line 1, column 2: unexpected end of expression", + "ERROR 1 Syntax Error on line 1, column 1: unexpected token: [\"!\",<30>,line=1,col=1]", + "ERROR 2 Syntax Error on line 1, column 2: unexpected token: [\"\",<1>,line=1,col=2]", + "ERROR 1 Syntax Error on line 1, column 1: unexpected token: [\"!\",<30>,line=1,col=1]" + ], + [ + "!a", + "(OpNOT|30|! (Expression|4|expression (PropertyOrFieldNode|33|a)))", + "ERROR 1 Syntax Error on line 1, column 1: unexpected token: [\"!\",<30>,line=1,col=1]" + ], + [ + "!!a", + "(OpNOT|30|! (OpNOT|30|! (Expression|4|expression (PropertyOrFieldNode|33|a))))", + "ERROR 1 Syntax Error on line 1, column 1: unexpected token: [\"!\",<30>,line=1,col=1]" + ], + [ + "--a", + "(OpUnaryMinus|25|- (OpUnaryMinus|25|- (Expression|4|expression (PropertyOrFieldNode|33|a))))", + "ERROR 1 Syntax Error on line 1, column 1: unexpected token: [\"-\",<25>,line=1,col=1]" + ], + [ + "+-a", + "(OpUnaryPlus|24|+ (OpUnaryMinus|25|- (Expression|4|expression (PropertyOrFieldNode|33|a))))", + "ERROR 1 Syntax Error on line 1, column 1: unexpected token: [\"+\",<24>,line=1,col=1]" + ], + [ + "- - a", + "(OpUnaryMinus|25|- (OpUnaryMinus|25|- (Expression|4|expression (PropertyOrFieldNode|33|a))))", + "ERROR 1 Syntax Error on line 1, column 1: unexpected token: [\"-\",<25>,line=1,col=1]" + ], + [ + "a+-b", + "(OpADD|24|+ (Expression|4|expression (PropertyOrFieldNode|33|a)) (OpUnaryMinus|25|- (Expression|4|expression (PropertyOrFieldNode|33|b))))", + "(Expression|4|expression (PropertyOrFieldNode|33|a))" + ], + [ + "a- -b", + "(OpSUBTRACT|25|- (Expression|4|expression (PropertyOrFieldNode|33|a)) (OpUnaryMinus|25|- (Expression|4|expression (PropertyOrFieldNode|33|b))))", + "(Expression|4|expression (PropertyOrFieldNode|33|a))" + ], + [ + "a--b", + "(OpSUBTRACT|25|- (Expression|4|expression (PropertyOrFieldNode|33|a)) (OpUnaryMinus|25|- (Expression|4|expression (PropertyOrFieldNode|33|b))))", + "(Expression|4|expression (PropertyOrFieldNode|33|a))" + ], + [ + "new a", + "ERROR 6 Syntax Error on line 1, column 6: unexpected end of expression", + "ERROR 6 Syntax Error on line 1, column 6: unexpected end of expression", + "ERROR 6 Syntax Error on line 1, column 6: expecting \"LBRACKET\", found ''", + "ERROR 6 Syntax Error on line 1, column 6: expecting \"LBRACKET\", found ''" + ], + [ + "new a.", + "ERROR 6 Syntax Error on line 1, column 6: expecting \"EOF\", found '.'", + "ERROR 6 Syntax Error on line 1, column 6: unexpected token: [\".\",<31>,line=1,col=6]", + "ERROR 7 Syntax Error on line 1, column 7: expecting \"ID\", found ''", + "ERROR 7 Syntax Error on line 1, column 7: expecting \"ID\", found ''" + ], + [ + "new a.b", + "ERROR 8 Syntax Error on line 1, column 8: unexpected end of expression", + "ERROR 8 Syntax Error on line 1, column 8: unexpected end of expression", + "ERROR 8 Syntax Error on line 1, column 8: expecting \"LBRACKET\", found ''", + "ERROR 8 Syntax Error on line 1, column 8: expecting \"LBRACKET\", found ''" + ], + [ + "new T(a)", + "ERROR 5 Syntax Error on line 1, column 5: unexpected token: [\"T(\",<44>,line=1,col=5]", + "ERROR 5 Syntax Error on line 1, column 5: unexpected token: [\"T(\",<44>,line=1,col=5]", + "ERROR 1 Syntax Error on line 1, column 1: unexpected token: [\"new\",<49>,line=1,col=1]", + "ERROR 1 Syntax Error on line 1, column 1: unexpected token: [\"new\",<49>,line=1,col=1]" + ], + [ + "new a.T(b)", + "ERROR 6 Syntax Error on line 1, column 6: expecting \"EOF\", found '.'", + "ERROR 6 Syntax Error on line 1, column 6: unexpected token: [\".\",<31>,line=1,col=6]", + "ERROR 7 Syntax Error on line 1, column 7: expecting \"ID\", found 'T('", + "ERROR 7 Syntax Error on line 1, column 7: expecting \"ID\", found 'T('" + ], + [ + "new a.in()", + "ERROR 6 Syntax Error on line 1, column 6: expecting \"EOF\", found '.'", + "ERROR 6 Syntax Error on line 1, column 6: unexpected token: [\".\",<31>,line=1,col=6]", + "ERROR 7 Syntax Error on line 1, column 7: expecting \"ID\", found 'in'", + "ERROR 7 Syntax Error on line 1, column 7: expecting \"ID\", found 'in'" + ], + [ + "new 1", + "ERROR 5 Syntax Error on line 1, column 5: unexpected token: [\"1\",<51>,line=1,col=5]", + "ERROR 5 Syntax Error on line 1, column 5: unexpected token: [\"1\",<51>,line=1,col=5]", + "ERROR 1 Syntax Error on line 1, column 1: unexpected token: [\"new\",<49>,line=1,col=1]", + "ERROR 1 Syntax Error on line 1, column 1: unexpected token: [\"new\",<49>,line=1,col=1]" + ], + [ + "a.in", + "ERROR 5 Syntax Error on line 1, column 5: unexpected end of expression", + "(Expression|4|expression (PropertyOrFieldNode|33|a))", + "ERROR 5 Syntax Error on line 1, column 5: unexpected token: [\"\",<1>,line=1,col=5]", + "(Expression|4|expression (PropertyOrFieldNode|33|a))" + ], + [ + "in.a", + "ERROR 1 Syntax Error on line 1, column 1: unexpected token: [\"in\",<11>,line=1,col=1]", + "ERROR 1 Syntax Error on line 1, column 1: unexpected token: [\"in\",<11>,line=1,col=1]" + ], + [ + "a.new", + "ERROR 3 Syntax Error on line 1, column 3: expecting \"EOF\", found 'new'", + "(Expression|4|expression (PropertyOrFieldNode|33|a))", + "ERROR 3 Syntax Error on line 1, column 3: unexpected token: [\"new\",<49>,line=1,col=3]", + "(Expression|4|expression (PropertyOrFieldNode|33|a))" + ], + [ + "a.true", + "ERROR 3 Syntax Error on line 1, column 3: expecting \"EOF\", found 'true'", + "(Expression|4|expression (PropertyOrFieldNode|33|a))", + "ERROR 3 Syntax Error on line 1, column 3: unexpected token: [\"true\",<7>,line=1,col=3]", + "(Expression|4|expression (PropertyOrFieldNode|33|a))" + ], + [ + "true.a", + "(Expression|4|expression (BooleanLiteralNode|7|true) (PropertyOrFieldNode|33|a))", + "(Expression|4|expression (BooleanLiteralNode|7|true) (PropertyOrFieldNode|33|a))" + ], + [ + "1 .2", + "ERROR 3 Syntax Error on line 1, column 3: expecting \"EOF\", found '.2'", + "ERROR 3 Syntax Error on line 1, column 3: unexpected token: [\".2\",<53>,line=1,col=3]", + "ERROR 3 Syntax Error on line 1, column 3: unexpected token: [\".2\",<53>,line=1,col=3]", + "ERROR 3 Syntax Error on line 1, column 3: unexpected token: [\".2\",<53>,line=1,col=3]" + ], + [ + "1.2.3", + "ERROR 4 Syntax Error on line 1, column 4: expecting \"EOF\", found '.3'", + "ERROR 4 Syntax Error on line 1, column 4: unexpected token: [\".3\",<53>,line=1,col=4]", + "ERROR 4 Syntax Error on line 1, column 4: unexpected token: [\".3\",<53>,line=1,col=4]", + "ERROR 4 Syntax Error on line 1, column 4: unexpected token: [\".3\",<53>,line=1,col=4]" + ], + [ + "T(a):", + "ERROR 5 Syntax Error on line 1, column 5: expecting \"EOF\", found ':'", + "(Expression|4|expression (TypeNode|4|a))" + ], + [ + "T(a:b)", + "ERROR 4 Syntax Error on line 1, column 4: unexpected token: [\":\",<23>,line=1,col=4]", + "ERROR 4 Syntax Error on line 1, column 4: unexpected token: [\":\",<23>,line=1,col=4]", + "ERROR 4 Syntax Error on line 1, column 4: expecting \"RPAREN\", found ':'", + "ERROR 4 Syntax Error on line 1, column 4: expecting \"RPAREN\", found ':'" + ], + [ + "T('a')", + "ERROR 3 Syntax Error on line 1, column 3: unexpected token: [\"a\",<46>,line=1,col=3]", + "ERROR 3 Syntax Error on line 1, column 3: unexpected token: [\"a\",<46>,line=1,col=3]", + "ERROR 3 Syntax Error on line 1, column 3: expecting \"ID\", found 'a'", + "ERROR 3 Syntax Error on line 1, column 3: expecting \"ID\", found 'a'" + ], + [ + "@('a')", + "(Expression|4|expression (ReferenceNode|4|ref (QualifiedIdentifier|46|a)))", + "(Expression|4|expression (ReferenceNode|4|ref (QualifiedIdentifier|46|a)))" + ], + [ + "@('a':b)", + "(Expression|4|expression (ReferenceNode|4|ref (QualifiedIdentifier|46|a) (QualifiedIdentifier|33|b)))", + "(Expression|4|expression (ReferenceNode|4|ref (QualifiedIdentifier|46|a) (QualifiedIdentifier|33|b)))" + ], + [ + "@(a:'b')", + "(Expression|4|expression (ReferenceNode|4|ref (QualifiedIdentifier|33|a) (QualifiedIdentifier|46|b)))", + "(Expression|4|expression (ReferenceNode|4|ref (QualifiedIdentifier|33|a) (QualifiedIdentifier|46|b)))" + ], + [ + "@(in)", + "ERROR 3 Syntax Error on line 1, column 3: unexpected token: [\"in\",<11>,line=1,col=3]", + "ERROR 3 Syntax Error on line 1, column 3: unexpected token: [\"in\",<11>,line=1,col=3]" + ], + [ + "@(a in:b)", + "(Expression|4|expression (ReferenceNode|4|ref (QualifiedIdentifier|33|ain) (QualifiedIdentifier|33|b)))", + "(Expression|4|expression (ReferenceNode|4|ref (QualifiedIdentifier|33|ain) (QualifiedIdentifier|33|b)))" + ], + [ + "T(a in b)", + "(Expression|4|expression (TypeNode|4|ainb))", + "(Expression|4|expression (TypeNode|4|ainb))" + ], + [ + "T(in)", + "ERROR 3 Syntax Error on line 1, column 3: unexpected token: [\"in\",<11>,line=1,col=3]", + "ERROR 3 Syntax Error on line 1, column 3: unexpected token: [\"in\",<11>,line=1,col=3]", + "ERROR 3 Syntax Error on line 1, column 3: expecting \"ID\", found 'in'", + "ERROR 3 Syntax Error on line 1, column 3: expecting \"ID\", found 'in'" + ], + [ + "T(T(a))", + "ERROR 3 Syntax Error on line 1, column 3: unexpected token: [\"T(\",<44>,line=1,col=3]", + "ERROR 3 Syntax Error on line 1, column 3: unexpected token: [\"T(\",<44>,line=1,col=3]", + "ERROR 3 Syntax Error on line 1, column 3: expecting \"ID\", found 'T('", + "ERROR 3 Syntax Error on line 1, column 3: expecting \"ID\", found 'T('" + ], + [ + "T(a T(b)", + "(Expression|4|expression (TypeNode|4|aT(b))", + "(Expression|4|expression (TypeNode|4|aT(b))" + ], + [ + "a b[", + "ERROR 5 Syntax Error on line 1, column 5: unexpected end of expression", + "ERROR 5 Syntax Error on line 1, column 5: unexpected end of expression", + "ERROR 5 Syntax Error on line 1, column 5: unexpected token: [\"\",<1>,line=1,col=5]", + "ERROR 5 Syntax Error on line 1, column 5: unexpected token: [\"\",<1>,line=1,col=5]" + ], + [ + "a(b", + "ERROR 4 Syntax Error on line 1, column 4: unexpected end of expression", + "ERROR 4 Syntax Error on line 1, column 4: unexpected end of expression", + "ERROR 4 Syntax Error on line 1, column 4: expecting \"RPAREN\", found ''", + "ERROR 4 Syntax Error on line 1, column 4: expecting \"RPAREN\", found ''" + ], + [ + "a +", + "ERROR 4 Syntax Error on line 1, column 4: unexpected end of expression", + "(Expression|4|expression (PropertyOrFieldNode|33|a))", + "ERROR 4 Syntax Error on line 1, column 4: unexpected token: [\"\",<1>,line=1,col=4]", + "(Expression|4|expression (PropertyOrFieldNode|33|a))" + ], + [ + "a ?{", + "ERROR 5 Syntax Error on line 1, column 5: unexpected end of expression", + "ERROR 5 Syntax Error on line 1, column 5: unexpected end of expression", + "ERROR 5 Syntax Error on line 1, column 5: unexpected token: [\"\",<1>,line=1,col=5]", + "ERROR 5 Syntax Error on line 1, column 5: unexpected token: [\"\",<1>,line=1,col=5]" + ], + [ + "android", + "(Expression|4|expression (PropertyOrFieldNode|33|android))", + "(Expression|4|expression (PropertyOrFieldNode|33|android))" + ], + [ + "input.x", + "(Expression|4|expression (PropertyOrFieldNode|33|input) (PropertyOrFieldNode|33|x))", + "(Expression|4|expression (PropertyOrFieldNode|33|input) (PropertyOrFieldNode|33|x))" + ], + [ + "and", + "ERROR 1 Syntax Error on line 1, column 1: unexpected token: [\"and\",<8>,line=1,col=1]", + "ERROR 1 Syntax Error on line 1, column 1: unexpected token: [\"and\",<8>,line=1,col=1]" + ], + [ + "Name.Length + 1", + "(OpADD|24|+ (Expression|4|expression (PropertyOrFieldNode|33|Name) (PropertyOrFieldNode|33|Length)) (Expression|4|expression (IntLiteralNode|51|1)))", + "(Expression|4|expression (PropertyOrFieldNode|33|Name) (PropertyOrFieldNode|33|Length))" + ], + [ + "foo.bar[0].baz(1, 'x').?{#this > 1}.!{Name}", + "(Expression|4|expression (PropertyOrFieldNode|33|foo) (PropertyOrFieldNode|33|bar) (IndexerNode|37|[ (Expression|4|expression (IntLiteralNode|51|0))) (MethodNode|33|baz (Expression|4|expression (IntLiteralNode|51|1)) (Expression|4|expression (StringLiteralNode|46|x))) (SelectionNode|41|?{ (OpGreater|4|> (Expression|4|expression (VariableNode|33|this)) (Expression|4|expression (IntLiteralNode|51|1)))) (ProjectionNode|39|!{ (Expression|4|expression (PropertyOrFieldNode|33|Name))))", + "(Expression|4|expression (PropertyOrFieldNode|33|foo) (PropertyOrFieldNode|33|bar) (IndexerNode|37|[ (Expression|4|expression (IntLiteralNode|51|0))) (MethodNode|33|baz (Expression|4|expression (IntLiteralNode|51|1)) (Expression|4|expression (StringLiteralNode|46|x))) (SelectionNode|41|?{ (OpGreater|4|> (Expression|4|expression (VariableNode|33|this)) (Expression|4|expression (IntLiteralNode|51|1)))) (ProjectionNode|39|!{ (Expression|4|expression (PropertyOrFieldNode|33|Name))))" + ], + [ + "T(System.Collections.Generic.List`1[[System.Int32, mscorlib]], mscorlib)", + "(Expression|4|expression (TypeNode|4|System.Collections.Generic.List`1[[System.Int32,mscorlib]],mscorlib))", + "(Expression|4|expression (TypeNode|4|System.Collections.Generic.List`1[[System.Int32,mscorlib]],mscorlib))" + ] +] \ No newline at end of file diff --git a/test/Spring/Spring.Core.Tests/Expressions/ExpressionGrammarTests.cs b/test/Spring/Spring.Core.Tests/Expressions/ExpressionGrammarTests.cs new file mode 100644 index 000000000..31413b824 --- /dev/null +++ b/test/Spring/Spring.Core.Tests/Expressions/ExpressionGrammarTests.cs @@ -0,0 +1,246 @@ +using System.Reflection; +using System.Runtime.ExceptionServices; +using System.Runtime.Serialization; +using System.Text; +using Newtonsoft.Json; +using NUnit.Framework; + +namespace Spring.Expressions; + +[TestFixture] +public class ExpressionGrammarTests +{ + private static string Print(object node) + { + var builder = new StringBuilder(); + Print((SpringAST) node, builder); + return builder.ToString(); + } + + private static void Print(SpringAST node, StringBuilder builder) + { + builder.Append('(').Append(node.GetType().Name).Append('|').Append(node.Type).Append('|').Append(node.getText()); + for (var child = (SpringAST) node.getFirstChild(); child != null; child = (SpringAST) child.getNextSibling()) + { + builder.Append(' '); + Print(child, builder); + } + + builder.Append(')'); + } + + private static T Internal(string method, string input) + { + try + { + return (T) typeof(Expression) + .GetMethod(method, BindingFlags.Static | BindingFlags.NonPublic, null, new[] { typeof(string) }, null) + .Invoke(null, new object[] { input }); + } + catch (TargetInvocationException e) when (e.InnerException is SyntaxErrorException) + { + ExceptionDispatchInfo.Capture(e.InnerException).Throw(); + throw; + } + } + + /// Fails instead of hanging when parsing takes much longer than it should. + private static IExpression ParseWithinTimeLimit(string input) + { + var task = Task.Run(() => Expression.Parse(input)); + Assert.That(Task.WaitAny(new Task[] { task }, TimeSpan.FromSeconds(5)), Is.EqualTo(0), "Parsing took too long"); + return task.GetAwaiter().GetResult(); + } + + private static string Describe(Func parse) + { + try + { + return Print(parse()); + } + catch (SyntaxErrorException e) + { + return "ERROR " + e.Column + " " + e.Message.Split(new[] { " in expression" }, StringSplitOptions.None)[0]; + } + } + + /// + /// The trees and syntax errors of the ANTLR 2 parser that this grammar replaced, written by that parser. The entries + /// with five items are the errors with a deliberate difference: the position or text of this parser, at the token it + /// could not read, then those of the former one, kept for reference. + /// + [Test] + public void SameTreesAndErrorsAsTheFormerParser() + { + string[][] entries; + using (var stream = typeof(ExpressionGrammarTests).Assembly.GetManifestResourceStream("Spring.Expressions.ExpressionGrammarGolden.json")) + using (var reader = new StreamReader(stream)) + { + entries = JsonConvert.DeserializeObject(reader.ReadToEnd()); + } + + var failures = new StringBuilder(); + foreach (var entry in entries) + { + var input = entry[0]; + var expression = Describe(() => Expression.Parse(input)); + var primary = Describe(() => Internal("ParsePrimary", input)); + if (expression != entry[1]) + { + failures.AppendLine($"{input}{Environment.NewLine} expected {entry[1]}{Environment.NewLine} actual {expression}"); + } + + if (primary != entry[2]) + { + failures.AppendLine($"primary {input}{Environment.NewLine} expected {entry[2]}{Environment.NewLine} actual {primary}"); + } + } + + Assert.That(failures.ToString(), Is.Empty); + } + + [TestCase("'date", 6, "expecting ''', found ''")] + [TestCase("a ~", 3, "unexpected char: '~'")] + [TestCase("0xg", 3, "unexpected char: 'g'")] + [TestCase("1.5e!", 5, "unexpected char: '!'")] + [TestCase("a, b", 2, "expecting \"EOF\", found ','")] + [TestCase("a\tb\t~", 17, "unexpected char: '~'")] + public void SyntaxErrorsReportTheOffendingText(string input, int column, string message) + { + var e = Assert.Throws(() => Expression.Parse(input)); + Assert.That(e.Line, Is.EqualTo(1)); + Assert.That(e.Column, Is.EqualTo(column)); + Assert.That(e.Message, Does.StartWith($"Syntax Error on line 1, column {column}: {message} in expression")); + Assert.That(e.Expression, Is.EqualTo(input)); + } + + [TestCase("a?b", 4)] + [TestCase("new a", 6)] + [TestCase("new a.b", 8)] + public void IncompleteExpressionsReportTheEndOfTheInput(string input, int column) + { + var e = Assert.Throws(() => Expression.Parse(input)); + Assert.That(e.Message, Does.StartWith($"Syntax Error on line 1, column {column}: unexpected end of expression in expression")); + } + + [Test] + public void SyntaxErrorsKeepTheirStateWhenSerialized() + { + var original = Assert.Throws(() => Expression.Parse("a ~")); + +#pragma warning disable SYSLIB0050 // what is tested + var info = new SerializationInfo(typeof(SyntaxErrorException), new FormatterConverter()); + ((ISerializable) original).GetObjectData(info, default); +#pragma warning restore SYSLIB0050 + var copy = (SyntaxErrorException) Activator.CreateInstance( + typeof(SyntaxErrorException), + BindingFlags.Instance | BindingFlags.NonPublic, + null, + new object[] { info, default(StreamingContext) }, + null); + + Assert.That(copy.Line, Is.EqualTo(original.Line)); + Assert.That(copy.Column, Is.EqualTo(original.Column)); + Assert.That(copy.Expression, Is.EqualTo(original.Expression)); + Assert.That(copy.Message, Is.EqualTo(original.Message)); + Assert.That(copy.HResult, Is.EqualTo(original.HResult)); + Assert.That(copy.StackTrace, Is.EqualTo(original.StackTrace)); + } + + [TestCase("foo", "(PropertyOrFieldNode|33|foo)")] + [TestCase(" foo bar", "(PropertyOrFieldNode|33|foo)")] + [TestCase("foo-bar", "(PropertyOrFieldNode|33|foo)")] + [TestCase("foo~", "(PropertyOrFieldNode|33|foo)")] + [TestCase("in", "ERROR 1 Syntax Error on line 1, column 1: expecting \"ID\", found 'in'")] + [TestCase("T(a", "ERROR 1 Syntax Error on line 1, column 1: expecting \"ID\", found 'T('")] + [TestCase("1a", "ERROR 1 Syntax Error on line 1, column 1: expecting \"ID\", found '1'")] + public void PropertyRuleReadsOneName(string input, string expected) + { + Assert.That(Describe(() => Internal("ParseProperty", input)), Is.EqualTo(expected)); + } + + [TestCase("{|a|$a}", "(LambdaExpressionNode|4|lambda (SpringAST|4|args (SpringAST|33|a)) (Expression|4|expression (LocalVariableNode|33|a)))")] + [TestCase("{||1} ~", "(LambdaExpressionNode|4|lambda (Expression|4|expression (IntLiteralNode|51|1)))")] + [TestCase("x", "ERROR 1 Syntax Error on line 1, column 1: expecting \"LAMBDA\", found 'x'")] + [TestCase("{|a", "ERROR 4 Syntax Error on line 1, column 4: unexpected end of expression")] + public void LambdaRuleStopsAtItsBrace(string input, string expected) + { + Assert.That(Describe(() => Internal("ParseLambda", input) as IExpression), Is.EqualTo(expected)); + } + + [TestCase(" ")] + [TestCase("")] + [TestCase(null)] + public void BlankTextIsAnEmptyExpression(string input) + { + Assert.That(Expression.Parse(input), Is.TypeOf()); + } + + [Test] + public void DepthOfParenthesesDoesNotCostExponentialTime() + { + // The former parser read each parenthesis twice: this one took 3 s at depth 18 and doubled with each level + var input = new string('(', 50) + "1" + new string(')', 50); + Assert.That(ParseWithinTimeLimit(input).GetValue(), Is.EqualTo(1)); + } + + [TestCase("(", ")")] + [TestCase("{", "}")] + [TestCase("a[", "]")] + [TestCase("f(", ")")] + [TestCase("-(", ")")] + public void DeepNestingIsASyntaxError(string open, string close) + { + var input = string.Concat(Enumerable.Repeat(open, 500_000)) + "1" + string.Concat(Enumerable.Repeat(close, 500_000)); + var e = Assert.Throws(() => Expression.Parse(input)); + Assert.That(e.Message, Does.Contain("nested too deeply")); + } + + [Test] + public void DeepNestingOfUnaryOperatorsIsASyntaxError() + { + var e = Assert.Throws(() => Expression.Parse(new string('-', 500_000) + "1")); + Assert.That(e.Message, Does.Contain("nested too deeply")); + } + + [Test] + public void FailedNamedArgumentsAreNotReadAgain() + { + // Reading each one again as an assignment took 1.6 s at depth 22, and multiplied by 1.5 with each level + var input = string.Concat(Enumerable.Repeat("new a(b=", 60)) + "1"; + Assert.Throws(() => ParseWithinTimeLimit(input)); + } + + [Test] + public void LongPathsTakeLinearTime() + { + // Appending a node walked the others, which took 11 s for this path + var input = "a" + string.Concat(Enumerable.Repeat(".a", 160_000)); + Assert.That(ParseWithinTimeLimit(input), Is.TypeOf()); + } + + [TestCase(100_000, "1+")] + public void EvaluatingTooDeepATreeThrows(int count, string repeated) + { + var input = string.Concat(Enumerable.Repeat(repeated, count)) + "1"; + Exception exception = null; + + // On a small stack, where the tree is too deep for the evaluation although the parser read it + var thread = new Thread(() => + { + try + { + Expression.Parse(input).GetValue(); + } + catch (Exception e) + { + exception = e; + } + }, 256 * 1024); + + thread.Start(); + thread.Join(); + + Assert.That(exception, Is.TypeOf()); + } +} diff --git a/test/Spring/Spring.Core.Tests/Spring.Core.Tests.csproj b/test/Spring/Spring.Core.Tests/Spring.Core.Tests.csproj index cdf057e18..6be8f601d 100644 --- a/test/Spring/Spring.Core.Tests/Spring.Core.Tests.csproj +++ b/test/Spring/Spring.Core.Tests/Spring.Core.Tests.csproj @@ -57,6 +57,7 @@ + diff --git a/test/Spring/Spring.Core.Tests/StandardsComplianceTest.cs b/test/Spring/Spring.Core.Tests/StandardsComplianceTest.cs index 635827530..c77935b51 100644 --- a/test/Spring/Spring.Core.Tests/StandardsComplianceTest.cs +++ b/test/Spring/Spring.Core.Tests/StandardsComplianceTest.cs @@ -75,8 +75,6 @@ protected void ProcessAssembly(Assembly a) { foreach (Type t in a.GetTypes()) { - // TODO: make antlr compliant - if (t.FullName.IndexOf(".antlr.") > -1) continue; if ((t.IsPublic || t.IsNestedPublic) && IsCheckedType(t))