├── .gitignore
├── .npmignore
├── .nuke
├── CHANGELOG.md
├── GitVersion.yml
├── Jenkinsfile
├── LICENSE.md
├── README.md
├── build.cmd
├── build.ps1
├── build.sh
├── build
├── .editorconfig
├── Build.cs
├── _build.csproj
└── _build.csproj.DotSettings
├── demo
├── Web.config
├── css
│ ├── custom-menu.css
│ ├── custom-styles.css
│ ├── plugins.min.css
│ └── style.cyan-600.min.css
├── favicon.png
├── fonts
│ ├── FontAwesome.otf
│ ├── Material-Design-Iconic-Font.eot
│ ├── Material-Design-Iconic-Font.svg
│ ├── Material-Design-Iconic-Font.ttf
│ ├── Material-Design-Iconic-Font.woff
│ ├── Material-Design-Iconic-Font.woff2
│ ├── fontawesome-webfont.eot
│ ├── fontawesome-webfont.svg
│ ├── fontawesome-webfont.ttf
│ ├── fontawesome-webfont.woff
│ ├── fontawesome-webfont.woff2
│ ├── glyphicons-halflings-regular.eot
│ ├── glyphicons-halflings-regular.svg
│ ├── glyphicons-halflings-regular.ttf
│ ├── glyphicons-halflings-regular.woff
│ └── glyphicons-halflings-regular.woff2
├── img
│ ├── abstract.jpg
│ ├── close.png
│ ├── loading.gif
│ ├── next.png
│ └── prev.png
├── index.html
└── js
│ ├── app.min.js
│ └── plugins.min.js
├── karma.conf.ci.js
├── karma.conf.js
├── package-lock.json
├── package.json
├── src
├── .antlr
│ ├── Calculator.interp
│ ├── Calculator.tokens
│ ├── CalculatorBaseListener.java
│ ├── CalculatorLexer.interp
│ ├── CalculatorLexer.java
│ ├── CalculatorLexer.tokens
│ ├── CalculatorListener.java
│ └── CalculatorParser.java
├── CalculationResult.ts
├── Calculator.g4
├── Calculator.spec.ts
├── Calculator.ts
├── FormulaErrorListener.ts
├── FormulaVisitor.ts
├── GeneratedAntlr
│ ├── Calculator.interp
│ ├── Calculator.tokens
│ ├── CalculatorLexer.interp
│ ├── CalculatorLexer.tokens
│ ├── CalculatorLexer.ts
│ ├── CalculatorListener.ts
│ ├── CalculatorParser.ts
│ └── CalculatorVisitor.ts
└── index.ts
├── tsconfig.json
├── tsconfig.spec.json
├── webpack-test.config.js
└── webpack.config.js
/.gitignore:
--------------------------------------------------------------------------------
1 | ## Ignore Visual Studio temporary files, build results, and
2 | ## files generated by popular Visual Studio add-ons.
3 |
4 | # User-specific files
5 | *.suo
6 | *.user
7 | *.userosscache
8 | *.sln.docstates
9 |
10 | # User-specific files (MonoDevelop/Xamarin Studio)
11 | *.userprefs
12 |
13 | # Build results
14 | [Dd]ebug/
15 | [Dd]ebugPublic/
16 | [Rr]elease/
17 | [Rr]eleases/
18 | x64/
19 | x86/
20 | bld/
21 | [Bb]in/
22 | [Oo]bj/
23 | [Ll]og/
24 |
25 | # Visual Studio 2015 cache/options directory
26 | .vs/
27 | # Uncomment if you have tasks that create the project's static files in wwwroot
28 | #wwwroot/
29 |
30 | # MSTest test Results
31 | [Tt]est[Rr]esult*/
32 | [Bb]uild[Ll]og.*
33 |
34 | # NUNIT
35 | *.VisualState.xml
36 | TestResult.xml
37 |
38 | # Build Results of an ATL Project
39 | [Dd]ebugPS/
40 | [Rr]eleasePS/
41 | dlldata.c
42 |
43 | # DNX
44 | project.lock.json
45 | project.fragment.lock.json
46 | artifacts/
47 |
48 | *_i.c
49 | *_p.c
50 | *_i.h
51 | *.ilk
52 | *.meta
53 | *.obj
54 | *.pch
55 | *.pdb
56 | *.pgc
57 | *.pgd
58 | *.rsp
59 | *.sbr
60 | *.tlb
61 | *.tli
62 | *.tlh
63 | *.tmp
64 | *.tmp_proj
65 | *.log
66 | *.vspscc
67 | *.vssscc
68 | .builds
69 | *.pidb
70 | *.svclog
71 | *.scc
72 |
73 | # Chutzpah Test files
74 | _Chutzpah*
75 |
76 | # Visual C++ cache files
77 | ipch/
78 | *.aps
79 | *.ncb
80 | *.opendb
81 | *.opensdf
82 | *.sdf
83 | *.cachefile
84 | *.VC.db
85 | *.VC.VC.opendb
86 |
87 | # Visual Studio profiler
88 | *.psess
89 | *.vsp
90 | *.vspx
91 | *.sap
92 |
93 | # TFS 2012 Local Workspace
94 | $tf/
95 |
96 | # Guidance Automation Toolkit
97 | *.gpState
98 |
99 | # ReSharper is a .NET coding add-in
100 | _ReSharper*/
101 | *.[Rr]e[Ss]harper
102 | *.DotSettings.user
103 |
104 | # JustCode is a .NET coding add-in
105 | .JustCode
106 |
107 | # TeamCity is a build add-in
108 | _TeamCity*
109 |
110 | # DotCover is a Code Coverage Tool
111 | *.dotCover
112 |
113 | # Visual Studio code coverage results
114 | *.coverage
115 | *.coveragexml
116 |
117 | # NCrunch
118 | _NCrunch_*
119 | .*crunch*.local.xml
120 | nCrunchTemp_*
121 |
122 | # MightyMoose
123 | *.mm.*
124 | AutoTest.Net/
125 |
126 | # Web workbench (sass)
127 | .sass-cache/
128 |
129 | # Installshield output folder
130 | [Ee]xpress/
131 |
132 | # DocProject is a documentation generator add-in
133 | DocProject/buildhelp/
134 | DocProject/Help/*.HxT
135 | DocProject/Help/*.HxC
136 | DocProject/Help/*.hhc
137 | DocProject/Help/*.hhk
138 | DocProject/Help/*.hhp
139 | DocProject/Help/Html2
140 | DocProject/Help/html
141 |
142 | # Click-Once directory
143 | publish/
144 |
145 | # Publish Web Output
146 | *.[Pp]ublish.xml
147 | *.azurePubxml
148 | # TODO: Comment the next line if you want to checkin your web deploy settings
149 | # but database connection strings (with potential passwords) will be unencrypted
150 | *.pubxml
151 | *.publishproj
152 |
153 | # Microsoft Azure Web App publish settings. Comment the next line if you want to
154 | # checkin your Azure Web App publish settings, but sensitive information contained
155 | # in these scripts will be unencrypted
156 | PublishScripts/
157 |
158 | # NuGet Packages
159 | *.nupkg
160 | # The packages folder can be ignored because of Package Restore
161 | **/packages/*
162 | # except build/, which is used as an MSBuild target.
163 | !**/packages/build/
164 | # Uncomment if necessary however generally it will be regenerated when needed
165 | #!**/packages/repositories.config
166 | # NuGet v3's project.json files produces more ignoreable files
167 | *.nuget.props
168 | *.nuget.targets
169 |
170 | # Microsoft Azure Build Output
171 | csx/
172 | *.build.csdef
173 |
174 | # Microsoft Azure Emulator
175 | ecf/
176 | rcf/
177 |
178 | # Windows Store app package directories and files
179 | AppPackages/
180 | BundleArtifacts/
181 | Package.StoreAssociation.xml
182 | _pkginfo.txt
183 |
184 | # Visual Studio cache files
185 | # files ending in .cache can be ignored
186 | *.[Cc]ache
187 | # but keep track of directories ending in .cache
188 | !*.[Cc]ache/
189 |
190 | # Others
191 | ClientBin/
192 | ~$*
193 | *~
194 | *.dbmdl
195 | *.dbproj.schemaview
196 | *.jfm
197 | *.pfx
198 | *.publishsettings
199 | node_modules/
200 | orleans.codegen.cs
201 |
202 | # Since there are multiple workflows, uncomment next line to ignore bower_components
203 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
204 | #bower_components/
205 |
206 | # RIA/Silverlight projects
207 | Generated_Code/
208 |
209 | # Backup & report files from converting an old project file
210 | # to a newer Visual Studio version. Backup files are not needed,
211 | # because we have git ;-)
212 | _UpgradeReport_Files/
213 | Backup*/
214 | UpgradeLog*.XML
215 | UpgradeLog*.htm
216 |
217 | # SQL Server files
218 | *.mdf
219 | *.ldf
220 |
221 | # Business Intelligence projects
222 | *.rdl.data
223 | *.bim.layout
224 | *.bim_*.settings
225 |
226 | # Microsoft Fakes
227 | FakesAssemblies/
228 |
229 | # GhostDoc plugin setting file
230 | *.GhostDoc.xml
231 |
232 | # Node.js Tools for Visual Studio
233 | .ntvs_analysis.dat
234 |
235 | # Visual Studio 6 build log
236 | *.plg
237 |
238 | # Visual Studio 6 workspace options file
239 | *.opt
240 |
241 | # Visual Studio LightSwitch build output
242 | **/*.HTMLClient/GeneratedArtifacts
243 | **/*.DesktopClient/GeneratedArtifacts
244 | **/*.DesktopClient/ModelManifest.xml
245 | **/*.Server/GeneratedArtifacts
246 | **/*.Server/ModelManifest.xml
247 | _Pvt_Extensions
248 |
249 | # Paket dependency manager
250 | .paket/paket.exe
251 | paket-files/
252 |
253 | # FAKE - F# Make
254 | .fake/
255 |
256 | # JetBrains Rider
257 | .idea/
258 | *.sln.iml
259 |
260 | # CodeRush
261 | .cr/
262 |
263 | # Python Tools for Visual Studio (PTVS)
264 | __pycache__/
265 | *.pyc
266 | 0Suchvorgang...
267 |
268 | # TypeScript typings
269 | typings/
270 |
271 | src/*.js
272 | src/*.js.map
273 | dist/
274 |
275 | output/
276 |
277 | coverage/
278 |
--------------------------------------------------------------------------------
/.npmignore:
--------------------------------------------------------------------------------
1 | .vs/
2 | bin/
3 | obj/
4 | .gitignore
5 | *.csproj
6 | *.user
7 | *.sln
8 | *.g4
9 | *.spec.js
10 | *.spec.ts
11 | chutzpah.json
12 | index.html
13 | favicon.png
14 | tsconfig.json
15 | systemjs.config.js
16 | webpack.config.antlr.js
17 | webpack.config.js
18 | Jenkinsfile
19 | *.js.map
20 | *.tokens
21 | Web.config
22 | css/
23 | fonts/
24 | img/
25 | js/
26 |
--------------------------------------------------------------------------------
/.nuke:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GeorgDangl/antlr-calculator/d250c929d3a7b6893b30e2fa9755cb332532e94b/.nuke
--------------------------------------------------------------------------------
/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | # Changelog
2 |
3 | All notable changes to **antlr-calculator** are documented here.
4 |
5 | ## v2.4.0:
6 |
7 | - Square `[]` and curly `{}` parentheses are now also valid for formulas. They are only used to group expressions, and implicit multiplication like `2(3)=6` is not allowed with those
8 |
9 | ## v2.3.0:
10 |
11 | - Added support for ranges, e.g. `#START..#END` to implement custom sum logic
12 |
13 | ## v2.2.0:
14 |
15 | - Added support for `Min` and `Max` formulas
16 |
17 | ## v2.1.0:
18 |
19 | - The calculator now supports trailing comments in a formula, separated by a semicolon `;` at the end of the actual formula input. For example, `1 + 2; Hello World!` now just evaluates `1 + 2` and ignores everything after the semicolon `;`
20 | - Add support for substitutions in formulas
21 |
22 | ## v2.0.4:
23 |
24 | - The internal check for null or empty formulas was changed for better compatibility with Node
25 |
26 | ## v2.0.3:
27 |
28 | - Automatic creation of GitHub releases was added
29 |
30 | ## v2.0.0:
31 |
32 | - The library was updated to use the Antlr TypeScript target instead of the older JavaScript package
33 |
--------------------------------------------------------------------------------
/GitVersion.yml:
--------------------------------------------------------------------------------
1 | assembly-versioning-scheme: MajorMinorPatch
2 | assembly-file-versioning-scheme: MajorMinorPatch
3 | mode: Mainline
4 |
5 | branches:
6 | master:
7 | regex: (origin/)?master
8 | develop:
9 | increment: Patch
10 | tag: beta
11 | regex: (origin/)?dev(elop)?(ment)?$
12 | feature:
13 | increment: Inherit
14 | mode: ContinuousDeployment
15 |
--------------------------------------------------------------------------------
/Jenkinsfile:
--------------------------------------------------------------------------------
1 | pipeline {
2 | options {
3 | disableConcurrentBuilds()
4 | }
5 | agent {
6 | node {
7 | label 'master'
8 | }
9 | }
10 | environment {
11 | KeyVaultBaseUrl = credentials('AzureCiKeyVaultBaseUrl')
12 | KeyVaultClientId = credentials('AzureCiKeyVaultClientId')
13 | KeyVaultClientSecret = credentials('AzureCiKeyVaultClientSecret')
14 | NODE_OPTIONS = '--openssl-legacy-provider'
15 | }
16 | stages {
17 | stage ('Test') {
18 | steps {
19 | powershell './build.cmd Test'
20 | }
21 | post {
22 | always {
23 | xunit([
24 | JUnit(deleteOutputFiles: true, failIfNotNew: true, pattern: 'karma-results.xml', skipNoTestFiles: false, stopProcessingIfError: true)
25 | ])
26 | }
27 | }
28 | }
29 | stage ('Publish Library') {
30 | steps {
31 | powershell './build.cmd Publish'
32 | }
33 | }
34 | stage ('Deploy Demo') {
35 | steps {
36 | powershell './build.cmd DeployDemo'
37 | }
38 | }
39 | stage ('Publish GitHub Release') {
40 | steps {
41 | powershell './build.cmd PublishGitHubRelease'
42 | }
43 | }
44 | }
45 | post {
46 | always {
47 | step([$class: 'Mailer',
48 | notifyEveryUnstableBuild: true,
49 | recipients: "georg.dangl@dangl-it.com",
50 | sendToIndividuals: true])
51 | cleanWs()
52 | }
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/LICENSE.md:
--------------------------------------------------------------------------------
1 | ### The MIT License (MIT)
2 |
3 | #### Copyright (c) 2016 Georg Dangl, [https://blog.dangl.me](https://blog.dangl.me)
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in
13 | all copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | THE SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # antlr-calculator
2 |
3 | [](https://jenkins.dangl.me/job/GeorgDangl/job/antlr-calculator/job/develop/)
4 | [](https://www.npmjs.com/package/antlr-calculator)
5 |
6 | This calculator is using the [ANTLR4 TypeScript target](https://github.com/tunnelvisionlabs/antlr4ts)
7 | to calculate results from formulas that are passed in as string. Both JavaScript and TypeScript are supported.
8 |
9 | Whenever a calculation is performed, a `CalculationResult` is returned with the following properties:
10 |
11 | | Property | Type | |
12 | | ------------- | ------- | ------------------------------------------------------------------------------------------- |
13 | | isValid | boolean | `true` if the formula could be parsed and calculated, else `false` |
14 | | errorPosition | number | Position of the offending symbol in the line, 0 based index, for invalid results, else null |
15 | | errorMessage | string | ANTLR error message for invalid formulas, else null |
16 | | result | number | `NaN` for invalid formulas, else the actual result |
17 |
18 | [You can check out the live demo here!](https://antlr-calculator.dangl.me)
19 |
20 | You can find the .NET version here: https://github.com/GeorgDangl/Dangl.Calculator
21 |
22 | ## Installation
23 |
24 | Clone this repository or just go with `npm install antlr-calculator`.
25 |
26 | ## JavaScript
27 |
28 | Just reference `dist/bundle.js` and the global variable `antlrCalc` is available.
29 |
30 | ```javascript
31 | var result = antlrCalc.Calculator.calculate('4*5');
32 | console.log(JSON.stringify(result, null, 2));
33 |
34 | // {
35 | // "isValid": true,
36 | // "errorPosition": null,
37 | // "errorMessage": null,
38 | // "result": 20
39 | // }
40 | ```
41 |
42 | ## TypeScript
43 |
44 | Import the `Calculator` class and use the static `calculate(formula: string)` method to evaluate formulas.
45 |
46 | ```typescript
47 | import { Calculator } from 'antlr-calculator';
48 |
49 | var result = Calculator.calculate('4*5');
50 | console.log(JSON.stringify(result, null, 2));
51 |
52 | // {
53 | // "isValid": true,
54 | // "errorPosition": null,
55 | // "errorMessage": null,
56 | // "result": 20
57 | // }
58 | ```
59 |
60 | ## Supported functions
61 |
62 | | Expression | |
63 | | -------------------------------------------- | --------------------------------------------------------------- |
64 | | `FLOOR expression` | Round down to zero accuracy |
65 | | `CEIL expression` | Round up to zero accuracy |
66 | | `ABS expression` | Absolute value |
67 | | `ROUNDK '(' expression ';' expression ')'` | Round expr_1 with expr_2 accuracy |
68 | | `ROUND expression` | Round with zero accuracy |
69 | | `TRUNC expression` | Trim decimal digits |
70 | | `SIN expression` | Sinus |
71 | | `COS expression` | Cosinus |
72 | | `TAN expression` | Tangens |
73 | | `COT expression` | Cotangens |
74 | | `SINH expression` | Sinus Hypererbolicus |
75 | | `COSH expression` | Cosinus Hyperbolicus |
76 | | `TANH expression` | Tangens Hyperbolicus |
77 | | `ARCSIN expression` | Inverse Sinus |
78 | | `ARCCOS expression` | Inverse Cosinus |
79 | | `ARCTAN expression` | Inverse Tangens |
80 | | `ARCTAN2 '(' expression ';' expression ')'` | Atan2 |
81 | | `ARCCOT expression` | Inverse Cotangens |
82 | | `EXP expression` | e ^ expr |
83 | | `LN expression` | Logarithm to e |
84 | | `EEX expression` | 10 ^ expr |
85 | | `LOG expression` | Logarithm to 10 |
86 | | `RAD expression` | Angle to radians (360° base) |
87 | | `DEG expression` | Radians to angle (360° base) |
88 | | `SQRT expression` | Square root |
89 | | `SQR expression` | Square product |
90 | | `expression op = ('^' \| '\*\*') expression` | expr_1 to the expr_2 th power |
91 | | `expression (MOD \| '%' ) expression` | Modulo |
92 | | `expression DIV expression` | Whole part of division rest |
93 | | `expression op = ('~' \| '//') expression` | expr_1 nth root of expr_2 |
94 | | `expression op = ('\*' \| '/') expression` | Multiplication or division |
95 | | `expression op = ('+' \| '-') expression` | Addition or subtraction |
96 | | `NUMBER` | Single integer or float number |
97 | | `'(' expression ')'` | Expression within parentheses |
98 | | `MIN '(' expression (';' expression)* ')'` | Minimum |
99 | | `MAX '(' expression (';' expression)* ')'` | Maximum |
100 | | `PI '()'?` | Mathematical constant pi = 3,141593 |
101 | | `expression E+ expression` | Exponent, e.g. 10e+43 |
102 | | `expression E- expression` | Inverted Exponent, e.g. 10e-43 |
103 | | `EULER` | Mathematical constant e = 2,718282 |
104 | | `'-' expression` | Unary minus sign (negative numbers) |
105 | | `'+' expression` | Unary plus sign (positive numbers) |
106 | | `'(' expression ')' expression` | Expressions without multiplication sign, e.g. `2(3)` -> `2*(3)` |
107 | | `expression '(' expression ')'` | Expressions without multiplication sign, e.g. `2(3)` -> `2*(3)` |
108 |
109 | _expression_ may be any expression as functions can be nested. Example: `DEG(2*PI)` or `LOG(10^3)`.
110 |
111 | Formulas can be case invariant, e.g. `SIN`, `sin` and `siN` are all considered the same.
112 |
113 | ## Comments in Formulas
114 |
115 | Comments in Formulas are supported by encapsulating them either in `/*...*/`, `'...'` or `"..."` quote styles. Examples:
116 |
117 | `4/*Length*/*3/*Width*/` resolves to `12`
118 |
119 | `4'Length'*3'Width'` resolves to `12`
120 |
121 | `4"Length"*3"Width"` resolves to `12`
122 |
123 | ## Substitutions
124 |
125 | The calculator can be called with an overload that accepts a callback function for substitution values. For example, take the following formula:
126 | `1,2*#Z4+3`
127 | Here, `#Z4` is a _substitution_, which is a placeholder that can be externally supplied. Let's say you want to resolve `#Z4` to the value three, you could make this simple call:
128 |
129 | ```typescript
130 | const formula = '1,2*#Z4+3';
131 | const result = Calculator.calculate(formula, (substitution) => {
132 | if (substitution === '#Z4') {
133 | return 3;
134 | }
135 |
136 | return null;
137 | });
138 | ```
139 |
140 | The callback is in the form of a `(substitution: string) => number`, and it will be called for every substitution found in the formula. Multiple substitutions are supported. If duplicates in substitutions are present, the calculator will request each one individually. If a substitution resolves to `null`, the formula is considered invalid.
141 |
142 | Substitutions must always start with the `#` character and can then have the following characters: `[a-z] | [A-Z] | [äÄöÖüÜ] | [0-9]`
143 |
144 | ## Trailing comments
145 |
146 | Formulas may be terminated with a semicolon `;` at the end, followed by extra input that is not evaluated. This is useful when, instead of regular comments, you
147 | just want to attach some trailing formation at the end of a formula. For example, the following formula:
148 | `1 + 3; As per our counting`
149 | Would just evaluate the `1 + 3` portion and return a valid result with the value `4`, ignoring the trailing semicolon and all input that follows.
150 |
151 | ---
152 |
153 | [MIT License](License.md)
154 |
--------------------------------------------------------------------------------
/build.cmd:
--------------------------------------------------------------------------------
1 | :; set -eo pipefail
2 | :; ./build.sh "$@"
3 | :; exit $?
4 |
5 | @ECHO OFF
6 | powershell -ExecutionPolicy ByPass -NoProfile %0\..\build.ps1 %*
7 |
--------------------------------------------------------------------------------
/build.ps1:
--------------------------------------------------------------------------------
1 | [CmdletBinding()]
2 | Param(
3 | [Parameter(Position=0,Mandatory=$false,ValueFromRemainingArguments=$true)]
4 | [string[]]$BuildArguments
5 | )
6 |
7 | Write-Output "PowerShell $($PSVersionTable.PSEdition) version $($PSVersionTable.PSVersion)"
8 |
9 | Set-StrictMode -Version 2.0; $ErrorActionPreference = "Stop"; $ConfirmPreference = "None"; trap { Write-Error $_ -ErrorAction Continue; exit 1 }
10 | $PSScriptRoot = Split-Path $MyInvocation.MyCommand.Path -Parent
11 |
12 | ###########################################################################
13 | # CONFIGURATION
14 | ###########################################################################
15 |
16 | $BuildProjectFile = "$PSScriptRoot\build\_build.csproj"
17 | $TempDirectory = "$PSScriptRoot\\.tmp"
18 |
19 | $DotNetGlobalFile = "$PSScriptRoot\\global.json"
20 | $DotNetInstallUrl = "https://dot.net/v1/dotnet-install.ps1"
21 | $DotNetChannel = "Current"
22 |
23 | $env:DOTNET_SKIP_FIRST_TIME_EXPERIENCE = 1
24 | $env:DOTNET_CLI_TELEMETRY_OPTOUT = 1
25 |
26 | ###########################################################################
27 | # EXECUTION
28 | ###########################################################################
29 |
30 | function ExecSafe([scriptblock] $cmd) {
31 | & $cmd
32 | if ($LASTEXITCODE) { exit $LASTEXITCODE }
33 | }
34 |
35 | # If global.json exists, load expected version
36 | if (Test-Path $DotNetGlobalFile) {
37 | $DotNetGlobal = $(Get-Content $DotNetGlobalFile | Out-String | ConvertFrom-Json)
38 | if ($DotNetGlobal.PSObject.Properties["sdk"] -and $DotNetGlobal.sdk.PSObject.Properties["version"]) {
39 | $DotNetVersion = $DotNetGlobal.sdk.version
40 | }
41 | }
42 |
43 | # If dotnet is installed locally, and expected version is not set or installation matches the expected version
44 | if ($null -ne (Get-Command "dotnet" -ErrorAction SilentlyContinue) -and `
45 | (!(Test-Path variable:DotNetVersion) -or $(& dotnet --version) -eq $DotNetVersion)) {
46 | $env:DOTNET_EXE = (Get-Command "dotnet").Path
47 | }
48 | else {
49 | $DotNetDirectory = "$TempDirectory\dotnet-win"
50 | $env:DOTNET_EXE = "$DotNetDirectory\dotnet.exe"
51 |
52 | # Download install script
53 | $DotNetInstallFile = "$TempDirectory\dotnet-install.ps1"
54 | New-Item -ItemType Directory -Path $TempDirectory -Force | Out-Null
55 | [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
56 | (New-Object System.Net.WebClient).DownloadFile($DotNetInstallUrl, $DotNetInstallFile)
57 |
58 | # Install by channel or version
59 | if (!(Test-Path variable:DotNetVersion)) {
60 | ExecSafe { & $DotNetInstallFile -InstallDir $DotNetDirectory -Channel $DotNetChannel -NoPath }
61 | } else {
62 | ExecSafe { & $DotNetInstallFile -InstallDir $DotNetDirectory -Version $DotNetVersion -NoPath }
63 | }
64 | }
65 |
66 | Write-Output "Microsoft (R) .NET Core SDK version $(& $env:DOTNET_EXE --version)"
67 |
68 | ExecSafe { & $env:DOTNET_EXE build $BuildProjectFile /nodeReuse:false -nologo -clp:NoSummary --verbosity quiet }
69 | ExecSafe { & $env:DOTNET_EXE run --project $BuildProjectFile --no-build -- $BuildArguments }
70 |
--------------------------------------------------------------------------------
/build.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | echo $(bash --version 2>&1 | head -n 1)
4 |
5 | set -eo pipefail
6 | SCRIPT_DIR=$(cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd)
7 |
8 | ###########################################################################
9 | # CONFIGURATION
10 | ###########################################################################
11 |
12 | BUILD_PROJECT_FILE="$SCRIPT_DIR/build/_build.csproj"
13 | TEMP_DIRECTORY="$SCRIPT_DIR//.tmp"
14 |
15 | DOTNET_GLOBAL_FILE="$SCRIPT_DIR//global.json"
16 | DOTNET_INSTALL_URL="https://dot.net/v1/dotnet-install.sh"
17 | DOTNET_CHANNEL="Current"
18 |
19 | export DOTNET_CLI_TELEMETRY_OPTOUT=1
20 | export DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1
21 |
22 | ###########################################################################
23 | # EXECUTION
24 | ###########################################################################
25 |
26 | function FirstJsonValue {
27 | perl -nle 'print $1 if m{"'$1'": "([^"]+)",?}' <<< ${@:2}
28 | }
29 |
30 | # If global.json exists, load expected version
31 | if [[ -f "$DOTNET_GLOBAL_FILE" ]]; then
32 | DOTNET_VERSION=$(FirstJsonValue "version" $(cat "$DOTNET_GLOBAL_FILE"))
33 | if [[ "$DOTNET_VERSION" == "" ]]; then
34 | unset DOTNET_VERSION
35 | fi
36 | fi
37 |
38 | # If dotnet is installed locally, and expected version is not set or installation matches the expected version
39 | if [[ -x "$(command -v dotnet)" && (-z ${DOTNET_VERSION+x} || $(dotnet --version 2>&1) == "$DOTNET_VERSION") ]]; then
40 | export DOTNET_EXE="$(command -v dotnet)"
41 | else
42 | DOTNET_DIRECTORY="$TEMP_DIRECTORY/dotnet-unix"
43 | export DOTNET_EXE="$DOTNET_DIRECTORY/dotnet"
44 |
45 | # Download install script
46 | DOTNET_INSTALL_FILE="$TEMP_DIRECTORY/dotnet-install.sh"
47 | mkdir -p "$TEMP_DIRECTORY"
48 | curl -Lsfo "$DOTNET_INSTALL_FILE" "$DOTNET_INSTALL_URL"
49 | chmod +x "$DOTNET_INSTALL_FILE"
50 |
51 | # Install by channel or version
52 | if [[ -z ${DOTNET_VERSION+x} ]]; then
53 | "$DOTNET_INSTALL_FILE" --install-dir "$DOTNET_DIRECTORY" --channel "$DOTNET_CHANNEL" --no-path
54 | else
55 | "$DOTNET_INSTALL_FILE" --install-dir "$DOTNET_DIRECTORY" --version "$DOTNET_VERSION" --no-path
56 | fi
57 | fi
58 |
59 | echo "Microsoft (R) .NET Core SDK version $("$DOTNET_EXE" --version)"
60 |
61 | "$DOTNET_EXE" build "$BUILD_PROJECT_FILE" /nodeReuse:false -nologo -clp:NoSummary --verbosity quiet
62 | "$DOTNET_EXE" run --project "$BUILD_PROJECT_FILE" --no-build -- "$@"
63 |
--------------------------------------------------------------------------------
/build/.editorconfig:
--------------------------------------------------------------------------------
1 | [*.cs]
2 | dotnet_style_qualification_for_field = false:warning
3 | dotnet_style_qualification_for_property = false:warning
4 | dotnet_style_qualification_for_method = false:warning
5 | dotnet_style_qualification_for_event = false:warning
6 | dotnet_style_require_accessibility_modifiers = never:warning
7 |
8 | csharp_style_expression_bodied_methods = true:silent
9 | csharp_style_expression_bodied_properties = true:warning
10 | csharp_style_expression_bodied_indexers = true:warning
11 | csharp_style_expression_bodied_accessors = true:warning
12 |
--------------------------------------------------------------------------------
/build/Build.cs:
--------------------------------------------------------------------------------
1 | using Nuke.Common;
2 | using Nuke.Common.Execution;
3 | using Nuke.Common.Tools.GitVersion;
4 | using static Nuke.Common.IO.FileSystemTasks;
5 | using static Nuke.Common.Tools.Npm.NpmTasks;
6 | using static Nuke.Common.ChangeLog.ChangelogTasks;
7 | using static Nuke.Common.IO.TextTasks;
8 | using static Nuke.GitHub.GitHubTasks;
9 | using Nuke.GitHub;
10 | using Nuke.Common.Git;
11 | using System;
12 | using System.Linq;
13 | using Nuke.Common.IO;
14 | using System.IO.Compression;
15 | using System.Text;
16 | using System.Net.Http;
17 | using Nuke.Common.Tools.AzureKeyVault.Attributes;
18 | using Nuke.Common.Tools.AzureKeyVault;
19 | using static Nuke.Common.Tools.Slack.SlackTasks;
20 | using Nuke.Common.Tools.Slack;
21 | using System.IO;
22 | using Nuke.Common.Tools.Teams;
23 |
24 | [UnsetVisualStudioEnvironmentVariables]
25 | class Build : NukeBuild
26 | {
27 | /// Support plugins are available for:
28 | /// - JetBrains ReSharper https://nuke.build/resharper
29 | /// - JetBrains Rider https://nuke.build/rider
30 | /// - Microsoft VisualStudio https://nuke.build/visualstudio
31 | /// - Microsoft VSCode https://nuke.build/vscode
32 |
33 | public static int Main() => Execute(x => x.Clean);
34 |
35 | [Parameter] readonly string Configuration = IsLocalBuild ? "Debug" : "Release";
36 |
37 | [GitVersion(Framework = "netcoreapp3.1")] readonly GitVersion GitVersion;
38 | [GitRepository] readonly GitRepository GitRepository;
39 |
40 | AbsolutePath ChangeLogFile => RootDirectory / "CHANGELOG.md";
41 | AbsolutePath OutputDirectory => RootDirectory / "output";
42 |
43 | [KeyVaultSettings(
44 | BaseUrlParameterName = nameof(KeyVaultBaseUrl),
45 | ClientIdParameterName = nameof(KeyVaultClientId),
46 | ClientSecretParameterName = nameof(KeyVaultClientSecret))]
47 | readonly KeyVaultSettings KeyVaultSettings;
48 | [Parameter] string KeyVaultBaseUrl;
49 | [Parameter] string KeyVaultClientId;
50 | [Parameter] string KeyVaultClientSecret;
51 | [KeyVault] KeyVault KeyVault;
52 |
53 | [KeyVaultSecret] string DanglCiCdSlackWebhookUrl;
54 | [KeyVaultSecret("AntlrCalculatorDemo-WebDeployUsername")] string WebDeployUsername;
55 | [KeyVaultSecret("AntlrCalculatorDemo-WebDeployPassword")] string WebDeployPassword;
56 | [KeyVaultSecret] string GitHubAuthenticationToken;
57 | [KeyVaultSecret] readonly string DanglCiCdTeamsWebhookUrl;
58 | [Parameter] string AppServiceName = "antlr-calculator-demo";
59 |
60 | protected override void OnTargetFailed(string target)
61 | {
62 | if (IsServerBuild)
63 | {
64 | SendTeamsMessage("Build Failed", $"Target {target} failed for antlr-calculator, " +
65 | $"Branch: {GitRepository.Branch}", true);
66 | }
67 | }
68 |
69 | void SendTeamsMessage(string title, string message, bool isError)
70 | {
71 | if (!string.IsNullOrWhiteSpace(DanglCiCdTeamsWebhookUrl))
72 | {
73 | var themeColor = isError ? "f44336" : "00acc1";
74 | TeamsTasks
75 | .SendTeamsMessage(m => m
76 | .SetTitle(title)
77 | .SetText(message)
78 | .SetThemeColor(themeColor),
79 | DanglCiCdTeamsWebhookUrl);
80 | }
81 | }
82 |
83 | Target Clean => _ => _
84 | .Executes(() =>
85 | {
86 | DeleteDirectory(RootDirectory / "dist");
87 | DeleteDirectory(RootDirectory / "demo" / "dist");
88 | DeleteDirectory(RootDirectory / "coverage");
89 | DeleteFile(RootDirectory / "karma-results.xml");
90 | EnsureCleanDirectory(OutputDirectory);
91 | });
92 |
93 | Target Test => _ => _
94 | .DependsOn(Clean)
95 | .Executes(() =>
96 | {
97 | Npm("ci", RootDirectory);
98 | Npm("run test:ci", RootDirectory);
99 | });
100 |
101 | Target Publish => _ => _
102 | .DependsOn(Clean)
103 | .OnlyWhenDynamic(() => Nuke.Common.CI.Jenkins.Jenkins.Instance == null
104 | || Nuke.Common.CI.Jenkins.Jenkins.Instance.ChangeId == null)
105 | .Executes(() =>
106 | {
107 | Npm("ci", RootDirectory);
108 | Npm("run build", RootDirectory);
109 | var distDirectory = RootDirectory / "dist";
110 | CopyDirectoryRecursively(RootDirectory / "demo" / "dist", distDirectory);
111 | CopyFile(RootDirectory / "README.md", distDirectory / "README.md");
112 | CopyFile(RootDirectory / "LICENSE.md", distDirectory / "LICENSE.md");
113 | CopyFile(RootDirectory / "CHANGELOG.md", distDirectory / "CHANGELOG.md");
114 | CopyFile(RootDirectory / "package.json", distDirectory / "package.json");
115 | Npm($"version {GitVersion.NuGetVersion}", distDirectory);
116 |
117 | var npmTag = GitVersion.BranchName.Equals("master") || GitVersion.BranchName.Equals("origin/master")
118 | ? "latest"
119 | : "next";
120 |
121 | Npm($"publish --tag={npmTag}", distDirectory);
122 |
123 | if (npmTag == "latest")
124 | {
125 | SendTeamsMessage("New Release", $"New release available for antlr-calculator: {GitVersion.NuGetVersion}", false);
126 | }
127 |
128 | });
129 |
130 | Target DeployDemo => _ => _
131 | .DependsOn(Clean)
132 | .Requires(() => WebDeployUsername)
133 | .Requires(() => WebDeployPassword)
134 | .Requires(() => AppServiceName)
135 | .Requires(() => DanglCiCdSlackWebhookUrl)
136 | .OnlyWhenDynamic(() => Nuke.Common.CI.Jenkins.Jenkins.Instance == null
137 | || Nuke.Common.CI.Jenkins.Jenkins.Instance.ChangeId == null)
138 | .Executes(async () =>
139 | {
140 | Npm("ci", RootDirectory);
141 | Npm("run build", RootDirectory);
142 | WriteAllText(RootDirectory / "demo" / "index.html", ReadAllText(RootDirectory / "demo" / "index.html")
143 | .Replace("@@APP_VERSION@@", GitVersion.NuGetVersion));
144 |
145 | var base64Auth = Convert.ToBase64String(Encoding.Default.GetBytes($"{WebDeployUsername}:{WebDeployPassword}"));
146 | ZipFile.CreateFromDirectory(RootDirectory / "demo", OutputDirectory / "deployment.zip");
147 | using (var memStream = new MemoryStream(ReadAllBytes(OutputDirectory / "deployment.zip")))
148 | {
149 | memStream.Position = 0;
150 | var content = new StreamContent(memStream);
151 | var httpClient = new HttpClient();
152 | httpClient.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Basic", base64Auth);
153 | var requestUrl = $"https://{AppServiceName}.scm.azurewebsites.net/api/zipdeploy";
154 | var response = await httpClient.PostAsync(requestUrl, content);
155 | var responseString = await response.Content.ReadAsStringAsync();
156 | Logger.Normal(responseString);
157 | Logger.Normal("Deployment finished");
158 | if (!response.IsSuccessStatusCode)
159 | {
160 | ControlFlow.Fail("Deployment returned status code: " + response.StatusCode);
161 | }
162 | else
163 | {
164 | await SendSlackMessageAsync(c => c
165 | .SetUsername("Dangl CI Build")
166 | .SetAttachments(new SlackMessageAttachment()
167 | .SetText($"A new version was deployed for antlr-calculator")
168 | .SetColor("good")
169 | .SetFields(new[]
170 | {
171 | new SlackMessageField
172 | ()
173 | .SetTitle("Version")
174 | .SetValue(GitVersion.NuGetVersion)
175 | })),
176 | DanglCiCdSlackWebhookUrl);
177 | }
178 | }
179 | });
180 |
181 | Target PublishGitHubRelease => _ => _
182 | .Requires(() => GitHubAuthenticationToken)
183 | .OnlyWhenDynamic(() => GitVersion.BranchName.Equals("master") || GitVersion.BranchName.Equals("origin/master"))
184 | .Executes(async () =>
185 | {
186 | var releaseTag = $"v{GitVersion.MajorMinorPatch}";
187 |
188 | var changeLogSectionEntries = ExtractChangelogSectionNotes(ChangeLogFile);
189 | var latestChangeLog = changeLogSectionEntries
190 | .Aggregate((c, n) => c + Environment.NewLine + n);
191 | var completeChangeLog = $"## {releaseTag}" + Environment.NewLine + latestChangeLog;
192 |
193 | var repositoryInfo = GetGitHubRepositoryInfo(GitRepository);
194 |
195 | await PublishRelease(x => x
196 | .SetCommitSha(GitVersion.Sha)
197 | .SetReleaseNotes(completeChangeLog)
198 | .SetRepositoryName(repositoryInfo.repositoryName)
199 | .SetRepositoryOwner(repositoryInfo.gitHubOwner)
200 | .SetTag(releaseTag)
201 | .SetToken(GitHubAuthenticationToken));
202 | });
203 | }
204 |
--------------------------------------------------------------------------------
/build/_build.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | netcoreapp3.1
6 |
7 | CS0649;CS0169
8 | ..
9 | ..
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/build/_build.csproj.DotSettings:
--------------------------------------------------------------------------------
1 |
2 | DO_NOT_SHOW
3 | DO_NOT_SHOW
4 | DO_NOT_SHOW
5 | DO_NOT_SHOW
6 | Implicit
7 | Implicit
8 | ExpressionBody
9 | 0
10 | NEXT_LINE
11 | True
12 | False
13 | 120
14 | IF_OWNER_IS_SINGLE_LINE
15 | WRAP_IF_LONG
16 | False
17 | <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" />
18 | <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" />
19 | True
20 | True
21 | True
22 | True
23 | True
24 | True
25 | True
26 | True
27 |
--------------------------------------------------------------------------------
/demo/Web.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/demo/css/custom-menu.css:
--------------------------------------------------------------------------------
1 |
2 |
3 | /* Below is to have nav menu use primary color instead of white */
4 | .ms-navbar .navbar-collapse .navbar-nav .nav-item > a:before, .ms-lead-navbar .navbar-collapse .navbar-nav .nav-item > a:before {
5 | background-color: #00acc1;
6 | }
7 |
8 | .ms-navbar .navbar-collapse .navbar-nav .nav-item a:hover,
9 | .ms-navbar .navbar-collapse .navbar-nav .nav-item.active a:hover,
10 | .ms-navbar .navbar-collapse .navbar-nav .nav-item.dropdown.show a,
11 | .ms-navbar .navbar-collapse .navbar-nav .nav-item.dropdown.show a:hover,
12 | .ms-navbar .navbar-collapse .navbar-nav .nav-item.dropdown.show.active a:hover,
13 | .ms-navbar .navbar-collapse .navbar-nav .nav-item a:focus,
14 | .ms-navbar .navbar-collapse .navbar-nav .nav-item.active a:focus,
15 | .ms-navbar .navbar-collapse .navbar-nav .nav-item.dropdown.show a:focus,
16 | .ms-navbar .navbar-collapse .navbar-nav .nav-item.dropdown.show.active a:focus {
17 | color: #fff;
18 | }
19 |
20 | .ms-navbar .navbar-collapse .navbar-nav .nav-item.dropdown .dropdown-menu {
21 | background-color: #424242;
22 | color: #fff;
23 | }
24 |
25 | .ms-navbar .navbar-collapse .navbar-nav .nav-item.dropdown .dropdown-menu li .dropdown-item,
26 | .ms-navbar .navbar-collapse .navbar-nav .nav-item.dropdown .dropdown-menu li .dropdown-item:focus,
27 | .ms-navbar .navbar-collapse .navbar-nav .nav-item.dropdown .dropdown-menu li .dropdown-item:hover {
28 | background-color: #424242;
29 | color: #fff;
30 | }
31 |
32 | .ms-navbar .navbar-collapse .navbar-nav .nav-item.dropdown .dropdown-menu li.active .dropdown-item
33 | {
34 | background-color: #00acc1;
35 | color: #fff;
36 | }
37 |
38 | .ms-navbar .navbar-collapse .navbar-nav .nav-item.dropdown .dropdown-menu li .dropdown-item:hover,
39 | .ms-navbar .navbar-collapse .navbar-nav .nav-item.dropdown .dropdown-menu li .dropdown-item:focus,
40 | .ms-lead-navbar .navbar-collapse .navbar-nav .nav-item.dropdown .dropdown-menu li .dropdown-item:hover,
41 | .ms-lead-navbar .navbar-collapse .navbar-nav .nav-item.dropdown .dropdown-menu li .dropdown-item:focus {
42 | background-color: #00acc1;
43 | color: #fff;
44 | }
45 |
46 | .ms-navbar .navbar-nav li.active > a, .ms-navbar .navbar-nav li.active > a:hover, .ms-navbar .navbar-nav li.active > a {
47 | background-color: #00acc1;
48 | color: #fff;
49 | }
50 |
--------------------------------------------------------------------------------
/demo/css/custom-styles.css:
--------------------------------------------------------------------------------
1 | .ms-slidebar .ms-slidebar-header {
2 | background-image: url(../img/abstract.jpg);
3 | background-size: cover;
4 | }
5 |
6 | .menu-flag {
7 | height: 40px;
8 | padding: 10px 0;
9 | }
10 |
11 | .slidenav-flag {
12 | max-height: 25px;
13 | }
14 |
15 | .two_cols {
16 | width: 100%;
17 | overflow: hidden;
18 | font-size: large;
19 | }
20 | .two_cols li {
21 | float: left;
22 | width: 50%;
23 | margin-bottom: 2rem;
24 | }
25 | .two_cols li a {
26 | display: block;
27 | padding: 2px 0;
28 | }
29 | .two_cols li a i {
30 | margin-right: 10px;
31 | width: 15px;
32 | text-align: center;
33 | color: #00acc1;
34 | }
35 | .two_cols li a:hover i {
36 | transition: all ease 0.5s;
37 | color: #ffa726;
38 | transform: rotateY(360deg);
39 | }
40 |
41 | .post-preview-image {
42 | max-width: 75px;
43 | max-height: 75px;
44 | }
45 |
46 | .ms-footer-media .media {
47 | margin-bottom: 0;
48 | }
49 |
50 | .contact-social-media a {
51 | margin: 0 5px;
52 | }
53 |
54 | .ms-footer .ms-logo {
55 | margin-right: 0.5rem;
56 | transform: scale(0.8);
57 | }
58 |
59 | .ms-hero-bg-dark-light .card {
60 | color: #757575;
61 | }
62 |
63 | .break-word-wrap {
64 | word-wrap: break-word;
65 | }
66 |
67 | .product-description img {
68 | max-width: 100%;
69 | }
70 |
71 | .no-line-break {
72 | white-space: nowrap;
73 | }
74 |
75 | @media (max-width: 480px) {
76 | .no-line-break {
77 | font-size: 24px;
78 | }
79 | }
80 |
81 | .same-icon-width i {
82 | min-width: 13px;
83 | }
84 |
85 | .text-left {
86 | text-align: left;
87 | }
88 |
89 | .full-height-thumbnail {
90 | height:100%;
91 | }
92 |
93 | .full-height {
94 | height: 100%;
95 | }
96 |
97 | .full-width-card {
98 | width: 100%;
99 | }
100 |
101 | @media (min-width: 1024px) {
102 | .container {
103 | padding-right: 0;
104 | padding-left: 0;
105 | }
106 | }
107 |
108 | .no-border {
109 | border: none;
110 | }
111 |
112 | .article-body img {
113 | max-width: 100%;
114 | }
115 |
116 | .customer-review-carousel-inner {
117 | padding: 0 20px;
118 | }
119 |
120 | @media (max-width: 480px) {
121 | .card blockquote.blockquote.blockquote-avatar {
122 | padding: 1rem;
123 | font-size: 1.4rem;
124 | }
125 | }
126 |
127 | @media (max-width: 1199px) {
128 | .ms-navbar.navbar .container .navbar-collapse .navbar-nav .nav-item a {
129 | padding: 0 14px;
130 | }
131 | }
132 |
133 | @media (max-width: 992px) {
134 | .ms-navbar.navbar .container .navbar-collapse .navbar-nav .nav-item a {
135 | padding: 0 8px;
136 | }
137 | }
138 |
139 | .btn:disabled,
140 | .btn[disabled][disabled] {
141 | background-color: #00acc1;
142 | }
143 |
--------------------------------------------------------------------------------
/demo/favicon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GeorgDangl/antlr-calculator/d250c929d3a7b6893b30e2fa9755cb332532e94b/demo/favicon.png
--------------------------------------------------------------------------------
/demo/fonts/FontAwesome.otf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GeorgDangl/antlr-calculator/d250c929d3a7b6893b30e2fa9755cb332532e94b/demo/fonts/FontAwesome.otf
--------------------------------------------------------------------------------
/demo/fonts/Material-Design-Iconic-Font.eot:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GeorgDangl/antlr-calculator/d250c929d3a7b6893b30e2fa9755cb332532e94b/demo/fonts/Material-Design-Iconic-Font.eot
--------------------------------------------------------------------------------
/demo/fonts/Material-Design-Iconic-Font.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GeorgDangl/antlr-calculator/d250c929d3a7b6893b30e2fa9755cb332532e94b/demo/fonts/Material-Design-Iconic-Font.ttf
--------------------------------------------------------------------------------
/demo/fonts/Material-Design-Iconic-Font.woff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GeorgDangl/antlr-calculator/d250c929d3a7b6893b30e2fa9755cb332532e94b/demo/fonts/Material-Design-Iconic-Font.woff
--------------------------------------------------------------------------------
/demo/fonts/Material-Design-Iconic-Font.woff2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GeorgDangl/antlr-calculator/d250c929d3a7b6893b30e2fa9755cb332532e94b/demo/fonts/Material-Design-Iconic-Font.woff2
--------------------------------------------------------------------------------
/demo/fonts/fontawesome-webfont.eot:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GeorgDangl/antlr-calculator/d250c929d3a7b6893b30e2fa9755cb332532e94b/demo/fonts/fontawesome-webfont.eot
--------------------------------------------------------------------------------
/demo/fonts/fontawesome-webfont.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GeorgDangl/antlr-calculator/d250c929d3a7b6893b30e2fa9755cb332532e94b/demo/fonts/fontawesome-webfont.ttf
--------------------------------------------------------------------------------
/demo/fonts/fontawesome-webfont.woff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GeorgDangl/antlr-calculator/d250c929d3a7b6893b30e2fa9755cb332532e94b/demo/fonts/fontawesome-webfont.woff
--------------------------------------------------------------------------------
/demo/fonts/fontawesome-webfont.woff2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GeorgDangl/antlr-calculator/d250c929d3a7b6893b30e2fa9755cb332532e94b/demo/fonts/fontawesome-webfont.woff2
--------------------------------------------------------------------------------
/demo/fonts/glyphicons-halflings-regular.eot:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GeorgDangl/antlr-calculator/d250c929d3a7b6893b30e2fa9755cb332532e94b/demo/fonts/glyphicons-halflings-regular.eot
--------------------------------------------------------------------------------
/demo/fonts/glyphicons-halflings-regular.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GeorgDangl/antlr-calculator/d250c929d3a7b6893b30e2fa9755cb332532e94b/demo/fonts/glyphicons-halflings-regular.ttf
--------------------------------------------------------------------------------
/demo/fonts/glyphicons-halflings-regular.woff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GeorgDangl/antlr-calculator/d250c929d3a7b6893b30e2fa9755cb332532e94b/demo/fonts/glyphicons-halflings-regular.woff
--------------------------------------------------------------------------------
/demo/fonts/glyphicons-halflings-regular.woff2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GeorgDangl/antlr-calculator/d250c929d3a7b6893b30e2fa9755cb332532e94b/demo/fonts/glyphicons-halflings-regular.woff2
--------------------------------------------------------------------------------
/demo/img/abstract.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GeorgDangl/antlr-calculator/d250c929d3a7b6893b30e2fa9755cb332532e94b/demo/img/abstract.jpg
--------------------------------------------------------------------------------
/demo/img/close.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GeorgDangl/antlr-calculator/d250c929d3a7b6893b30e2fa9755cb332532e94b/demo/img/close.png
--------------------------------------------------------------------------------
/demo/img/loading.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GeorgDangl/antlr-calculator/d250c929d3a7b6893b30e2fa9755cb332532e94b/demo/img/loading.gif
--------------------------------------------------------------------------------
/demo/img/next.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GeorgDangl/antlr-calculator/d250c929d3a7b6893b30e2fa9755cb332532e94b/demo/img/next.png
--------------------------------------------------------------------------------
/demo/img/prev.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GeorgDangl/antlr-calculator/d250c929d3a7b6893b30e2fa9755cb332532e94b/demo/img/prev.png
--------------------------------------------------------------------------------
/demo/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | antlr-calculator Demo
6 |
7 |
8 |
12 |
13 |
17 |
23 |
27 |
31 |
32 |
33 |
34 |
35 |
36 |
63 |
64 |
65 |
66 |
67 |
77 |
78 |
132 |
133 |
134 |
antlr-calculator-demo
135 |
Version @@APP_VERSION@@
136 |
Enter your formula here:
137 |
138 |
145 |
146 |
148 |
Result:
149 |
150 |
151 |
152 |
171 |
172 | Fork me on GitHub
178 |
179 |
180 |
181 |
182 |
--------------------------------------------------------------------------------
/demo/js/app.min.js:
--------------------------------------------------------------------------------
1 | function openConf(t){$("#ms-configurator").animate({right:"0px"},400),$(".ms-configurator-btn").animate({right:"-60px"},200)}function closeConf(){$("#ms-configurator").animate({right:"-310px"},200),$(".ms-configurator-btn").animate({right:"20px"},400)}function slidebar(){var t=$(".ms-slidebar"),o=$(".ms-site-container"),n=$(".ms-toggle-left"),e=!1,i=!1;n.click(function(){i?(t.removeClass("open"),i=!1):(t.addClass("open"),i=!0),e=!0}),o.click(function(){!e&&i&&(t.removeClass("open"),i=!1),e=!1})}!function(c,p,t){var u=c();c.fn.dropdownHover=function(l){return"ontouchstart"in document?this:(u=u.add(this.parent()),this.each(function(){var o,n,e=c(this),i=e.parent(),t={delay:c(this).data("delay"),hoverDelay:c(this).data("hover-delay"),instantlyCloseOthers:c(this).data("close-others")},a="show.bs.dropdown",s=c.extend(!0,{},{delay:0,hoverDelay:0,instantlyCloseOthers:!0},l,t);function r(t){p.clearTimeout(o),p.clearTimeout(n),n=p.setTimeout(function(){u.find(":focus").blur(),!0===s.instantlyCloseOthers&&u.removeClass("show"),p.clearTimeout(n),e.attr("aria-expanded","true"),i.addClass("show"),e.trigger(a)},s.hoverDelay)}i.hover(function(t){if(!i.hasClass("show")&&!e.is(t.target))return!0;767 label > input[type=checkbox], label.checkbox-inline > input[type=checkbox]",togglebuttonElements:".togglebutton > label > input[type=checkbox]",radioElements:".radio > label > input[type=radio], label.radio-inline > input[type=radio]"},checkbox:function(t){o(a(t||this.options.checkboxElements).filter(":notmdproc").data("mdproc",!0).after(""))},togglebutton:function(t){o(a(t||this.options.togglebuttonElements).filter(":notmdproc").data("mdproc",!0).after(""))},radio:function(t){o(a(t||this.options.radioElements).filter(":notmdproc").data("mdproc",!0).after(""))},input:function(t){a(t||this.options.inputElements).filter(":notmdproc").data("mdproc",!0).each(function(){var n=a(this),e=n.closest(".form-group");0!==e.length||"hidden"===n.attr("type")||n.attr("hidden")||(n.wrap(""),e=n.closest(".form-group")),n.attr("data-hint")&&(n.after(""+n.attr("data-hint")+"
"),n.removeAttr("data-hint"));if(a.each({"input-lg":"form-group-lg","input-sm":"form-group-sm"},function(t,o){n.hasClass(t)&&(n.removeClass(t),e.addClass(o))}),n.hasClass("floating-label")){var t=n.attr("placeholder");n.attr("placeholder",null).removeClass("floating-label");var o=n.attr("id"),i="";o&&(i="for='"+o+"'"),e.addClass("label-floating"),n.after("")}null!==n.val()&&"undefined"!=n.val()&&""!==n.val()||e.addClass("is-empty"),0');var o=s.children(".ripple-container"),n=c.getRelY(o,t),e=c.getRelX(o,t);if(n||e){var i=c.getRipplesColor(s),a=r("");a.addClass("ripple").css({left:e,top:n,"background-color":i}),o.append(a),l.getComputedStyle(a[0]).opacity,c.rippleOn(s,a),setTimeout(function(){c.rippleEnd(a)},500),s.on("mouseup mouseleave touchend",function(){a.data("mousedown","off"),"off"===a.data("animating")&&c.rippleOut(a)})}}})},a.prototype.getNewSize=function(t,o){return Math.max(t.outerWidth(),t.outerHeight())/o.outerWidth()*2.5},a.prototype.getRelX=function(t,o){var n=t.offset();return c.isTouch()?1===(o=o.originalEvent).touches.length&&o.touches[0].pageX-n.left:o.pageX-n.left},a.prototype.getRelY=function(t,o){var n=t.offset();return c.isTouch()?1===(o=o.originalEvent).touches.length&&o.touches[0].pageY-n.top:o.pageY-n.top},a.prototype.getRipplesColor=function(t){return t.data("ripple-color")?t.data("ripple-color"):l.getComputedStyle(t[0]).color},a.prototype.hasTransitionSupport=function(){var t=(o.body||o.documentElement).style;return t.transition!==n||t.WebkitTransition!==n||t.MozTransition!==n||t.MsTransition!==n||t.OTransition!==n},a.prototype.isTouch=function(){return/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)},a.prototype.rippleEnd=function(t){t.data("animating","off"),"off"===t.data("mousedown")&&c.rippleOut(t)},a.prototype.rippleOut=function(t){t.off(),c.hasTransitionSupport()?t.addClass("ripple-out"):t.animate({opacity:0},100,function(){t.trigger("transitionend")}),t.on("transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd",function(){t.remove()})},a.prototype.rippleOn=function(t,o){var n=c.getNewSize(t,o);c.hasTransitionSupport()?o.css({"-ms-transform":"scale("+n+")","-moz-transform":"scale("+n+")","-webkit-transform":"scale("+n+")",transform:"scale("+n+")"}).addClass("ripple-on").data("animating","on").data("mousedown","on"):o.animate({width:2*Math.max(t.outerWidth(),t.outerHeight()),height:2*Math.max(t.outerWidth(),t.outerHeight()),"margin-left":-1*Math.max(t.outerWidth(),t.outerHeight()),"margin-top":-1*Math.max(t.outerWidth(),t.outerHeight()),opacity:.2},500,function(){o.trigger("transitionend")})},r.fn.ripples=function(t){return this.each(function(){r.data(this,"plugin_"+e)||r.data(this,"plugin_"+e,new a(this,t))})}}(jQuery,window,document),window.onresize=tabs;var handler=window.onresize;function tabs(){for(var t=$(".nav.nav-tabs"),i={},a={},o=0;o'));var r=$("#i"+n);i["tabW"+n]=[],a["tabL"+n]=[];var l=i["tabW"+n],c=a["tabL"+n],p=0;for(m=0;m li").click(function(t){var o=(s=$(this).parent()).data("id");s.children().removeClass("current"),$(this).addClass("current");for(var n=s.children(),e=0;eThe default implementation does nothing.
18 | */
19 | @Override public void enterCalculator(CalculatorParser.CalculatorContext ctx) { }
20 | /**
21 | * {@inheritDoc}
22 | *
23 | * The default implementation does nothing.
24 | */
25 | @Override public void exitCalculator(CalculatorParser.CalculatorContext ctx) { }
26 | /**
27 | * {@inheritDoc}
28 | *
29 | * The default implementation does nothing.
30 | */
31 | @Override public void enterTan(CalculatorParser.TanContext ctx) { }
32 | /**
33 | * {@inheritDoc}
34 | *
35 | * The default implementation does nothing.
36 | */
37 | @Override public void exitTan(CalculatorParser.TanContext ctx) { }
38 | /**
39 | * {@inheritDoc}
40 | *
41 | * The default implementation does nothing.
42 | */
43 | @Override public void enterCosh(CalculatorParser.CoshContext ctx) { }
44 | /**
45 | * {@inheritDoc}
46 | *
47 | * The default implementation does nothing.
48 | */
49 | @Override public void exitCosh(CalculatorParser.CoshContext ctx) { }
50 | /**
51 | * {@inheritDoc}
52 | *
53 | * The default implementation does nothing.
54 | */
55 | @Override public void enterSqRoot(CalculatorParser.SqRootContext ctx) { }
56 | /**
57 | * {@inheritDoc}
58 | *
59 | * The default implementation does nothing.
60 | */
61 | @Override public void exitSqRoot(CalculatorParser.SqRootContext ctx) { }
62 | /**
63 | * {@inheritDoc}
64 | *
65 | * The default implementation does nothing.
66 | */
67 | @Override public void enterNegExponent(CalculatorParser.NegExponentContext ctx) { }
68 | /**
69 | * {@inheritDoc}
70 | *
71 | * The default implementation does nothing.
72 | */
73 | @Override public void exitNegExponent(CalculatorParser.NegExponentContext ctx) { }
74 | /**
75 | * {@inheritDoc}
76 | *
77 | * The default implementation does nothing.
78 | */
79 | @Override public void enterExponent(CalculatorParser.ExponentContext ctx) { }
80 | /**
81 | * {@inheritDoc}
82 | *
83 | * The default implementation does nothing.
84 | */
85 | @Override public void exitExponent(CalculatorParser.ExponentContext ctx) { }
86 | /**
87 | * {@inheritDoc}
88 | *
89 | * The default implementation does nothing.
90 | */
91 | @Override public void enterArctan2(CalculatorParser.Arctan2Context ctx) { }
92 | /**
93 | * {@inheritDoc}
94 | *
95 | * The default implementation does nothing.
96 | */
97 | @Override public void exitArctan2(CalculatorParser.Arctan2Context ctx) { }
98 | /**
99 | * {@inheritDoc}
100 | *
101 | * The default implementation does nothing.
102 | */
103 | @Override public void enterMax(CalculatorParser.MaxContext ctx) { }
104 | /**
105 | * {@inheritDoc}
106 | *
107 | * The default implementation does nothing.
108 | */
109 | @Override public void exitMax(CalculatorParser.MaxContext ctx) { }
110 | /**
111 | * {@inheritDoc}
112 | *
113 | * The default implementation does nothing.
114 | */
115 | @Override public void enterMulDiv(CalculatorParser.MulDivContext ctx) { }
116 | /**
117 | * {@inheritDoc}
118 | *
119 | * The default implementation does nothing.
120 | */
121 | @Override public void exitMulDiv(CalculatorParser.MulDivContext ctx) { }
122 | /**
123 | * {@inheritDoc}
124 | *
125 | * The default implementation does nothing.
126 | */
127 | @Override public void enterArcsin(CalculatorParser.ArcsinContext ctx) { }
128 | /**
129 | * {@inheritDoc}
130 | *
131 | * The default implementation does nothing.
132 | */
133 | @Override public void exitArcsin(CalculatorParser.ArcsinContext ctx) { }
134 | /**
135 | * {@inheritDoc}
136 | *
137 | * The default implementation does nothing.
138 | */
139 | @Override public void enterUnaryPlus(CalculatorParser.UnaryPlusContext ctx) { }
140 | /**
141 | * {@inheritDoc}
142 | *
143 | * The default implementation does nothing.
144 | */
145 | @Override public void exitUnaryPlus(CalculatorParser.UnaryPlusContext ctx) { }
146 | /**
147 | * {@inheritDoc}
148 | *
149 | * The default implementation does nothing.
150 | */
151 | @Override public void enterArccot(CalculatorParser.ArccotContext ctx) { }
152 | /**
153 | * {@inheritDoc}
154 | *
155 | * The default implementation does nothing.
156 | */
157 | @Override public void exitArccot(CalculatorParser.ArccotContext ctx) { }
158 | /**
159 | * {@inheritDoc}
160 | *
161 | * The default implementation does nothing.
162 | */
163 | @Override public void enterArccos(CalculatorParser.ArccosContext ctx) { }
164 | /**
165 | * {@inheritDoc}
166 | *
167 | * The default implementation does nothing.
168 | */
169 | @Override public void exitArccos(CalculatorParser.ArccosContext ctx) { }
170 | /**
171 | * {@inheritDoc}
172 | *
173 | * The default implementation does nothing.
174 | */
175 | @Override public void enterEuler(CalculatorParser.EulerContext ctx) { }
176 | /**
177 | * {@inheritDoc}
178 | *
179 | * The default implementation does nothing.
180 | */
181 | @Override public void exitEuler(CalculatorParser.EulerContext ctx) { }
182 | /**
183 | * {@inheritDoc}
184 | *
185 | * The default implementation does nothing.
186 | */
187 | @Override public void enterArctan(CalculatorParser.ArctanContext ctx) { }
188 | /**
189 | * {@inheritDoc}
190 | *
191 | * The default implementation does nothing.
192 | */
193 | @Override public void exitArctan(CalculatorParser.ArctanContext ctx) { }
194 | /**
195 | * {@inheritDoc}
196 | *
197 | * The default implementation does nothing.
198 | */
199 | @Override public void enterParenthesis(CalculatorParser.ParenthesisContext ctx) { }
200 | /**
201 | * {@inheritDoc}
202 | *
203 | * The default implementation does nothing.
204 | */
205 | @Override public void exitParenthesis(CalculatorParser.ParenthesisContext ctx) { }
206 | /**
207 | * {@inheritDoc}
208 | *
209 | * The default implementation does nothing.
210 | */
211 | @Override public void enterAbs(CalculatorParser.AbsContext ctx) { }
212 | /**
213 | * {@inheritDoc}
214 | *
215 | * The default implementation does nothing.
216 | */
217 | @Override public void exitAbs(CalculatorParser.AbsContext ctx) { }
218 | /**
219 | * {@inheritDoc}
220 | *
221 | * The default implementation does nothing.
222 | */
223 | @Override public void enterNumber(CalculatorParser.NumberContext ctx) { }
224 | /**
225 | * {@inheritDoc}
226 | *
227 | * The default implementation does nothing.
228 | */
229 | @Override public void exitNumber(CalculatorParser.NumberContext ctx) { }
230 | /**
231 | * {@inheritDoc}
232 | *
233 | * The default implementation does nothing.
234 | */
235 | @Override public void enterSubstitution(CalculatorParser.SubstitutionContext ctx) { }
236 | /**
237 | * {@inheritDoc}
238 | *
239 | * The default implementation does nothing.
240 | */
241 | @Override public void exitSubstitution(CalculatorParser.SubstitutionContext ctx) { }
242 | /**
243 | * {@inheritDoc}
244 | *
245 | * The default implementation does nothing.
246 | */
247 | @Override public void enterSinh(CalculatorParser.SinhContext ctx) { }
248 | /**
249 | * {@inheritDoc}
250 | *
251 | * The default implementation does nothing.
252 | */
253 | @Override public void exitSinh(CalculatorParser.SinhContext ctx) { }
254 | /**
255 | * {@inheritDoc}
256 | *
257 | * The default implementation does nothing.
258 | */
259 | @Override public void enterRound(CalculatorParser.RoundContext ctx) { }
260 | /**
261 | * {@inheritDoc}
262 | *
263 | * The default implementation does nothing.
264 | */
265 | @Override public void exitRound(CalculatorParser.RoundContext ctx) { }
266 | /**
267 | * {@inheritDoc}
268 | *
269 | * The default implementation does nothing.
270 | */
271 | @Override public void enterTrunc(CalculatorParser.TruncContext ctx) { }
272 | /**
273 | * {@inheritDoc}
274 | *
275 | * The default implementation does nothing.
276 | */
277 | @Override public void exitTrunc(CalculatorParser.TruncContext ctx) { }
278 | /**
279 | * {@inheritDoc}
280 | *
281 | * The default implementation does nothing.
282 | */
283 | @Override public void enterPi(CalculatorParser.PiContext ctx) { }
284 | /**
285 | * {@inheritDoc}
286 | *
287 | * The default implementation does nothing.
288 | */
289 | @Override public void exitPi(CalculatorParser.PiContext ctx) { }
290 | /**
291 | * {@inheritDoc}
292 | *
293 | * The default implementation does nothing.
294 | */
295 | @Override public void enterTanh(CalculatorParser.TanhContext ctx) { }
296 | /**
297 | * {@inheritDoc}
298 | *
299 | * The default implementation does nothing.
300 | */
301 | @Override public void exitTanh(CalculatorParser.TanhContext ctx) { }
302 | /**
303 | * {@inheritDoc}
304 | *
305 | * The default implementation does nothing.
306 | */
307 | @Override public void enterFloor(CalculatorParser.FloorContext ctx) { }
308 | /**
309 | * {@inheritDoc}
310 | *
311 | * The default implementation does nothing.
312 | */
313 | @Override public void exitFloor(CalculatorParser.FloorContext ctx) { }
314 | /**
315 | * {@inheritDoc}
316 | *
317 | * The default implementation does nothing.
318 | */
319 | @Override public void enterLn(CalculatorParser.LnContext ctx) { }
320 | /**
321 | * {@inheritDoc}
322 | *
323 | * The default implementation does nothing.
324 | */
325 | @Override public void exitLn(CalculatorParser.LnContext ctx) { }
326 | /**
327 | * {@inheritDoc}
328 | *
329 | * The default implementation does nothing.
330 | */
331 | @Override public void enterMod(CalculatorParser.ModContext ctx) { }
332 | /**
333 | * {@inheritDoc}
334 | *
335 | * The default implementation does nothing.
336 | */
337 | @Override public void exitMod(CalculatorParser.ModContext ctx) { }
338 | /**
339 | * {@inheritDoc}
340 | *
341 | * The default implementation does nothing.
342 | */
343 | @Override public void enterLog(CalculatorParser.LogContext ctx) { }
344 | /**
345 | * {@inheritDoc}
346 | *
347 | * The default implementation does nothing.
348 | */
349 | @Override public void exitLog(CalculatorParser.LogContext ctx) { }
350 | /**
351 | * {@inheritDoc}
352 | *
353 | * The default implementation does nothing.
354 | */
355 | @Override public void enterAddSub(CalculatorParser.AddSubContext ctx) { }
356 | /**
357 | * {@inheritDoc}
358 | *
359 | * The default implementation does nothing.
360 | */
361 | @Override public void exitAddSub(CalculatorParser.AddSubContext ctx) { }
362 | /**
363 | * {@inheritDoc}
364 | *
365 | * The default implementation does nothing.
366 | */
367 | @Override public void enterCos(CalculatorParser.CosContext ctx) { }
368 | /**
369 | * {@inheritDoc}
370 | *
371 | * The default implementation does nothing.
372 | */
373 | @Override public void exitCos(CalculatorParser.CosContext ctx) { }
374 | /**
375 | * {@inheritDoc}
376 | *
377 | * The default implementation does nothing.
378 | */
379 | @Override public void enterDeg(CalculatorParser.DegContext ctx) { }
380 | /**
381 | * {@inheritDoc}
382 | *
383 | * The default implementation does nothing.
384 | */
385 | @Override public void exitDeg(CalculatorParser.DegContext ctx) { }
386 | /**
387 | * {@inheritDoc}
388 | *
389 | * The default implementation does nothing.
390 | */
391 | @Override public void enterSqrt(CalculatorParser.SqrtContext ctx) { }
392 | /**
393 | * {@inheritDoc}
394 | *
395 | * The default implementation does nothing.
396 | */
397 | @Override public void exitSqrt(CalculatorParser.SqrtContext ctx) { }
398 | /**
399 | * {@inheritDoc}
400 | *
401 | * The default implementation does nothing.
402 | */
403 | @Override public void enterCot(CalculatorParser.CotContext ctx) { }
404 | /**
405 | * {@inheritDoc}
406 | *
407 | * The default implementation does nothing.
408 | */
409 | @Override public void exitCot(CalculatorParser.CotContext ctx) { }
410 | /**
411 | * {@inheritDoc}
412 | *
413 | * The default implementation does nothing.
414 | */
415 | @Override public void enterRange(CalculatorParser.RangeContext ctx) { }
416 | /**
417 | * {@inheritDoc}
418 | *
419 | * The default implementation does nothing.
420 | */
421 | @Override public void exitRange(CalculatorParser.RangeContext ctx) { }
422 | /**
423 | * {@inheritDoc}
424 | *
425 | * The default implementation does nothing.
426 | */
427 | @Override public void enterWhole(CalculatorParser.WholeContext ctx) { }
428 | /**
429 | * {@inheritDoc}
430 | *
431 | * The default implementation does nothing.
432 | */
433 | @Override public void exitWhole(CalculatorParser.WholeContext ctx) { }
434 | /**
435 | * {@inheritDoc}
436 | *
437 | * The default implementation does nothing.
438 | */
439 | @Override public void enterUnary(CalculatorParser.UnaryContext ctx) { }
440 | /**
441 | * {@inheritDoc}
442 | *
443 | * The default implementation does nothing.
444 | */
445 | @Override public void exitUnary(CalculatorParser.UnaryContext ctx) { }
446 | /**
447 | * {@inheritDoc}
448 | *
449 | * The default implementation does nothing.
450 | */
451 | @Override public void enterMin(CalculatorParser.MinContext ctx) { }
452 | /**
453 | * {@inheritDoc}
454 | *
455 | * The default implementation does nothing.
456 | */
457 | @Override public void exitMin(CalculatorParser.MinContext ctx) { }
458 | /**
459 | * {@inheritDoc}
460 | *
461 | * The default implementation does nothing.
462 | */
463 | @Override public void enterRad(CalculatorParser.RadContext ctx) { }
464 | /**
465 | * {@inheritDoc}
466 | *
467 | * The default implementation does nothing.
468 | */
469 | @Override public void exitRad(CalculatorParser.RadContext ctx) { }
470 | /**
471 | * {@inheritDoc}
472 | *
473 | * The default implementation does nothing.
474 | */
475 | @Override public void enterMult(CalculatorParser.MultContext ctx) { }
476 | /**
477 | * {@inheritDoc}
478 | *
479 | * The default implementation does nothing.
480 | */
481 | @Override public void exitMult(CalculatorParser.MultContext ctx) { }
482 | /**
483 | * {@inheritDoc}
484 | *
485 | * The default implementation does nothing.
486 | */
487 | @Override public void enterSqr(CalculatorParser.SqrContext ctx) { }
488 | /**
489 | * {@inheritDoc}
490 | *
491 | * The default implementation does nothing.
492 | */
493 | @Override public void exitSqr(CalculatorParser.SqrContext ctx) { }
494 | /**
495 | * {@inheritDoc}
496 | *
497 | * The default implementation does nothing.
498 | */
499 | @Override public void enterSin(CalculatorParser.SinContext ctx) { }
500 | /**
501 | * {@inheritDoc}
502 | *
503 | * The default implementation does nothing.
504 | */
505 | @Override public void exitSin(CalculatorParser.SinContext ctx) { }
506 | /**
507 | * {@inheritDoc}
508 | *
509 | * The default implementation does nothing.
510 | */
511 | @Override public void enterEex(CalculatorParser.EexContext ctx) { }
512 | /**
513 | * {@inheritDoc}
514 | *
515 | * The default implementation does nothing.
516 | */
517 | @Override public void exitEex(CalculatorParser.EexContext ctx) { }
518 | /**
519 | * {@inheritDoc}
520 | *
521 | * The default implementation does nothing.
522 | */
523 | @Override public void enterPow(CalculatorParser.PowContext ctx) { }
524 | /**
525 | * {@inheritDoc}
526 | *
527 | * The default implementation does nothing.
528 | */
529 | @Override public void exitPow(CalculatorParser.PowContext ctx) { }
530 | /**
531 | * {@inheritDoc}
532 | *
533 | * The default implementation does nothing.
534 | */
535 | @Override public void enterCeil(CalculatorParser.CeilContext ctx) { }
536 | /**
537 | * {@inheritDoc}
538 | *
539 | * The default implementation does nothing.
540 | */
541 | @Override public void exitCeil(CalculatorParser.CeilContext ctx) { }
542 | /**
543 | * {@inheritDoc}
544 | *
545 | * The default implementation does nothing.
546 | */
547 | @Override public void enterExp(CalculatorParser.ExpContext ctx) { }
548 | /**
549 | * {@inheritDoc}
550 | *
551 | * The default implementation does nothing.
552 | */
553 | @Override public void exitExp(CalculatorParser.ExpContext ctx) { }
554 | /**
555 | * {@inheritDoc}
556 | *
557 | * The default implementation does nothing.
558 | */
559 | @Override public void enterRoundk(CalculatorParser.RoundkContext ctx) { }
560 | /**
561 | * {@inheritDoc}
562 | *
563 | * The default implementation does nothing.
564 | */
565 | @Override public void exitRoundk(CalculatorParser.RoundkContext ctx) { }
566 | /**
567 | * {@inheritDoc}
568 | *
569 | * The default implementation does nothing.
570 | */
571 | @Override public void enterTrailingComment(CalculatorParser.TrailingCommentContext ctx) { }
572 | /**
573 | * {@inheritDoc}
574 | *
575 | * The default implementation does nothing.
576 | */
577 | @Override public void exitTrailingComment(CalculatorParser.TrailingCommentContext ctx) { }
578 | /**
579 | * {@inheritDoc}
580 | *
581 | * The default implementation does nothing.
582 | */
583 | @Override public void enterCompileUnit(CalculatorParser.CompileUnitContext ctx) { }
584 | /**
585 | * {@inheritDoc}
586 | *
587 | * The default implementation does nothing.
588 | */
589 | @Override public void exitCompileUnit(CalculatorParser.CompileUnitContext ctx) { }
590 |
591 | /**
592 | * {@inheritDoc}
593 | *
594 | * The default implementation does nothing.
595 | */
596 | @Override public void enterEveryRule(ParserRuleContext ctx) { }
597 | /**
598 | * {@inheritDoc}
599 | *
600 | * The default implementation does nothing.
601 | */
602 | @Override public void exitEveryRule(ParserRuleContext ctx) { }
603 | /**
604 | * {@inheritDoc}
605 | *
606 | * The default implementation does nothing.
607 | */
608 | @Override public void visitTerminal(TerminalNode node) { }
609 | /**
610 | * {@inheritDoc}
611 | *
612 | * The default implementation does nothing.
613 | */
614 | @Override public void visitErrorNode(ErrorNode node) { }
615 | }
--------------------------------------------------------------------------------
/src/.antlr/CalculatorLexer.interp:
--------------------------------------------------------------------------------
1 | token literal names:
2 | null
3 | '='
4 | '('
5 | ')'
6 | '^'
7 | '**'
8 | '%'
9 | '~'
10 | '//'
11 | '['
12 | ']'
13 | '{'
14 | '}'
15 | '()'
16 | '..'
17 | null
18 | null
19 | null
20 | null
21 | null
22 | '*'
23 | '/'
24 | '+'
25 | '-'
26 | null
27 | null
28 | null
29 | null
30 | null
31 | null
32 | null
33 | null
34 | null
35 | null
36 | null
37 | null
38 | null
39 | null
40 | null
41 | null
42 | null
43 | null
44 | null
45 | null
46 | null
47 | null
48 | null
49 | null
50 | null
51 | null
52 | null
53 | null
54 | null
55 | null
56 | null
57 | null
58 | null
59 | null
60 | null
61 | ';'
62 | null
63 |
64 | token symbolic names:
65 | null
66 | null
67 | null
68 | null
69 | null
70 | null
71 | null
72 | null
73 | null
74 | null
75 | null
76 | null
77 | null
78 | null
79 | null
80 | NUMBER
81 | FLOAT
82 | DIGIT
83 | MOD
84 | WHOLE
85 | MUL
86 | DIV
87 | ADD
88 | SUB
89 | PI
90 | EXPONENT
91 | NEGEXPONENT
92 | EULER
93 | SQRT
94 | SQR
95 | FLOOR
96 | CEIL
97 | ABS
98 | ROUNDK
99 | ROUND
100 | TRUNC
101 | SIN
102 | COS
103 | TAN
104 | COT
105 | SINH
106 | COSH
107 | TANH
108 | ARCSIN
109 | ARCCOS
110 | ARCTAN
111 | ARCTAN2
112 | ARCCOT
113 | EXP
114 | LN
115 | EEX
116 | LOG
117 | RAD
118 | DEG
119 | MIN
120 | MAX
121 | WS
122 | COM
123 | SUBSTITUTION
124 | SEMICOLON
125 | INVALID
126 |
127 | rule names:
128 | T__0
129 | T__1
130 | T__2
131 | T__3
132 | T__4
133 | T__5
134 | T__6
135 | T__7
136 | T__8
137 | T__9
138 | T__10
139 | T__11
140 | T__12
141 | T__13
142 | NUMBER
143 | FLOAT
144 | DIGIT
145 | MOD
146 | WHOLE
147 | MUL
148 | DIV
149 | ADD
150 | SUB
151 | PI
152 | EXPONENT
153 | NEGEXPONENT
154 | EULER
155 | SQRT
156 | SQR
157 | FLOOR
158 | CEIL
159 | ABS
160 | ROUNDK
161 | ROUND
162 | TRUNC
163 | SIN
164 | COS
165 | TAN
166 | COT
167 | SINH
168 | COSH
169 | TANH
170 | ARCSIN
171 | ARCCOS
172 | ARCTAN
173 | ARCTAN2
174 | ARCCOT
175 | EXP
176 | LN
177 | EEX
178 | LOG
179 | RAD
180 | DEG
181 | MIN
182 | MAX
183 | WS
184 | COM
185 | SUBSTITUTION
186 | SEMICOLON
187 | INVALID
188 | COMMENT
189 |
190 | channel names:
191 | DEFAULT_TOKEN_CHANNEL
192 | HIDDEN
193 |
194 | mode names:
195 | DEFAULT_MODE
196 |
197 | atn:
198 | [4, 0, 60, 400, 6, -1, 2, 0, 7, 0, 2, 1, 7, 1, 2, 2, 7, 2, 2, 3, 7, 3, 2, 4, 7, 4, 2, 5, 7, 5, 2, 6, 7, 6, 2, 7, 7, 7, 2, 8, 7, 8, 2, 9, 7, 9, 2, 10, 7, 10, 2, 11, 7, 11, 2, 12, 7, 12, 2, 13, 7, 13, 2, 14, 7, 14, 2, 15, 7, 15, 2, 16, 7, 16, 2, 17, 7, 17, 2, 18, 7, 18, 2, 19, 7, 19, 2, 20, 7, 20, 2, 21, 7, 21, 2, 22, 7, 22, 2, 23, 7, 23, 2, 24, 7, 24, 2, 25, 7, 25, 2, 26, 7, 26, 2, 27, 7, 27, 2, 28, 7, 28, 2, 29, 7, 29, 2, 30, 7, 30, 2, 31, 7, 31, 2, 32, 7, 32, 2, 33, 7, 33, 2, 34, 7, 34, 2, 35, 7, 35, 2, 36, 7, 36, 2, 37, 7, 37, 2, 38, 7, 38, 2, 39, 7, 39, 2, 40, 7, 40, 2, 41, 7, 41, 2, 42, 7, 42, 2, 43, 7, 43, 2, 44, 7, 44, 2, 45, 7, 45, 2, 46, 7, 46, 2, 47, 7, 47, 2, 48, 7, 48, 2, 49, 7, 49, 2, 50, 7, 50, 2, 51, 7, 51, 2, 52, 7, 52, 2, 53, 7, 53, 2, 54, 7, 54, 2, 55, 7, 55, 2, 56, 7, 56, 2, 57, 7, 57, 2, 58, 7, 58, 2, 59, 7, 59, 2, 60, 7, 60, 1, 0, 1, 0, 1, 1, 1, 1, 1, 2, 1, 2, 1, 3, 1, 3, 1, 4, 1, 4, 1, 4, 1, 5, 1, 5, 1, 6, 1, 6, 1, 7, 1, 7, 1, 7, 1, 8, 1, 8, 1, 9, 1, 9, 1, 10, 1, 10, 1, 11, 1, 11, 1, 12, 1, 12, 1, 12, 1, 13, 1, 13, 1, 13, 1, 14, 1, 14, 4, 14, 158, 8, 14, 11, 14, 12, 14, 159, 3, 14, 162, 8, 14, 1, 15, 4, 15, 165, 8, 15, 11, 15, 12, 15, 166, 1, 15, 1, 15, 5, 15, 171, 8, 15, 10, 15, 12, 15, 174, 9, 15, 1, 15, 1, 15, 4, 15, 178, 8, 15, 11, 15, 12, 15, 179, 3, 15, 182, 8, 15, 1, 16, 1, 16, 1, 17, 1, 17, 1, 17, 1, 17, 1, 18, 1, 18, 1, 18, 1, 18, 1, 19, 1, 19, 1, 20, 1, 20, 1, 21, 1, 21, 1, 22, 1, 22, 1, 23, 1, 23, 1, 23, 1, 24, 1, 24, 1, 24, 1, 25, 1, 25, 1, 25, 1, 26, 1, 26, 1, 27, 1, 27, 1, 27, 1, 27, 1, 27, 1, 28, 1, 28, 1, 28, 1, 28, 1, 29, 1, 29, 1, 29, 1, 29, 1, 29, 1, 29, 1, 30, 1, 30, 1, 30, 1, 30, 1, 30, 1, 31, 1, 31, 1, 31, 1, 31, 1, 32, 1, 32, 1, 32, 1, 32, 1, 32, 1, 32, 1, 32, 1, 33, 1, 33, 1, 33, 1, 33, 1, 33, 1, 33, 1, 34, 1, 34, 1, 34, 1, 34, 1, 34, 1, 34, 1, 35, 1, 35, 1, 35, 1, 35, 1, 36, 1, 36, 1, 36, 1, 36, 1, 37, 1, 37, 1, 37, 1, 37, 1, 38, 1, 38, 1, 38, 1, 38, 1, 39, 1, 39, 1, 39, 1, 39, 1, 39, 1, 40, 1, 40, 1, 40, 1, 40, 1, 40, 1, 41, 1, 41, 1, 41, 1, 41, 1, 41, 1, 42, 1, 42, 1, 42, 1, 42, 1, 42, 1, 42, 1, 42, 1, 43, 1, 43, 1, 43, 1, 43, 1, 43, 1, 43, 1, 43, 1, 44, 1, 44, 1, 44, 1, 44, 1, 44, 1, 44, 1, 44, 1, 45, 1, 45, 1, 45, 1, 45, 1, 45, 1, 45, 1, 45, 1, 45, 1, 46, 1, 46, 1, 46, 1, 46, 1, 46, 1, 46, 1, 46, 1, 47, 1, 47, 1, 47, 1, 47, 1, 48, 1, 48, 1, 48, 1, 49, 1, 49, 1, 49, 1, 49, 1, 50, 1, 50, 1, 50, 1, 50, 1, 51, 1, 51, 1, 51, 1, 51, 1, 52, 1, 52, 1, 52, 1, 52, 1, 53, 1, 53, 1, 53, 1, 53, 1, 54, 1, 54, 1, 54, 1, 54, 1, 55, 1, 55, 1, 55, 1, 55, 1, 56, 1, 56, 1, 56, 1, 56, 1, 57, 1, 57, 4, 57, 364, 8, 57, 11, 57, 12, 57, 365, 1, 58, 1, 58, 1, 59, 1, 59, 1, 60, 1, 60, 1, 60, 1, 60, 5, 60, 376, 8, 60, 10, 60, 12, 60, 379, 9, 60, 1, 60, 1, 60, 1, 60, 1, 60, 5, 60, 385, 8, 60, 10, 60, 12, 60, 388, 9, 60, 1, 60, 1, 60, 1, 60, 5, 60, 393, 8, 60, 10, 60, 12, 60, 396, 9, 60, 1, 60, 3, 60, 399, 8, 60, 3, 377, 386, 394, 0, 61, 1, 1, 3, 2, 5, 3, 7, 4, 9, 5, 11, 6, 13, 7, 15, 8, 17, 9, 19, 10, 21, 11, 23, 12, 25, 13, 27, 14, 29, 15, 31, 16, 33, 17, 35, 18, 37, 19, 39, 20, 41, 21, 43, 22, 45, 23, 47, 24, 49, 25, 51, 26, 53, 27, 55, 28, 57, 29, 59, 30, 61, 31, 63, 32, 65, 33, 67, 34, 69, 35, 71, 36, 73, 37, 75, 38, 77, 39, 79, 40, 81, 41, 83, 42, 85, 43, 87, 44, 89, 45, 91, 46, 93, 47, 95, 48, 97, 49, 99, 50, 101, 51, 103, 52, 105, 53, 107, 54, 109, 55, 111, 56, 113, 57, 115, 58, 117, 59, 119, 60, 121, 0, 1, 0, 27, 2, 0, 44, 44, 46, 46, 1, 0, 48, 57, 2, 0, 77, 77, 109, 109, 2, 0, 79, 79, 111, 111, 2, 0, 68, 68, 100, 100, 2, 0, 73, 73, 105, 105, 2, 0, 86, 86, 118, 118, 2, 0, 80, 80, 112, 112, 2, 0, 69, 69, 101, 101, 2, 0, 83, 83, 115, 115, 2, 0, 81, 81, 113, 113, 2, 0, 82, 82, 114, 114, 2, 0, 84, 84, 116, 116, 2, 0, 70, 70, 102, 102, 2, 0, 76, 76, 108, 108, 2, 0, 67, 67, 99, 99, 2, 0, 65, 65, 97, 97, 2, 0, 66, 66, 98, 98, 2, 0, 85, 85, 117, 117, 2, 0, 78, 78, 110, 110, 2, 0, 75, 75, 107, 107, 2, 0, 72, 72, 104, 104, 1, 0, 50, 50, 2, 0, 88, 88, 120, 120, 2, 0, 71, 71, 103, 103, 3, 0, 9, 10, 13, 13, 32, 32, 10, 0, 48, 57, 65, 90, 97, 122, 164, 164, 182, 182, 188, 188, 195, 195, 339, 339, 8211, 8211, 8222, 8222, 410, 0, 1, 1, 0, 0, 0, 0, 3, 1, 0, 0, 0, 0, 5, 1, 0, 0, 0, 0, 7, 1, 0, 0, 0, 0, 9, 1, 0, 0, 0, 0, 11, 1, 0, 0, 0, 0, 13, 1, 0, 0, 0, 0, 15, 1, 0, 0, 0, 0, 17, 1, 0, 0, 0, 0, 19, 1, 0, 0, 0, 0, 21, 1, 0, 0, 0, 0, 23, 1, 0, 0, 0, 0, 25, 1, 0, 0, 0, 0, 27, 1, 0, 0, 0, 0, 29, 1, 0, 0, 0, 0, 31, 1, 0, 0, 0, 0, 33, 1, 0, 0, 0, 0, 35, 1, 0, 0, 0, 0, 37, 1, 0, 0, 0, 0, 39, 1, 0, 0, 0, 0, 41, 1, 0, 0, 0, 0, 43, 1, 0, 0, 0, 0, 45, 1, 0, 0, 0, 0, 47, 1, 0, 0, 0, 0, 49, 1, 0, 0, 0, 0, 51, 1, 0, 0, 0, 0, 53, 1, 0, 0, 0, 0, 55, 1, 0, 0, 0, 0, 57, 1, 0, 0, 0, 0, 59, 1, 0, 0, 0, 0, 61, 1, 0, 0, 0, 0, 63, 1, 0, 0, 0, 0, 65, 1, 0, 0, 0, 0, 67, 1, 0, 0, 0, 0, 69, 1, 0, 0, 0, 0, 71, 1, 0, 0, 0, 0, 73, 1, 0, 0, 0, 0, 75, 1, 0, 0, 0, 0, 77, 1, 0, 0, 0, 0, 79, 1, 0, 0, 0, 0, 81, 1, 0, 0, 0, 0, 83, 1, 0, 0, 0, 0, 85, 1, 0, 0, 0, 0, 87, 1, 0, 0, 0, 0, 89, 1, 0, 0, 0, 0, 91, 1, 0, 0, 0, 0, 93, 1, 0, 0, 0, 0, 95, 1, 0, 0, 0, 0, 97, 1, 0, 0, 0, 0, 99, 1, 0, 0, 0, 0, 101, 1, 0, 0, 0, 0, 103, 1, 0, 0, 0, 0, 105, 1, 0, 0, 0, 0, 107, 1, 0, 0, 0, 0, 109, 1, 0, 0, 0, 0, 111, 1, 0, 0, 0, 0, 113, 1, 0, 0, 0, 0, 115, 1, 0, 0, 0, 0, 117, 1, 0, 0, 0, 0, 119, 1, 0, 0, 0, 1, 123, 1, 0, 0, 0, 3, 125, 1, 0, 0, 0, 5, 127, 1, 0, 0, 0, 7, 129, 1, 0, 0, 0, 9, 131, 1, 0, 0, 0, 11, 134, 1, 0, 0, 0, 13, 136, 1, 0, 0, 0, 15, 138, 1, 0, 0, 0, 17, 141, 1, 0, 0, 0, 19, 143, 1, 0, 0, 0, 21, 145, 1, 0, 0, 0, 23, 147, 1, 0, 0, 0, 25, 149, 1, 0, 0, 0, 27, 152, 1, 0, 0, 0, 29, 161, 1, 0, 0, 0, 31, 181, 1, 0, 0, 0, 33, 183, 1, 0, 0, 0, 35, 185, 1, 0, 0, 0, 37, 189, 1, 0, 0, 0, 39, 193, 1, 0, 0, 0, 41, 195, 1, 0, 0, 0, 43, 197, 1, 0, 0, 0, 45, 199, 1, 0, 0, 0, 47, 201, 1, 0, 0, 0, 49, 204, 1, 0, 0, 0, 51, 207, 1, 0, 0, 0, 53, 210, 1, 0, 0, 0, 55, 212, 1, 0, 0, 0, 57, 217, 1, 0, 0, 0, 59, 221, 1, 0, 0, 0, 61, 227, 1, 0, 0, 0, 63, 232, 1, 0, 0, 0, 65, 236, 1, 0, 0, 0, 67, 243, 1, 0, 0, 0, 69, 249, 1, 0, 0, 0, 71, 255, 1, 0, 0, 0, 73, 259, 1, 0, 0, 0, 75, 263, 1, 0, 0, 0, 77, 267, 1, 0, 0, 0, 79, 271, 1, 0, 0, 0, 81, 276, 1, 0, 0, 0, 83, 281, 1, 0, 0, 0, 85, 286, 1, 0, 0, 0, 87, 293, 1, 0, 0, 0, 89, 300, 1, 0, 0, 0, 91, 307, 1, 0, 0, 0, 93, 315, 1, 0, 0, 0, 95, 322, 1, 0, 0, 0, 97, 326, 1, 0, 0, 0, 99, 329, 1, 0, 0, 0, 101, 333, 1, 0, 0, 0, 103, 337, 1, 0, 0, 0, 105, 341, 1, 0, 0, 0, 107, 345, 1, 0, 0, 0, 109, 349, 1, 0, 0, 0, 111, 353, 1, 0, 0, 0, 113, 357, 1, 0, 0, 0, 115, 361, 1, 0, 0, 0, 117, 367, 1, 0, 0, 0, 119, 369, 1, 0, 0, 0, 121, 398, 1, 0, 0, 0, 123, 124, 5, 61, 0, 0, 124, 2, 1, 0, 0, 0, 125, 126, 5, 40, 0, 0, 126, 4, 1, 0, 0, 0, 127, 128, 5, 41, 0, 0, 128, 6, 1, 0, 0, 0, 129, 130, 5, 94, 0, 0, 130, 8, 1, 0, 0, 0, 131, 132, 5, 42, 0, 0, 132, 133, 5, 42, 0, 0, 133, 10, 1, 0, 0, 0, 134, 135, 5, 37, 0, 0, 135, 12, 1, 0, 0, 0, 136, 137, 5, 126, 0, 0, 137, 14, 1, 0, 0, 0, 138, 139, 5, 47, 0, 0, 139, 140, 5, 47, 0, 0, 140, 16, 1, 0, 0, 0, 141, 142, 5, 91, 0, 0, 142, 18, 1, 0, 0, 0, 143, 144, 5, 93, 0, 0, 144, 20, 1, 0, 0, 0, 145, 146, 5, 123, 0, 0, 146, 22, 1, 0, 0, 0, 147, 148, 5, 125, 0, 0, 148, 24, 1, 0, 0, 0, 149, 150, 5, 40, 0, 0, 150, 151, 5, 41, 0, 0, 151, 26, 1, 0, 0, 0, 152, 153, 5, 46, 0, 0, 153, 154, 5, 46, 0, 0, 154, 28, 1, 0, 0, 0, 155, 162, 3, 31, 15, 0, 156, 158, 3, 33, 16, 0, 157, 156, 1, 0, 0, 0, 158, 159, 1, 0, 0, 0, 159, 157, 1, 0, 0, 0, 159, 160, 1, 0, 0, 0, 160, 162, 1, 0, 0, 0, 161, 155, 1, 0, 0, 0, 161, 157, 1, 0, 0, 0, 162, 30, 1, 0, 0, 0, 163, 165, 3, 33, 16, 0, 164, 163, 1, 0, 0, 0, 165, 166, 1, 0, 0, 0, 166, 164, 1, 0, 0, 0, 166, 167, 1, 0, 0, 0, 167, 168, 1, 0, 0, 0, 168, 172, 7, 0, 0, 0, 169, 171, 3, 33, 16, 0, 170, 169, 1, 0, 0, 0, 171, 174, 1, 0, 0, 0, 172, 170, 1, 0, 0, 0, 172, 173, 1, 0, 0, 0, 173, 182, 1, 0, 0, 0, 174, 172, 1, 0, 0, 0, 175, 177, 7, 0, 0, 0, 176, 178, 3, 33, 16, 0, 177, 176, 1, 0, 0, 0, 178, 179, 1, 0, 0, 0, 179, 177, 1, 0, 0, 0, 179, 180, 1, 0, 0, 0, 180, 182, 1, 0, 0, 0, 181, 164, 1, 0, 0, 0, 181, 175, 1, 0, 0, 0, 182, 32, 1, 0, 0, 0, 183, 184, 7, 1, 0, 0, 184, 34, 1, 0, 0, 0, 185, 186, 7, 2, 0, 0, 186, 187, 7, 3, 0, 0, 187, 188, 7, 4, 0, 0, 188, 36, 1, 0, 0, 0, 189, 190, 7, 4, 0, 0, 190, 191, 7, 5, 0, 0, 191, 192, 7, 6, 0, 0, 192, 38, 1, 0, 0, 0, 193, 194, 5, 42, 0, 0, 194, 40, 1, 0, 0, 0, 195, 196, 5, 47, 0, 0, 196, 42, 1, 0, 0, 0, 197, 198, 5, 43, 0, 0, 198, 44, 1, 0, 0, 0, 199, 200, 5, 45, 0, 0, 200, 46, 1, 0, 0, 0, 201, 202, 7, 7, 0, 0, 202, 203, 7, 5, 0, 0, 203, 48, 1, 0, 0, 0, 204, 205, 7, 8, 0, 0, 205, 206, 5, 43, 0, 0, 206, 50, 1, 0, 0, 0, 207, 208, 7, 8, 0, 0, 208, 209, 5, 45, 0, 0, 209, 52, 1, 0, 0, 0, 210, 211, 7, 8, 0, 0, 211, 54, 1, 0, 0, 0, 212, 213, 7, 9, 0, 0, 213, 214, 7, 10, 0, 0, 214, 215, 7, 11, 0, 0, 215, 216, 7, 12, 0, 0, 216, 56, 1, 0, 0, 0, 217, 218, 7, 9, 0, 0, 218, 219, 7, 10, 0, 0, 219, 220, 7, 11, 0, 0, 220, 58, 1, 0, 0, 0, 221, 222, 7, 13, 0, 0, 222, 223, 7, 14, 0, 0, 223, 224, 7, 3, 0, 0, 224, 225, 7, 3, 0, 0, 225, 226, 7, 11, 0, 0, 226, 60, 1, 0, 0, 0, 227, 228, 7, 15, 0, 0, 228, 229, 7, 8, 0, 0, 229, 230, 7, 5, 0, 0, 230, 231, 7, 14, 0, 0, 231, 62, 1, 0, 0, 0, 232, 233, 7, 16, 0, 0, 233, 234, 7, 17, 0, 0, 234, 235, 7, 9, 0, 0, 235, 64, 1, 0, 0, 0, 236, 237, 7, 11, 0, 0, 237, 238, 7, 3, 0, 0, 238, 239, 7, 18, 0, 0, 239, 240, 7, 19, 0, 0, 240, 241, 7, 4, 0, 0, 241, 242, 7, 20, 0, 0, 242, 66, 1, 0, 0, 0, 243, 244, 7, 11, 0, 0, 244, 245, 7, 3, 0, 0, 245, 246, 7, 18, 0, 0, 246, 247, 7, 19, 0, 0, 247, 248, 7, 4, 0, 0, 248, 68, 1, 0, 0, 0, 249, 250, 7, 12, 0, 0, 250, 251, 7, 11, 0, 0, 251, 252, 7, 18, 0, 0, 252, 253, 7, 19, 0, 0, 253, 254, 7, 15, 0, 0, 254, 70, 1, 0, 0, 0, 255, 256, 7, 9, 0, 0, 256, 257, 7, 5, 0, 0, 257, 258, 7, 19, 0, 0, 258, 72, 1, 0, 0, 0, 259, 260, 7, 15, 0, 0, 260, 261, 7, 3, 0, 0, 261, 262, 7, 9, 0, 0, 262, 74, 1, 0, 0, 0, 263, 264, 7, 12, 0, 0, 264, 265, 7, 16, 0, 0, 265, 266, 7, 19, 0, 0, 266, 76, 1, 0, 0, 0, 267, 268, 7, 15, 0, 0, 268, 269, 7, 3, 0, 0, 269, 270, 7, 12, 0, 0, 270, 78, 1, 0, 0, 0, 271, 272, 7, 9, 0, 0, 272, 273, 7, 5, 0, 0, 273, 274, 7, 19, 0, 0, 274, 275, 7, 21, 0, 0, 275, 80, 1, 0, 0, 0, 276, 277, 7, 15, 0, 0, 277, 278, 7, 3, 0, 0, 278, 279, 7, 9, 0, 0, 279, 280, 7, 21, 0, 0, 280, 82, 1, 0, 0, 0, 281, 282, 7, 12, 0, 0, 282, 283, 7, 16, 0, 0, 283, 284, 7, 19, 0, 0, 284, 285, 7, 21, 0, 0, 285, 84, 1, 0, 0, 0, 286, 287, 7, 16, 0, 0, 287, 288, 7, 11, 0, 0, 288, 289, 7, 15, 0, 0, 289, 290, 7, 9, 0, 0, 290, 291, 7, 5, 0, 0, 291, 292, 7, 19, 0, 0, 292, 86, 1, 0, 0, 0, 293, 294, 7, 16, 0, 0, 294, 295, 7, 11, 0, 0, 295, 296, 7, 15, 0, 0, 296, 297, 7, 15, 0, 0, 297, 298, 7, 3, 0, 0, 298, 299, 7, 9, 0, 0, 299, 88, 1, 0, 0, 0, 300, 301, 7, 16, 0, 0, 301, 302, 7, 11, 0, 0, 302, 303, 7, 15, 0, 0, 303, 304, 7, 12, 0, 0, 304, 305, 7, 16, 0, 0, 305, 306, 7, 19, 0, 0, 306, 90, 1, 0, 0, 0, 307, 308, 7, 16, 0, 0, 308, 309, 7, 11, 0, 0, 309, 310, 7, 15, 0, 0, 310, 311, 7, 12, 0, 0, 311, 312, 7, 16, 0, 0, 312, 313, 7, 19, 0, 0, 313, 314, 7, 22, 0, 0, 314, 92, 1, 0, 0, 0, 315, 316, 7, 16, 0, 0, 316, 317, 7, 11, 0, 0, 317, 318, 7, 15, 0, 0, 318, 319, 7, 15, 0, 0, 319, 320, 7, 3, 0, 0, 320, 321, 7, 12, 0, 0, 321, 94, 1, 0, 0, 0, 322, 323, 7, 8, 0, 0, 323, 324, 7, 23, 0, 0, 324, 325, 7, 7, 0, 0, 325, 96, 1, 0, 0, 0, 326, 327, 7, 14, 0, 0, 327, 328, 7, 19, 0, 0, 328, 98, 1, 0, 0, 0, 329, 330, 7, 8, 0, 0, 330, 331, 7, 8, 0, 0, 331, 332, 7, 23, 0, 0, 332, 100, 1, 0, 0, 0, 333, 334, 7, 14, 0, 0, 334, 335, 7, 3, 0, 0, 335, 336, 7, 24, 0, 0, 336, 102, 1, 0, 0, 0, 337, 338, 7, 11, 0, 0, 338, 339, 7, 16, 0, 0, 339, 340, 7, 4, 0, 0, 340, 104, 1, 0, 0, 0, 341, 342, 7, 4, 0, 0, 342, 343, 7, 8, 0, 0, 343, 344, 7, 24, 0, 0, 344, 106, 1, 0, 0, 0, 345, 346, 7, 2, 0, 0, 346, 347, 7, 5, 0, 0, 347, 348, 7, 19, 0, 0, 348, 108, 1, 0, 0, 0, 349, 350, 7, 2, 0, 0, 350, 351, 7, 16, 0, 0, 351, 352, 7, 23, 0, 0, 352, 110, 1, 0, 0, 0, 353, 354, 7, 25, 0, 0, 354, 355, 1, 0, 0, 0, 355, 356, 6, 55, 0, 0, 356, 112, 1, 0, 0, 0, 357, 358, 3, 121, 60, 0, 358, 359, 1, 0, 0, 0, 359, 360, 6, 56, 0, 0, 360, 114, 1, 0, 0, 0, 361, 363, 5, 35, 0, 0, 362, 364, 7, 26, 0, 0, 363, 362, 1, 0, 0, 0, 364, 365, 1, 0, 0, 0, 365, 363, 1, 0, 0, 0, 365, 366, 1, 0, 0, 0, 366, 116, 1, 0, 0, 0, 367, 368, 5, 59, 0, 0, 368, 118, 1, 0, 0, 0, 369, 370, 9, 0, 0, 0, 370, 120, 1, 0, 0, 0, 371, 372, 5, 47, 0, 0, 372, 373, 5, 42, 0, 0, 373, 377, 1, 0, 0, 0, 374, 376, 9, 0, 0, 0, 375, 374, 1, 0, 0, 0, 376, 379, 1, 0, 0, 0, 377, 378, 1, 0, 0, 0, 377, 375, 1, 0, 0, 0, 378, 380, 1, 0, 0, 0, 379, 377, 1, 0, 0, 0, 380, 381, 5, 42, 0, 0, 381, 399, 5, 47, 0, 0, 382, 386, 5, 39, 0, 0, 383, 385, 9, 0, 0, 0, 384, 383, 1, 0, 0, 0, 385, 388, 1, 0, 0, 0, 386, 387, 1, 0, 0, 0, 386, 384, 1, 0, 0, 0, 387, 389, 1, 0, 0, 0, 388, 386, 1, 0, 0, 0, 389, 399, 5, 39, 0, 0, 390, 394, 5, 34, 0, 0, 391, 393, 9, 0, 0, 0, 392, 391, 1, 0, 0, 0, 393, 396, 1, 0, 0, 0, 394, 395, 1, 0, 0, 0, 394, 392, 1, 0, 0, 0, 395, 397, 1, 0, 0, 0, 396, 394, 1, 0, 0, 0, 397, 399, 5, 34, 0, 0, 398, 371, 1, 0, 0, 0, 398, 382, 1, 0, 0, 0, 398, 390, 1, 0, 0, 0, 399, 122, 1, 0, 0, 0, 13, 0, 159, 161, 166, 172, 179, 181, 363, 365, 377, 386, 394, 398, 1, 6, 0, 0]
--------------------------------------------------------------------------------
/src/.antlr/CalculatorLexer.tokens:
--------------------------------------------------------------------------------
1 | T__0=1
2 | T__1=2
3 | T__2=3
4 | T__3=4
5 | T__4=5
6 | T__5=6
7 | T__6=7
8 | T__7=8
9 | T__8=9
10 | T__9=10
11 | T__10=11
12 | T__11=12
13 | T__12=13
14 | T__13=14
15 | NUMBER=15
16 | FLOAT=16
17 | DIGIT=17
18 | MOD=18
19 | WHOLE=19
20 | MUL=20
21 | DIV=21
22 | ADD=22
23 | SUB=23
24 | PI=24
25 | EXPONENT=25
26 | NEGEXPONENT=26
27 | EULER=27
28 | SQRT=28
29 | SQR=29
30 | FLOOR=30
31 | CEIL=31
32 | ABS=32
33 | ROUNDK=33
34 | ROUND=34
35 | TRUNC=35
36 | SIN=36
37 | COS=37
38 | TAN=38
39 | COT=39
40 | SINH=40
41 | COSH=41
42 | TANH=42
43 | ARCSIN=43
44 | ARCCOS=44
45 | ARCTAN=45
46 | ARCTAN2=46
47 | ARCCOT=47
48 | EXP=48
49 | LN=49
50 | EEX=50
51 | LOG=51
52 | RAD=52
53 | DEG=53
54 | MIN=54
55 | MAX=55
56 | WS=56
57 | COM=57
58 | SUBSTITUTION=58
59 | SEMICOLON=59
60 | INVALID=60
61 | '='=1
62 | '('=2
63 | ')'=3
64 | '^'=4
65 | '**'=5
66 | '%'=6
67 | '~'=7
68 | '//'=8
69 | '['=9
70 | ']'=10
71 | '{'=11
72 | '}'=12
73 | '()'=13
74 | '..'=14
75 | '*'=20
76 | '/'=21
77 | '+'=22
78 | '-'=23
79 | ';'=59
80 |
--------------------------------------------------------------------------------
/src/CalculationResult.ts:
--------------------------------------------------------------------------------
1 | export class CalculationResult {
2 | public isValid: boolean = false;
3 | public errorPosition: number | null = null;
4 | public errorMessage: string | null = null;
5 | public result: number = NaN;
6 | }
7 |
--------------------------------------------------------------------------------
/src/Calculator.g4:
--------------------------------------------------------------------------------
1 | grammar Calculator;
2 |
3 | /*
4 | * Parser Rules
5 | */
6 |
7 | // Main entry for the calculator
8 | calculator: expression '='? trailingComment? compileUnit;
9 |
10 | // Possible expression types
11 | expression:
12 | SUB expression # Unary // Unary minus sign (negative numbers)
13 | | ADD expression # UnaryPlus // Unary plus sign (positive numbers)
14 | | FLOOR expression # Floor // Round down to zero accuracy
15 | | CEIL expression # Ceil // Round up to zero accuracy
16 | | ABS expression # Abs // Absolute value
17 | | ROUNDK '(' expression ';' expression ')' # Roundk // Round expr_1 with expr_2 accuracy
18 | | ROUND expression # Round // Round with zero accuracy
19 | | TRUNC expression # Trunc // Trim decimal digits
20 | | SIN expression # Sin // Sinus
21 | | COS expression # Cos // Cosinus
22 | | TAN expression # Tan // Tangens
23 | | COT expression # Cot // Cotangens
24 | | SINH expression # Sinh // Sinus Hypererbolicus
25 | | COSH expression # Cosh // Cosinus Hyperbolicus
26 | | TANH expression # Tanh // Tangens Hyperbolicus
27 | | ARCSIN expression # Arcsin // Inverse Sinus
28 | | ARCCOS expression # Arccos // Inverse Cosinus
29 | | ARCTAN expression # Arctan // Inverse Tangens
30 | | ARCTAN2 '(' expression ';' expression ')' # Arctan2 // Atan2
31 | | ARCCOT expression # Arccot // Inverse Cotangens
32 | | EXP expression # Exp // e ^ expr
33 | | LN expression # Ln // Logarithm to e
34 | | EEX expression # Eex // 10 ^ expr
35 | | LOG expression # Log // Logarithm to 10
36 | | RAD expression # Rad // Angle to radians (360� base)
37 | | DEG expression # Deg // Radians to angle (360� base)
38 | | SQRT expression # Sqrt // Square root
39 | | SQR expression # Sqr // Square product
40 | | expression EXPONENT expression # Exponent // Exponent, e.g. 10e+43
41 | | expression NEGEXPONENT expression # NegExponent // Inverted Exponent, e.g. 10e-43
42 | | expression op = ('^' | '**') expression # Pow // expr_1 to the expr_2 th power
43 | | expression (MOD | '%') expression # Mod // Modulo
44 | | expression WHOLE expression # Whole // Whole part of division rest
45 | | expression op = ('~' | '//') expression # SqRoot // expr_1 nth root of expr_2
46 | | expression op = ('*' | '/') expression # MulDiv // Multiplication or division
47 | | '(' expression ')' # Parenthesis // Expression within parentheses
48 | | '[' expression ']' # Parenthesis // Expression within parentheses
49 | | '{' expression '}' # Parenthesis // Expression within parentheses
50 | | expression '(' expression ')' # Mult // Multiplication without sign
51 | | '(' expression ')' expression # Mult // Multiplication without sign
52 | | MIN '(' expr += expression (';' expr += expression)* ')' # Min // Minimum
53 | | MAX '(' expr += expression (';' expr += expression)* ')' # Max // Maximum
54 | | expression op = (ADD | SUB) expression # AddSub // Addition or subtraction
55 | | NUMBER # Number // Single integer or float number
56 | | PI '()'? # Pi // Mathematical constant pi = 3,141593
57 | | EULER # Euler // Mathematical constant e = 2,718282
58 | | start = SUBSTITUTION '..' end = SUBSTITUTION # Range
59 | | SUBSTITUTION # Substitution;
60 |
61 | // End of file
62 | trailingComment: SEMICOLON .*?;
63 | compileUnit: EOF;
64 |
65 | /*
66 | * Lexer Rules
67 | */
68 |
69 | NUMBER: FLOAT | DIGIT+;
70 | FLOAT: DIGIT+ (',' | '.') DIGIT* | (',' | '.') DIGIT+;
71 | DIGIT: [0-9];
72 | MOD: [Mm][Oo][Dd];
73 | WHOLE: [Dd][Ii][Vv];
74 | MUL: '*';
75 | DIV: '/';
76 | ADD: '+';
77 | SUB: '-';
78 | PI: [Pp][Ii];
79 | EXPONENT: [Ee] '+';
80 | NEGEXPONENT: [Ee] '-';
81 | EULER: [Ee];
82 | SQRT: [Ss][Qq][Rr][Tt];
83 | SQR: [Ss][Qq][Rr];
84 | FLOOR: [Ff][Ll][Oo][Oo][Rr];
85 | CEIL: [Cc][Ee][Ii][Ll];
86 | ABS: [Aa][Bb][Ss];
87 | ROUNDK: [Rr][Oo][Uu][Nn][Dd][Kk];
88 | ROUND: [Rr][Oo][Uu][Nn][Dd];
89 | TRUNC: [Tt][Rr][Uu][Nn][Cc];
90 | SIN: [Ss][Ii][Nn];
91 | COS: [Cc][Oo][Ss];
92 | TAN: [Tt][Aa][Nn];
93 | COT: [Cc][Oo][Tt];
94 | SINH: [Ss][Ii][Nn][Hh];
95 | COSH: [Cc][Oo][Ss][Hh];
96 | TANH: [Tt][Aa][Nn][Hh];
97 | ARCSIN: [Aa][Rr][Cc][Ss][Ii][Nn];
98 | ARCCOS: [Aa][Rr][Cc][Cc][Oo][Ss];
99 | ARCTAN: [Aa][Rr][Cc][Tt][Aa][Nn];
100 | ARCTAN2: [Aa][Rr][Cc][Tt][Aa][Nn][2];
101 | ARCCOT: [Aa][Rr][Cc][Cc][Oo][Tt];
102 | EXP: [Ee][Xx][Pp];
103 | LN: [Ll][Nn];
104 | EEX: [Ee][Ee][Xx];
105 | LOG: [Ll][Oo][Gg];
106 | RAD: [Rr][Aa][Dd];
107 | DEG: [Dd][Ee][Gg];
108 | MIN: [Mm][Ii][Nn];
109 | MAX: [Mm][Aa][Xx];
110 | WS: (' ' | '\t' | '\r' | '\n') -> skip;
111 | COM: COMMENT -> skip;
112 | SUBSTITUTION: '#' ([a-z] | [A-Z] | [äÄöÖüÜ] | [0-9])+;
113 | SEMICOLON: ';';
114 | INVALID: .;
115 |
116 | fragment COMMENT: '/*' .*? '*/' | '\'' .*? '\'' | '"' .*? '"';
--------------------------------------------------------------------------------
/src/Calculator.ts:
--------------------------------------------------------------------------------
1 | import { CharStreams, CommonTokenStream } from 'antlr4ts';
2 |
3 | import { CalculationResult } from './CalculationResult';
4 | import { CalculatorLexer } from './GeneratedAntlr/CalculatorLexer';
5 | import { CalculatorParser } from './GeneratedAntlr/CalculatorParser';
6 | import { FormulaErrorListener } from './FormulaErrorListener';
7 | import { FormulaVisitor } from './FormulaVisitor';
8 |
9 | export class Calculator {
10 | public static calculate(
11 | formula: string,
12 | substitutionResolver?: (substitution: string) => number,
13 | rangeResolver?: (range: { start: string; end: string }) => number
14 | ): CalculationResult {
15 | var result = new CalculationResult();
16 | if (formula == null || /^\s*$/.test(formula)) {
17 | result.result = 0;
18 | result.isValid = true;
19 | return result;
20 | }
21 | var inputStream = CharStreams.fromString(formula);
22 | var lexer = new CalculatorLexer(inputStream);
23 | var commonTokenStream = new CommonTokenStream(lexer);
24 | var parser = new CalculatorParser(commonTokenStream);
25 | var errorListener = new FormulaErrorListener();
26 | parser.removeErrorListeners();
27 | parser.addErrorListener(errorListener);
28 | if (!substitutionResolver) {
29 | substitutionResolver = (_) => null;
30 | }
31 |
32 | if (!rangeResolver) {
33 | rangeResolver = (_) => null;
34 | }
35 |
36 | var visitor = new FormulaVisitor(
37 | substitutionResolver,
38 | rangeResolver,
39 | errorListener
40 | );
41 | var parseTree = parser.calculator();
42 | var visitorResult = visitor.visitCalculator(parseTree);
43 | if (errorListener.isValid) {
44 | if (isNaN(visitorResult)) {
45 | result.isValid = false;
46 | result.result = NaN;
47 | } else {
48 | result.isValid = true;
49 | result.result = visitorResult;
50 | }
51 | return result;
52 | }
53 | result.isValid = false;
54 | result.errorPosition = errorListener.errorLocation;
55 | result.errorMessage = errorListener.errorMessage;
56 | result.result = NaN;
57 | return result;
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/src/FormulaErrorListener.ts:
--------------------------------------------------------------------------------
1 | export class FormulaErrorListener {
2 | private _isValid = true;
3 | private _errorLocation: number | null = null;
4 | private _errorMessage: string | null = null;
5 |
6 | public get isValid() {
7 | return this._isValid;
8 | }
9 |
10 | public get errorLocation() {
11 | return this._errorLocation;
12 | }
13 |
14 | public get errorMessage() {
15 | return this._errorMessage;
16 | }
17 |
18 | public syntaxError(recognizer, offendingSymbol, line, column, msg, e) {
19 | this._isValid = false;
20 | this._errorLocation = column;
21 | this._errorMessage = msg;
22 | }
23 |
24 | /**
25 | * Method stub - does nothing
26 | * @param recognizer
27 | * @param dfa
28 | * @param startIndex
29 | * @param stopIndex
30 | * @param exact
31 | * @param ambigAlts
32 | * @param configs
33 | */
34 | public reportAmbiguity(
35 | recognizer,
36 | dfa,
37 | startIndex,
38 | stopIndex,
39 | exact,
40 | ambigAlts,
41 | configs
42 | ) {}
43 |
44 | /**
45 | * Method stub - does nothing
46 | * @param recognizer
47 | * @param dfa
48 | * @param startIndex
49 | * @param stopIndex
50 | * @param conflictingAlts
51 | * @param configs
52 | */
53 | public reportAttemptingFullContext(
54 | recognizer,
55 | dfa,
56 | startIndex,
57 | stopIndex,
58 | conflictingAlts,
59 | configs
60 | ) {}
61 |
62 | /**
63 | * Method stub - does nothing
64 | * @param recognizer
65 | * @param dfa
66 | * @param startIndex
67 | * @param stopIndex
68 | * @param prediction
69 | * @param configs
70 | */
71 | public reportContextSensitivity(
72 | recognizer,
73 | dfa,
74 | startIndex,
75 | stopIndex,
76 | prediction,
77 | configs
78 | ) {}
79 |
80 | public reportSubstitutionNotFound(
81 | errorLocation: number,
82 | substitution: string
83 | ) {
84 | this._isValid = false;
85 | this._errorLocation = errorLocation;
86 | this._errorMessage = `The substitution '${substitution}' could not be resolved`;
87 | }
88 |
89 | public reportRangeNotFound(errorLocation: number, range: string) {
90 | this._isValid = false;
91 | this._errorLocation = errorLocation;
92 | this._errorMessage = `The range '${range}' could not be resolved`;
93 | }
94 | }
95 |
--------------------------------------------------------------------------------
/src/FormulaVisitor.ts:
--------------------------------------------------------------------------------
1 | import {
2 | AbsContext,
3 | MaxContext,
4 | MinContext,
5 | RangeContext,
6 | SubstitutionContext
7 | } from './GeneratedAntlr/CalculatorParser';
8 |
9 | import { AbstractParseTreeVisitor } from 'antlr4ts/tree/AbstractParseTreeVisitor';
10 | import { AddSubContext } from './GeneratedAntlr/CalculatorParser';
11 | import { ArccosContext } from './GeneratedAntlr/CalculatorParser';
12 | import { ArccotContext } from './GeneratedAntlr/CalculatorParser';
13 | import { ArcsinContext } from './GeneratedAntlr/CalculatorParser';
14 | import { Arctan2Context } from './GeneratedAntlr/CalculatorParser';
15 | import { ArctanContext } from './GeneratedAntlr/CalculatorParser';
16 | import { CalculatorContext } from './GeneratedAntlr/CalculatorParser';
17 | import { CalculatorVisitor } from './GeneratedAntlr/CalculatorVisitor';
18 | import { CeilContext } from './GeneratedAntlr/CalculatorParser';
19 | import { CosContext } from './GeneratedAntlr/CalculatorParser';
20 | import { CoshContext } from './GeneratedAntlr/CalculatorParser';
21 | import { CotContext } from './GeneratedAntlr/CalculatorParser';
22 | import { DegContext } from './GeneratedAntlr/CalculatorParser';
23 | import { EexContext } from './GeneratedAntlr/CalculatorParser';
24 | import { EulerContext } from './GeneratedAntlr/CalculatorParser';
25 | import { ExpContext } from './GeneratedAntlr/CalculatorParser';
26 | import { ExponentContext } from './GeneratedAntlr/CalculatorParser';
27 | import { ExpressionContext } from './GeneratedAntlr/CalculatorParser';
28 | import { FloorContext } from './GeneratedAntlr/CalculatorParser';
29 | import { FormulaErrorListener } from './FormulaErrorListener';
30 | import { LnContext } from './GeneratedAntlr/CalculatorParser';
31 | import { LogContext } from './GeneratedAntlr/CalculatorParser';
32 | import { ModContext } from './GeneratedAntlr/CalculatorParser';
33 | import { MulDivContext } from './GeneratedAntlr/CalculatorParser';
34 | import { MultContext } from './GeneratedAntlr/CalculatorParser';
35 | import { NegExponentContext } from './GeneratedAntlr/CalculatorParser';
36 | import { NumberContext } from './GeneratedAntlr/CalculatorParser';
37 | import { ParenthesisContext } from './GeneratedAntlr/CalculatorParser';
38 | import { PiContext } from './GeneratedAntlr/CalculatorParser';
39 | import { PowContext } from './GeneratedAntlr/CalculatorParser';
40 | import { RadContext } from './GeneratedAntlr/CalculatorParser';
41 | import { RoundContext } from './GeneratedAntlr/CalculatorParser';
42 | import { RoundkContext } from './GeneratedAntlr/CalculatorParser';
43 | import { SinContext } from './GeneratedAntlr/CalculatorParser';
44 | import { SinhContext } from './GeneratedAntlr/CalculatorParser';
45 | import { SqRootContext } from './GeneratedAntlr/CalculatorParser';
46 | import { SqrContext } from './GeneratedAntlr/CalculatorParser';
47 | import { SqrtContext } from './GeneratedAntlr/CalculatorParser';
48 | import { TanContext } from './GeneratedAntlr/CalculatorParser';
49 | import { TanhContext } from './GeneratedAntlr/CalculatorParser';
50 | import { TruncContext } from './GeneratedAntlr/CalculatorParser';
51 | import { UnaryContext } from './GeneratedAntlr/CalculatorParser';
52 | import { UnaryPlusContext } from './GeneratedAntlr/CalculatorParser';
53 | import { WholeContext } from './GeneratedAntlr/CalculatorParser';
54 |
55 | export class FormulaVisitor
56 | extends AbstractParseTreeVisitor
57 | implements CalculatorVisitor
58 | {
59 | protected defaultResult(): number {
60 | return 0;
61 | }
62 |
63 | constructor(
64 | private substitutionResolver: (substitution: string) => number,
65 | private rangeResolver: (range: { start: string; end: string }) => number,
66 | private formulaErrorListener: FormulaErrorListener
67 | ) {
68 | super();
69 | }
70 |
71 | visitSubstitution(context: SubstitutionContext): number {
72 | const substitution = context.text;
73 | const resolved = this.substitutionResolver(substitution);
74 | if (resolved != null) {
75 | return resolved;
76 | }
77 |
78 | this.formulaErrorListener.reportSubstitutionNotFound(
79 | context.start.tokenIndex,
80 | substitution
81 | );
82 | return 0;
83 | }
84 |
85 | visitRange(context: RangeContext): number {
86 | const resolved = this.rangeResolver({
87 | start: context.start.text,
88 | end: context._end.text
89 | });
90 | if (resolved != null) {
91 | return resolved;
92 | }
93 |
94 | this.formulaErrorListener.reportRangeNotFound(
95 | context.start.tokenIndex,
96 | context.text
97 | );
98 | return 0;
99 | }
100 |
101 | // Visit a parse tree produced by calculatorParser#calculator.
102 | visitCalculator(context: CalculatorContext): number {
103 | return context.expression().accept(this);
104 | }
105 |
106 | visitMin(context: MinContext): number {
107 | let currentMin = this.visitExpression(context._expr[0]);
108 |
109 | if (context._expr.length > 1) {
110 | for (let i = 1; i < context._expr.length; i++) {
111 | currentMin = Math.min(
112 | currentMin,
113 | this.visitExpression(context._expr[i])
114 | );
115 | }
116 | }
117 |
118 | return currentMin;
119 | }
120 |
121 | visitMax(context: MaxContext): number {
122 | let currentMax = this.visitExpression(context._expr[0]);
123 |
124 | if (context._expr.length > 1) {
125 | for (let i = 1; i < context._expr.length; i++) {
126 | currentMax = Math.max(
127 | currentMax,
128 | this.visitExpression(context._expr[i])
129 | );
130 | }
131 | }
132 |
133 | return currentMax;
134 | }
135 |
136 | visitExpression(context: ExpressionContext): number {
137 | return context.accept(this);
138 | }
139 |
140 | // Visit a parse tree produced by calculatorParser#Tan.
141 | visitTan(context: TanContext): number {
142 | return Math.tan(this.visitExpression(context.expression()));
143 | }
144 |
145 | // Visit a parse tree produced by calculatorParser#Cosh.
146 | visitCosh(context: CoshContext): number {
147 | return Math.cosh(this.visitExpression(context.expression()));
148 | }
149 |
150 | // Visit a parse tree produced by calculatorParser#SqRoot.
151 | visitSqRoot(context: SqRootContext): number {
152 | var nthRoot = this.visitExpression(context.expression(0));
153 | if (nthRoot === 0) {
154 | return NaN;
155 | }
156 | return Math.pow(this.visitExpression(context.expression(1)), 1 / nthRoot);
157 | }
158 |
159 | // Visit a parse tree produced by calculatorParser#NegExponent.
160 | visitNegExponent(context: NegExponentContext): number {
161 | return (
162 | this.visitExpression(context.expression(0)) *
163 | Math.pow(10, -1 * this.visitExpression(context.expression(1)))
164 | );
165 | }
166 |
167 | // Visit a parse tree produced by calculatorParser#Exponent.
168 | visitExponent(context: ExponentContext): number {
169 | return (
170 | this.visitExpression(context.expression(0)) *
171 | Math.pow(10, this.visitExpression(context.expression(1)))
172 | );
173 | }
174 |
175 | // Visit a parse tree produced by calculatorParser#Arctan2.
176 | visitArctan2(context: Arctan2Context): number {
177 | return Math.atan2(
178 | this.visitExpression(context.expression(0)),
179 | this.visitExpression(context.expression(1))
180 | );
181 | }
182 |
183 | // Visit a parse tree produced by calculatorParser#MulDiv.
184 | visitMulDiv(context: MulDivContext): number {
185 | if (context._op.text === '*') {
186 | return (
187 | this.visitExpression(context.expression(0)) *
188 | this.visitExpression(context.expression(1))
189 | );
190 | } else {
191 | var divisor = this.visitExpression(context.expression(1));
192 | if (divisor !== 0) {
193 | return this.visitExpression(context.expression(0)) / divisor;
194 | }
195 | return NaN;
196 | }
197 | }
198 |
199 | visitMult(context: MultContext): number {
200 | return (
201 | this.visitExpression(context.expression(0)) *
202 | this.visitExpression(context.expression(1))
203 | );
204 | }
205 |
206 | // Visit a parse tree produced by calculatorParser#Arcsin.
207 | visitArcsin(context: ArcsinContext): number {
208 | return Math.asin(this.visitExpression(context.expression()));
209 | }
210 |
211 | // Visit a parse tree produced by calculatorParser#Arccot.
212 | visitArccot(context: ArccotContext): number {
213 | return (
214 | Math.PI * 0.5 - Math.atan(this.visitExpression(context.expression()))
215 | );
216 | }
217 |
218 | // Visit a parse tree produced by calculatorParser#Arccos.
219 | visitArccos(context: ArccosContext): number {
220 | return Math.acos(this.visitExpression(context.expression()));
221 | }
222 |
223 | // Visit a parse tree produced by calculatorParser#Euler.
224 | visitEuler(context: EulerContext): number {
225 | return Math.E;
226 | }
227 |
228 | // Visit a parse tree produced by calculatorParser#Arctan.
229 | visitArctan(context: ArctanContext): number {
230 | return Math.atan(this.visitExpression(context.expression()));
231 | }
232 |
233 | // Visit a parse tree produced by calculatorParser#Parenthesis.
234 | visitParenthesis(context: ParenthesisContext): number {
235 | return this.visitExpression(context.expression());
236 | }
237 |
238 | // Visit a parse tree produced by calculatorParser#Abs.
239 | visitAbs(context: AbsContext): number {
240 | return Math.abs(this.visitExpression(context.expression()));
241 | }
242 |
243 | // Visit a parse tree produced by calculatorParser#Number.
244 | visitNumber(context: NumberContext): number {
245 | return Number(context.text.replace(',', '.'));
246 | }
247 |
248 | // Visit a parse tree produced by calculatorParser#Sinh.
249 | visitSinh(context: SinhContext): number {
250 | return Math.sinh(this.visitExpression(context.expression()));
251 | }
252 |
253 | // Visit a parse tree produced by calculatorParser#Round.
254 | visitRound(context: RoundContext): number {
255 | return Math.round(this.visitExpression(context.expression()));
256 | }
257 |
258 | // Visit a parse tree produced by calculatorParser#Trunc.
259 | visitTrunc(context: TruncContext): number {
260 | return Math.trunc(this.visitExpression(context.expression()));
261 | }
262 |
263 | // Visit a parse tree produced by calculatorParser#Pi.
264 | visitPi(context: PiContext): number {
265 | return Math.PI;
266 | }
267 |
268 | // Visit a parse tree produced by calculatorParser#Tanh.
269 | visitTanh(context: TanhContext): number {
270 | return Math.tanh(this.visitExpression(context.expression()));
271 | }
272 |
273 | // Visit a parse tree produced by calculatorParser#Floor.
274 | visitFloor(context: FloorContext): number {
275 | return Math.floor(this.visitExpression(context.expression()));
276 | }
277 |
278 | // Visit a parse tree produced by calculatorParser#Ln.
279 | visitLn(context: LnContext): number {
280 | return Math.log(this.visitExpression(context.expression()));
281 | }
282 |
283 | // Visit a parse tree produced by calculatorParser#Mod.
284 | visitMod(context: ModContext): number {
285 | return (
286 | this.visitExpression(context.expression(0)) %
287 | this.visitExpression(context.expression(1))
288 | );
289 | }
290 |
291 | // Visit a parse tree produced by calculatorParser#Log.
292 | visitLog(context: LogContext): number {
293 | return Math.log10(this.visitExpression(context.expression()));
294 | }
295 |
296 | // Visit a parse tree produced by calculatorParser#AddSub.
297 | visitAddSub(context: AddSubContext): number {
298 | return context._op.text === '+'
299 | ? this.visitExpression(context.expression(0)) +
300 | this.visitExpression(context.expression(1))
301 | : this.visitExpression(context.expression(0)) -
302 | this.visitExpression(context.expression(1));
303 | }
304 |
305 | // Visit a parse tree produced by calculatorParser#Cos.
306 | visitCos(context: CosContext): number {
307 | return Math.cos(this.visitExpression(context.expression()));
308 | }
309 |
310 | // Visit a parse tree produced by calculatorParser#Deg.
311 | visitDeg(context: DegContext): number {
312 | return (this.visitExpression(context.expression()) * 180) / Math.PI;
313 | }
314 |
315 | // Visit a parse tree produced by calculatorParser#Sqrt.
316 | visitSqrt(context: SqrtContext): number {
317 | return Math.sqrt(this.visitExpression(context.expression()));
318 | }
319 |
320 | // Visit a parse tree produced by calculatorParser#Cot.
321 | visitCot(context: CotContext): number {
322 | return 1 / Math.tan(this.visitExpression(context.expression()));
323 | }
324 |
325 | // Visit a parse tree produced by calculatorParser#Whole.
326 | visitWhole(context: WholeContext): number {
327 | return Math.trunc(
328 | this.visitExpression(context.expression(0)) /
329 | this.visitExpression(context.expression(1))
330 | );
331 | }
332 |
333 | // Visit a parse tree produced by calculatorParser#Unary.
334 | visitUnary(context: UnaryContext): number {
335 | return -1 * this.visitExpression(context.expression());
336 | }
337 |
338 | // Visit a parse tree produced by calculatorParser#UnaryPlus.
339 | visitUnaryPlus(context: UnaryPlusContext): number {
340 | return this.visitExpression(context.expression());
341 | }
342 |
343 | // Visit a parse tree produced by calculatorParser#Rad.
344 | visitRad(context: RadContext): number {
345 | return (this.visitExpression(context.expression()) * Math.PI) / 180;
346 | }
347 |
348 | // Visit a parse tree produced by calculatorParser#Sqr.
349 | visitSqr(context: SqrContext): number {
350 | return (
351 | this.visitExpression(context.expression()) *
352 | this.visitExpression(context.expression())
353 | );
354 | }
355 |
356 | // Visit a parse tree produced by calculatorParser#Sin.
357 | visitSin(context: SinContext): number {
358 | return Math.sin(this.visitExpression(context.expression()));
359 | }
360 |
361 | // Visit a parse tree produced by calculatorParser#Eex.
362 | visitEex(context: EexContext): number {
363 | return Math.pow(10, this.visitExpression(context.expression()));
364 | }
365 |
366 | // Visit a parse tree produced by calculatorParser#Pow.
367 | visitPow(context: PowContext): number {
368 | return Math.pow(
369 | this.visitExpression(context.expression(0)),
370 | this.visitExpression(context.expression(1))
371 | );
372 | }
373 |
374 | // Visit a parse tree produced by calculatorParser#Ceil.
375 | visitCeil(context: CeilContext): number {
376 | return Math.ceil(this.visitExpression(context.expression()));
377 | }
378 |
379 | // Visit a parse tree produced by calculatorParser#Exp.
380 | visitExp(context: ExpContext): number {
381 | return Math.pow(Math.E, this.visitExpression(context.expression()));
382 | }
383 |
384 | // Visit a parse tree produced by calculatorParser#Roundk.
385 | visitRoundk(context: RoundkContext): number {
386 | return (
387 | Math.round(
388 | this.visitExpression(context.expression(0)) *
389 | Math.pow(10, this.visitExpression(context.expression(1)))
390 | ) / Math.pow(10, this.visitExpression(context.expression(1)))
391 | );
392 | }
393 | }
394 |
--------------------------------------------------------------------------------
/src/GeneratedAntlr/Calculator.interp:
--------------------------------------------------------------------------------
1 | token literal names:
2 | null
3 | '='
4 | '('
5 | ')'
6 | '^'
7 | '**'
8 | '%'
9 | '~'
10 | '//'
11 | '['
12 | ']'
13 | '{'
14 | '}'
15 | '()'
16 | '..'
17 | null
18 | null
19 | null
20 | null
21 | null
22 | '*'
23 | '/'
24 | '+'
25 | '-'
26 | null
27 | null
28 | null
29 | null
30 | null
31 | null
32 | null
33 | null
34 | null
35 | null
36 | null
37 | null
38 | null
39 | null
40 | null
41 | null
42 | null
43 | null
44 | null
45 | null
46 | null
47 | null
48 | null
49 | null
50 | null
51 | null
52 | null
53 | null
54 | null
55 | null
56 | null
57 | null
58 | null
59 | null
60 | null
61 | ';'
62 | null
63 |
64 | token symbolic names:
65 | null
66 | null
67 | null
68 | null
69 | null
70 | null
71 | null
72 | null
73 | null
74 | null
75 | null
76 | null
77 | null
78 | null
79 | null
80 | NUMBER
81 | FLOAT
82 | DIGIT
83 | MOD
84 | WHOLE
85 | MUL
86 | DIV
87 | ADD
88 | SUB
89 | PI
90 | EXPONENT
91 | NEGEXPONENT
92 | EULER
93 | SQRT
94 | SQR
95 | FLOOR
96 | CEIL
97 | ABS
98 | ROUNDK
99 | ROUND
100 | TRUNC
101 | SIN
102 | COS
103 | TAN
104 | COT
105 | SINH
106 | COSH
107 | TANH
108 | ARCSIN
109 | ARCCOS
110 | ARCTAN
111 | ARCTAN2
112 | ARCCOT
113 | EXP
114 | LN
115 | EEX
116 | LOG
117 | RAD
118 | DEG
119 | MIN
120 | MAX
121 | WS
122 | COM
123 | SUBSTITUTION
124 | SEMICOLON
125 | INVALID
126 |
127 | rule names:
128 | calculator
129 | expression
130 | trailingComment
131 | compileUnit
132 |
133 |
134 | atn:
135 | [3, 51485, 51898, 1421, 44986, 20307, 1543, 60043, 49729, 3, 62, 183, 4, 2, 9, 2, 4, 3, 9, 3, 4, 4, 9, 4, 4, 5, 9, 5, 3, 2, 3, 2, 5, 2, 13, 10, 2, 3, 2, 5, 2, 16, 10, 2, 3, 2, 3, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 7, 3, 109, 10, 3, 12, 3, 14, 3, 112, 11, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 7, 3, 121, 10, 3, 12, 3, 14, 3, 124, 11, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 5, 3, 131, 10, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 5, 3, 138, 10, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 7, 3, 169, 10, 3, 12, 3, 14, 3, 172, 11, 3, 3, 4, 3, 4, 7, 4, 176, 10, 4, 12, 4, 14, 4, 179, 11, 4, 3, 5, 3, 5, 3, 5, 3, 177, 2, 3, 4, 6, 2, 2, 4, 2, 6, 2, 8, 2, 2, 7, 3, 2, 6, 7, 4, 2, 8, 8, 20, 20, 3, 2, 9, 10, 3, 2, 22, 23, 3, 2, 24, 25, 2, 231, 2, 10, 3, 2, 2, 2, 4, 137, 3, 2, 2, 2, 6, 173, 3, 2, 2, 2, 8, 180, 3, 2, 2, 2, 10, 12, 5, 4, 3, 2, 11, 13, 7, 3, 2, 2, 12, 11, 3, 2, 2, 2, 12, 13, 3, 2, 2, 2, 13, 15, 3, 2, 2, 2, 14, 16, 5, 6, 4, 2, 15, 14, 3, 2, 2, 2, 15, 16, 3, 2, 2, 2, 16, 17, 3, 2, 2, 2, 17, 18, 5, 8, 5, 2, 18, 3, 3, 2, 2, 2, 19, 20, 8, 3, 1, 2, 20, 21, 7, 25, 2, 2, 21, 138, 5, 4, 3, 50, 22, 23, 7, 24, 2, 2, 23, 138, 5, 4, 3, 49, 24, 25, 7, 32, 2, 2, 25, 138, 5, 4, 3, 48, 26, 27, 7, 33, 2, 2, 27, 138, 5, 4, 3, 47, 28, 29, 7, 34, 2, 2, 29, 138, 5, 4, 3, 46, 30, 31, 7, 35, 2, 2, 31, 32, 7, 4, 2, 2, 32, 33, 5, 4, 3, 2, 33, 34, 7, 61, 2, 2, 34, 35, 5, 4, 3, 2, 35, 36, 7, 5, 2, 2, 36, 138, 3, 2, 2, 2, 37, 38, 7, 36, 2, 2, 38, 138, 5, 4, 3, 44, 39, 40, 7, 37, 2, 2, 40, 138, 5, 4, 3, 43, 41, 42, 7, 38, 2, 2, 42, 138, 5, 4, 3, 42, 43, 44, 7, 39, 2, 2, 44, 138, 5, 4, 3, 41, 45, 46, 7, 40, 2, 2, 46, 138, 5, 4, 3, 40, 47, 48, 7, 41, 2, 2, 48, 138, 5, 4, 3, 39, 49, 50, 7, 42, 2, 2, 50, 138, 5, 4, 3, 38, 51, 52, 7, 43, 2, 2, 52, 138, 5, 4, 3, 37, 53, 54, 7, 44, 2, 2, 54, 138, 5, 4, 3, 36, 55, 56, 7, 45, 2, 2, 56, 138, 5, 4, 3, 35, 57, 58, 7, 46, 2, 2, 58, 138, 5, 4, 3, 34, 59, 60, 7, 47, 2, 2, 60, 138, 5, 4, 3, 33, 61, 62, 7, 48, 2, 2, 62, 63, 7, 4, 2, 2, 63, 64, 5, 4, 3, 2, 64, 65, 7, 61, 2, 2, 65, 66, 5, 4, 3, 2, 66, 67, 7, 5, 2, 2, 67, 138, 3, 2, 2, 2, 68, 69, 7, 49, 2, 2, 69, 138, 5, 4, 3, 31, 70, 71, 7, 50, 2, 2, 71, 138, 5, 4, 3, 30, 72, 73, 7, 51, 2, 2, 73, 138, 5, 4, 3, 29, 74, 75, 7, 52, 2, 2, 75, 138, 5, 4, 3, 28, 76, 77, 7, 53, 2, 2, 77, 138, 5, 4, 3, 27, 78, 79, 7, 54, 2, 2, 79, 138, 5, 4, 3, 26, 80, 81, 7, 55, 2, 2, 81, 138, 5, 4, 3, 25, 82, 83, 7, 30, 2, 2, 83, 138, 5, 4, 3, 24, 84, 85, 7, 31, 2, 2, 85, 138, 5, 4, 3, 23, 86, 87, 7, 4, 2, 2, 87, 88, 5, 4, 3, 2, 88, 89, 7, 5, 2, 2, 89, 138, 3, 2, 2, 2, 90, 91, 7, 11, 2, 2, 91, 92, 5, 4, 3, 2, 92, 93, 7, 12, 2, 2, 93, 138, 3, 2, 2, 2, 94, 95, 7, 13, 2, 2, 95, 96, 5, 4, 3, 2, 96, 97, 7, 14, 2, 2, 97, 138, 3, 2, 2, 2, 98, 99, 7, 4, 2, 2, 99, 100, 5, 4, 3, 2, 100, 101, 7, 5, 2, 2, 101, 102, 5, 4, 3, 11, 102, 138, 3, 2, 2, 2, 103, 104, 7, 56, 2, 2, 104, 105, 7, 4, 2, 2, 105, 110, 5, 4, 3, 2, 106, 107, 7, 61, 2, 2, 107, 109, 5, 4, 3, 2, 108, 106, 3, 2, 2, 2, 109, 112, 3, 2, 2, 2, 110, 108, 3, 2, 2, 2, 110, 111, 3, 2, 2, 2, 111, 113, 3, 2, 2, 2, 112, 110, 3, 2, 2, 2, 113, 114, 7, 5, 2, 2, 114, 138, 3, 2, 2, 2, 115, 116, 7, 57, 2, 2, 116, 117, 7, 4, 2, 2, 117, 122, 5, 4, 3, 2, 118, 119, 7, 61, 2, 2, 119, 121, 5, 4, 3, 2, 120, 118, 3, 2, 2, 2, 121, 124, 3, 2, 2, 2, 122, 120, 3, 2, 2, 2, 122, 123, 3, 2, 2, 2, 123, 125, 3, 2, 2, 2, 124, 122, 3, 2, 2, 2, 125, 126, 7, 5, 2, 2, 126, 138, 3, 2, 2, 2, 127, 138, 7, 17, 2, 2, 128, 130, 7, 26, 2, 2, 129, 131, 7, 15, 2, 2, 130, 129, 3, 2, 2, 2, 130, 131, 3, 2, 2, 2, 131, 138, 3, 2, 2, 2, 132, 138, 7, 29, 2, 2, 133, 134, 7, 60, 2, 2, 134, 135, 7, 16, 2, 2, 135, 138, 7, 60, 2, 2, 136, 138, 7, 60, 2, 2, 137, 19, 3, 2, 2, 2, 137, 22, 3, 2, 2, 2, 137, 24, 3, 2, 2, 2, 137, 26, 3, 2, 2, 2, 137, 28, 3, 2, 2, 2, 137, 30, 3, 2, 2, 2, 137, 37, 3, 2, 2, 2, 137, 39, 3, 2, 2, 2, 137, 41, 3, 2, 2, 2, 137, 43, 3, 2, 2, 2, 137, 45, 3, 2, 2, 2, 137, 47, 3, 2, 2, 2, 137, 49, 3, 2, 2, 2, 137, 51, 3, 2, 2, 2, 137, 53, 3, 2, 2, 2, 137, 55, 3, 2, 2, 2, 137, 57, 3, 2, 2, 2, 137, 59, 3, 2, 2, 2, 137, 61, 3, 2, 2, 2, 137, 68, 3, 2, 2, 2, 137, 70, 3, 2, 2, 2, 137, 72, 3, 2, 2, 2, 137, 74, 3, 2, 2, 2, 137, 76, 3, 2, 2, 2, 137, 78, 3, 2, 2, 2, 137, 80, 3, 2, 2, 2, 137, 82, 3, 2, 2, 2, 137, 84, 3, 2, 2, 2, 137, 86, 3, 2, 2, 2, 137, 90, 3, 2, 2, 2, 137, 94, 3, 2, 2, 2, 137, 98, 3, 2, 2, 2, 137, 103, 3, 2, 2, 2, 137, 115, 3, 2, 2, 2, 137, 127, 3, 2, 2, 2, 137, 128, 3, 2, 2, 2, 137, 132, 3, 2, 2, 2, 137, 133, 3, 2, 2, 2, 137, 136, 3, 2, 2, 2, 138, 170, 3, 2, 2, 2, 139, 140, 12, 22, 2, 2, 140, 141, 7, 27, 2, 2, 141, 169, 5, 4, 3, 23, 142, 143, 12, 21, 2, 2, 143, 144, 7, 28, 2, 2, 144, 169, 5, 4, 3, 22, 145, 146, 12, 20, 2, 2, 146, 147, 9, 2, 2, 2, 147, 169, 5, 4, 3, 21, 148, 149, 12, 19, 2, 2, 149, 150, 9, 3, 2, 2, 150, 169, 5, 4, 3, 20, 151, 152, 12, 18, 2, 2, 152, 153, 7, 21, 2, 2, 153, 169, 5, 4, 3, 19, 154, 155, 12, 17, 2, 2, 155, 156, 9, 4, 2, 2, 156, 169, 5, 4, 3, 18, 157, 158, 12, 16, 2, 2, 158, 159, 9, 5, 2, 2, 159, 169, 5, 4, 3, 17, 160, 161, 12, 8, 2, 2, 161, 162, 9, 6, 2, 2, 162, 169, 5, 4, 3, 9, 163, 164, 12, 12, 2, 2, 164, 165, 7, 4, 2, 2, 165, 166, 5, 4, 3, 2, 166, 167, 7, 5, 2, 2, 167, 169, 3, 2, 2, 2, 168, 139, 3, 2, 2, 2, 168, 142, 3, 2, 2, 2, 168, 145, 3, 2, 2, 2, 168, 148, 3, 2, 2, 2, 168, 151, 3, 2, 2, 2, 168, 154, 3, 2, 2, 2, 168, 157, 3, 2, 2, 2, 168, 160, 3, 2, 2, 2, 168, 163, 3, 2, 2, 2, 169, 172, 3, 2, 2, 2, 170, 168, 3, 2, 2, 2, 170, 171, 3, 2, 2, 2, 171, 5, 3, 2, 2, 2, 172, 170, 3, 2, 2, 2, 173, 177, 7, 61, 2, 2, 174, 176, 11, 2, 2, 2, 175, 174, 3, 2, 2, 2, 176, 179, 3, 2, 2, 2, 177, 178, 3, 2, 2, 2, 177, 175, 3, 2, 2, 2, 178, 7, 3, 2, 2, 2, 179, 177, 3, 2, 2, 2, 180, 181, 7, 2, 2, 3, 181, 9, 3, 2, 2, 2, 11, 12, 15, 110, 122, 130, 137, 168, 170, 177]
--------------------------------------------------------------------------------
/src/GeneratedAntlr/Calculator.tokens:
--------------------------------------------------------------------------------
1 | T__0=1
2 | T__1=2
3 | T__2=3
4 | T__3=4
5 | T__4=5
6 | T__5=6
7 | T__6=7
8 | T__7=8
9 | T__8=9
10 | T__9=10
11 | T__10=11
12 | T__11=12
13 | T__12=13
14 | T__13=14
15 | NUMBER=15
16 | FLOAT=16
17 | DIGIT=17
18 | MOD=18
19 | WHOLE=19
20 | MUL=20
21 | DIV=21
22 | ADD=22
23 | SUB=23
24 | PI=24
25 | EXPONENT=25
26 | NEGEXPONENT=26
27 | EULER=27
28 | SQRT=28
29 | SQR=29
30 | FLOOR=30
31 | CEIL=31
32 | ABS=32
33 | ROUNDK=33
34 | ROUND=34
35 | TRUNC=35
36 | SIN=36
37 | COS=37
38 | TAN=38
39 | COT=39
40 | SINH=40
41 | COSH=41
42 | TANH=42
43 | ARCSIN=43
44 | ARCCOS=44
45 | ARCTAN=45
46 | ARCTAN2=46
47 | ARCCOT=47
48 | EXP=48
49 | LN=49
50 | EEX=50
51 | LOG=51
52 | RAD=52
53 | DEG=53
54 | MIN=54
55 | MAX=55
56 | WS=56
57 | COM=57
58 | SUBSTITUTION=58
59 | SEMICOLON=59
60 | INVALID=60
61 | '='=1
62 | '('=2
63 | ')'=3
64 | '^'=4
65 | '**'=5
66 | '%'=6
67 | '~'=7
68 | '//'=8
69 | '['=9
70 | ']'=10
71 | '{'=11
72 | '}'=12
73 | '()'=13
74 | '..'=14
75 | '*'=20
76 | '/'=21
77 | '+'=22
78 | '-'=23
79 | ';'=59
80 |
--------------------------------------------------------------------------------
/src/GeneratedAntlr/CalculatorLexer.interp:
--------------------------------------------------------------------------------
1 | token literal names:
2 | null
3 | '='
4 | '('
5 | ')'
6 | '^'
7 | '**'
8 | '%'
9 | '~'
10 | '//'
11 | '['
12 | ']'
13 | '{'
14 | '}'
15 | '()'
16 | '..'
17 | null
18 | null
19 | null
20 | null
21 | null
22 | '*'
23 | '/'
24 | '+'
25 | '-'
26 | null
27 | null
28 | null
29 | null
30 | null
31 | null
32 | null
33 | null
34 | null
35 | null
36 | null
37 | null
38 | null
39 | null
40 | null
41 | null
42 | null
43 | null
44 | null
45 | null
46 | null
47 | null
48 | null
49 | null
50 | null
51 | null
52 | null
53 | null
54 | null
55 | null
56 | null
57 | null
58 | null
59 | null
60 | null
61 | ';'
62 | null
63 |
64 | token symbolic names:
65 | null
66 | null
67 | null
68 | null
69 | null
70 | null
71 | null
72 | null
73 | null
74 | null
75 | null
76 | null
77 | null
78 | null
79 | null
80 | NUMBER
81 | FLOAT
82 | DIGIT
83 | MOD
84 | WHOLE
85 | MUL
86 | DIV
87 | ADD
88 | SUB
89 | PI
90 | EXPONENT
91 | NEGEXPONENT
92 | EULER
93 | SQRT
94 | SQR
95 | FLOOR
96 | CEIL
97 | ABS
98 | ROUNDK
99 | ROUND
100 | TRUNC
101 | SIN
102 | COS
103 | TAN
104 | COT
105 | SINH
106 | COSH
107 | TANH
108 | ARCSIN
109 | ARCCOS
110 | ARCTAN
111 | ARCTAN2
112 | ARCCOT
113 | EXP
114 | LN
115 | EEX
116 | LOG
117 | RAD
118 | DEG
119 | MIN
120 | MAX
121 | WS
122 | COM
123 | SUBSTITUTION
124 | SEMICOLON
125 | INVALID
126 |
127 | rule names:
128 | T__0
129 | T__1
130 | T__2
131 | T__3
132 | T__4
133 | T__5
134 | T__6
135 | T__7
136 | T__8
137 | T__9
138 | T__10
139 | T__11
140 | T__12
141 | T__13
142 | NUMBER
143 | FLOAT
144 | DIGIT
145 | MOD
146 | WHOLE
147 | MUL
148 | DIV
149 | ADD
150 | SUB
151 | PI
152 | EXPONENT
153 | NEGEXPONENT
154 | EULER
155 | SQRT
156 | SQR
157 | FLOOR
158 | CEIL
159 | ABS
160 | ROUNDK
161 | ROUND
162 | TRUNC
163 | SIN
164 | COS
165 | TAN
166 | COT
167 | SINH
168 | COSH
169 | TANH
170 | ARCSIN
171 | ARCCOS
172 | ARCTAN
173 | ARCTAN2
174 | ARCCOT
175 | EXP
176 | LN
177 | EEX
178 | LOG
179 | RAD
180 | DEG
181 | MIN
182 | MAX
183 | WS
184 | COM
185 | SUBSTITUTION
186 | SEMICOLON
187 | INVALID
188 | COMMENT
189 |
190 | channel names:
191 | DEFAULT_TOKEN_CHANNEL
192 | HIDDEN
193 |
194 | mode names:
195 | DEFAULT_MODE
196 |
197 | atn:
198 | [3, 51485, 51898, 1421, 44986, 20307, 1543, 60043, 49729, 2, 62, 402, 8, 1, 4, 2, 9, 2, 4, 3, 9, 3, 4, 4, 9, 4, 4, 5, 9, 5, 4, 6, 9, 6, 4, 7, 9, 7, 4, 8, 9, 8, 4, 9, 9, 9, 4, 10, 9, 10, 4, 11, 9, 11, 4, 12, 9, 12, 4, 13, 9, 13, 4, 14, 9, 14, 4, 15, 9, 15, 4, 16, 9, 16, 4, 17, 9, 17, 4, 18, 9, 18, 4, 19, 9, 19, 4, 20, 9, 20, 4, 21, 9, 21, 4, 22, 9, 22, 4, 23, 9, 23, 4, 24, 9, 24, 4, 25, 9, 25, 4, 26, 9, 26, 4, 27, 9, 27, 4, 28, 9, 28, 4, 29, 9, 29, 4, 30, 9, 30, 4, 31, 9, 31, 4, 32, 9, 32, 4, 33, 9, 33, 4, 34, 9, 34, 4, 35, 9, 35, 4, 36, 9, 36, 4, 37, 9, 37, 4, 38, 9, 38, 4, 39, 9, 39, 4, 40, 9, 40, 4, 41, 9, 41, 4, 42, 9, 42, 4, 43, 9, 43, 4, 44, 9, 44, 4, 45, 9, 45, 4, 46, 9, 46, 4, 47, 9, 47, 4, 48, 9, 48, 4, 49, 9, 49, 4, 50, 9, 50, 4, 51, 9, 51, 4, 52, 9, 52, 4, 53, 9, 53, 4, 54, 9, 54, 4, 55, 9, 55, 4, 56, 9, 56, 4, 57, 9, 57, 4, 58, 9, 58, 4, 59, 9, 59, 4, 60, 9, 60, 4, 61, 9, 61, 4, 62, 9, 62, 3, 2, 3, 2, 3, 3, 3, 3, 3, 4, 3, 4, 3, 5, 3, 5, 3, 6, 3, 6, 3, 6, 3, 7, 3, 7, 3, 8, 3, 8, 3, 9, 3, 9, 3, 9, 3, 10, 3, 10, 3, 11, 3, 11, 3, 12, 3, 12, 3, 13, 3, 13, 3, 14, 3, 14, 3, 14, 3, 15, 3, 15, 3, 15, 3, 16, 3, 16, 6, 16, 160, 10, 16, 13, 16, 14, 16, 161, 5, 16, 164, 10, 16, 3, 17, 6, 17, 167, 10, 17, 13, 17, 14, 17, 168, 3, 17, 3, 17, 7, 17, 173, 10, 17, 12, 17, 14, 17, 176, 11, 17, 3, 17, 3, 17, 6, 17, 180, 10, 17, 13, 17, 14, 17, 181, 5, 17, 184, 10, 17, 3, 18, 3, 18, 3, 19, 3, 19, 3, 19, 3, 19, 3, 20, 3, 20, 3, 20, 3, 20, 3, 21, 3, 21, 3, 22, 3, 22, 3, 23, 3, 23, 3, 24, 3, 24, 3, 25, 3, 25, 3, 25, 3, 26, 3, 26, 3, 26, 3, 27, 3, 27, 3, 27, 3, 28, 3, 28, 3, 29, 3, 29, 3, 29, 3, 29, 3, 29, 3, 30, 3, 30, 3, 30, 3, 30, 3, 31, 3, 31, 3, 31, 3, 31, 3, 31, 3, 31, 3, 32, 3, 32, 3, 32, 3, 32, 3, 32, 3, 33, 3, 33, 3, 33, 3, 33, 3, 34, 3, 34, 3, 34, 3, 34, 3, 34, 3, 34, 3, 34, 3, 35, 3, 35, 3, 35, 3, 35, 3, 35, 3, 35, 3, 36, 3, 36, 3, 36, 3, 36, 3, 36, 3, 36, 3, 37, 3, 37, 3, 37, 3, 37, 3, 38, 3, 38, 3, 38, 3, 38, 3, 39, 3, 39, 3, 39, 3, 39, 3, 40, 3, 40, 3, 40, 3, 40, 3, 41, 3, 41, 3, 41, 3, 41, 3, 41, 3, 42, 3, 42, 3, 42, 3, 42, 3, 42, 3, 43, 3, 43, 3, 43, 3, 43, 3, 43, 3, 44, 3, 44, 3, 44, 3, 44, 3, 44, 3, 44, 3, 44, 3, 45, 3, 45, 3, 45, 3, 45, 3, 45, 3, 45, 3, 45, 3, 46, 3, 46, 3, 46, 3, 46, 3, 46, 3, 46, 3, 46, 3, 47, 3, 47, 3, 47, 3, 47, 3, 47, 3, 47, 3, 47, 3, 47, 3, 48, 3, 48, 3, 48, 3, 48, 3, 48, 3, 48, 3, 48, 3, 49, 3, 49, 3, 49, 3, 49, 3, 50, 3, 50, 3, 50, 3, 51, 3, 51, 3, 51, 3, 51, 3, 52, 3, 52, 3, 52, 3, 52, 3, 53, 3, 53, 3, 53, 3, 53, 3, 54, 3, 54, 3, 54, 3, 54, 3, 55, 3, 55, 3, 55, 3, 55, 3, 56, 3, 56, 3, 56, 3, 56, 3, 57, 3, 57, 3, 57, 3, 57, 3, 58, 3, 58, 3, 58, 3, 58, 3, 59, 3, 59, 6, 59, 366, 10, 59, 13, 59, 14, 59, 367, 3, 60, 3, 60, 3, 61, 3, 61, 3, 62, 3, 62, 3, 62, 3, 62, 7, 62, 378, 10, 62, 12, 62, 14, 62, 381, 11, 62, 3, 62, 3, 62, 3, 62, 3, 62, 7, 62, 387, 10, 62, 12, 62, 14, 62, 390, 11, 62, 3, 62, 3, 62, 3, 62, 7, 62, 395, 10, 62, 12, 62, 14, 62, 398, 11, 62, 3, 62, 5, 62, 401, 10, 62, 5, 379, 388, 396, 2, 2, 63, 3, 2, 3, 5, 2, 4, 7, 2, 5, 9, 2, 6, 11, 2, 7, 13, 2, 8, 15, 2, 9, 17, 2, 10, 19, 2, 11, 21, 2, 12, 23, 2, 13, 25, 2, 14, 27, 2, 15, 29, 2, 16, 31, 2, 17, 33, 2, 18, 35, 2, 19, 37, 2, 20, 39, 2, 21, 41, 2, 22, 43, 2, 23, 45, 2, 24, 47, 2, 25, 49, 2, 26, 51, 2, 27, 53, 2, 28, 55, 2, 29, 57, 2, 30, 59, 2, 31, 61, 2, 32, 63, 2, 33, 65, 2, 34, 67, 2, 35, 69, 2, 36, 71, 2, 37, 73, 2, 38, 75, 2, 39, 77, 2, 40, 79, 2, 41, 81, 2, 42, 83, 2, 43, 85, 2, 44, 87, 2, 45, 89, 2, 46, 91, 2, 47, 93, 2, 48, 95, 2, 49, 97, 2, 50, 99, 2, 51, 101, 2, 52, 103, 2, 53, 105, 2, 54, 107, 2, 55, 109, 2, 56, 111, 2, 57, 113, 2, 58, 115, 2, 59, 117, 2, 60, 119, 2, 61, 121, 2, 62, 123, 2, 2, 3, 2, 29, 4, 2, 46, 46, 48, 48, 3, 2, 50, 59, 4, 2, 79, 79, 111, 111, 4, 2, 81, 81, 113, 113, 4, 2, 70, 70, 102, 102, 4, 2, 75, 75, 107, 107, 4, 2, 88, 88, 120, 120, 4, 2, 82, 82, 114, 114, 4, 2, 71, 71, 103, 103, 4, 2, 85, 85, 117, 117, 4, 2, 83, 83, 115, 115, 4, 2, 84, 84, 116, 116, 4, 2, 86, 86, 118, 118, 4, 2, 72, 72, 104, 104, 4, 2, 78, 78, 110, 110, 4, 2, 69, 69, 101, 101, 4, 2, 67, 67, 99, 99, 4, 2, 68, 68, 100, 100, 4, 2, 87, 87, 119, 119, 4, 2, 80, 80, 112, 112, 4, 2, 77, 77, 109, 109, 4, 2, 74, 74, 106, 106, 3, 2, 52, 52, 4, 2, 90, 90, 122, 122, 4, 2, 73, 73, 105, 105, 5, 2, 11, 12, 15, 15, 34, 34, 11, 2, 50, 59, 67, 92, 99, 124, 198, 198, 216, 216, 222, 222, 230, 230, 248, 248, 254, 254, 2, 412, 2, 3, 3, 2, 2, 2, 2, 5, 3, 2, 2, 2, 2, 7, 3, 2, 2, 2, 2, 9, 3, 2, 2, 2, 2, 11, 3, 2, 2, 2, 2, 13, 3, 2, 2, 2, 2, 15, 3, 2, 2, 2, 2, 17, 3, 2, 2, 2, 2, 19, 3, 2, 2, 2, 2, 21, 3, 2, 2, 2, 2, 23, 3, 2, 2, 2, 2, 25, 3, 2, 2, 2, 2, 27, 3, 2, 2, 2, 2, 29, 3, 2, 2, 2, 2, 31, 3, 2, 2, 2, 2, 33, 3, 2, 2, 2, 2, 35, 3, 2, 2, 2, 2, 37, 3, 2, 2, 2, 2, 39, 3, 2, 2, 2, 2, 41, 3, 2, 2, 2, 2, 43, 3, 2, 2, 2, 2, 45, 3, 2, 2, 2, 2, 47, 3, 2, 2, 2, 2, 49, 3, 2, 2, 2, 2, 51, 3, 2, 2, 2, 2, 53, 3, 2, 2, 2, 2, 55, 3, 2, 2, 2, 2, 57, 3, 2, 2, 2, 2, 59, 3, 2, 2, 2, 2, 61, 3, 2, 2, 2, 2, 63, 3, 2, 2, 2, 2, 65, 3, 2, 2, 2, 2, 67, 3, 2, 2, 2, 2, 69, 3, 2, 2, 2, 2, 71, 3, 2, 2, 2, 2, 73, 3, 2, 2, 2, 2, 75, 3, 2, 2, 2, 2, 77, 3, 2, 2, 2, 2, 79, 3, 2, 2, 2, 2, 81, 3, 2, 2, 2, 2, 83, 3, 2, 2, 2, 2, 85, 3, 2, 2, 2, 2, 87, 3, 2, 2, 2, 2, 89, 3, 2, 2, 2, 2, 91, 3, 2, 2, 2, 2, 93, 3, 2, 2, 2, 2, 95, 3, 2, 2, 2, 2, 97, 3, 2, 2, 2, 2, 99, 3, 2, 2, 2, 2, 101, 3, 2, 2, 2, 2, 103, 3, 2, 2, 2, 2, 105, 3, 2, 2, 2, 2, 107, 3, 2, 2, 2, 2, 109, 3, 2, 2, 2, 2, 111, 3, 2, 2, 2, 2, 113, 3, 2, 2, 2, 2, 115, 3, 2, 2, 2, 2, 117, 3, 2, 2, 2, 2, 119, 3, 2, 2, 2, 2, 121, 3, 2, 2, 2, 3, 125, 3, 2, 2, 2, 5, 127, 3, 2, 2, 2, 7, 129, 3, 2, 2, 2, 9, 131, 3, 2, 2, 2, 11, 133, 3, 2, 2, 2, 13, 136, 3, 2, 2, 2, 15, 138, 3, 2, 2, 2, 17, 140, 3, 2, 2, 2, 19, 143, 3, 2, 2, 2, 21, 145, 3, 2, 2, 2, 23, 147, 3, 2, 2, 2, 25, 149, 3, 2, 2, 2, 27, 151, 3, 2, 2, 2, 29, 154, 3, 2, 2, 2, 31, 163, 3, 2, 2, 2, 33, 183, 3, 2, 2, 2, 35, 185, 3, 2, 2, 2, 37, 187, 3, 2, 2, 2, 39, 191, 3, 2, 2, 2, 41, 195, 3, 2, 2, 2, 43, 197, 3, 2, 2, 2, 45, 199, 3, 2, 2, 2, 47, 201, 3, 2, 2, 2, 49, 203, 3, 2, 2, 2, 51, 206, 3, 2, 2, 2, 53, 209, 3, 2, 2, 2, 55, 212, 3, 2, 2, 2, 57, 214, 3, 2, 2, 2, 59, 219, 3, 2, 2, 2, 61, 223, 3, 2, 2, 2, 63, 229, 3, 2, 2, 2, 65, 234, 3, 2, 2, 2, 67, 238, 3, 2, 2, 2, 69, 245, 3, 2, 2, 2, 71, 251, 3, 2, 2, 2, 73, 257, 3, 2, 2, 2, 75, 261, 3, 2, 2, 2, 77, 265, 3, 2, 2, 2, 79, 269, 3, 2, 2, 2, 81, 273, 3, 2, 2, 2, 83, 278, 3, 2, 2, 2, 85, 283, 3, 2, 2, 2, 87, 288, 3, 2, 2, 2, 89, 295, 3, 2, 2, 2, 91, 302, 3, 2, 2, 2, 93, 309, 3, 2, 2, 2, 95, 317, 3, 2, 2, 2, 97, 324, 3, 2, 2, 2, 99, 328, 3, 2, 2, 2, 101, 331, 3, 2, 2, 2, 103, 335, 3, 2, 2, 2, 105, 339, 3, 2, 2, 2, 107, 343, 3, 2, 2, 2, 109, 347, 3, 2, 2, 2, 111, 351, 3, 2, 2, 2, 113, 355, 3, 2, 2, 2, 115, 359, 3, 2, 2, 2, 117, 363, 3, 2, 2, 2, 119, 369, 3, 2, 2, 2, 121, 371, 3, 2, 2, 2, 123, 400, 3, 2, 2, 2, 125, 126, 7, 63, 2, 2, 126, 4, 3, 2, 2, 2, 127, 128, 7, 42, 2, 2, 128, 6, 3, 2, 2, 2, 129, 130, 7, 43, 2, 2, 130, 8, 3, 2, 2, 2, 131, 132, 7, 96, 2, 2, 132, 10, 3, 2, 2, 2, 133, 134, 7, 44, 2, 2, 134, 135, 7, 44, 2, 2, 135, 12, 3, 2, 2, 2, 136, 137, 7, 39, 2, 2, 137, 14, 3, 2, 2, 2, 138, 139, 7, 128, 2, 2, 139, 16, 3, 2, 2, 2, 140, 141, 7, 49, 2, 2, 141, 142, 7, 49, 2, 2, 142, 18, 3, 2, 2, 2, 143, 144, 7, 93, 2, 2, 144, 20, 3, 2, 2, 2, 145, 146, 7, 95, 2, 2, 146, 22, 3, 2, 2, 2, 147, 148, 7, 125, 2, 2, 148, 24, 3, 2, 2, 2, 149, 150, 7, 127, 2, 2, 150, 26, 3, 2, 2, 2, 151, 152, 7, 42, 2, 2, 152, 153, 7, 43, 2, 2, 153, 28, 3, 2, 2, 2, 154, 155, 7, 48, 2, 2, 155, 156, 7, 48, 2, 2, 156, 30, 3, 2, 2, 2, 157, 164, 5, 33, 17, 2, 158, 160, 5, 35, 18, 2, 159, 158, 3, 2, 2, 2, 160, 161, 3, 2, 2, 2, 161, 159, 3, 2, 2, 2, 161, 162, 3, 2, 2, 2, 162, 164, 3, 2, 2, 2, 163, 157, 3, 2, 2, 2, 163, 159, 3, 2, 2, 2, 164, 32, 3, 2, 2, 2, 165, 167, 5, 35, 18, 2, 166, 165, 3, 2, 2, 2, 167, 168, 3, 2, 2, 2, 168, 166, 3, 2, 2, 2, 168, 169, 3, 2, 2, 2, 169, 170, 3, 2, 2, 2, 170, 174, 9, 2, 2, 2, 171, 173, 5, 35, 18, 2, 172, 171, 3, 2, 2, 2, 173, 176, 3, 2, 2, 2, 174, 172, 3, 2, 2, 2, 174, 175, 3, 2, 2, 2, 175, 184, 3, 2, 2, 2, 176, 174, 3, 2, 2, 2, 177, 179, 9, 2, 2, 2, 178, 180, 5, 35, 18, 2, 179, 178, 3, 2, 2, 2, 180, 181, 3, 2, 2, 2, 181, 179, 3, 2, 2, 2, 181, 182, 3, 2, 2, 2, 182, 184, 3, 2, 2, 2, 183, 166, 3, 2, 2, 2, 183, 177, 3, 2, 2, 2, 184, 34, 3, 2, 2, 2, 185, 186, 9, 3, 2, 2, 186, 36, 3, 2, 2, 2, 187, 188, 9, 4, 2, 2, 188, 189, 9, 5, 2, 2, 189, 190, 9, 6, 2, 2, 190, 38, 3, 2, 2, 2, 191, 192, 9, 6, 2, 2, 192, 193, 9, 7, 2, 2, 193, 194, 9, 8, 2, 2, 194, 40, 3, 2, 2, 2, 195, 196, 7, 44, 2, 2, 196, 42, 3, 2, 2, 2, 197, 198, 7, 49, 2, 2, 198, 44, 3, 2, 2, 2, 199, 200, 7, 45, 2, 2, 200, 46, 3, 2, 2, 2, 201, 202, 7, 47, 2, 2, 202, 48, 3, 2, 2, 2, 203, 204, 9, 9, 2, 2, 204, 205, 9, 7, 2, 2, 205, 50, 3, 2, 2, 2, 206, 207, 9, 10, 2, 2, 207, 208, 7, 45, 2, 2, 208, 52, 3, 2, 2, 2, 209, 210, 9, 10, 2, 2, 210, 211, 7, 47, 2, 2, 211, 54, 3, 2, 2, 2, 212, 213, 9, 10, 2, 2, 213, 56, 3, 2, 2, 2, 214, 215, 9, 11, 2, 2, 215, 216, 9, 12, 2, 2, 216, 217, 9, 13, 2, 2, 217, 218, 9, 14, 2, 2, 218, 58, 3, 2, 2, 2, 219, 220, 9, 11, 2, 2, 220, 221, 9, 12, 2, 2, 221, 222, 9, 13, 2, 2, 222, 60, 3, 2, 2, 2, 223, 224, 9, 15, 2, 2, 224, 225, 9, 16, 2, 2, 225, 226, 9, 5, 2, 2, 226, 227, 9, 5, 2, 2, 227, 228, 9, 13, 2, 2, 228, 62, 3, 2, 2, 2, 229, 230, 9, 17, 2, 2, 230, 231, 9, 10, 2, 2, 231, 232, 9, 7, 2, 2, 232, 233, 9, 16, 2, 2, 233, 64, 3, 2, 2, 2, 234, 235, 9, 18, 2, 2, 235, 236, 9, 19, 2, 2, 236, 237, 9, 11, 2, 2, 237, 66, 3, 2, 2, 2, 238, 239, 9, 13, 2, 2, 239, 240, 9, 5, 2, 2, 240, 241, 9, 20, 2, 2, 241, 242, 9, 21, 2, 2, 242, 243, 9, 6, 2, 2, 243, 244, 9, 22, 2, 2, 244, 68, 3, 2, 2, 2, 245, 246, 9, 13, 2, 2, 246, 247, 9, 5, 2, 2, 247, 248, 9, 20, 2, 2, 248, 249, 9, 21, 2, 2, 249, 250, 9, 6, 2, 2, 250, 70, 3, 2, 2, 2, 251, 252, 9, 14, 2, 2, 252, 253, 9, 13, 2, 2, 253, 254, 9, 20, 2, 2, 254, 255, 9, 21, 2, 2, 255, 256, 9, 17, 2, 2, 256, 72, 3, 2, 2, 2, 257, 258, 9, 11, 2, 2, 258, 259, 9, 7, 2, 2, 259, 260, 9, 21, 2, 2, 260, 74, 3, 2, 2, 2, 261, 262, 9, 17, 2, 2, 262, 263, 9, 5, 2, 2, 263, 264, 9, 11, 2, 2, 264, 76, 3, 2, 2, 2, 265, 266, 9, 14, 2, 2, 266, 267, 9, 18, 2, 2, 267, 268, 9, 21, 2, 2, 268, 78, 3, 2, 2, 2, 269, 270, 9, 17, 2, 2, 270, 271, 9, 5, 2, 2, 271, 272, 9, 14, 2, 2, 272, 80, 3, 2, 2, 2, 273, 274, 9, 11, 2, 2, 274, 275, 9, 7, 2, 2, 275, 276, 9, 21, 2, 2, 276, 277, 9, 23, 2, 2, 277, 82, 3, 2, 2, 2, 278, 279, 9, 17, 2, 2, 279, 280, 9, 5, 2, 2, 280, 281, 9, 11, 2, 2, 281, 282, 9, 23, 2, 2, 282, 84, 3, 2, 2, 2, 283, 284, 9, 14, 2, 2, 284, 285, 9, 18, 2, 2, 285, 286, 9, 21, 2, 2, 286, 287, 9, 23, 2, 2, 287, 86, 3, 2, 2, 2, 288, 289, 9, 18, 2, 2, 289, 290, 9, 13, 2, 2, 290, 291, 9, 17, 2, 2, 291, 292, 9, 11, 2, 2, 292, 293, 9, 7, 2, 2, 293, 294, 9, 21, 2, 2, 294, 88, 3, 2, 2, 2, 295, 296, 9, 18, 2, 2, 296, 297, 9, 13, 2, 2, 297, 298, 9, 17, 2, 2, 298, 299, 9, 17, 2, 2, 299, 300, 9, 5, 2, 2, 300, 301, 9, 11, 2, 2, 301, 90, 3, 2, 2, 2, 302, 303, 9, 18, 2, 2, 303, 304, 9, 13, 2, 2, 304, 305, 9, 17, 2, 2, 305, 306, 9, 14, 2, 2, 306, 307, 9, 18, 2, 2, 307, 308, 9, 21, 2, 2, 308, 92, 3, 2, 2, 2, 309, 310, 9, 18, 2, 2, 310, 311, 9, 13, 2, 2, 311, 312, 9, 17, 2, 2, 312, 313, 9, 14, 2, 2, 313, 314, 9, 18, 2, 2, 314, 315, 9, 21, 2, 2, 315, 316, 9, 24, 2, 2, 316, 94, 3, 2, 2, 2, 317, 318, 9, 18, 2, 2, 318, 319, 9, 13, 2, 2, 319, 320, 9, 17, 2, 2, 320, 321, 9, 17, 2, 2, 321, 322, 9, 5, 2, 2, 322, 323, 9, 14, 2, 2, 323, 96, 3, 2, 2, 2, 324, 325, 9, 10, 2, 2, 325, 326, 9, 25, 2, 2, 326, 327, 9, 9, 2, 2, 327, 98, 3, 2, 2, 2, 328, 329, 9, 16, 2, 2, 329, 330, 9, 21, 2, 2, 330, 100, 3, 2, 2, 2, 331, 332, 9, 10, 2, 2, 332, 333, 9, 10, 2, 2, 333, 334, 9, 25, 2, 2, 334, 102, 3, 2, 2, 2, 335, 336, 9, 16, 2, 2, 336, 337, 9, 5, 2, 2, 337, 338, 9, 26, 2, 2, 338, 104, 3, 2, 2, 2, 339, 340, 9, 13, 2, 2, 340, 341, 9, 18, 2, 2, 341, 342, 9, 6, 2, 2, 342, 106, 3, 2, 2, 2, 343, 344, 9, 6, 2, 2, 344, 345, 9, 10, 2, 2, 345, 346, 9, 26, 2, 2, 346, 108, 3, 2, 2, 2, 347, 348, 9, 4, 2, 2, 348, 349, 9, 7, 2, 2, 349, 350, 9, 21, 2, 2, 350, 110, 3, 2, 2, 2, 351, 352, 9, 4, 2, 2, 352, 353, 9, 18, 2, 2, 353, 354, 9, 25, 2, 2, 354, 112, 3, 2, 2, 2, 355, 356, 9, 27, 2, 2, 356, 357, 3, 2, 2, 2, 357, 358, 8, 57, 2, 2, 358, 114, 3, 2, 2, 2, 359, 360, 5, 123, 62, 2, 360, 361, 3, 2, 2, 2, 361, 362, 8, 58, 2, 2, 362, 116, 3, 2, 2, 2, 363, 365, 7, 37, 2, 2, 364, 366, 9, 28, 2, 2, 365, 364, 3, 2, 2, 2, 366, 367, 3, 2, 2, 2, 367, 365, 3, 2, 2, 2, 367, 368, 3, 2, 2, 2, 368, 118, 3, 2, 2, 2, 369, 370, 7, 61, 2, 2, 370, 120, 3, 2, 2, 2, 371, 372, 11, 2, 2, 2, 372, 122, 3, 2, 2, 2, 373, 374, 7, 49, 2, 2, 374, 375, 7, 44, 2, 2, 375, 379, 3, 2, 2, 2, 376, 378, 11, 2, 2, 2, 377, 376, 3, 2, 2, 2, 378, 381, 3, 2, 2, 2, 379, 380, 3, 2, 2, 2, 379, 377, 3, 2, 2, 2, 380, 382, 3, 2, 2, 2, 381, 379, 3, 2, 2, 2, 382, 383, 7, 44, 2, 2, 383, 401, 7, 49, 2, 2, 384, 388, 7, 41, 2, 2, 385, 387, 11, 2, 2, 2, 386, 385, 3, 2, 2, 2, 387, 390, 3, 2, 2, 2, 388, 389, 3, 2, 2, 2, 388, 386, 3, 2, 2, 2, 389, 391, 3, 2, 2, 2, 390, 388, 3, 2, 2, 2, 391, 401, 7, 41, 2, 2, 392, 396, 7, 36, 2, 2, 393, 395, 11, 2, 2, 2, 394, 393, 3, 2, 2, 2, 395, 398, 3, 2, 2, 2, 396, 397, 3, 2, 2, 2, 396, 394, 3, 2, 2, 2, 397, 399, 3, 2, 2, 2, 398, 396, 3, 2, 2, 2, 399, 401, 7, 36, 2, 2, 400, 373, 3, 2, 2, 2, 400, 384, 3, 2, 2, 2, 400, 392, 3, 2, 2, 2, 401, 124, 3, 2, 2, 2, 15, 2, 161, 163, 168, 174, 181, 183, 365, 367, 379, 388, 396, 400, 3, 8, 2, 2]
--------------------------------------------------------------------------------
/src/GeneratedAntlr/CalculatorLexer.tokens:
--------------------------------------------------------------------------------
1 | T__0=1
2 | T__1=2
3 | T__2=3
4 | T__3=4
5 | T__4=5
6 | T__5=6
7 | T__6=7
8 | T__7=8
9 | T__8=9
10 | T__9=10
11 | T__10=11
12 | T__11=12
13 | T__12=13
14 | T__13=14
15 | NUMBER=15
16 | FLOAT=16
17 | DIGIT=17
18 | MOD=18
19 | WHOLE=19
20 | MUL=20
21 | DIV=21
22 | ADD=22
23 | SUB=23
24 | PI=24
25 | EXPONENT=25
26 | NEGEXPONENT=26
27 | EULER=27
28 | SQRT=28
29 | SQR=29
30 | FLOOR=30
31 | CEIL=31
32 | ABS=32
33 | ROUNDK=33
34 | ROUND=34
35 | TRUNC=35
36 | SIN=36
37 | COS=37
38 | TAN=38
39 | COT=39
40 | SINH=40
41 | COSH=41
42 | TANH=42
43 | ARCSIN=43
44 | ARCCOS=44
45 | ARCTAN=45
46 | ARCTAN2=46
47 | ARCCOT=47
48 | EXP=48
49 | LN=49
50 | EEX=50
51 | LOG=51
52 | RAD=52
53 | DEG=53
54 | MIN=54
55 | MAX=55
56 | WS=56
57 | COM=57
58 | SUBSTITUTION=58
59 | SEMICOLON=59
60 | INVALID=60
61 | '='=1
62 | '('=2
63 | ')'=3
64 | '^'=4
65 | '**'=5
66 | '%'=6
67 | '~'=7
68 | '//'=8
69 | '['=9
70 | ']'=10
71 | '{'=11
72 | '}'=12
73 | '()'=13
74 | '..'=14
75 | '*'=20
76 | '/'=21
77 | '+'=22
78 | '-'=23
79 | ';'=59
80 |
--------------------------------------------------------------------------------
/src/GeneratedAntlr/CalculatorLexer.ts:
--------------------------------------------------------------------------------
1 | // Generated from ./src/Calculator.g4 by ANTLR 4.9.0-SNAPSHOT
2 |
3 |
4 | import { ATN } from "antlr4ts/atn/ATN";
5 | import { ATNDeserializer } from "antlr4ts/atn/ATNDeserializer";
6 | import { CharStream } from "antlr4ts/CharStream";
7 | import { Lexer } from "antlr4ts/Lexer";
8 | import { LexerATNSimulator } from "antlr4ts/atn/LexerATNSimulator";
9 | import { NotNull } from "antlr4ts/Decorators";
10 | import { Override } from "antlr4ts/Decorators";
11 | import { RuleContext } from "antlr4ts/RuleContext";
12 | import { Vocabulary } from "antlr4ts/Vocabulary";
13 | import { VocabularyImpl } from "antlr4ts/VocabularyImpl";
14 |
15 | import * as Utils from "antlr4ts/misc/Utils";
16 |
17 |
18 | export class CalculatorLexer extends Lexer {
19 | public static readonly T__0 = 1;
20 | public static readonly T__1 = 2;
21 | public static readonly T__2 = 3;
22 | public static readonly T__3 = 4;
23 | public static readonly T__4 = 5;
24 | public static readonly T__5 = 6;
25 | public static readonly T__6 = 7;
26 | public static readonly T__7 = 8;
27 | public static readonly T__8 = 9;
28 | public static readonly T__9 = 10;
29 | public static readonly T__10 = 11;
30 | public static readonly T__11 = 12;
31 | public static readonly T__12 = 13;
32 | public static readonly T__13 = 14;
33 | public static readonly NUMBER = 15;
34 | public static readonly FLOAT = 16;
35 | public static readonly DIGIT = 17;
36 | public static readonly MOD = 18;
37 | public static readonly WHOLE = 19;
38 | public static readonly MUL = 20;
39 | public static readonly DIV = 21;
40 | public static readonly ADD = 22;
41 | public static readonly SUB = 23;
42 | public static readonly PI = 24;
43 | public static readonly EXPONENT = 25;
44 | public static readonly NEGEXPONENT = 26;
45 | public static readonly EULER = 27;
46 | public static readonly SQRT = 28;
47 | public static readonly SQR = 29;
48 | public static readonly FLOOR = 30;
49 | public static readonly CEIL = 31;
50 | public static readonly ABS = 32;
51 | public static readonly ROUNDK = 33;
52 | public static readonly ROUND = 34;
53 | public static readonly TRUNC = 35;
54 | public static readonly SIN = 36;
55 | public static readonly COS = 37;
56 | public static readonly TAN = 38;
57 | public static readonly COT = 39;
58 | public static readonly SINH = 40;
59 | public static readonly COSH = 41;
60 | public static readonly TANH = 42;
61 | public static readonly ARCSIN = 43;
62 | public static readonly ARCCOS = 44;
63 | public static readonly ARCTAN = 45;
64 | public static readonly ARCTAN2 = 46;
65 | public static readonly ARCCOT = 47;
66 | public static readonly EXP = 48;
67 | public static readonly LN = 49;
68 | public static readonly EEX = 50;
69 | public static readonly LOG = 51;
70 | public static readonly RAD = 52;
71 | public static readonly DEG = 53;
72 | public static readonly MIN = 54;
73 | public static readonly MAX = 55;
74 | public static readonly WS = 56;
75 | public static readonly COM = 57;
76 | public static readonly SUBSTITUTION = 58;
77 | public static readonly SEMICOLON = 59;
78 | public static readonly INVALID = 60;
79 |
80 | // tslint:disable:no-trailing-whitespace
81 | public static readonly channelNames: string[] = [
82 | "DEFAULT_TOKEN_CHANNEL", "HIDDEN",
83 | ];
84 |
85 | // tslint:disable:no-trailing-whitespace
86 | public static readonly modeNames: string[] = [
87 | "DEFAULT_MODE",
88 | ];
89 |
90 | public static readonly ruleNames: string[] = [
91 | "T__0", "T__1", "T__2", "T__3", "T__4", "T__5", "T__6", "T__7", "T__8",
92 | "T__9", "T__10", "T__11", "T__12", "T__13", "NUMBER", "FLOAT", "DIGIT",
93 | "MOD", "WHOLE", "MUL", "DIV", "ADD", "SUB", "PI", "EXPONENT", "NEGEXPONENT",
94 | "EULER", "SQRT", "SQR", "FLOOR", "CEIL", "ABS", "ROUNDK", "ROUND", "TRUNC",
95 | "SIN", "COS", "TAN", "COT", "SINH", "COSH", "TANH", "ARCSIN", "ARCCOS",
96 | "ARCTAN", "ARCTAN2", "ARCCOT", "EXP", "LN", "EEX", "LOG", "RAD", "DEG",
97 | "MIN", "MAX", "WS", "COM", "SUBSTITUTION", "SEMICOLON", "INVALID", "COMMENT",
98 | ];
99 |
100 | private static readonly _LITERAL_NAMES: Array = [
101 | undefined, "'='", "'('", "')'", "'^'", "'**'", "'%'", "'~'", "'//'", "'['",
102 | "']'", "'{'", "'}'", "'()'", "'..'", undefined, undefined, undefined,
103 | undefined, undefined, "'*'", "'/'", "'+'", "'-'", undefined, undefined,
104 | undefined, undefined, undefined, undefined, undefined, undefined, undefined,
105 | undefined, undefined, undefined, undefined, undefined, undefined, undefined,
106 | undefined, undefined, undefined, undefined, undefined, undefined, undefined,
107 | undefined, undefined, undefined, undefined, undefined, undefined, undefined,
108 | undefined, undefined, undefined, undefined, undefined, "';'",
109 | ];
110 | private static readonly _SYMBOLIC_NAMES: Array = [
111 | undefined, undefined, undefined, undefined, undefined, undefined, undefined,
112 | undefined, undefined, undefined, undefined, undefined, undefined, undefined,
113 | undefined, "NUMBER", "FLOAT", "DIGIT", "MOD", "WHOLE", "MUL", "DIV", "ADD",
114 | "SUB", "PI", "EXPONENT", "NEGEXPONENT", "EULER", "SQRT", "SQR", "FLOOR",
115 | "CEIL", "ABS", "ROUNDK", "ROUND", "TRUNC", "SIN", "COS", "TAN", "COT",
116 | "SINH", "COSH", "TANH", "ARCSIN", "ARCCOS", "ARCTAN", "ARCTAN2", "ARCCOT",
117 | "EXP", "LN", "EEX", "LOG", "RAD", "DEG", "MIN", "MAX", "WS", "COM", "SUBSTITUTION",
118 | "SEMICOLON", "INVALID",
119 | ];
120 | public static readonly VOCABULARY: Vocabulary = new VocabularyImpl(CalculatorLexer._LITERAL_NAMES, CalculatorLexer._SYMBOLIC_NAMES, []);
121 |
122 | // @Override
123 | // @NotNull
124 | public get vocabulary(): Vocabulary {
125 | return CalculatorLexer.VOCABULARY;
126 | }
127 | // tslint:enable:no-trailing-whitespace
128 |
129 |
130 | constructor(input: CharStream) {
131 | super(input);
132 | this._interp = new LexerATNSimulator(CalculatorLexer._ATN, this);
133 | }
134 |
135 | // @Override
136 | public get grammarFileName(): string { return "Calculator.g4"; }
137 |
138 | // @Override
139 | public get ruleNames(): string[] { return CalculatorLexer.ruleNames; }
140 |
141 | // @Override
142 | public get serializedATN(): string { return CalculatorLexer._serializedATN; }
143 |
144 | // @Override
145 | public get channelNames(): string[] { return CalculatorLexer.channelNames; }
146 |
147 | // @Override
148 | public get modeNames(): string[] { return CalculatorLexer.modeNames; }
149 |
150 | public static readonly _serializedATN: string =
151 | "\x03\uC91D\uCABA\u058D\uAFBA\u4F53\u0607\uEA8B\uC241\x02>\u0192\b\x01" +
152 | "\x04\x02\t\x02\x04\x03\t\x03\x04\x04\t\x04\x04\x05\t\x05\x04\x06\t\x06" +
153 | "\x04\x07\t\x07\x04\b\t\b\x04\t\t\t\x04\n\t\n\x04\v\t\v\x04\f\t\f\x04\r" +
154 | "\t\r\x04\x0E\t\x0E\x04\x0F\t\x0F\x04\x10\t\x10\x04\x11\t\x11\x04\x12\t" +
155 | "\x12\x04\x13\t\x13\x04\x14\t\x14\x04\x15\t\x15\x04\x16\t\x16\x04\x17\t" +
156 | "\x17\x04\x18\t\x18\x04\x19\t\x19\x04\x1A\t\x1A\x04\x1B\t\x1B\x04\x1C\t" +
157 | "\x1C\x04\x1D\t\x1D\x04\x1E\t\x1E\x04\x1F\t\x1F\x04 \t \x04!\t!\x04\"\t" +
158 | "\"\x04#\t#\x04$\t$\x04%\t%\x04&\t&\x04\'\t\'\x04(\t(\x04)\t)\x04*\t*\x04" +
159 | "+\t+\x04,\t,\x04-\t-\x04.\t.\x04/\t/\x040\t0\x041\t1\x042\t2\x043\t3\x04" +
160 | "4\t4\x045\t5\x046\t6\x047\t7\x048\t8\x049\t9\x04:\t:\x04;\t;\x04<\t<\x04" +
161 | "=\t=\x04>\t>\x03\x02\x03\x02\x03\x03\x03\x03\x03\x04\x03\x04\x03\x05\x03" +
162 | "\x05\x03\x06\x03\x06\x03\x06\x03\x07\x03\x07\x03\b\x03\b\x03\t\x03\t\x03" +
163 | "\t\x03\n\x03\n\x03\v\x03\v\x03\f\x03\f\x03\r\x03\r\x03\x0E\x03\x0E\x03" +
164 | "\x0E\x03\x0F\x03\x0F\x03\x0F\x03\x10\x03\x10\x06\x10\xA0\n\x10\r\x10\x0E" +
165 | "\x10\xA1\x05\x10\xA4\n\x10\x03\x11\x06\x11\xA7\n\x11\r\x11\x0E\x11\xA8" +
166 | "\x03\x11\x03\x11\x07\x11\xAD\n\x11\f\x11\x0E\x11\xB0\v\x11\x03\x11\x03" +
167 | "\x11\x06\x11\xB4\n\x11\r\x11\x0E\x11\xB5\x05\x11\xB8\n\x11\x03\x12\x03" +
168 | "\x12\x03\x13\x03\x13\x03\x13\x03\x13\x03\x14\x03\x14\x03\x14\x03\x14\x03" +
169 | "\x15\x03\x15\x03\x16\x03\x16\x03\x17\x03\x17\x03\x18\x03\x18\x03\x19\x03" +
170 | "\x19\x03\x19\x03\x1A\x03\x1A\x03\x1A\x03\x1B\x03\x1B\x03\x1B\x03\x1C\x03" +
171 | "\x1C\x03\x1D\x03\x1D\x03\x1D\x03\x1D\x03\x1D\x03\x1E\x03\x1E\x03\x1E\x03" +
172 | "\x1E\x03\x1F\x03\x1F\x03\x1F\x03\x1F\x03\x1F\x03\x1F\x03 \x03 \x03 \x03" +
173 | " \x03 \x03!\x03!\x03!\x03!\x03\"\x03\"\x03\"\x03\"\x03\"\x03\"\x03\"\x03" +
174 | "#\x03#\x03#\x03#\x03#\x03#\x03$\x03$\x03$\x03$\x03$\x03$\x03%\x03%\x03" +
175 | "%\x03%\x03&\x03&\x03&\x03&\x03\'\x03\'\x03\'\x03\'\x03(\x03(\x03(\x03" +
176 | "(\x03)\x03)\x03)\x03)\x03)\x03*\x03*\x03*\x03*\x03*\x03+\x03+\x03+\x03" +
177 | "+\x03+\x03,\x03,\x03,\x03,\x03,\x03,\x03,\x03-\x03-\x03-\x03-\x03-\x03" +
178 | "-\x03-\x03.\x03.\x03.\x03.\x03.\x03.\x03.\x03/\x03/\x03/\x03/\x03/\x03" +
179 | "/\x03/\x03/\x030\x030\x030\x030\x030\x030\x030\x031\x031\x031\x031\x03" +
180 | "2\x032\x032\x033\x033\x033\x033\x034\x034\x034\x034\x035\x035\x035\x03" +
181 | "5\x036\x036\x036\x036\x037\x037\x037\x037\x038\x038\x038\x038\x039\x03" +
182 | "9\x039\x039\x03:\x03:\x03:\x03:\x03;\x03;\x06;\u016E\n;\r;\x0E;\u016F" +
183 | "\x03<\x03<\x03=\x03=\x03>\x03>\x03>\x03>\x07>\u017A\n>\f>\x0E>\u017D\v" +
184 | ">\x03>\x03>\x03>\x03>\x07>\u0183\n>\f>\x0E>\u0186\v>\x03>\x03>\x03>\x07" +
185 | ">\u018B\n>\f>\x0E>\u018E\v>\x03>\x05>\u0191\n>\x05\u017B\u0184\u018C\x02" +
186 | "\x02?\x03\x02\x03\x05\x02\x04\x07\x02\x05\t\x02\x06\v\x02\x07\r\x02\b" +
187 | "\x0F\x02\t\x11\x02\n\x13\x02\v\x15\x02\f\x17\x02\r\x19\x02\x0E\x1B\x02" +
188 | "\x0F\x1D\x02\x10\x1F\x02\x11!\x02\x12#\x02\x13%\x02\x14\'\x02\x15)\x02" +
189 | "\x16+\x02\x17-\x02\x18/\x02\x191\x02\x1A3\x02\x1B5\x02\x1C7\x02\x1D9\x02" +
190 | "\x1E;\x02\x1F=\x02 ?\x02!A\x02\"C\x02#E\x02$G\x02%I\x02&K\x02\'M\x02(" +
191 | "O\x02)Q\x02*S\x02+U\x02,W\x02-Y\x02.[\x02/]\x020_\x021a\x022c\x023e\x02" +
192 | "4g\x025i\x026k\x027m\x028o\x029q\x02:s\x02;u\x02{\x02\x02" +
193 | "\x03\x02\x1D\x04\x02..00\x03\x022;\x04\x02OOoo\x04\x02QQqq\x04\x02FFf" +
194 | "f\x04\x02KKkk\x04\x02XXxx\x04\x02RRrr\x04\x02GGgg\x04\x02UUuu\x04\x02" +
195 | "SSss\x04\x02TTtt\x04\x02VVvv\x04\x02HHhh\x04\x02NNnn\x04\x02EEee\x04\x02" +
196 | "CCcc\x04\x02DDdd\x04\x02WWww\x04\x02PPpp\x04\x02MMmm\x04\x02JJjj\x03\x02" +
197 | "44\x04\x02ZZzz\x04\x02IIii\x05\x02\v\f\x0F\x0F\"\"\v\x022;C\\c|\xC6\xC6" +
198 | "\xD8\xD8\xDE\xDE\xE6\xE6\xF8\xF8\xFE\xFE\x02\u019C\x02\x03\x03\x02\x02" +
199 | "\x02\x02\x05\x03\x02\x02\x02\x02\x07\x03\x02\x02\x02\x02\t\x03\x02\x02" +
200 | "\x02\x02\v\x03\x02\x02\x02\x02\r\x03\x02\x02\x02\x02\x0F\x03\x02\x02\x02" +
201 | "\x02\x11\x03\x02\x02\x02\x02\x13\x03\x02\x02\x02\x02\x15\x03\x02\x02\x02" +
202 | "\x02\x17\x03\x02\x02\x02\x02\x19\x03\x02\x02\x02\x02\x1B\x03\x02\x02\x02" +
203 | "\x02\x1D\x03\x02\x02\x02\x02\x1F\x03\x02\x02\x02\x02!\x03\x02\x02\x02" +
204 | "\x02#\x03\x02\x02\x02\x02%\x03\x02\x02\x02\x02\'\x03\x02\x02\x02\x02)" +
205 | "\x03\x02\x02\x02\x02+\x03\x02\x02\x02\x02-\x03\x02\x02\x02\x02/\x03\x02" +
206 | "\x02\x02\x021\x03\x02\x02\x02\x023\x03\x02\x02\x02\x025\x03\x02\x02\x02" +
207 | "\x027\x03\x02\x02\x02\x029\x03\x02\x02\x02\x02;\x03\x02\x02\x02\x02=\x03" +
208 | "\x02\x02\x02\x02?\x03\x02\x02\x02\x02A\x03\x02\x02\x02\x02C\x03\x02\x02" +
209 | "\x02\x02E\x03\x02\x02\x02\x02G\x03\x02\x02\x02\x02I\x03\x02\x02\x02\x02" +
210 | "K\x03\x02\x02\x02\x02M\x03\x02\x02\x02\x02O\x03\x02\x02\x02\x02Q\x03\x02" +
211 | "\x02\x02\x02S\x03\x02\x02\x02\x02U\x03\x02\x02\x02\x02W\x03\x02\x02\x02" +
212 | "\x02Y\x03\x02\x02\x02\x02[\x03\x02\x02\x02\x02]\x03\x02\x02\x02\x02_\x03" +
213 | "\x02\x02\x02\x02a\x03\x02\x02\x02\x02c\x03\x02\x02\x02\x02e\x03\x02\x02" +
214 | "\x02\x02g\x03\x02\x02\x02\x02i\x03\x02\x02\x02\x02k\x03\x02\x02\x02\x02" +
215 | "m\x03\x02\x02\x02\x02o\x03\x02\x02\x02\x02q\x03\x02\x02\x02\x02s\x03\x02" +
216 | "\x02\x02\x02u\x03\x02\x02\x02\x02w\x03\x02\x02\x02\x02y\x03\x02\x02\x02" +
217 | "\x03}\x03\x02\x02\x02\x05\x7F\x03\x02\x02\x02\x07\x81\x03\x02\x02\x02" +
218 | "\t\x83\x03\x02\x02\x02\v\x85\x03\x02\x02\x02\r\x88\x03\x02\x02\x02\x0F" +
219 | "\x8A\x03\x02\x02\x02\x11\x8C\x03\x02\x02\x02\x13\x8F\x03\x02\x02\x02\x15" +
220 | "\x91\x03\x02\x02\x02\x17\x93\x03\x02\x02\x02\x19\x95\x03\x02\x02\x02\x1B" +
221 | "\x97\x03\x02\x02\x02\x1D\x9A\x03\x02\x02\x02\x1F\xA3\x03\x02\x02\x02!" +
222 | "\xB7\x03\x02\x02\x02#\xB9\x03\x02\x02\x02%\xBB\x03\x02\x02\x02\'\xBF\x03" +
223 | "\x02\x02\x02)\xC3\x03\x02\x02\x02+\xC5\x03\x02\x02\x02-\xC7\x03\x02\x02" +
224 | "\x02/\xC9\x03\x02\x02\x021\xCB\x03\x02\x02\x023\xCE\x03\x02\x02\x025\xD1" +
225 | "\x03\x02\x02\x027\xD4\x03\x02\x02\x029\xD6\x03\x02\x02\x02;\xDB\x03\x02" +
226 | "\x02\x02=\xDF\x03\x02\x02\x02?\xE5\x03\x02\x02\x02A\xEA\x03\x02\x02\x02" +
227 | "C\xEE\x03\x02\x02\x02E\xF5\x03\x02\x02\x02G\xFB\x03\x02\x02\x02I\u0101" +
228 | "\x03\x02\x02\x02K\u0105\x03\x02\x02\x02M\u0109\x03\x02\x02\x02O\u010D" +
229 | "\x03\x02\x02\x02Q\u0111\x03\x02\x02\x02S\u0116\x03\x02\x02\x02U\u011B" +
230 | "\x03\x02\x02\x02W\u0120\x03\x02\x02\x02Y\u0127\x03\x02\x02\x02[\u012E" +
231 | "\x03\x02\x02\x02]\u0135\x03\x02\x02\x02_\u013D\x03\x02\x02\x02a\u0144" +
232 | "\x03\x02\x02\x02c\u0148\x03\x02\x02\x02e\u014B\x03\x02\x02\x02g\u014F" +
233 | "\x03\x02\x02\x02i\u0153\x03\x02\x02\x02k\u0157\x03\x02\x02\x02m\u015B" +
234 | "\x03\x02\x02\x02o\u015F\x03\x02\x02\x02q\u0163\x03\x02\x02\x02s\u0167" +
235 | "\x03\x02\x02\x02u\u016B\x03\x02\x02\x02w\u0171\x03\x02\x02\x02y\u0173" +
236 | "\x03\x02\x02\x02{\u0190\x03\x02\x02\x02}~\x07?\x02\x02~\x04\x03\x02\x02" +
237 | "\x02\x7F\x80\x07*\x02\x02\x80\x06\x03\x02\x02\x02\x81\x82\x07+\x02\x02" +
238 | "\x82\b\x03\x02\x02\x02\x83\x84\x07`\x02\x02\x84\n\x03\x02\x02\x02\x85" +
239 | "\x86\x07,\x02\x02\x86\x87\x07,\x02\x02\x87\f\x03\x02\x02\x02\x88\x89\x07" +
240 | "\'\x02\x02\x89\x0E\x03\x02\x02\x02\x8A\x8B\x07\x80\x02\x02\x8B\x10\x03" +
241 | "\x02\x02\x02\x8C\x8D\x071\x02\x02\x8D\x8E\x071\x02\x02\x8E\x12\x03\x02" +
242 | "\x02\x02\x8F\x90\x07]\x02\x02\x90\x14\x03\x02\x02\x02\x91\x92\x07_\x02" +
243 | "\x02\x92\x16\x03\x02\x02\x02\x93\x94\x07}\x02\x02\x94\x18\x03\x02\x02" +
244 | "\x02\x95\x96\x07\x7F\x02\x02\x96\x1A\x03\x02\x02\x02\x97\x98\x07*\x02" +
245 | "\x02\x98\x99\x07+\x02\x02\x99\x1C\x03\x02\x02\x02\x9A\x9B\x070\x02\x02" +
246 | "\x9B\x9C\x070\x02\x02\x9C\x1E\x03\x02\x02\x02\x9D\xA4\x05!\x11\x02\x9E" +
247 | "\xA0\x05#\x12\x02\x9F\x9E\x03\x02\x02\x02\xA0\xA1\x03\x02\x02\x02\xA1" +
248 | "\x9F\x03\x02\x02\x02\xA1\xA2\x03\x02\x02\x02\xA2\xA4\x03\x02\x02\x02\xA3" +
249 | "\x9D\x03\x02\x02\x02\xA3\x9F\x03\x02\x02\x02\xA4 \x03\x02\x02\x02\xA5" +
250 | "\xA7\x05#\x12\x02\xA6\xA5\x03\x02\x02\x02\xA7\xA8\x03\x02\x02\x02\xA8" +
251 | "\xA6\x03\x02\x02\x02\xA8\xA9\x03\x02\x02\x02\xA9\xAA\x03\x02\x02\x02\xAA" +
252 | "\xAE\t\x02\x02\x02\xAB\xAD\x05#\x12\x02\xAC\xAB\x03\x02\x02\x02\xAD\xB0" +
253 | "\x03\x02\x02\x02\xAE\xAC\x03\x02\x02\x02\xAE\xAF\x03\x02\x02\x02\xAF\xB8" +
254 | "\x03\x02\x02\x02\xB0\xAE\x03\x02\x02\x02\xB1\xB3\t\x02\x02\x02\xB2\xB4" +
255 | "\x05#\x12\x02\xB3\xB2\x03\x02\x02\x02\xB4\xB5\x03\x02\x02\x02\xB5\xB3" +
256 | "\x03\x02\x02\x02\xB5\xB6\x03\x02\x02\x02\xB6\xB8\x03\x02\x02\x02\xB7\xA6" +
257 | "\x03\x02\x02\x02\xB7\xB1\x03\x02\x02\x02\xB8\"\x03\x02\x02\x02\xB9\xBA" +
258 | "\t\x03\x02\x02\xBA$\x03\x02\x02\x02\xBB\xBC\t\x04\x02\x02\xBC\xBD\t\x05" +
259 | "\x02\x02\xBD\xBE\t\x06\x02\x02\xBE&\x03\x02\x02\x02\xBF\xC0\t\x06\x02" +
260 | "\x02\xC0\xC1\t\x07\x02\x02\xC1\xC2\t\b\x02\x02\xC2(\x03\x02\x02\x02\xC3" +
261 | "\xC4\x07,\x02\x02\xC4*\x03\x02\x02\x02\xC5\xC6\x071\x02\x02\xC6,\x03\x02" +
262 | "\x02\x02\xC7\xC8\x07-\x02\x02\xC8.\x03\x02\x02\x02\xC9\xCA\x07/\x02\x02" +
263 | "\xCA0\x03\x02\x02\x02\xCB\xCC\t\t\x02\x02\xCC\xCD\t\x07\x02\x02\xCD2\x03" +
264 | "\x02\x02\x02\xCE\xCF\t\n\x02\x02\xCF\xD0\x07-\x02\x02\xD04\x03\x02\x02" +
265 | "\x02\xD1\xD2\t\n\x02\x02\xD2\xD3\x07/\x02\x02\xD36\x03\x02\x02\x02\xD4" +
266 | "\xD5\t\n\x02\x02\xD58\x03\x02\x02\x02\xD6\xD7\t\v\x02\x02\xD7\xD8\t\f" +
267 | "\x02\x02\xD8\xD9\t\r\x02\x02\xD9\xDA\t\x0E\x02\x02\xDA:\x03\x02\x02\x02" +
268 | "\xDB\xDC\t\v\x02\x02\xDC\xDD\t\f\x02\x02\xDD\xDE\t\r\x02\x02\xDE<\x03" +
269 | "\x02\x02\x02\xDF\xE0\t\x0F\x02\x02\xE0\xE1\t\x10\x02\x02\xE1\xE2\t\x05" +
270 | "\x02\x02\xE2\xE3\t\x05\x02\x02\xE3\xE4\t\r\x02\x02\xE4>\x03\x02\x02\x02" +
271 | "\xE5\xE6\t\x11\x02\x02\xE6\xE7\t\n\x02\x02\xE7\xE8\t\x07\x02\x02\xE8\xE9" +
272 | "\t\x10\x02\x02\xE9@\x03\x02\x02\x02\xEA\xEB\t\x12\x02\x02\xEB\xEC\t\x13" +
273 | "\x02\x02\xEC\xED\t\v\x02\x02\xEDB\x03\x02\x02\x02\xEE\xEF\t\r\x02\x02" +
274 | "\xEF\xF0\t\x05\x02\x02\xF0\xF1\t\x14\x02\x02\xF1\xF2\t\x15\x02\x02\xF2" +
275 | "\xF3\t\x06\x02\x02\xF3\xF4\t\x16\x02\x02\xF4D\x03\x02\x02\x02\xF5\xF6" +
276 | "\t\r\x02\x02\xF6\xF7\t\x05\x02\x02\xF7\xF8\t\x14\x02\x02\xF8\xF9\t\x15" +
277 | "\x02\x02\xF9\xFA\t\x06\x02\x02\xFAF\x03\x02\x02\x02\xFB\xFC\t\x0E\x02" +
278 | "\x02\xFC\xFD\t\r\x02\x02\xFD\xFE\t\x14\x02\x02\xFE\xFF\t\x15\x02\x02\xFF" +
279 | "\u0100\t\x11\x02\x02\u0100H\x03\x02\x02\x02\u0101\u0102\t\v\x02\x02\u0102" +
280 | "\u0103\t\x07\x02\x02\u0103\u0104\t\x15\x02\x02\u0104J\x03\x02\x02\x02" +
281 | "\u0105\u0106\t\x11\x02\x02\u0106\u0107\t\x05\x02\x02\u0107\u0108\t\v\x02" +
282 | "\x02\u0108L\x03\x02\x02\x02\u0109\u010A\t\x0E\x02\x02\u010A\u010B\t\x12" +
283 | "\x02\x02\u010B\u010C\t\x15\x02\x02\u010CN\x03\x02\x02\x02\u010D\u010E" +
284 | "\t\x11\x02\x02\u010E\u010F\t\x05\x02\x02\u010F\u0110\t\x0E\x02\x02\u0110" +
285 | "P\x03\x02\x02\x02\u0111\u0112\t\v\x02\x02\u0112\u0113\t\x07\x02\x02\u0113" +
286 | "\u0114\t\x15\x02\x02\u0114\u0115\t\x17\x02\x02\u0115R\x03\x02\x02\x02" +
287 | "\u0116\u0117\t\x11\x02\x02\u0117\u0118\t\x05\x02\x02\u0118\u0119\t\v\x02" +
288 | "\x02\u0119\u011A\t\x17\x02\x02\u011AT\x03\x02\x02\x02\u011B\u011C\t\x0E" +
289 | "\x02\x02\u011C\u011D\t\x12\x02\x02\u011D\u011E\t\x15\x02\x02\u011E\u011F" +
290 | "\t\x17\x02\x02\u011FV\x03\x02\x02\x02\u0120\u0121\t\x12\x02\x02\u0121" +
291 | "\u0122\t\r\x02\x02\u0122\u0123\t\x11\x02\x02\u0123\u0124\t\v\x02\x02\u0124" +
292 | "\u0125\t\x07\x02\x02\u0125\u0126\t\x15\x02\x02\u0126X\x03\x02\x02\x02" +
293 | "\u0127\u0128\t\x12\x02\x02\u0128\u0129\t\r\x02\x02\u0129\u012A\t\x11\x02" +
294 | "\x02\u012A\u012B\t\x11\x02\x02\u012B\u012C\t\x05\x02\x02\u012C\u012D\t" +
295 | "\v\x02\x02\u012DZ\x03\x02\x02\x02\u012E\u012F\t\x12\x02\x02\u012F\u0130" +
296 | "\t\r\x02\x02\u0130\u0131\t\x11\x02\x02\u0131\u0132\t\x0E\x02\x02\u0132" +
297 | "\u0133\t\x12\x02\x02\u0133\u0134\t\x15\x02\x02\u0134\\\x03\x02\x02\x02" +
298 | "\u0135\u0136\t\x12\x02\x02\u0136\u0137\t\r\x02\x02\u0137\u0138\t\x11\x02" +
299 | "\x02\u0138\u0139\t\x0E\x02\x02\u0139\u013A\t\x12\x02\x02\u013A\u013B\t" +
300 | "\x15\x02\x02\u013B\u013C\t\x18\x02\x02\u013C^\x03\x02\x02\x02\u013D\u013E" +
301 | "\t\x12\x02\x02\u013E\u013F\t\r\x02\x02\u013F\u0140\t\x11\x02\x02\u0140" +
302 | "\u0141\t\x11\x02\x02\u0141\u0142\t\x05\x02\x02\u0142\u0143\t\x0E\x02\x02" +
303 | "\u0143`\x03\x02\x02\x02\u0144\u0145\t\n\x02\x02\u0145\u0146\t\x19\x02" +
304 | "\x02\u0146\u0147\t\t\x02\x02\u0147b\x03\x02\x02\x02\u0148\u0149\t\x10" +
305 | "\x02\x02\u0149\u014A\t\x15\x02\x02\u014Ad\x03\x02\x02\x02\u014B\u014C" +
306 | "\t\n\x02\x02\u014C\u014D\t\n\x02\x02\u014D\u014E\t\x19\x02\x02\u014Ef" +
307 | "\x03\x02\x02\x02\u014F\u0150\t\x10\x02\x02\u0150\u0151\t\x05\x02\x02\u0151" +
308 | "\u0152\t\x1A\x02\x02\u0152h\x03\x02\x02\x02\u0153\u0154\t\r\x02\x02\u0154" +
309 | "\u0155\t\x12\x02\x02\u0155\u0156\t\x06\x02\x02\u0156j\x03\x02\x02\x02" +
310 | "\u0157\u0158\t\x06\x02\x02\u0158\u0159\t\n\x02\x02\u0159\u015A\t\x1A\x02" +
311 | "\x02\u015Al\x03\x02\x02\x02\u015B\u015C\t\x04\x02\x02\u015C\u015D\t\x07" +
312 | "\x02\x02\u015D\u015E\t\x15\x02\x02\u015En\x03\x02\x02\x02\u015F\u0160" +
313 | "\t\x04\x02\x02\u0160\u0161\t\x12\x02\x02\u0161\u0162\t\x19\x02\x02\u0162" +
314 | "p\x03\x02\x02\x02\u0163\u0164\t\x1B\x02\x02\u0164\u0165\x03\x02\x02\x02" +
315 | "\u0165\u0166\b9\x02\x02\u0166r\x03\x02\x02\x02\u0167\u0168\x05{>\x02\u0168" +
316 | "\u0169\x03\x02\x02\x02\u0169\u016A\b:\x02\x02\u016At\x03\x02\x02\x02\u016B" +
317 | "\u016D\x07%\x02\x02\u016C\u016E\t\x1C\x02\x02\u016D\u016C\x03\x02\x02" +
318 | "\x02\u016E\u016F\x03\x02\x02\x02\u016F\u016D\x03\x02\x02\x02\u016F\u0170" +
319 | "\x03\x02\x02\x02\u0170v\x03\x02\x02\x02\u0171\u0172\x07=\x02\x02\u0172" +
320 | "x\x03\x02\x02\x02\u0173\u0174\v\x02\x02\x02\u0174z\x03\x02\x02\x02\u0175" +
321 | "\u0176\x071\x02\x02\u0176\u0177\x07,\x02\x02\u0177\u017B\x03\x02\x02\x02" +
322 | "\u0178\u017A\v\x02\x02\x02\u0179\u0178\x03\x02\x02\x02\u017A\u017D\x03" +
323 | "\x02\x02\x02\u017B\u017C\x03\x02\x02\x02\u017B\u0179\x03\x02\x02\x02\u017C" +
324 | "\u017E\x03\x02\x02\x02\u017D\u017B\x03\x02\x02\x02\u017E\u017F\x07,\x02" +
325 | "\x02\u017F\u0191\x071\x02\x02\u0180\u0184\x07)\x02\x02\u0181\u0183\v\x02" +
326 | "\x02\x02\u0182\u0181\x03\x02\x02\x02\u0183\u0186\x03\x02\x02\x02\u0184" +
327 | "\u0185\x03\x02\x02\x02\u0184\u0182\x03\x02\x02\x02\u0185\u0187\x03\x02" +
328 | "\x02\x02\u0186\u0184\x03\x02\x02\x02\u0187\u0191\x07)\x02\x02\u0188\u018C" +
329 | "\x07$\x02\x02\u0189\u018B\v\x02\x02\x02\u018A\u0189\x03\x02\x02\x02\u018B" +
330 | "\u018E\x03\x02\x02\x02\u018C\u018D\x03\x02\x02\x02\u018C\u018A\x03\x02" +
331 | "\x02\x02\u018D\u018F\x03\x02\x02\x02\u018E\u018C\x03\x02\x02\x02\u018F" +
332 | "\u0191\x07$\x02\x02\u0190\u0175\x03\x02\x02\x02\u0190\u0180\x03\x02\x02" +
333 | "\x02\u0190\u0188\x03\x02\x02\x02\u0191|\x03\x02\x02\x02\x0F\x02\xA1\xA3" +
334 | "\xA8\xAE\xB5\xB7\u016D\u016F\u017B\u0184\u018C\u0190\x03\b\x02\x02";
335 | public static __ATN: ATN;
336 | public static get _ATN(): ATN {
337 | if (!CalculatorLexer.__ATN) {
338 | CalculatorLexer.__ATN = new ATNDeserializer().deserialize(Utils.toCharArray(CalculatorLexer._serializedATN));
339 | }
340 |
341 | return CalculatorLexer.__ATN;
342 | }
343 |
344 | }
345 |
346 |
--------------------------------------------------------------------------------
/src/GeneratedAntlr/CalculatorVisitor.ts:
--------------------------------------------------------------------------------
1 | // Generated from ./src/Calculator.g4 by ANTLR 4.9.0-SNAPSHOT
2 |
3 |
4 | import { ParseTreeVisitor } from "antlr4ts/tree/ParseTreeVisitor";
5 |
6 | import { UnaryContext } from "./CalculatorParser";
7 | import { UnaryPlusContext } from "./CalculatorParser";
8 | import { FloorContext } from "./CalculatorParser";
9 | import { CeilContext } from "./CalculatorParser";
10 | import { AbsContext } from "./CalculatorParser";
11 | import { RoundkContext } from "./CalculatorParser";
12 | import { RoundContext } from "./CalculatorParser";
13 | import { TruncContext } from "./CalculatorParser";
14 | import { SinContext } from "./CalculatorParser";
15 | import { CosContext } from "./CalculatorParser";
16 | import { TanContext } from "./CalculatorParser";
17 | import { CotContext } from "./CalculatorParser";
18 | import { SinhContext } from "./CalculatorParser";
19 | import { CoshContext } from "./CalculatorParser";
20 | import { TanhContext } from "./CalculatorParser";
21 | import { ArcsinContext } from "./CalculatorParser";
22 | import { ArccosContext } from "./CalculatorParser";
23 | import { ArctanContext } from "./CalculatorParser";
24 | import { Arctan2Context } from "./CalculatorParser";
25 | import { ArccotContext } from "./CalculatorParser";
26 | import { ExpContext } from "./CalculatorParser";
27 | import { LnContext } from "./CalculatorParser";
28 | import { EexContext } from "./CalculatorParser";
29 | import { LogContext } from "./CalculatorParser";
30 | import { RadContext } from "./CalculatorParser";
31 | import { DegContext } from "./CalculatorParser";
32 | import { SqrtContext } from "./CalculatorParser";
33 | import { SqrContext } from "./CalculatorParser";
34 | import { ExponentContext } from "./CalculatorParser";
35 | import { NegExponentContext } from "./CalculatorParser";
36 | import { PowContext } from "./CalculatorParser";
37 | import { ModContext } from "./CalculatorParser";
38 | import { WholeContext } from "./CalculatorParser";
39 | import { SqRootContext } from "./CalculatorParser";
40 | import { MulDivContext } from "./CalculatorParser";
41 | import { ParenthesisContext } from "./CalculatorParser";
42 | import { MultContext } from "./CalculatorParser";
43 | import { MinContext } from "./CalculatorParser";
44 | import { MaxContext } from "./CalculatorParser";
45 | import { AddSubContext } from "./CalculatorParser";
46 | import { NumberContext } from "./CalculatorParser";
47 | import { PiContext } from "./CalculatorParser";
48 | import { EulerContext } from "./CalculatorParser";
49 | import { RangeContext } from "./CalculatorParser";
50 | import { SubstitutionContext } from "./CalculatorParser";
51 | import { CalculatorContext } from "./CalculatorParser";
52 | import { ExpressionContext } from "./CalculatorParser";
53 | import { TrailingCommentContext } from "./CalculatorParser";
54 | import { CompileUnitContext } from "./CalculatorParser";
55 |
56 |
57 | /**
58 | * This interface defines a complete generic visitor for a parse tree produced
59 | * by `CalculatorParser`.
60 | *
61 | * @param The return type of the visit operation. Use `void` for
62 | * operations with no return type.
63 | */
64 | export interface CalculatorVisitor extends ParseTreeVisitor {
65 | /**
66 | * Visit a parse tree produced by the `Unary`
67 | * labeled alternative in `CalculatorParser.expression`.
68 | * @param ctx the parse tree
69 | * @return the visitor result
70 | */
71 | visitUnary?: (ctx: UnaryContext) => Result;
72 |
73 | /**
74 | * Visit a parse tree produced by the `UnaryPlus`
75 | * labeled alternative in `CalculatorParser.expression`.
76 | * @param ctx the parse tree
77 | * @return the visitor result
78 | */
79 | visitUnaryPlus?: (ctx: UnaryPlusContext) => Result;
80 |
81 | /**
82 | * Visit a parse tree produced by the `Floor`
83 | * labeled alternative in `CalculatorParser.expression`.
84 | * @param ctx the parse tree
85 | * @return the visitor result
86 | */
87 | visitFloor?: (ctx: FloorContext) => Result;
88 |
89 | /**
90 | * Visit a parse tree produced by the `Ceil`
91 | * labeled alternative in `CalculatorParser.expression`.
92 | * @param ctx the parse tree
93 | * @return the visitor result
94 | */
95 | visitCeil?: (ctx: CeilContext) => Result;
96 |
97 | /**
98 | * Visit a parse tree produced by the `Abs`
99 | * labeled alternative in `CalculatorParser.expression`.
100 | * @param ctx the parse tree
101 | * @return the visitor result
102 | */
103 | visitAbs?: (ctx: AbsContext) => Result;
104 |
105 | /**
106 | * Visit a parse tree produced by the `Roundk`
107 | * labeled alternative in `CalculatorParser.expression`.
108 | * @param ctx the parse tree
109 | * @return the visitor result
110 | */
111 | visitRoundk?: (ctx: RoundkContext) => Result;
112 |
113 | /**
114 | * Visit a parse tree produced by the `Round`
115 | * labeled alternative in `CalculatorParser.expression`.
116 | * @param ctx the parse tree
117 | * @return the visitor result
118 | */
119 | visitRound?: (ctx: RoundContext) => Result;
120 |
121 | /**
122 | * Visit a parse tree produced by the `Trunc`
123 | * labeled alternative in `CalculatorParser.expression`.
124 | * @param ctx the parse tree
125 | * @return the visitor result
126 | */
127 | visitTrunc?: (ctx: TruncContext) => Result;
128 |
129 | /**
130 | * Visit a parse tree produced by the `Sin`
131 | * labeled alternative in `CalculatorParser.expression`.
132 | * @param ctx the parse tree
133 | * @return the visitor result
134 | */
135 | visitSin?: (ctx: SinContext) => Result;
136 |
137 | /**
138 | * Visit a parse tree produced by the `Cos`
139 | * labeled alternative in `CalculatorParser.expression`.
140 | * @param ctx the parse tree
141 | * @return the visitor result
142 | */
143 | visitCos?: (ctx: CosContext) => Result;
144 |
145 | /**
146 | * Visit a parse tree produced by the `Tan`
147 | * labeled alternative in `CalculatorParser.expression`.
148 | * @param ctx the parse tree
149 | * @return the visitor result
150 | */
151 | visitTan?: (ctx: TanContext) => Result;
152 |
153 | /**
154 | * Visit a parse tree produced by the `Cot`
155 | * labeled alternative in `CalculatorParser.expression`.
156 | * @param ctx the parse tree
157 | * @return the visitor result
158 | */
159 | visitCot?: (ctx: CotContext) => Result;
160 |
161 | /**
162 | * Visit a parse tree produced by the `Sinh`
163 | * labeled alternative in `CalculatorParser.expression`.
164 | * @param ctx the parse tree
165 | * @return the visitor result
166 | */
167 | visitSinh?: (ctx: SinhContext) => Result;
168 |
169 | /**
170 | * Visit a parse tree produced by the `Cosh`
171 | * labeled alternative in `CalculatorParser.expression`.
172 | * @param ctx the parse tree
173 | * @return the visitor result
174 | */
175 | visitCosh?: (ctx: CoshContext) => Result;
176 |
177 | /**
178 | * Visit a parse tree produced by the `Tanh`
179 | * labeled alternative in `CalculatorParser.expression`.
180 | * @param ctx the parse tree
181 | * @return the visitor result
182 | */
183 | visitTanh?: (ctx: TanhContext) => Result;
184 |
185 | /**
186 | * Visit a parse tree produced by the `Arcsin`
187 | * labeled alternative in `CalculatorParser.expression`.
188 | * @param ctx the parse tree
189 | * @return the visitor result
190 | */
191 | visitArcsin?: (ctx: ArcsinContext) => Result;
192 |
193 | /**
194 | * Visit a parse tree produced by the `Arccos`
195 | * labeled alternative in `CalculatorParser.expression`.
196 | * @param ctx the parse tree
197 | * @return the visitor result
198 | */
199 | visitArccos?: (ctx: ArccosContext) => Result;
200 |
201 | /**
202 | * Visit a parse tree produced by the `Arctan`
203 | * labeled alternative in `CalculatorParser.expression`.
204 | * @param ctx the parse tree
205 | * @return the visitor result
206 | */
207 | visitArctan?: (ctx: ArctanContext) => Result;
208 |
209 | /**
210 | * Visit a parse tree produced by the `Arctan2`
211 | * labeled alternative in `CalculatorParser.expression`.
212 | * @param ctx the parse tree
213 | * @return the visitor result
214 | */
215 | visitArctan2?: (ctx: Arctan2Context) => Result;
216 |
217 | /**
218 | * Visit a parse tree produced by the `Arccot`
219 | * labeled alternative in `CalculatorParser.expression`.
220 | * @param ctx the parse tree
221 | * @return the visitor result
222 | */
223 | visitArccot?: (ctx: ArccotContext) => Result;
224 |
225 | /**
226 | * Visit a parse tree produced by the `Exp`
227 | * labeled alternative in `CalculatorParser.expression`.
228 | * @param ctx the parse tree
229 | * @return the visitor result
230 | */
231 | visitExp?: (ctx: ExpContext) => Result;
232 |
233 | /**
234 | * Visit a parse tree produced by the `Ln`
235 | * labeled alternative in `CalculatorParser.expression`.
236 | * @param ctx the parse tree
237 | * @return the visitor result
238 | */
239 | visitLn?: (ctx: LnContext) => Result;
240 |
241 | /**
242 | * Visit a parse tree produced by the `Eex`
243 | * labeled alternative in `CalculatorParser.expression`.
244 | * @param ctx the parse tree
245 | * @return the visitor result
246 | */
247 | visitEex?: (ctx: EexContext) => Result;
248 |
249 | /**
250 | * Visit a parse tree produced by the `Log`
251 | * labeled alternative in `CalculatorParser.expression`.
252 | * @param ctx the parse tree
253 | * @return the visitor result
254 | */
255 | visitLog?: (ctx: LogContext) => Result;
256 |
257 | /**
258 | * Visit a parse tree produced by the `Rad`
259 | * labeled alternative in `CalculatorParser.expression`.
260 | * @param ctx the parse tree
261 | * @return the visitor result
262 | */
263 | visitRad?: (ctx: RadContext) => Result;
264 |
265 | /**
266 | * Visit a parse tree produced by the `Deg`
267 | * labeled alternative in `CalculatorParser.expression`.
268 | * @param ctx the parse tree
269 | * @return the visitor result
270 | */
271 | visitDeg?: (ctx: DegContext) => Result;
272 |
273 | /**
274 | * Visit a parse tree produced by the `Sqrt`
275 | * labeled alternative in `CalculatorParser.expression`.
276 | * @param ctx the parse tree
277 | * @return the visitor result
278 | */
279 | visitSqrt?: (ctx: SqrtContext) => Result;
280 |
281 | /**
282 | * Visit a parse tree produced by the `Sqr`
283 | * labeled alternative in `CalculatorParser.expression`.
284 | * @param ctx the parse tree
285 | * @return the visitor result
286 | */
287 | visitSqr?: (ctx: SqrContext) => Result;
288 |
289 | /**
290 | * Visit a parse tree produced by the `Exponent`
291 | * labeled alternative in `CalculatorParser.expression`.
292 | * @param ctx the parse tree
293 | * @return the visitor result
294 | */
295 | visitExponent?: (ctx: ExponentContext) => Result;
296 |
297 | /**
298 | * Visit a parse tree produced by the `NegExponent`
299 | * labeled alternative in `CalculatorParser.expression`.
300 | * @param ctx the parse tree
301 | * @return the visitor result
302 | */
303 | visitNegExponent?: (ctx: NegExponentContext) => Result;
304 |
305 | /**
306 | * Visit a parse tree produced by the `Pow`
307 | * labeled alternative in `CalculatorParser.expression`.
308 | * @param ctx the parse tree
309 | * @return the visitor result
310 | */
311 | visitPow?: (ctx: PowContext) => Result;
312 |
313 | /**
314 | * Visit a parse tree produced by the `Mod`
315 | * labeled alternative in `CalculatorParser.expression`.
316 | * @param ctx the parse tree
317 | * @return the visitor result
318 | */
319 | visitMod?: (ctx: ModContext) => Result;
320 |
321 | /**
322 | * Visit a parse tree produced by the `Whole`
323 | * labeled alternative in `CalculatorParser.expression`.
324 | * @param ctx the parse tree
325 | * @return the visitor result
326 | */
327 | visitWhole?: (ctx: WholeContext) => Result;
328 |
329 | /**
330 | * Visit a parse tree produced by the `SqRoot`
331 | * labeled alternative in `CalculatorParser.expression`.
332 | * @param ctx the parse tree
333 | * @return the visitor result
334 | */
335 | visitSqRoot?: (ctx: SqRootContext) => Result;
336 |
337 | /**
338 | * Visit a parse tree produced by the `MulDiv`
339 | * labeled alternative in `CalculatorParser.expression`.
340 | * @param ctx the parse tree
341 | * @return the visitor result
342 | */
343 | visitMulDiv?: (ctx: MulDivContext) => Result;
344 |
345 | /**
346 | * Visit a parse tree produced by the `Parenthesis`
347 | * labeled alternative in `CalculatorParser.expression`.
348 | * @param ctx the parse tree
349 | * @return the visitor result
350 | */
351 | visitParenthesis?: (ctx: ParenthesisContext) => Result;
352 |
353 | /**
354 | * Visit a parse tree produced by the `Mult`
355 | * labeled alternative in `CalculatorParser.expression`.
356 | * @param ctx the parse tree
357 | * @return the visitor result
358 | */
359 | visitMult?: (ctx: MultContext) => Result;
360 |
361 | /**
362 | * Visit a parse tree produced by the `Min`
363 | * labeled alternative in `CalculatorParser.expression`.
364 | * @param ctx the parse tree
365 | * @return the visitor result
366 | */
367 | visitMin?: (ctx: MinContext) => Result;
368 |
369 | /**
370 | * Visit a parse tree produced by the `Max`
371 | * labeled alternative in `CalculatorParser.expression`.
372 | * @param ctx the parse tree
373 | * @return the visitor result
374 | */
375 | visitMax?: (ctx: MaxContext) => Result;
376 |
377 | /**
378 | * Visit a parse tree produced by the `AddSub`
379 | * labeled alternative in `CalculatorParser.expression`.
380 | * @param ctx the parse tree
381 | * @return the visitor result
382 | */
383 | visitAddSub?: (ctx: AddSubContext) => Result;
384 |
385 | /**
386 | * Visit a parse tree produced by the `Number`
387 | * labeled alternative in `CalculatorParser.expression`.
388 | * @param ctx the parse tree
389 | * @return the visitor result
390 | */
391 | visitNumber?: (ctx: NumberContext) => Result;
392 |
393 | /**
394 | * Visit a parse tree produced by the `Pi`
395 | * labeled alternative in `CalculatorParser.expression`.
396 | * @param ctx the parse tree
397 | * @return the visitor result
398 | */
399 | visitPi?: (ctx: PiContext) => Result;
400 |
401 | /**
402 | * Visit a parse tree produced by the `Euler`
403 | * labeled alternative in `CalculatorParser.expression`.
404 | * @param ctx the parse tree
405 | * @return the visitor result
406 | */
407 | visitEuler?: (ctx: EulerContext) => Result;
408 |
409 | /**
410 | * Visit a parse tree produced by the `Range`
411 | * labeled alternative in `CalculatorParser.expression`.
412 | * @param ctx the parse tree
413 | * @return the visitor result
414 | */
415 | visitRange?: (ctx: RangeContext) => Result;
416 |
417 | /**
418 | * Visit a parse tree produced by the `Substitution`
419 | * labeled alternative in `CalculatorParser.expression`.
420 | * @param ctx the parse tree
421 | * @return the visitor result
422 | */
423 | visitSubstitution?: (ctx: SubstitutionContext) => Result;
424 |
425 | /**
426 | * Visit a parse tree produced by `CalculatorParser.calculator`.
427 | * @param ctx the parse tree
428 | * @return the visitor result
429 | */
430 | visitCalculator?: (ctx: CalculatorContext) => Result;
431 |
432 | /**
433 | * Visit a parse tree produced by `CalculatorParser.expression`.
434 | * @param ctx the parse tree
435 | * @return the visitor result
436 | */
437 | visitExpression?: (ctx: ExpressionContext) => Result;
438 |
439 | /**
440 | * Visit a parse tree produced by `CalculatorParser.trailingComment`.
441 | * @param ctx the parse tree
442 | * @return the visitor result
443 | */
444 | visitTrailingComment?: (ctx: TrailingCommentContext) => Result;
445 |
446 | /**
447 | * Visit a parse tree produced by `CalculatorParser.compileUnit`.
448 | * @param ctx the parse tree
449 | * @return the visitor result
450 | */
451 | visitCompileUnit?: (ctx: CompileUnitContext) => Result;
452 | }
453 |
454 |
--------------------------------------------------------------------------------
/src/index.ts:
--------------------------------------------------------------------------------
1 | export * from './Calculator';
2 | export * from './CalculationResult';
3 |
--------------------------------------------------------------------------------
/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "ES2015",
4 | "module": "ES2020",
5 | "declaration": true,
6 | "outDir": "./demo/dist",
7 | "noImplicitAny": false,
8 | "lib": ["es2015", "es2015.core", "DOM"],
9 | "types": [
10 | "jasmine"
11 | ],
12 | "sourceMap": true,
13 | "esModuleInterop": true,
14 | "moduleResolution": "Node"
15 | },
16 | "include": ["src"],
17 | "compileOnSave": false,
18 | "exclude": [
19 | "node_modules",
20 | "**/*.spec.ts"
21 | ]
22 | }
23 |
--------------------------------------------------------------------------------
/tsconfig.spec.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "es2015",
4 | "module": "commonjs",
5 | "declaration": true,
6 | "outDir": "./dist",
7 | "noImplicitAny": false,
8 | "lib": ["es2015", "es2015.core", "DOM"],
9 | "types": [
10 | "jasmine"
11 | ]
12 | },
13 | "include": ["src"],
14 | "compileOnSave": false,
15 | "exclude": [
16 | "node_modules"
17 | ]
18 | }
19 |
--------------------------------------------------------------------------------
/webpack-test.config.js:
--------------------------------------------------------------------------------
1 | const path = require('path');
2 | const TerserPlugin = require('terser-webpack-plugin');
3 | const webpack = require('webpack');
4 |
5 | module.exports = {
6 | resolve: {
7 | extensions: ['.ts', '.js']
8 | },
9 | module: {
10 | rules: [
11 | {
12 | test: /\.ts$/,
13 | use: 'ts-loader',
14 | exclude: /node_modules/
15 | }
16 | ]
17 | },
18 | plugins: [
19 | new webpack.DefinePlugin({
20 | 'process.env.NODE_DEBUG': false,
21 | }),
22 | ],
23 | };
24 |
--------------------------------------------------------------------------------
/webpack.config.js:
--------------------------------------------------------------------------------
1 | const path = require('path');
2 | const TerserPlugin = require('terser-webpack-plugin');
3 | const webpack = require('webpack');
4 |
5 | module.exports = {
6 | entry: {
7 | 'antlrCalc': './src/index.ts'
8 | },
9 | output: {
10 | path: path.resolve(__dirname, 'demo', 'dist', 'bundles'),
11 | filename: '[name].js',
12 | libraryTarget: 'umd',
13 | library: 'antlrCalc',
14 | umdNamedDefine: true
15 | },
16 | devtool: 'source-map',
17 | resolve: {
18 | extensions: ['.ts', '.js']
19 | },
20 | module: {
21 | rules: [{
22 | test: /\.ts$/,
23 | use: 'ts-loader',
24 | exclude: /node_modules/
25 | }]
26 | },
27 | plugins: [
28 | new webpack.DefinePlugin({
29 | 'process.env.NODE_DEBUG': false,
30 | }),
31 | ],
32 | optimization: {
33 | minimizer: [
34 | new TerserPlugin({
35 | parallel: true
36 | }),
37 | ],
38 | },
39 | performance: {
40 | maxEntrypointSize: 512000,
41 | maxAssetSize: 512000
42 | }
43 | };
44 |
--------------------------------------------------------------------------------