From 58e628bab9c0773fa7333c3f1b16c7dfbad2aaae Mon Sep 17 00:00:00 2001 From: Emmanouil Dermitzakis Date: Mon, 19 Feb 2024 21:04:38 +0200 Subject: [PATCH 01/13] feat: initial CSharp interpreter --- CSharp/.gitignore | 424 ++- CSharp/CSharp.csproj | 22 + CSharp/CSharp.sln | 16 + CSharp/Interpreter/ArcscriptExpression.cs | 345 +++ CSharp/Interpreter/ArcscriptFunctions.cs | 183 ++ CSharp/Interpreter/ArcscriptOutputs.cs | 148 + CSharp/Interpreter/ArcscriptParserBase.cs | 135 + CSharp/Interpreter/ArcscriptState.cs | 47 + CSharp/Interpreter/ArcscriptTranspiler.cs | 71 + CSharp/Interpreter/ArcscriptVisitor.cs | 461 +++ .../Interpreter/Generated/ArcscriptLexer.cs | 363 +++ .../Interpreter/Generated/ArcscriptParser.cs | 2634 +++++++++++++++++ .../Generated/ArcscriptParserBaseVisitor.cs | 419 +++ .../Generated/ArcscriptParserVisitor.cs | 264 ++ CSharp/Interpreter/Generated/AssemblyInfo.cs | 3 + CSharp/Interpreter/INodes/IAttribute.cs | 29 + CSharp/Interpreter/INodes/IBoard.cs | 6 + CSharp/Interpreter/INodes/IComponent.cs | 6 + CSharp/Interpreter/INodes/IConnection.cs | 20 + CSharp/Interpreter/INodes/IElement.cs | 24 + CSharp/Interpreter/INodes/IHasAttributes.cs | 19 + CSharp/Interpreter/INodes/IHelperClasses.cs | 37 + CSharp/Interpreter/INodes/INode.cs | 10 + CSharp/Interpreter/INodes/IProject.cs | 20 + CSharp/Interpreter/INodes/IVariable.cs | 23 + CSharp/Interpreter/Nodes.cs | 31 + CSharp/Interpreter/Utils.cs | 27 + CSharp/Project/Attribute.cs | 11 + CSharp/Project/Component.cs | 10 + CSharp/Project/Connection.cs | 27 + CSharp/Project/Element.cs | 32 + CSharp/Project/HelperClasses.cs | 23 + CSharp/Project/Project.cs | 26 + CSharp/Project/Variable.cs | 22 + CSharp/TestObjects.cs | 25 + CSharp/UnitTests.cs | 134 + CSharp/__tests__/conditions.json | 100 + CSharp/__tests__/parseErrors.json | 96 + CSharp/__tests__/replaceVariables.json | 62 + CSharp/__tests__/runtimeErrors.json | 60 + CSharp/__tests__/valid.json | 446 +++ 41 files changed, 6860 insertions(+), 1 deletion(-) create mode 100644 CSharp/CSharp.csproj create mode 100644 CSharp/CSharp.sln create mode 100644 CSharp/Interpreter/ArcscriptExpression.cs create mode 100644 CSharp/Interpreter/ArcscriptFunctions.cs create mode 100644 CSharp/Interpreter/ArcscriptOutputs.cs create mode 100644 CSharp/Interpreter/ArcscriptParserBase.cs create mode 100644 CSharp/Interpreter/ArcscriptState.cs create mode 100644 CSharp/Interpreter/ArcscriptTranspiler.cs create mode 100644 CSharp/Interpreter/ArcscriptVisitor.cs create mode 100644 CSharp/Interpreter/Generated/ArcscriptLexer.cs create mode 100644 CSharp/Interpreter/Generated/ArcscriptParser.cs create mode 100644 CSharp/Interpreter/Generated/ArcscriptParserBaseVisitor.cs create mode 100644 CSharp/Interpreter/Generated/ArcscriptParserVisitor.cs create mode 100644 CSharp/Interpreter/Generated/AssemblyInfo.cs create mode 100644 CSharp/Interpreter/INodes/IAttribute.cs create mode 100644 CSharp/Interpreter/INodes/IBoard.cs create mode 100644 CSharp/Interpreter/INodes/IComponent.cs create mode 100644 CSharp/Interpreter/INodes/IConnection.cs create mode 100644 CSharp/Interpreter/INodes/IElement.cs create mode 100644 CSharp/Interpreter/INodes/IHasAttributes.cs create mode 100644 CSharp/Interpreter/INodes/IHelperClasses.cs create mode 100644 CSharp/Interpreter/INodes/INode.cs create mode 100644 CSharp/Interpreter/INodes/IProject.cs create mode 100644 CSharp/Interpreter/INodes/IVariable.cs create mode 100644 CSharp/Interpreter/Nodes.cs create mode 100644 CSharp/Interpreter/Utils.cs create mode 100644 CSharp/Project/Attribute.cs create mode 100644 CSharp/Project/Component.cs create mode 100644 CSharp/Project/Connection.cs create mode 100644 CSharp/Project/Element.cs create mode 100644 CSharp/Project/HelperClasses.cs create mode 100644 CSharp/Project/Project.cs create mode 100644 CSharp/Project/Variable.cs create mode 100644 CSharp/TestObjects.cs create mode 100644 CSharp/UnitTests.cs create mode 100644 CSharp/__tests__/conditions.json create mode 100644 CSharp/__tests__/parseErrors.json create mode 100644 CSharp/__tests__/replaceVariables.json create mode 100644 CSharp/__tests__/runtimeErrors.json create mode 100644 CSharp/__tests__/valid.json diff --git a/CSharp/.gitignore b/CSharp/.gitignore index 21bc544..893d366 100644 --- a/CSharp/.gitignore +++ b/CSharp/.gitignore @@ -1 +1,423 @@ -src/Generated \ No newline at end of file +src/Generated + +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. +## +## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore + +# User-specific files +*.rsuser +*.suo +*.user +*.userosscache +*.sln.docstates + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Mono auto generated files +mono_crash.* + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +[Aa][Rr][Mm]/ +[Aa][Rr][Mm]64/ +bld/ +[Bb]in/ +[Oo]bj/ +[Ll]og/ + +# Visual Studio 2015/2017 cache/options directory +.vs/ +# Uncomment if you have tasks that create the project's static files in wwwroot +#wwwroot/ + +# Visual Studio 2017 auto generated files +Generated\ Files/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUNIT +*.VisualState.xml +TestResult.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# Benchmark Results +BenchmarkDotNet.Artifacts/ + +# .NET Core +project.lock.json +project.fragment.lock.json +artifacts/ + +# StyleCop +StyleCopReport.xml + +# Files built by Visual Studio +*_i.c +*_p.c +*_h.h +*.ilk +*.meta +*.obj +*.iobj +*.pch +*.pdb +*.ipdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*_wpftmp.csproj +*.log +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opendb +*.opensdf +*.sdf +*.cachefile +*.VC.db +*.VC.VC.opendb + +# Visual Studio profiler +*.psess +*.vsp +*.vspx +*.sap + +# Visual Studio Trace Files +*.e2e + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# JustCode is a .NET coding add-in +.JustCode + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# AxoCover is a Code Coverage Tool +.axoCover/* +!.axoCover/settings.json + +# Visual Studio code coverage results +*.coverage +*.coveragexml + +# NCrunch +_NCrunch_* +.*crunch*.local.xml +nCrunchTemp_* + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +# Note: Comment the next line if you want to checkin your web deploy settings, +# but database connection strings (with potential passwords) will be unencrypted +*.pubxml +*.publishproj + +# Microsoft Azure Web App publish settings. Comment the next line if you want to +# checkin your Azure Web App publish settings, but sensitive information contained +# in these scripts will be unencrypted +PublishScripts/ + +# NuGet Packages +*.nupkg +# The packages folder can be ignored because of Package Restore +**/[Pp]ackages/* +# except build/, which is used as an MSBuild target. +!**/[Pp]ackages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/[Pp]ackages/repositories.config +# NuGet v3's project.json files produces more ignorable files +*.nuget.props +*.nuget.targets + +# Microsoft Azure Build Output +csx/ +*.build.csdef + +# Microsoft Azure Emulator +ecf/ +rcf/ + +# Windows Store app package directories and files +AppPackages/ +BundleArtifacts/ +Package.StoreAssociation.xml +_pkginfo.txt +*.appx +*.appxbundle +*.appxupload + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!?*.[Cc]ache/ + +# Others +ClientBin/ +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.jfm +*.pfx +*.publishsettings +orleans.codegen.cs + +# Including strong name files can present a security risk +# (https://github.com/github/gitignore/pull/2483#issue-259490424) +#*.snk + +# Since there are multiple workflows, uncomment next line to ignore bower_components +# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) +#bower_components/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm +ServiceFabricBackup/ +*.rptproj.bak + +# SQL Server files +*.mdf +*.ldf +*.ndf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings +*.rptproj.rsuser +*- Backup*.rdl + +# Microsoft Fakes +FakesAssemblies/ + +# GhostDoc plugin setting file +*.GhostDoc.xml + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat +node_modules/ + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# Visual Studio 6 auto-generated workspace file (contains which files were open etc.) +*.vbw + +# Visual Studio LightSwitch build output +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions + +# Paket dependency manager +.paket/paket.exe +paket-files/ + +# FAKE - F# Make +.fake/ + +# CodeRush personal settings +.cr/personal + +# Python Tools for Visual Studio (PTVS) +__pycache__/ +*.pyc + +# Cake - Uncomment if you are using it +# tools/** +# !tools/packages.config + +# Tabs Studio +*.tss + +# Telerik's JustMock configuration file +*.jmconfig + +# BizTalk build output +*.btp.cs +*.btm.cs +*.odx.cs +*.xsd.cs + +# OpenCover UI analysis results +OpenCover/ + +# Azure Stream Analytics local run output +ASALocalRun/ + +# MSBuild Binary and Structured Log +*.binlog + +# NVidia Nsight GPU debugger configuration file +*.nvuser + +# MFractors (Xamarin productivity tool) working folder +.mfractor/ + +# Local History for Visual Studio +.localhistory/ + +# BeatPulse healthcheck temp database +healthchecksdb + +# Backup folder for Package Reference Convert tool in Visual Studio 2017 +MigrationBackup/ + + + +## VS CODE +.vscode/* +!.vscode/settings.json +!.vscode/tasks.json +!.vscode/launch.json +!.vscode/extensions.json + + +# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm +# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 + +# User-specific stuff +.idea/**/workspace.xml +.idea/**/tasks.xml +.idea/**/usage.statistics.xml +.idea/**/dictionaries +.idea/**/shelf + +# Generated files +.idea/**/contentModel.xml + +# Sensitive or high-churn files +.idea/**/dataSources/ +.idea/**/dataSources.ids +.idea/**/dataSources.local.xml +.idea/**/sqlDataSources.xml +.idea/**/dynamic.xml +.idea/**/uiDesigner.xml +.idea/**/dbnavigator.xml + +# Gradle +.idea/**/gradle.xml +.idea/**/libraries + +# Gradle and Maven with auto-import +# When using Gradle or Maven with auto-import, you should exclude module files, +# since they will be recreated, and may cause churn. Uncomment if using +# auto-import. +# .idea/modules.xml +# .idea/*.iml +# .idea/modules + +# CMake +cmake-build-*/ + +# Mongo Explorer plugin +.idea/**/mongoSettings.xml + +# File-based project format +*.iws + +# IntelliJ +out/ + +# mpeltonen/sbt-idea plugin +.idea_modules/ + +# JIRA plugin +atlassian-ide-plugin.xml + +# Cursive Clojure plugin +.idea/replstate.xml + +# Crashlytics plugin (for Android Studio and IntelliJ) +com_crashlytics_export_strings.xml +crashlytics.properties +crashlytics-build.properties +fabric.properties + +# Editor-based Rest Client +.idea/httpRequests + +# Android studio 3.1+ serialized cache file +.idea/caches/build_file_checksums.ser \ No newline at end of file diff --git a/CSharp/CSharp.csproj b/CSharp/CSharp.csproj new file mode 100644 index 0000000..d74dd02 --- /dev/null +++ b/CSharp/CSharp.csproj @@ -0,0 +1,22 @@ + + + + net6.0 + enable + enable + + false + true + Arcweave + + + + + + + + + + + + diff --git a/CSharp/CSharp.sln b/CSharp/CSharp.sln new file mode 100644 index 0000000..c54d833 --- /dev/null +++ b/CSharp/CSharp.sln @@ -0,0 +1,16 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CSharp", "CSharp.csproj", "{46E8C9BE-D0EC-440D-9FBB-034D1FD4E434}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {46E8C9BE-D0EC-440D-9FBB-034D1FD4E434}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {46E8C9BE-D0EC-440D-9FBB-034D1FD4E434}.Debug|Any CPU.Build.0 = Debug|Any CPU + {46E8C9BE-D0EC-440D-9FBB-034D1FD4E434}.Release|Any CPU.ActiveCfg = Release|Any CPU + {46E8C9BE-D0EC-440D-9FBB-034D1FD4E434}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection +EndGlobal diff --git a/CSharp/Interpreter/ArcscriptExpression.cs b/CSharp/Interpreter/ArcscriptExpression.cs new file mode 100644 index 0000000..b56042c --- /dev/null +++ b/CSharp/Interpreter/ArcscriptExpression.cs @@ -0,0 +1,345 @@ + +using System; +using System.Collections; + +namespace Arcweave.Interpreter +{ + public class Expression : IComparable + { + public object Value { get; set; } + public Expression() { Value = null; } + public Expression(object value) { Value = value; } + public Expression(object value, Type type) { Value = Convert.ChangeType(value, type); } + public Expression(Expression expression) { Value = expression.Value; } + public void SetValue(object value) { Value = value; } + public Type Type() { return Value.GetType(); } + public static Expression operator +(Expression e) { return e; } + public static Expression operator -(Expression e) + { + if (e.Value is int i) + { + return new Expression(-i); + } + else if (e.Value is double value) + { + return new Expression(-value); + } + return e; + } + public static Expression operator +(Expression first, Expression second) + { + if (first.Type() == typeof(string) || second.Type() == typeof(string)) + { + return new Expression(first.Value.ToString() + second.Value.ToString()); + } + var doubleValues = GetDoubleValues(first.Value, second.Value); + if (!doubleValues.HasDouble) + { + var intValue = (int)(doubleValues.Value1 + doubleValues.Value2); + return new Expression(intValue); + } + else + { + return new Expression(doubleValues.Value1 + doubleValues.Value2); + } + } + + public static Expression operator -(Expression first, Expression second) + { + var doubleValues = GetDoubleValues(first.Value, second.Value); + if (!doubleValues.HasDouble) + { + var intValue = (int) (doubleValues.Value1 - doubleValues.Value2); + return new Expression(intValue); + } else + { + return new Expression(doubleValues.Value1 - doubleValues.Value2); + } + } + + public static Expression operator *(Expression first, Expression second) + { + var doubleValues = GetDoubleValues(first.Value, second.Value); + if (!doubleValues.HasDouble) + { + var intValue = (int)(doubleValues.Value1 * doubleValues.Value2); + return new Expression(intValue); + } + else + { + return new Expression(doubleValues.Value1 * doubleValues.Value2); + } + } + + public static Expression operator /(Expression first, Expression second) + { + var doubleValues = GetDoubleValues(first.Value, second.Value); + return new Expression(doubleValues.Value1 / doubleValues.Value2); + } + + public static bool operator ==(Expression first, Expression second) + { + System.Type type1 = first.Type(); + if (type1 == typeof(int) || type1 == typeof(double)) + { + DoubleValues doubleValues = GetDoubleValues(first.Value, second.Value); + return doubleValues.Value1 == doubleValues.Value2; + } + if (type1 == typeof(bool)) + { + return (bool)first.Value == (bool)second.Value; + } + if (type1 == typeof(string)) + { + return (string)first.Value == (string)second.Value; + } + return false; + } + + public int CompareTo(object? other) + { + Expression o = (Expression)other; + DoubleValues fValues = GetDoubleValues(this.Value, o.Value); + double result = fValues.Value1 - fValues.Value2; + if (result < 0) + { + return -1; + } else if (result > 0) + { + return 1; + } + return 0; + } + + public override bool Equals(object obj) + { + if (obj == null || !(obj is Expression)) + { + return false; + } + Expression e = (Expression)obj; + + System.Type type1 = Type(); + if (type1 == typeof(int) || type1 == typeof(double)) + { + DoubleValues doubleValues = GetDoubleValues(Value, e.Value); + return doubleValues.Value1 == doubleValues.Value2; + } + if (type1 == typeof(bool)) + { + return (bool)Value == (bool)e.Value; + } + if (type1 == typeof(string)) + { + return (string)Value == (string)e.Value; + } + return false; + } + + public static bool operator !=(Expression first, Expression second) + { + System.Type type1 = first.Type(); + if (type1 == typeof(int) || type1 == typeof(double)) + { + DoubleValues doubleValues = GetDoubleValues(first.Value, second.Value); + return doubleValues.Value1 != doubleValues.Value2; + } + if (type1 == typeof(bool)) + { + return (bool)first.Value != (bool)second.Value; + } + if (type1 == typeof(string)) + { + return (string)first.Value != (string)second.Value; + } + return true; + } + public static bool operator ==(Expression first, bool second) + { + return GetBoolValue(first.Value) == second; + } + public static bool operator !=(Expression first, bool second) + { + return GetBoolValue(first.Value) != second; + } + public static bool operator ==(Expression first, int second) + { + DoubleValues doubleValues = GetDoubleValues(first.Value, second); + return doubleValues.Value1 == doubleValues.Value2; + } + public static bool operator !=(Expression first, int second) + { + DoubleValues doubleValues = GetDoubleValues(first.Value, second); + return doubleValues.Value1 != doubleValues.Value2; + } + public static bool operator ==(Expression first, double second) + { + DoubleValues doubleValues = GetDoubleValues(first.Value, second); + return doubleValues.Value1 == doubleValues.Value2; + } + public static bool operator !=(Expression first, double second) + { + DoubleValues doubleValues = GetDoubleValues(first.Value, second); + return doubleValues.Value1 != doubleValues.Value2; + } + public static bool operator ==(Expression first, string second) + { + return (string)first.Value == second; + } + + public override int GetHashCode() + { + return Value.GetHashCode(); + } + public static bool operator !=(Expression first, string second) + { + return (string)first.Value == second; + } + + public static bool operator >(Expression first, Expression second) + { + DoubleValues doubleValues = GetDoubleValues(first.Value, second.Value); + return doubleValues.Value1 > doubleValues.Value2; + } + public static bool operator <(Expression first, Expression second) + { + DoubleValues doubleValues = GetDoubleValues(first.Value, second.Value); + return doubleValues.Value1 < doubleValues.Value2; + } + public static bool operator >=(Expression first, Expression second) + { + DoubleValues doubleValues = GetDoubleValues(first.Value, second.Value); + return doubleValues.Value1 >= doubleValues.Value2; + } + public static bool operator <=(Expression first, Expression second) + { + DoubleValues doubleValues = GetDoubleValues(first.Value, second.Value); + return doubleValues.Value1 <= doubleValues.Value2; + } + public static bool operator >(Expression first, int second) + { + DoubleValues doubleValues = GetDoubleValues(first.Value, second); + return doubleValues.Value1 > doubleValues.Value2; + } + public static bool operator <(Expression first, int second) + { + DoubleValues doubleValues = GetDoubleValues(first.Value, second); + return doubleValues.Value1 < doubleValues.Value2; + } + public static bool operator >=(Expression first, int second) + { + DoubleValues doubleValues = GetDoubleValues(first.Value, second); + return doubleValues.Value1 >= doubleValues.Value2; + } + public static bool operator <=(Expression first, int second) + { + DoubleValues doubleValues = GetDoubleValues(first.Value, second); + return doubleValues.Value1 <= doubleValues.Value2; + } + public static bool operator >(Expression first, double second) + { + DoubleValues doubleValues = GetDoubleValues(first.Value, second); + return doubleValues.Value1 > doubleValues.Value2; + } + public static bool operator <(Expression first, double second) + { + DoubleValues doubleValues = GetDoubleValues(first.Value, second); + return doubleValues.Value1 < doubleValues.Value2; + } + public static bool operator >=(Expression first, double second) + { + DoubleValues doubleValues = GetDoubleValues(first.Value, second); + return doubleValues.Value1 >= doubleValues.Value2; + } + public static bool operator <=(Expression first, double second) + { + DoubleValues doubleValues = GetDoubleValues(first.Value, second); + return doubleValues.Value1 <= doubleValues.Value2; + } + public static Expression operator !(Expression e) + { + return new Expression(!GetBoolValue(e.Value)); + } + public static bool operator true(Expression e) + { + return GetBoolValue(e.Value); + } + public static bool operator false(Expression e) + { + return !GetBoolValue(e.Value); + } + public static Expression operator &(Expression first, Expression second) + { + if (GetBoolValue(first.Value) && GetBoolValue(second.Value)) + { + return new Expression(true); + } + return new Expression(false); + } + + public static Expression operator |(Expression first, Expression second) + { + if (GetBoolValue(first.Value) || GetBoolValue(second.Value)) + { + return new Expression(true); + } + return new Expression(false); + } + + public override string ToString() + { + return Value.ToString(); + } + + private struct DoubleValues + { + public double Value1; + public double Value2; + public bool HasDouble; + + public DoubleValues(double val1, double val2, bool hasDouble) { Value1 = val1; Value2 = val2; HasDouble = hasDouble; } + } + + private static DoubleValues GetDoubleValues(object first, object second) { + bool hasDouble = false; + int value1, value2; + double flValue1 = 0, flValue2 = 0; + if (first.GetType() == typeof(int)) + { + value1 = (int)first; + flValue1 = value1; + } else if (first.GetType() == typeof(double)) + { + hasDouble = true; + flValue1 = (double)first; + } else if (first.GetType() == typeof(bool)) + { + flValue1 = (bool)first ? 1 : 0; + } + + if (second.GetType() == typeof(int)) + { + value2 = (int)second; + flValue2 = value2; + } else if (second.GetType() == typeof(double)) + { + hasDouble = true; + flValue2 = (double)second; + } else if (second.GetType() == typeof(bool)) + { + flValue2 = (bool)second ? 1 : 0; + } + + return new DoubleValues(flValue1, flValue2, hasDouble); + } + + internal static bool GetBoolValue(object value) + { + if (value.GetType() == typeof(bool)) { return (bool)value; } + if (value.GetType() == typeof(string)) { return ((string)value).Length > 0; } + if (value.GetType() == typeof(int)) { return (int)value > 0; } + if (value.GetType() == typeof(double)) { return (double)value > 0; } + return false; + } + } +} \ No newline at end of file diff --git a/CSharp/Interpreter/ArcscriptFunctions.cs b/CSharp/Interpreter/ArcscriptFunctions.cs new file mode 100644 index 0000000..284c9c0 --- /dev/null +++ b/CSharp/Interpreter/ArcscriptFunctions.cs @@ -0,0 +1,183 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using Arcweave.Interpreter.INodes; + +namespace Arcweave.Interpreter +{ + public class Functions + { + private static readonly Random _getrandom = new Random(); + private IProject _project; + private string elementId; + private ArcscriptState state; + public Dictionary, object>> functions { get; private set; } = new Dictionary, object>>(); + + public Dictionary returnTypes = new Dictionary() + { + { "sqrt", typeof (double) }, + { "sqr", typeof (double) }, + { "abs", typeof (double) }, + { "random", typeof (double) }, + { "roll", typeof (int) }, + { "show", typeof (string) }, + { "reset", typeof (void) }, + { "resetAll", typeof (void) }, + { "round", typeof (int) }, + { "min", typeof (double) }, + { "max", typeof (double) }, + { "visits", typeof (int) } + }; + + public Functions(string elementId, IProject project, ArcscriptState state) { + this._project = project; + this.elementId = elementId; + this.state = state; + + this.functions["sqrt"] = this.Sqrt; + this.functions["sqr"] = this.Sqr; + this.functions["abs"] = this.Abs; + this.functions["random"] = this.Random; + this.functions["roll"] = this.Roll; + this.functions["show"] = this.Show; + this.functions["reset"] = this.Reset; + this.functions["resetAll"] = this.ResetAll; + this.functions["round"] = this.Round; + this.functions["min"] = this.Min; + this.functions["max"] = this.Max; + this.functions["visits"] = this.Visits; + } + + public object Sqrt(IList args) { + Expression e = args[0] as Expression; + double n; + if (e.Value is int i) + { + n = i; + } else if (e.Value is double d) + { + n = d; + } + else + { + n = (double)e.Value; + } + return Math.Sqrt(n); + } + + public object Sqr(IList args) { + Expression e = args[0] as Expression; + double n; + if (e.Value is int i) + { + n = i; + } else if (e.Value is double d) + { + n = d; + } + else + { + n = (double)e.Value; + } + return n * n; + } + + public object Abs(IList args) { + Expression e = args[0] as Expression; + double n; + if (e.Value is int i) + { + n = i; + } else if (e.Value is double d) + { + n = d; + } + else + { + n = (double)e.Value; + } + return Math.Abs(n); + } + + public object Random(IList args) { + lock ( _getrandom ) { + return _getrandom.NextDouble(); + } + } + + public object Roll(IList args) { + Expression e = args[0] as Expression; + int maxRoll = (int)e.Value; + int numRolls = 1; + if ( args.Count == 2 ) { + Expression e2 = args[1] as Expression; + numRolls = (int)e2.Value; + } + int sum = 0; + for ( int i = 0; i < numRolls; i++ ) { + int oneRoll = _getrandom.Next(1, maxRoll + 1); + sum += oneRoll; + } + return sum; + } + + public object Show(IList args) { + List results = new List(); + foreach (Expression arg in args ) { + results.Add(arg.Value.ToString()); + } + string result = String.Join("", results.ToArray()); + //UnityEngine.Debug.Log(result); + // this.state.outputs.Add(result); + this.state.Outputs.AddScriptOutput(result); + return null; + } + + public object Reset(IList args) { + foreach (IVariable argument in args ) { + state.SetVarValue(argument.Name, argument.DefaultValue); + } + return null; + } + + public object ResetAll(IList args) { + List variableNames = new List(); + foreach ( IVariable argument in args ) { + variableNames.Add(argument.Name); + } + foreach ( IVariable variable in this._project.Variables ) { + if ( !variableNames.Contains(variable.Name) ) { + state.SetVarValue(variable.Name, variable.DefaultValue); + } + } + return null; + } + + public object Round(IList args) { + Expression e = args[0] as Expression; + double n = (double)e.Value; + return (int)Math.Round(n); + } + + public object Min(IList args) + { + IList arguments = args.Cast().ToList(); + return arguments.Min(); + } + + public object Max(IList args) { + IList arguments = args.Cast().ToList(); + return arguments.Max(); + } + + public object Visits(IList args) { + string elementId = this.elementId; + if ( args != null && args.Count == 1 ) { + ArcscriptVisitor.Mention mention = (ArcscriptVisitor.Mention)args[0]; + elementId = mention.attrs["data-id"]; + } + IElement element = this._project.ElementWithId(elementId); + return element.Visits; + } + } +} \ No newline at end of file diff --git a/CSharp/Interpreter/ArcscriptOutputs.cs b/CSharp/Interpreter/ArcscriptOutputs.cs new file mode 100644 index 0000000..90964b1 --- /dev/null +++ b/CSharp/Interpreter/ArcscriptOutputs.cs @@ -0,0 +1,148 @@ +namespace Arcweave.Interpreter; + +public interface IOutputNode +{ + public string GetText(); + public void MergeScriptOutput(string text); +} + +public interface IHasParagraphs +{ + public void AppendParagraph(string text); +} + +public class Paragraph : IOutputNode +{ + private string _text; + + public Paragraph(string text) + { + _text = text; + } + + public void MergeScriptOutput(string text) + { + if (text.Length > 0) + { + this._text += ' ' + text; + } + } + + public string GetText() + { + return "

" + _text + "

"; + } +} + +public class Blockquote : IHasParagraphs, IOutputNode +{ + public List Paragraphs { get; set; } = new(); + + public void AppendParagraph(string text) + { + Paragraphs.Add(new Paragraph(text)); + } + + public void MergeScriptOutput(string text) + { + if (Paragraphs.Count == 0) + { + AppendParagraph(text); + return; + } + + Paragraphs.Last().MergeScriptOutput(text); + } + + public string GetText() + { + var output = ""; + foreach (var p in Paragraphs) + { + output += p.GetText(); + } + + return "
" + output + "
"; + } +} + +public class ArcscriptOutputs : IHasParagraphs +{ + private List Outputs { get; } = new(); + private IHasParagraphs? _currentNode; + private bool _addedScript; + + public void AppendParagraph(string text) + { + Outputs.Add(new Paragraph(text)); + } + + public void AddParagraph(string text) + { + _currentNode ??= this; + + if (_addedScript) + { + if (Outputs.Count > 0 && Outputs.Last() is Blockquote && _currentNode is not Blockquote) + { + AppendParagraph(text); + } + else + { + AddScriptOutput(text); + } + _addedScript = false; + return; + } + _currentNode.AppendParagraph(text); + } + + public void AddBlockquote() + { + if (_addedScript && Outputs.Count > 0) + { + IOutputNode n = Outputs.Last(); + if (n is Blockquote blockquote) + { + _currentNode = blockquote; + return; + } + } + Blockquote b = new Blockquote(); + Outputs.Add(b); + _currentNode = b; + } + + public void AddScriptOutput(string? text) + { + _addedScript = true; + if (text == null) + { + return; + } + if (Outputs.Count == 0) + { + Outputs.Add(new Paragraph(text)); + return; + } + + var n = Outputs.Last(); + n.MergeScriptOutput(text); + } + + public void ExitBlockquote() + { + _currentNode = this; + } + + public string GetText() + { + var output = ""; + foreach (var o in Outputs) + { + output += o.GetText(); + } + + return output; + } +} \ No newline at end of file diff --git a/CSharp/Interpreter/ArcscriptParserBase.cs b/CSharp/Interpreter/ArcscriptParserBase.cs new file mode 100644 index 0000000..644a624 --- /dev/null +++ b/CSharp/Interpreter/ArcscriptParserBase.cs @@ -0,0 +1,135 @@ +using System.Collections.Generic; +using Antlr4.Runtime; +using System.IO; +using System.Linq; +using Arcweave.Interpreter.INodes; + +namespace Arcweave.Interpreter +{ + public class ArcscriptParserBase : Parser + { + private class FunctionArgs + { + public int? MinArgs { get; set; } + public int? MaxArgs { get; set; } + } + + private Dictionary ArcscriptFunctions; + private protected IProject Project { get; private set; } + + internal int currentLine; + internal int openTagEndPos; + public ArcscriptParserBase(ITokenStream input) : base(input) { + var functions = new Dictionary() + { + { "abs", new FunctionArgs { MinArgs=1, MaxArgs=1 } }, + { "max", new FunctionArgs { MinArgs=2 } }, + { "min", new FunctionArgs { MinArgs=2 } }, + { "random", new FunctionArgs { MinArgs=0, MaxArgs=0 } }, + { "roll", new FunctionArgs { MinArgs=1, MaxArgs=2 } }, + { "round", new FunctionArgs { MinArgs=1, MaxArgs=1 } }, + { "sqr", new FunctionArgs { MinArgs=1, MaxArgs=1 } }, + { "sqrt", new FunctionArgs { MinArgs=1, MaxArgs=1 } }, + { "visits", new FunctionArgs { MinArgs=0, MaxArgs=1 } }, + { "show", new FunctionArgs { MinArgs=1 } }, + { "reset", new FunctionArgs { MinArgs=1 } }, + { "resetAll", new FunctionArgs { MinArgs=0 } }, + }; + + this.ArcscriptFunctions = functions; + } + + public ArcscriptParserBase(ITokenStream input, TextWriter output, TextWriter errorOutput) : base(input, output, errorOutput) { + var functions = new Dictionary() + { + { "abs", new FunctionArgs { MinArgs=1, MaxArgs=1 } }, + { "max", new FunctionArgs { MinArgs=2 } }, + { "min", new FunctionArgs { MinArgs=2 } }, + { "random", new FunctionArgs { MinArgs=0, MaxArgs=0 } }, + { "roll", new FunctionArgs { MinArgs=1, MaxArgs=2 } }, + { "round", new FunctionArgs { MinArgs=1, MaxArgs=1 } }, + { "sqr", new FunctionArgs { MinArgs=1, MaxArgs=1 } }, + { "sqrt", new FunctionArgs { MinArgs=1, MaxArgs=1 } }, + { "visits", new FunctionArgs { MinArgs=0, MaxArgs=1 } }, + { "show", new FunctionArgs { MinArgs=1 } }, + { "reset", new FunctionArgs { MinArgs=1 } }, + { "resetAll", new FunctionArgs { MinArgs=0 } }, + }; + + this.ArcscriptFunctions = functions; + } + + public void SetProject(IProject project) { + this.Project = project; + } + + public override string[] RuleNames => throw new System.NotImplementedException(); + + public override IVocabulary Vocabulary => throw new System.NotImplementedException(); + + public override string GrammarFileName => throw new System.NotImplementedException(); + + public bool assertVariable(IToken variable) { + var variableName = variable.Text; + var found = this.Project.Variables.First(x => x.Name == variableName); + if ( found != null ) { + return false; + } + return true; + } + + public bool assertMention(IList attrCtxList) { + Dictionary attrs = new Dictionary(); + foreach ( var attrCtx in attrCtxList ) { + string attrName = attrCtx.GetToken(ArcscriptParser.ATTR_NAME, 0)?.GetText(); + string attrValue = attrCtx.GetToken(ArcscriptParser.ATTR_VALUE, 0)?.GetText() ?? ""; + if ( attrValue.StartsWith("\"") && attrValue.EndsWith("\"") ) { + attrValue = attrValue.Substring(1, attrValue.Length - 2); + } else if ( attrValue.StartsWith("'") && attrValue.EndsWith("'") ) { + attrValue = attrValue.Substring(1, attrValue.Length - 2); + } + attrs.Add(attrName, attrValue); + } + string[] classList = attrs["class"].Split(" "); + if ( !classList.Contains("mention") ) { + return false; + } + if ( attrs["data-type"] != "element" ) { + return false; + } + if ( this.Project.ElementWithId(attrs["data-id"]) == null ) { + return false; + } + return true; + } + + public bool assertFunctionArguments(IToken fname, ArcscriptParser.Argument_listContext argumentList) { + int argListLength = 0; + if ( argumentList != null && argumentList.argument() != null ) { + argListLength = argumentList.argument().Length; + } + var min = this.ArcscriptFunctions[fname.Text].MinArgs; + var max = this.ArcscriptFunctions[fname.Text].MaxArgs; + if ( ( min != null && argListLength < min ) || ( max != null && argListLength > max ) ) { + return false; + } + return true; + } + + public bool assertFunctionArguments(IToken fname, ArcscriptParser.Variable_listContext variable_List) { + int varListLength = variable_List.VARIABLE().Length; + var min = this.ArcscriptFunctions[fname.Text].MinArgs; + var max = this.ArcscriptFunctions[fname.Text].MaxArgs; + if ( ( min != null && varListLength < min ) || ( max != null && varListLength > max ) ) { + return false; + } + return true; + } + + internal void setLineStart(IToken token) + { + openTagEndPos = token.StartIndex + token.Text.Length; + } + } + +} \ No newline at end of file diff --git a/CSharp/Interpreter/ArcscriptState.cs b/CSharp/Interpreter/ArcscriptState.cs new file mode 100644 index 0000000..378ac62 --- /dev/null +++ b/CSharp/Interpreter/ArcscriptState.cs @@ -0,0 +1,47 @@ +using System.Collections.Generic; +using System.Linq; +using Arcweave.Interpreter.INodes; + +namespace Arcweave.Interpreter +{ + public class ArcscriptState + { + public Dictionary VariableChanges = new Dictionary(); + // public List outputs = new List(); + public ArcscriptOutputs Outputs; + public string currentElement { get; set; } + public IProject project { get; set; } + public ArcscriptState(string elementId, IProject project) + { + Outputs = new ArcscriptOutputs(); + this.currentElement = elementId; + this.project = project; + } + + public IVariable GetVariable(string name) { + try + { + return this.project.Variables.First(variable => variable.Name == name); + } + catch (System.InvalidOperationException) + { + return null; + } + } + + public object GetVarValue(string name) { + if ( this.VariableChanges.ContainsKey(name) ) { + return VariableChanges[name]; + } + return this.project.GetVariable(name).ObjectValue; + } + + public void SetVarValue(string name, object value) { VariableChanges[name] = value; } + + public void SetVarValues(string[] names, string[] values) { + for ( int i = 0; i < names.Length; i++ ) { + this.VariableChanges[names[i]] = values[i]; + } + } + } +} \ No newline at end of file diff --git a/CSharp/Interpreter/ArcscriptTranspiler.cs b/CSharp/Interpreter/ArcscriptTranspiler.cs new file mode 100644 index 0000000..85a6073 --- /dev/null +++ b/CSharp/Interpreter/ArcscriptTranspiler.cs @@ -0,0 +1,71 @@ +using Antlr4.Runtime; +using System.Collections.Generic; +using Arcweave.Interpreter.INodes; + +namespace Arcweave.Interpreter +{ + + public class AwInterpreter + { + private IProject Project { get; set; } + private string ElementId { get; set; } + + public AwInterpreter(IProject project, string elementId = "") + { + this.Project = project; + this.ElementId = elementId; + } + + private ArcscriptParser.InputContext GetParseTree(string code) + { + ICharStream stream = CharStreams.fromString(code); + ITokenSource lexer = new ArcscriptLexer(stream); + ITokenStream tokens = new CommonTokenStream(lexer); + ArcscriptParser parser = new ArcscriptParser(tokens); + parser.SetProject(Project); + + ArcscriptParser.InputContext tree = parser.input(); + return tree; + } + + public TranspilerOutput RunScript(string code) + { + ArcscriptParser.InputContext tree = this.GetParseTree(code); + ArcscriptVisitor visitor = new ArcscriptVisitor(this.ElementId, this.Project); + object result = tree.Accept(visitor); + + // List outputs = visitor.state.outputs; + var outputResult = visitor.state.Outputs.GetText(); + // if (outputs.Count > 0) + // { + // foreach (var t in outputs) + // { + // outputResult += t.Trim(); + // } + // + // //outputResult = Utils.CleanString(outputResult); + // } + + var isCondition = tree.script() != null; + + return new TranspilerOutput(outputResult, visitor.state.VariableChanges, result, isCondition); + } + + public class TranspilerOutput + { + public string Output { get; private set; } + public Dictionary Changes { get; private set; } + public object Result { get; private set; } + public bool IsCondition { get; private set; } + + public TranspilerOutput(string output, Dictionary changes, object result, + bool isCondition = false) + { + this.Result = result; + this.Output = output; + this.Changes = changes; + IsCondition = isCondition; + } + } + } +} \ No newline at end of file diff --git a/CSharp/Interpreter/ArcscriptVisitor.cs b/CSharp/Interpreter/ArcscriptVisitor.cs new file mode 100644 index 0000000..9b20627 --- /dev/null +++ b/CSharp/Interpreter/ArcscriptVisitor.cs @@ -0,0 +1,461 @@ +using Antlr4.Runtime.Misc; +using System.Collections.Generic; +using System; +using Antlr4.Runtime.Tree; +using Arcweave.Interpreter.INodes; + +namespace Arcweave.Interpreter +{ + public class ArcscriptVisitor : ArcscriptParserBaseVisitor + { + public IProject project; + public readonly ArcscriptState state; + public string elementId; + private readonly Functions _functions; + public ArcscriptVisitor(string elementId, IProject project) { + this.elementId = elementId; + this.project = project; + this.state = new ArcscriptState(elementId, project); + this._functions = new Functions(elementId, project, this.state); + } + + public override object VisitInput([NotNull] ArcscriptParser.InputContext context) { + if ( context.script() != null ) { + return this.VisitScript(context.script()); + } + + Expression comp_cond = (Expression)this.VisitCompound_condition_or(context.compound_condition_or()); + return Expression.GetBoolValue(comp_cond.Value); + } + + public override object VisitScript_section([NotNull] ArcscriptParser.Script_sectionContext context) { + if ( context == null ) { + return null; + } + + var blockquoteContexts = context.blockquote(); + if (blockquoteContexts != null && blockquoteContexts.Length > 0) + { + object[] result = new object[blockquoteContexts.Length]; + int index = 0; + foreach (var blockquoteContext in blockquoteContexts) + { + result[index++] = this.VisitBlockquote(blockquoteContext); + } + return result; + } + + var paragraphContexts = context.paragraph(); + if (paragraphContexts != null && paragraphContexts.Length > 0) + { + object[] result = new object[paragraphContexts.Length]; + int index = 0; + foreach (var paragraphContext in paragraphContexts) + { + result[index++] = this.VisitParagraph(paragraphContext); + } + return result; + } + // if ( context.normal_text() != null && context.normal_text().Length > 0 ) { + // this.state.outputs.Add(context.GetText()); + // return context.GetText(); + // } + + return this.VisitChildren(context); + } + + public override object VisitParagraph(ArcscriptParser.ParagraphContext context) + { + // this.state.outputs.Add(context.GetText()); + var paragraphEnd = context.PARAGRAPHEND().GetText(); + var paragraphContent = paragraphEnd.Substring(0, paragraphEnd.Length - "

".Length); + this.state.Outputs.AddParagraph(paragraphContent); + return context.GetText(); + } + + public override object VisitBlockquote(ArcscriptParser.BlockquoteContext context) + { + this.state.Outputs.AddBlockquote(); + this.VisitChildren(context); + this.state.Outputs.ExitBlockquote(); + return context.GetText(); + } + + public override object VisitAssignment_segment([NotNull] ArcscriptParser.Assignment_segmentContext context) { + this.state.Outputs.AddScriptOutput(null); + return this.VisitStatement_assignment(context.statement_assignment()); + } + + public override object VisitFunction_call_segment([NotNull] ArcscriptParser.Function_call_segmentContext context) { + this.state.Outputs.AddScriptOutput(null); + return this.VisitStatement_function_call(context.statement_function_call()); + } + + public override object VisitConditional_section([NotNull] ArcscriptParser.Conditional_sectionContext context) { + this.state.Outputs.AddScriptOutput(null); + ConditionalSection if_section = (ConditionalSection)this.VisitIf_section(context.if_section()); + if ( if_section.Clause ) { + this.state.Outputs.AddScriptOutput(null); + return if_section.Script; + } + foreach(ArcscriptParser.Else_if_sectionContext else_if_context in context.else_if_section()) + { + ConditionalSection elif_section = (ConditionalSection)this.VisitElse_if_section(else_if_context); + if (elif_section.Clause ) + { + return elif_section.Script; + } + } + + if ( context.else_section() != null ) { + ConditionalSection elseSection = (ConditionalSection)this.VisitElse_section(context.else_section()); + this.state.Outputs.AddScriptOutput(null); + return elseSection.Script; + } + this.state.Outputs.AddScriptOutput(null); + return null; + } + + public override object VisitIf_section([NotNull] ArcscriptParser.If_sectionContext context) { + Expression result = (Expression)this.VisitIf_clause(context.if_clause()); + ConditionalSection ifSection = new ConditionalSection(false, null); + if ( result ) { + ifSection.Clause = true; + ifSection.Script = this.VisitScript(context.script()); + } + return ifSection; + } + + public override object VisitElse_if_section([NotNull] ArcscriptParser.Else_if_sectionContext context) { + Expression result = (Expression)this.VisitElse_if_clause(context.else_if_clause()); + ConditionalSection elseIfSection = new ConditionalSection(false, null); + if ( result ) { + elseIfSection.Clause = true; + elseIfSection.Script = this.VisitScript(context.script()); + } + return elseIfSection; + } + + public override object VisitElse_section([NotNull] ArcscriptParser.Else_sectionContext context) { + return new ConditionalSection(true, this.VisitScript(context.script())); + } + + public override object VisitIf_clause([NotNull] ArcscriptParser.If_clauseContext context) { + return this.VisitCompound_condition_or(context.compound_condition_or()); + } + + public override object VisitElse_if_clause([NotNull] ArcscriptParser.Else_if_clauseContext context) { + return this.VisitCompound_condition_or(context.compound_condition_or()); + } + + public override object VisitStatement_assignment([NotNull] ArcscriptParser.Statement_assignmentContext context) { + string variableName = context.VARIABLE().GetText(); + IVariable variable = this.state.GetVariable(variableName); + + Expression compound_condition_or = (Expression)this.VisitCompound_condition_or(context.compound_condition_or()); + if ( context.ASSIGN() != null ) { + this.state.SetVarValue(variableName, compound_condition_or.Value); + return null; + } + + Expression variableValue = new Expression(this.state.GetVarValue(variableName)); + + if ( context.ASSIGNADD() != null ) { + variableValue += compound_condition_or; + } else if ( context.ASSIGNSUB() != null ) { + variableValue -= compound_condition_or; + } else if ( context.ASSIGNMUL() != null ) { + variableValue *= compound_condition_or; + } else if ( context.ASSIGNDIV() != null ) { + variableValue /= compound_condition_or; + } + + this.state.SetVarValue(variableName, variableValue.Value); + return null; + } + + public override object VisitCompound_condition_or([NotNull] ArcscriptParser.Compound_condition_orContext context) { + Expression compound_condition_and = (Expression)this.VisitCompound_condition_and(context.compound_condition_and()); + if ( context.compound_condition_or() != null ) { + Expression compound_condition_or = (Expression)this.VisitCompound_condition_or(context.compound_condition_or()); + Expression result = compound_condition_and || compound_condition_or; + return result; + } + return compound_condition_and; + } + + public override object VisitCompound_condition_and([NotNull] ArcscriptParser.Compound_condition_andContext context) { + Expression negated_unary_condition = (Expression)this.VisitNegated_unary_condition(context.negated_unary_condition()); + if ( context.compound_condition_and() != null ) { + Expression compound_condition_and = (Expression)this.VisitCompound_condition_and(context.compound_condition_and()); + Expression result = negated_unary_condition && compound_condition_and; + return result; + } + + return negated_unary_condition; + } + + public override object VisitNegated_unary_condition([NotNull] ArcscriptParser.Negated_unary_conditionContext context) { + Expression unary_condition = (Expression)this.VisitUnary_condition(context.unary_condition()); + + if ( context.NEG() != null || context.NOTKEYWORD() != null ) { + return !unary_condition; + } + + return unary_condition; + } + + public override object VisitUnary_condition([NotNull] ArcscriptParser.Unary_conditionContext context) { + return this.VisitCondition(context.condition()); + } + + public override object VisitCondition([NotNull] ArcscriptParser.ConditionContext context) { + if ( context.expression().Length == 1 ) { + return this.VisitExpression(context.expression()[0]); + } + ArcscriptParser.Conditional_operatorContext conditional_operator_context = context.conditional_operator(); + Expression exp0 = (Expression)this.VisitExpression(context.expression()[0]); + Expression exp1 = (Expression)this.VisitExpression(context.expression()[1]); + + bool result = false; + if ( conditional_operator_context.GT() != null ) { + result = exp0 > exp1; + + } + if ( conditional_operator_context.GE() != null ) { + result = exp0 >= exp1; + } + if ( conditional_operator_context.LT() != null ) { + result = exp0 < exp1; + } + if ( conditional_operator_context.LE() != null ) { + result = exp0 <= exp1; + } + if ( conditional_operator_context.EQ() != null ) { + result = exp0 == exp1; + } + if ( conditional_operator_context.NE() != null ) { + result = exp0 != exp1; + } + if ( conditional_operator_context.ISKEYWORD() != null ) { + if ( conditional_operator_context.NOTKEYWORD() != null ) { + result = exp0 != exp1; + } else + { + result = exp0 == exp1; + } + } + + return new Expression(result); + } + + public override object VisitExpression([NotNull] ArcscriptParser.ExpressionContext context) { + if ( context.STRING() != null ) { + string result = context.STRING().GetText(); + result = result.Substring(1, result.Length - 2); + return new Expression(result); + } + if ( context.BOOLEAN() != null ) { + return new Expression(context.BOOLEAN().GetText() == "true"); + } + return this.VisitAdditive_numeric_expression(context.additive_numeric_expression()); + } + + public override object VisitAdditive_numeric_expression([NotNull] ArcscriptParser.Additive_numeric_expressionContext context) { + Expression mult_num_expression = (Expression)this.VisitMultiplicative_numeric_expression(context.multiplicative_numeric_expression()); + + if ( context.additive_numeric_expression() != null ) { + Expression result = (Expression)this.VisitAdditive_numeric_expression(context.additive_numeric_expression()); + if ( context.ADD() != null ) { + return mult_num_expression + result; + } + // Else MINUS + return mult_num_expression - result; + } + + return mult_num_expression; + } + + public override object VisitMultiplicative_numeric_expression([NotNull] ArcscriptParser.Multiplicative_numeric_expressionContext context) { + Expression signed_unary_num_expr = (Expression)this.VisitSigned_unary_numeric_expression(context.signed_unary_numeric_expression()); + + if ( context.multiplicative_numeric_expression() != null ) { + Expression result = (Expression)this.VisitMultiplicative_numeric_expression(context.multiplicative_numeric_expression()); + if ( context.MUL() != null ) { + return signed_unary_num_expr * result; + } + // Else DIV + return signed_unary_num_expr / result; + } + + return signed_unary_num_expr; + } + + public override object VisitSigned_unary_numeric_expression([NotNull] ArcscriptParser.Signed_unary_numeric_expressionContext context) { + Expression unary_num_expr = (Expression)this.VisitUnary_numeric_expression(context.unary_numeric_expression()); + ArcscriptParser.SignContext sign = context.sign(); + + if ( sign != null ) { + if ( sign.ADD() != null ) { + return unary_num_expr; + } + // Else MINUS + return -unary_num_expr; + } + return unary_num_expr; + } + + public override object VisitUnary_numeric_expression([NotNull] ArcscriptParser.Unary_numeric_expressionContext context) { + if ( context.FLOAT() != null ) { + return new Expression(double.Parse(context.FLOAT().GetText())); + } + if ( context.INTEGER() != null ) { + return new Expression(int.Parse(context.INTEGER().GetText())); + } + if ( context.VARIABLE() != null ) { + string variableName = context.VARIABLE().GetText(); + return new Expression(this.state.GetVarValue(variableName)); + } + + if ( context.function_call() != null ) + { + object functionResult = this.VisitFunction_call(context.function_call()); + if (functionResult.GetType() == typeof(Expression)) + { + return functionResult; + } + return new Expression(functionResult); + } + return this.VisitCompound_condition_or(context.compound_condition_or()); + } + public override object VisitVoid_function_call([NotNull] ArcscriptParser.Void_function_callContext context) + { + string fname = ""; + IList argument_list_result = null; + if (context.VFNAME() != null) + { + fname = context.VFNAME().GetText(); + if (context.argument_list() != null) + { + argument_list_result = (IList)this.VisitArgument_list(context.argument_list()); + } + } + if (context.VFNAMEVARS() != null) + { + fname = context.VFNAMEVARS().GetText(); + if (context.variable_list() != null) + { + argument_list_result = (IList)this.VisitVariable_list(context.variable_list()); + } + } + + object returnValue = this._functions.functions[fname](argument_list_result); + + return returnValue; + } + + public override object VisitFunction_call([NotNull] ArcscriptParser.Function_callContext context) { + IList argument_list_result = null; + if ( context.argument_list() != null ) { + argument_list_result = (IList)this.VisitArgument_list(context.argument_list()); + } + + string fname = context.FNAME().GetText(); + + Type resultType = this._functions.returnTypes[fname]; + object returnValue = this._functions.functions[fname](argument_list_result); + + return returnValue; + } + + public override object VisitVariable_list([NotNull] ArcscriptParser.Variable_listContext context) + { + List variables = new List(); + foreach (ITerminalNode variable in context.VARIABLE()) + { + IVariable varObject = this.state.GetVariable(variable.GetText()); + variables.Add(varObject); + } + return variables; + } + + public override object VisitArgument_list([NotNull] ArcscriptParser.Argument_listContext context) { + List argumentList = new List(); + foreach ( ArcscriptParser.ArgumentContext argument in context.argument() ) { + argumentList.Add(this.VisitArgument(argument)); + } + return argumentList; + } + + public override object VisitArgument([NotNull] ArcscriptParser.ArgumentContext context) { + if ( context.STRING() != null ) { + string result = context.STRING().GetText(); + result = result.Substring(1, result.Length - 2); + return new Expression(result); + } + if ( context.mention() != null ) { + Mention mention_result = (Mention)this.VisitMention(context.mention()); + return mention_result; + } + return this.VisitAdditive_numeric_expression(context.additive_numeric_expression()); + } + + public override object VisitMention([NotNull] ArcscriptParser.MentionContext context) { + Dictionary attrs = new Dictionary(); + + foreach ( ArcscriptParser.Mention_attributesContext attr in context.mention_attributes() ) { + Dictionary res = (Dictionary)this.VisitMention_attributes(attr); + attrs.Add((string)res["name"], (string)res["value"]); + } + string label = ""; + if ( context.MENTION_LABEL() != null ) { + label = context.MENTION_LABEL().GetText(); + } + return new Mention(label, attrs); + } + + public override object VisitMention_attributes([NotNull] ArcscriptParser.Mention_attributesContext context) { + string name = context.ATTR_NAME().GetText(); + ITerminalNode ctxvalue = context.ATTR_VALUE(); + object value = true; + if ( ctxvalue != null ) { + string strvalue = ctxvalue.GetText(); + if ( ( strvalue.StartsWith('"') && strvalue.EndsWith('"') ) || + ( strvalue.StartsWith("'") && strvalue.EndsWith("'") ) ) { + strvalue = strvalue.Substring(1, strvalue.Length - 2); + } + value = strvalue; + } + return new Dictionary { { "name", name }, { "value", value } }; + } + + public class Argument + { + public Type type { get; private set; } + public object value { get; private set; } + public Argument(Type type, object value) { + this.type = type; + this.value = value; + } + } + + public class Mention + { + public string label { get; private set; } + public Dictionary attrs { get; private set; } + + public Mention(string label, Dictionary attrs) { + this.label = label; + this.attrs = attrs; + } + } + + public struct ConditionalSection + { + public bool Clause; + public object Script; + + public ConditionalSection(bool clause, object script) { Clause = clause; Script = script; } + } + } +} \ No newline at end of file diff --git a/CSharp/Interpreter/Generated/ArcscriptLexer.cs b/CSharp/Interpreter/Generated/ArcscriptLexer.cs new file mode 100644 index 0000000..30146fc --- /dev/null +++ b/CSharp/Interpreter/Generated/ArcscriptLexer.cs @@ -0,0 +1,363 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// ANTLR Version: 4.13.1 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +// Generated from ArcscriptLexer.g4 by ANTLR 4.13.1 + +// Unreachable code detected +#pragma warning disable 0162 +// The variable '...' is assigned but its value is never used +#pragma warning disable 0219 +// Missing XML comment for publicly visible type or member '...' +#pragma warning disable 1591 +// Ambiguous reference in cref attribute +#pragma warning disable 419 + +namespace Arcweave.Interpreter { +using System; +using System.IO; +using System.Text; +using Antlr4.Runtime; +using Antlr4.Runtime.Atn; +using Antlr4.Runtime.Misc; +using DFA = Antlr4.Runtime.Dfa.DFA; + +[System.CodeDom.Compiler.GeneratedCode("ANTLR", "4.13.1")] +[System.CLSCompliant(false)] +public partial class ArcscriptLexer : Lexer { + protected static DFA[] decisionToDFA; + protected static PredictionContextCache sharedContextCache = new PredictionContextCache(); + public const int + CODESTART=1, PARAGRAPHSTART=2, BLOCKQUOTESTART=3, NORMAL_WHITESPACE=4, + PARAGRAPHEND=5, BQ_CODESTART=6, BQ_PARAGRAPHSTART=7, BLOCKQUOTEEND=8, + BQ_WHITESPACE=9, CODEEND=10, MENTION_TAG_OPEN=11, FLOAT=12, INTEGER=13, + DIGIT=14, LPAREN=15, RPAREN=16, ASSIGNMUL=17, ASSIGNDIV=18, ASSIGNADD=19, + ASSIGNSUB=20, MUL=21, DIV=22, ADD=23, SUB=24, GE=25, GT=26, LE=27, LT=28, + EQ=29, NE=30, AND=31, OR=32, ASSIGN=33, NEG=34, COMMA=35, LBRACE=36, RBRACE=37, + BOOLEAN=38, FNAME=39, VFNAME=40, VFNAMEVARS=41, IFKEYWORD=42, ELSEKEYWORD=43, + ELSEIFKEYWORD=44, ENDIFKEYWORD=45, ANDKEYWORD=46, ORKEYWORD=47, ISKEYWORD=48, + NOTKEYWORD=49, STRING=50, VARIABLE=51, WHITESPACE=52, TAG_CLOSE=53, ATTR_NAME=54, + TAG_EQUALS=55, MENTION_TAG_CLOSE=56, TAG_WHITESPACE=57, TAG_OPEN=58, MENTION_LABEL=59, + ATTR_VALUE=60, ATTRIBUTE=61; + public const int + PARAGRAPH=1, BLOCKQUOTE=2, CODESEGMENT=3, MENTIONSEGMENT=4, MENTIONLABELSEGMENT=5, + MENTION_ATTR_SEGMENT=6; + public static string[] channelNames = { + "DEFAULT_TOKEN_CHANNEL", "HIDDEN" + }; + + public static string[] modeNames = { + "DEFAULT_MODE", "PARAGRAPH", "BLOCKQUOTE", "CODESEGMENT", "MENTIONSEGMENT", + "MENTIONLABELSEGMENT", "MENTION_ATTR_SEGMENT" + }; + + public static readonly string[] ruleNames = { + "CODESTART", "PARAGRAPHSTART", "BLOCKQUOTESTART", "NORMAL_WHITESPACE", + "PARAGRAPHEND", "BQ_CODESTART", "BQ_PARAGRAPHSTART", "BLOCKQUOTEEND", + "BQ_WHITESPACE", "CODEEND", "MENTION_TAG_OPEN", "FLOAT", "INTEGER", "DIGIT", + "LPAREN", "RPAREN", "ASSIGNMUL", "ASSIGNDIV", "ASSIGNADD", "ASSIGNSUB", + "MUL", "DIV", "ADD", "SUB", "GE", "GT", "LE", "LT", "EQ", "NE", "AND", + "OR", "ASSIGN", "NEG", "COMMA", "LBRACE", "RBRACE", "BOOLEAN", "FNAME", + "VFNAME", "VFNAMEVARS", "IFKEYWORD", "ELSEKEYWORD", "ELSEIFKEYWORD", "ENDIFKEYWORD", + "ANDKEYWORD", "ORKEYWORD", "ISKEYWORD", "NOTKEYWORD", "STRING", "STRING_CONTENT", + "VARIABLE", "WHITESPACE", "TAG_CLOSE", "ATTR_NAME", "TAG_EQUALS", "MENTION_TAG_CLOSE", + "TAG_WHITESPACE", "TAG_OPEN", "MENTION_LABEL", "ATTR_VALUE", "ATTRIBUTE", + "ATTCHARS", "ATTCHAR", "HEXCHARS", "DECCHARS", "DOUBLE_QUOTE_STRING", + "SINGLE_QUOTE_STRING" + }; + + + public ArcscriptLexer(ICharStream input) + : this(input, Console.Out, Console.Error) { } + + public ArcscriptLexer(ICharStream input, TextWriter output, TextWriter errorOutput) + : base(input, output, errorOutput) + { + Interpreter = new LexerATNSimulator(this, _ATN, decisionToDFA, sharedContextCache); + } + + private static readonly string[] _LiteralNames = { + null, null, null, null, null, null, null, null, "''", null, + "''", "''", null, null, "'/span>'", + null, "'<'" + }; + private static readonly string[] _SymbolicNames = { + null, "CODESTART", "PARAGRAPHSTART", "BLOCKQUOTESTART", "NORMAL_WHITESPACE", + "PARAGRAPHEND", "BQ_CODESTART", "BQ_PARAGRAPHSTART", "BLOCKQUOTEEND", + "BQ_WHITESPACE", "CODEEND", "MENTION_TAG_OPEN", "FLOAT", "INTEGER", "DIGIT", + "LPAREN", "RPAREN", "ASSIGNMUL", "ASSIGNDIV", "ASSIGNADD", "ASSIGNSUB", + "MUL", "DIV", "ADD", "SUB", "GE", "GT", "LE", "LT", "EQ", "NE", "AND", + "OR", "ASSIGN", "NEG", "COMMA", "LBRACE", "RBRACE", "BOOLEAN", "FNAME", + "VFNAME", "VFNAMEVARS", "IFKEYWORD", "ELSEKEYWORD", "ELSEIFKEYWORD", "ENDIFKEYWORD", + "ANDKEYWORD", "ORKEYWORD", "ISKEYWORD", "NOTKEYWORD", "STRING", "VARIABLE", + "WHITESPACE", "TAG_CLOSE", "ATTR_NAME", "TAG_EQUALS", "MENTION_TAG_CLOSE", + "TAG_WHITESPACE", "TAG_OPEN", "MENTION_LABEL", "ATTR_VALUE", "ATTRIBUTE" + }; + public static readonly IVocabulary DefaultVocabulary = new Vocabulary(_LiteralNames, _SymbolicNames); + + [NotNull] + public override IVocabulary Vocabulary + { + get + { + return DefaultVocabulary; + } + } + + public override string GrammarFileName { get { return "ArcscriptLexer.g4"; } } + + public override string[] RuleNames { get { return ruleNames; } } + + public override string[] ChannelNames { get { return channelNames; } } + + public override string[] ModeNames { get { return modeNames; } } + + public override int[] SerializedAtn { get { return _serializedATN; } } + + static ArcscriptLexer() { + decisionToDFA = new DFA[_ATN.NumberOfDecisions]; + for (int i = 0; i < _ATN.NumberOfDecisions; i++) { + decisionToDFA[i] = new DFA(_ATN.GetDecisionState(i), i); + } + } + private static int[] _serializedATN = { + 4,0,61,659,6,-1,6,-1,6,-1,6,-1,6,-1,6,-1,6,-1,2,0,7,0,2,1,7,1,2,2,7,2, + 2,3,7,3,2,4,7,4,2,5,7,5,2,6,7,6,2,7,7,7,2,8,7,8,2,9,7,9,2,10,7,10,2,11, + 7,11,2,12,7,12,2,13,7,13,2,14,7,14,2,15,7,15,2,16,7,16,2,17,7,17,2,18, + 7,18,2,19,7,19,2,20,7,20,2,21,7,21,2,22,7,22,2,23,7,23,2,24,7,24,2,25, + 7,25,2,26,7,26,2,27,7,27,2,28,7,28,2,29,7,29,2,30,7,30,2,31,7,31,2,32, + 7,32,2,33,7,33,2,34,7,34,2,35,7,35,2,36,7,36,2,37,7,37,2,38,7,38,2,39, + 7,39,2,40,7,40,2,41,7,41,2,42,7,42,2,43,7,43,2,44,7,44,2,45,7,45,2,46, + 7,46,2,47,7,47,2,48,7,48,2,49,7,49,2,50,7,50,2,51,7,51,2,52,7,52,2,53, + 7,53,2,54,7,54,2,55,7,55,2,56,7,56,2,57,7,57,2,58,7,58,2,59,7,59,2,60, + 7,60,2,61,7,61,2,62,7,62,2,63,7,63,2,64,7,64,2,65,7,65,2,66,7,66,2,67, + 7,67,1,0,1,0,1,0,1,0,1,0,1,0,5,0,150,8,0,10,0,12,0,153,9,0,1,0,1,0,1,0, + 1,0,1,0,1,0,1,0,1,0,5,0,163,8,0,10,0,12,0,166,9,0,1,0,1,0,1,0,1,0,1,1, + 1,1,1,1,1,1,1,1,1,1,1,1,1,1,5,1,180,8,1,10,1,12,1,183,9,1,1,1,3,1,186, + 8,1,1,1,1,1,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,5,2,203, + 8,2,10,2,12,2,206,9,2,1,2,1,2,1,2,1,2,1,3,4,3,213,8,3,11,3,12,3,214,1, + 3,1,3,1,4,5,4,220,8,4,10,4,12,4,223,9,4,1,4,1,4,1,4,1,4,1,4,1,4,1,4,1, + 5,1,5,1,5,1,5,1,5,1,5,5,5,238,8,5,10,5,12,5,241,9,5,1,5,1,5,1,5,1,5,1, + 5,1,5,1,5,1,5,5,5,251,8,5,10,5,12,5,254,9,5,1,5,1,5,1,5,1,5,1,6,1,6,1, + 6,1,6,1,6,1,6,1,6,1,6,5,6,268,8,6,10,6,12,6,271,9,6,1,6,3,6,274,8,6,1, + 6,1,6,1,7,1,7,1,7,1,7,1,7,1,7,1,7,1,7,1,7,1,7,1,7,1,7,1,7,1,7,1,7,1,7, + 1,8,4,8,295,8,8,11,8,12,8,296,1,8,1,8,1,9,1,9,1,9,1,9,1,9,1,9,1,9,1,9, + 1,9,1,9,1,9,1,9,1,9,1,9,1,9,1,9,1,10,1,10,1,10,1,10,1,10,1,10,1,10,1,10, + 1,11,5,11,326,8,11,10,11,12,11,329,9,11,1,11,1,11,4,11,333,8,11,11,11, + 12,11,334,1,12,4,12,338,8,12,11,12,12,12,339,1,13,1,13,1,14,1,14,1,15, + 1,15,1,16,1,16,1,16,1,17,1,17,1,17,1,18,1,18,1,18,1,19,1,19,1,19,1,20, + 1,20,1,21,1,21,1,22,1,22,1,23,1,23,1,24,1,24,1,24,1,25,1,25,1,25,1,25, + 1,25,3,25,376,8,25,1,26,1,26,1,26,1,27,1,27,1,27,1,27,1,27,3,27,386,8, + 27,1,28,1,28,1,28,1,29,1,29,1,29,1,30,1,30,1,30,1,30,1,30,1,30,1,30,1, + 30,1,30,1,30,1,30,1,30,3,30,406,8,30,1,31,1,31,1,31,1,32,1,32,1,33,1,33, + 1,34,1,34,1,35,1,35,1,36,1,36,1,37,1,37,1,37,1,37,1,37,1,37,1,37,1,37, + 1,37,3,37,430,8,37,1,38,1,38,1,38,1,38,1,38,1,38,1,38,1,38,1,38,1,38,1, + 38,1,38,1,38,1,38,1,38,1,38,1,38,1,38,1,38,1,38,1,38,1,38,1,38,1,38,1, + 38,1,38,1,38,1,38,1,38,1,38,1,38,1,38,1,38,1,38,1,38,1,38,1,38,3,38,469, + 8,38,1,39,1,39,1,39,1,39,1,39,1,40,1,40,1,40,1,40,1,40,1,40,1,40,1,40, + 1,40,1,40,1,40,1,40,1,40,3,40,489,8,40,1,41,1,41,1,41,1,42,1,42,1,42,1, + 42,1,42,1,43,1,43,1,43,1,43,1,43,1,43,1,43,1,44,1,44,1,44,1,44,1,44,1, + 44,1,45,1,45,1,45,1,45,1,46,1,46,1,46,1,47,1,47,1,47,1,48,1,48,1,48,1, + 48,1,49,1,49,5,49,528,8,49,10,49,12,49,531,9,49,1,49,1,49,1,49,5,49,536, + 8,49,10,49,12,49,539,9,49,1,49,3,49,542,8,49,1,50,1,50,1,50,3,50,547,8, + 50,1,51,1,51,5,51,551,8,51,10,51,12,51,554,9,51,1,52,4,52,557,8,52,11, + 52,12,52,558,1,52,1,52,1,53,1,53,1,53,1,53,1,54,1,54,5,54,569,8,54,10, + 54,12,54,572,9,54,1,55,1,55,1,55,1,55,1,56,1,56,1,56,1,56,1,56,1,56,1, + 56,1,56,1,56,1,57,1,57,1,57,1,57,1,58,1,58,1,58,1,58,1,59,4,59,596,8,59, + 11,59,12,59,597,1,60,5,60,601,8,60,10,60,12,60,604,9,60,1,60,1,60,1,60, + 1,60,1,61,1,61,1,61,1,61,1,61,3,61,615,8,61,1,62,4,62,618,8,62,11,62,12, + 62,619,1,62,3,62,623,8,62,1,63,3,63,626,8,63,1,64,1,64,4,64,630,8,64,11, + 64,12,64,631,1,65,4,65,635,8,65,11,65,12,65,636,1,65,3,65,640,8,65,1,66, + 1,66,5,66,644,8,66,10,66,12,66,647,9,66,1,66,1,66,1,67,1,67,5,67,653,8, + 67,10,67,12,67,656,9,67,1,67,1,67,1,221,0,68,7,1,9,2,11,3,13,4,15,5,17, + 6,19,7,21,8,23,9,25,10,27,11,29,12,31,13,33,14,35,15,37,16,39,17,41,18, + 43,19,45,20,47,21,49,22,51,23,53,24,55,25,57,26,59,27,61,28,63,29,65,30, + 67,31,69,32,71,33,73,34,75,35,77,36,79,37,81,38,83,39,85,40,87,41,89,42, + 91,43,93,44,95,45,97,46,99,47,101,48,103,49,105,50,107,0,109,51,111,52, + 113,53,115,54,117,55,119,56,121,57,123,58,125,59,127,60,129,61,131,0,133, + 0,135,0,137,0,139,0,141,0,7,0,1,2,3,4,5,6,14,1,0,62,62,3,0,9,10,13,13, + 32,32,1,0,48,57,5,0,10,10,13,13,34,34,39,39,92,92,9,0,34,34,39,39,92,92, + 97,98,102,102,110,110,114,114,116,116,118,118,4,0,36,36,65,90,95,95,97, + 122,5,0,36,36,48,57,65,90,95,95,97,122,3,0,58,58,65,90,97,122,5,0,45,46, + 48,58,65,90,95,95,97,122,1,0,60,60,7,0,35,35,43,59,61,61,63,63,65,90,95, + 95,97,122,3,0,48,57,65,70,97,102,2,0,34,34,60,60,2,0,39,39,60,60,693,0, + 7,1,0,0,0,0,9,1,0,0,0,0,11,1,0,0,0,0,13,1,0,0,0,1,15,1,0,0,0,2,17,1,0, + 0,0,2,19,1,0,0,0,2,21,1,0,0,0,2,23,1,0,0,0,3,25,1,0,0,0,3,27,1,0,0,0,3, + 29,1,0,0,0,3,31,1,0,0,0,3,33,1,0,0,0,3,35,1,0,0,0,3,37,1,0,0,0,3,39,1, + 0,0,0,3,41,1,0,0,0,3,43,1,0,0,0,3,45,1,0,0,0,3,47,1,0,0,0,3,49,1,0,0,0, + 3,51,1,0,0,0,3,53,1,0,0,0,3,55,1,0,0,0,3,57,1,0,0,0,3,59,1,0,0,0,3,61, + 1,0,0,0,3,63,1,0,0,0,3,65,1,0,0,0,3,67,1,0,0,0,3,69,1,0,0,0,3,71,1,0,0, + 0,3,73,1,0,0,0,3,75,1,0,0,0,3,77,1,0,0,0,3,79,1,0,0,0,3,81,1,0,0,0,3,83, + 1,0,0,0,3,85,1,0,0,0,3,87,1,0,0,0,3,89,1,0,0,0,3,91,1,0,0,0,3,93,1,0,0, + 0,3,95,1,0,0,0,3,97,1,0,0,0,3,99,1,0,0,0,3,101,1,0,0,0,3,103,1,0,0,0,3, + 105,1,0,0,0,3,109,1,0,0,0,3,111,1,0,0,0,4,113,1,0,0,0,4,115,1,0,0,0,4, + 117,1,0,0,0,4,119,1,0,0,0,4,121,1,0,0,0,5,123,1,0,0,0,5,125,1,0,0,0,6, + 127,1,0,0,0,6,129,1,0,0,0,7,143,1,0,0,0,9,185,1,0,0,0,11,189,1,0,0,0,13, + 212,1,0,0,0,15,221,1,0,0,0,17,231,1,0,0,0,19,273,1,0,0,0,21,277,1,0,0, + 0,23,294,1,0,0,0,25,300,1,0,0,0,27,316,1,0,0,0,29,327,1,0,0,0,31,337,1, + 0,0,0,33,341,1,0,0,0,35,343,1,0,0,0,37,345,1,0,0,0,39,347,1,0,0,0,41,350, + 1,0,0,0,43,353,1,0,0,0,45,356,1,0,0,0,47,359,1,0,0,0,49,361,1,0,0,0,51, + 363,1,0,0,0,53,365,1,0,0,0,55,367,1,0,0,0,57,375,1,0,0,0,59,377,1,0,0, + 0,61,385,1,0,0,0,63,387,1,0,0,0,65,390,1,0,0,0,67,405,1,0,0,0,69,407,1, + 0,0,0,71,410,1,0,0,0,73,412,1,0,0,0,75,414,1,0,0,0,77,416,1,0,0,0,79,418, + 1,0,0,0,81,429,1,0,0,0,83,468,1,0,0,0,85,470,1,0,0,0,87,488,1,0,0,0,89, + 490,1,0,0,0,91,493,1,0,0,0,93,498,1,0,0,0,95,505,1,0,0,0,97,511,1,0,0, + 0,99,515,1,0,0,0,101,518,1,0,0,0,103,521,1,0,0,0,105,541,1,0,0,0,107,546, + 1,0,0,0,109,548,1,0,0,0,111,556,1,0,0,0,113,562,1,0,0,0,115,566,1,0,0, + 0,117,573,1,0,0,0,119,577,1,0,0,0,121,586,1,0,0,0,123,590,1,0,0,0,125, + 595,1,0,0,0,127,602,1,0,0,0,129,614,1,0,0,0,131,617,1,0,0,0,133,625,1, + 0,0,0,135,627,1,0,0,0,137,634,1,0,0,0,139,641,1,0,0,0,141,650,1,0,0,0, + 143,144,5,60,0,0,144,145,5,112,0,0,145,146,5,114,0,0,146,147,5,101,0,0, + 147,151,1,0,0,0,148,150,8,0,0,0,149,148,1,0,0,0,150,153,1,0,0,0,151,149, + 1,0,0,0,151,152,1,0,0,0,152,154,1,0,0,0,153,151,1,0,0,0,154,155,5,62,0, + 0,155,156,5,60,0,0,156,157,5,99,0,0,157,158,5,111,0,0,158,159,5,100,0, + 0,159,160,5,101,0,0,160,164,1,0,0,0,161,163,8,0,0,0,162,161,1,0,0,0,163, + 166,1,0,0,0,164,162,1,0,0,0,164,165,1,0,0,0,165,167,1,0,0,0,166,164,1, + 0,0,0,167,168,5,62,0,0,168,169,1,0,0,0,169,170,6,0,0,0,170,8,1,0,0,0,171, + 172,5,60,0,0,172,173,5,112,0,0,173,186,5,62,0,0,174,175,5,60,0,0,175,176, + 5,112,0,0,176,177,5,32,0,0,177,181,1,0,0,0,178,180,8,0,0,0,179,178,1,0, + 0,0,180,183,1,0,0,0,181,179,1,0,0,0,181,182,1,0,0,0,182,184,1,0,0,0,183, + 181,1,0,0,0,184,186,5,62,0,0,185,171,1,0,0,0,185,174,1,0,0,0,186,187,1, + 0,0,0,187,188,6,1,1,0,188,10,1,0,0,0,189,190,5,60,0,0,190,191,5,98,0,0, + 191,192,5,108,0,0,192,193,5,111,0,0,193,194,5,99,0,0,194,195,5,107,0,0, + 195,196,5,113,0,0,196,197,5,117,0,0,197,198,5,111,0,0,198,199,5,116,0, + 0,199,200,5,101,0,0,200,204,1,0,0,0,201,203,8,0,0,0,202,201,1,0,0,0,203, + 206,1,0,0,0,204,202,1,0,0,0,204,205,1,0,0,0,205,207,1,0,0,0,206,204,1, + 0,0,0,207,208,5,62,0,0,208,209,1,0,0,0,209,210,6,2,2,0,210,12,1,0,0,0, + 211,213,7,1,0,0,212,211,1,0,0,0,213,214,1,0,0,0,214,212,1,0,0,0,214,215, + 1,0,0,0,215,216,1,0,0,0,216,217,6,3,3,0,217,14,1,0,0,0,218,220,9,0,0,0, + 219,218,1,0,0,0,220,223,1,0,0,0,221,222,1,0,0,0,221,219,1,0,0,0,222,224, + 1,0,0,0,223,221,1,0,0,0,224,225,5,60,0,0,225,226,5,47,0,0,226,227,5,112, + 0,0,227,228,5,62,0,0,228,229,1,0,0,0,229,230,6,4,4,0,230,16,1,0,0,0,231, + 232,5,60,0,0,232,233,5,112,0,0,233,234,5,114,0,0,234,235,5,101,0,0,235, + 239,1,0,0,0,236,238,8,0,0,0,237,236,1,0,0,0,238,241,1,0,0,0,239,237,1, + 0,0,0,239,240,1,0,0,0,240,242,1,0,0,0,241,239,1,0,0,0,242,243,5,62,0,0, + 243,244,5,60,0,0,244,245,5,99,0,0,245,246,5,111,0,0,246,247,5,100,0,0, + 247,248,5,101,0,0,248,252,1,0,0,0,249,251,8,0,0,0,250,249,1,0,0,0,251, + 254,1,0,0,0,252,250,1,0,0,0,252,253,1,0,0,0,253,255,1,0,0,0,254,252,1, + 0,0,0,255,256,5,62,0,0,256,257,1,0,0,0,257,258,6,5,0,0,258,18,1,0,0,0, + 259,260,5,60,0,0,260,261,5,112,0,0,261,274,5,62,0,0,262,263,5,60,0,0,263, + 264,5,112,0,0,264,265,5,32,0,0,265,269,1,0,0,0,266,268,8,0,0,0,267,266, + 1,0,0,0,268,271,1,0,0,0,269,267,1,0,0,0,269,270,1,0,0,0,270,272,1,0,0, + 0,271,269,1,0,0,0,272,274,5,62,0,0,273,259,1,0,0,0,273,262,1,0,0,0,274, + 275,1,0,0,0,275,276,6,6,1,0,276,20,1,0,0,0,277,278,5,60,0,0,278,279,5, + 47,0,0,279,280,5,98,0,0,280,281,5,108,0,0,281,282,5,111,0,0,282,283,5, + 99,0,0,283,284,5,107,0,0,284,285,5,113,0,0,285,286,5,117,0,0,286,287,5, + 111,0,0,287,288,5,116,0,0,288,289,5,101,0,0,289,290,5,62,0,0,290,291,1, + 0,0,0,291,292,6,7,4,0,292,22,1,0,0,0,293,295,7,1,0,0,294,293,1,0,0,0,295, + 296,1,0,0,0,296,294,1,0,0,0,296,297,1,0,0,0,297,298,1,0,0,0,298,299,6, + 8,3,0,299,24,1,0,0,0,300,301,5,60,0,0,301,302,5,47,0,0,302,303,5,99,0, + 0,303,304,5,111,0,0,304,305,5,100,0,0,305,306,5,101,0,0,306,307,5,62,0, + 0,307,308,5,60,0,0,308,309,5,47,0,0,309,310,5,112,0,0,310,311,5,114,0, + 0,311,312,5,101,0,0,312,313,5,62,0,0,313,314,1,0,0,0,314,315,6,9,4,0,315, + 26,1,0,0,0,316,317,5,60,0,0,317,318,5,115,0,0,318,319,5,112,0,0,319,320, + 5,97,0,0,320,321,5,110,0,0,321,322,1,0,0,0,322,323,6,10,5,0,323,28,1,0, + 0,0,324,326,3,33,13,0,325,324,1,0,0,0,326,329,1,0,0,0,327,325,1,0,0,0, + 327,328,1,0,0,0,328,330,1,0,0,0,329,327,1,0,0,0,330,332,5,46,0,0,331,333, + 3,33,13,0,332,331,1,0,0,0,333,334,1,0,0,0,334,332,1,0,0,0,334,335,1,0, + 0,0,335,30,1,0,0,0,336,338,3,33,13,0,337,336,1,0,0,0,338,339,1,0,0,0,339, + 337,1,0,0,0,339,340,1,0,0,0,340,32,1,0,0,0,341,342,7,2,0,0,342,34,1,0, + 0,0,343,344,5,40,0,0,344,36,1,0,0,0,345,346,5,41,0,0,346,38,1,0,0,0,347, + 348,5,42,0,0,348,349,5,61,0,0,349,40,1,0,0,0,350,351,5,47,0,0,351,352, + 5,61,0,0,352,42,1,0,0,0,353,354,5,43,0,0,354,355,5,61,0,0,355,44,1,0,0, + 0,356,357,5,45,0,0,357,358,5,61,0,0,358,46,1,0,0,0,359,360,5,42,0,0,360, + 48,1,0,0,0,361,362,5,47,0,0,362,50,1,0,0,0,363,364,5,43,0,0,364,52,1,0, + 0,0,365,366,5,45,0,0,366,54,1,0,0,0,367,368,3,57,25,0,368,369,5,61,0,0, + 369,56,1,0,0,0,370,376,5,62,0,0,371,372,5,38,0,0,372,373,5,103,0,0,373, + 374,5,116,0,0,374,376,5,59,0,0,375,370,1,0,0,0,375,371,1,0,0,0,376,58, + 1,0,0,0,377,378,3,61,27,0,378,379,5,61,0,0,379,60,1,0,0,0,380,386,5,60, + 0,0,381,382,5,38,0,0,382,383,5,108,0,0,383,384,5,116,0,0,384,386,5,59, + 0,0,385,380,1,0,0,0,385,381,1,0,0,0,386,62,1,0,0,0,387,388,5,61,0,0,388, + 389,5,61,0,0,389,64,1,0,0,0,390,391,5,33,0,0,391,392,5,61,0,0,392,66,1, + 0,0,0,393,394,5,38,0,0,394,406,5,38,0,0,395,396,5,38,0,0,396,397,5,97, + 0,0,397,398,5,109,0,0,398,399,5,112,0,0,399,400,5,59,0,0,400,401,5,38, + 0,0,401,402,5,97,0,0,402,403,5,109,0,0,403,404,5,112,0,0,404,406,5,59, + 0,0,405,393,1,0,0,0,405,395,1,0,0,0,406,68,1,0,0,0,407,408,5,124,0,0,408, + 409,5,124,0,0,409,70,1,0,0,0,410,411,5,61,0,0,411,72,1,0,0,0,412,413,5, + 33,0,0,413,74,1,0,0,0,414,415,5,44,0,0,415,76,1,0,0,0,416,417,5,123,0, + 0,417,78,1,0,0,0,418,419,5,125,0,0,419,80,1,0,0,0,420,421,5,116,0,0,421, + 422,5,114,0,0,422,423,5,117,0,0,423,430,5,101,0,0,424,425,5,102,0,0,425, + 426,5,97,0,0,426,427,5,108,0,0,427,428,5,115,0,0,428,430,5,101,0,0,429, + 420,1,0,0,0,429,424,1,0,0,0,430,82,1,0,0,0,431,432,5,97,0,0,432,433,5, + 98,0,0,433,469,5,115,0,0,434,435,5,109,0,0,435,436,5,97,0,0,436,469,5, + 120,0,0,437,438,5,109,0,0,438,439,5,105,0,0,439,469,5,110,0,0,440,441, + 5,114,0,0,441,442,5,97,0,0,442,443,5,110,0,0,443,444,5,100,0,0,444,445, + 5,111,0,0,445,469,5,109,0,0,446,447,5,114,0,0,447,448,5,111,0,0,448,449, + 5,108,0,0,449,469,5,108,0,0,450,451,5,114,0,0,451,452,5,111,0,0,452,453, + 5,117,0,0,453,454,5,110,0,0,454,469,5,100,0,0,455,456,5,115,0,0,456,457, + 5,113,0,0,457,469,5,114,0,0,458,459,5,115,0,0,459,460,5,113,0,0,460,461, + 5,114,0,0,461,469,5,116,0,0,462,463,5,118,0,0,463,464,5,105,0,0,464,465, + 5,115,0,0,465,466,5,105,0,0,466,467,5,116,0,0,467,469,5,115,0,0,468,431, + 1,0,0,0,468,434,1,0,0,0,468,437,1,0,0,0,468,440,1,0,0,0,468,446,1,0,0, + 0,468,450,1,0,0,0,468,455,1,0,0,0,468,458,1,0,0,0,468,462,1,0,0,0,469, + 84,1,0,0,0,470,471,5,115,0,0,471,472,5,104,0,0,472,473,5,111,0,0,473,474, + 5,119,0,0,474,86,1,0,0,0,475,476,5,114,0,0,476,477,5,101,0,0,477,478,5, + 115,0,0,478,479,5,101,0,0,479,489,5,116,0,0,480,481,5,114,0,0,481,482, + 5,101,0,0,482,483,5,115,0,0,483,484,5,101,0,0,484,485,5,116,0,0,485,486, + 5,65,0,0,486,487,5,108,0,0,487,489,5,108,0,0,488,475,1,0,0,0,488,480,1, + 0,0,0,489,88,1,0,0,0,490,491,5,105,0,0,491,492,5,102,0,0,492,90,1,0,0, + 0,493,494,5,101,0,0,494,495,5,108,0,0,495,496,5,115,0,0,496,497,5,101, + 0,0,497,92,1,0,0,0,498,499,5,101,0,0,499,500,5,108,0,0,500,501,5,115,0, + 0,501,502,5,101,0,0,502,503,5,105,0,0,503,504,5,102,0,0,504,94,1,0,0,0, + 505,506,5,101,0,0,506,507,5,110,0,0,507,508,5,100,0,0,508,509,5,105,0, + 0,509,510,5,102,0,0,510,96,1,0,0,0,511,512,5,97,0,0,512,513,5,110,0,0, + 513,514,5,100,0,0,514,98,1,0,0,0,515,516,5,111,0,0,516,517,5,114,0,0,517, + 100,1,0,0,0,518,519,5,105,0,0,519,520,5,115,0,0,520,102,1,0,0,0,521,522, + 5,110,0,0,522,523,5,111,0,0,523,524,5,116,0,0,524,104,1,0,0,0,525,529, + 5,34,0,0,526,528,3,107,50,0,527,526,1,0,0,0,528,531,1,0,0,0,529,527,1, + 0,0,0,529,530,1,0,0,0,530,532,1,0,0,0,531,529,1,0,0,0,532,542,5,34,0,0, + 533,537,5,39,0,0,534,536,3,107,50,0,535,534,1,0,0,0,536,539,1,0,0,0,537, + 535,1,0,0,0,537,538,1,0,0,0,538,540,1,0,0,0,539,537,1,0,0,0,540,542,5, + 39,0,0,541,525,1,0,0,0,541,533,1,0,0,0,542,106,1,0,0,0,543,547,8,3,0,0, + 544,545,5,92,0,0,545,547,7,4,0,0,546,543,1,0,0,0,546,544,1,0,0,0,547,108, + 1,0,0,0,548,552,7,5,0,0,549,551,7,6,0,0,550,549,1,0,0,0,551,554,1,0,0, + 0,552,550,1,0,0,0,552,553,1,0,0,0,553,110,1,0,0,0,554,552,1,0,0,0,555, + 557,7,1,0,0,556,555,1,0,0,0,557,558,1,0,0,0,558,556,1,0,0,0,558,559,1, + 0,0,0,559,560,1,0,0,0,560,561,6,52,3,0,561,112,1,0,0,0,562,563,5,62,0, + 0,563,564,1,0,0,0,564,565,6,53,6,0,565,114,1,0,0,0,566,570,7,7,0,0,567, + 569,7,8,0,0,568,567,1,0,0,0,569,572,1,0,0,0,570,568,1,0,0,0,570,571,1, + 0,0,0,571,116,1,0,0,0,572,570,1,0,0,0,573,574,5,61,0,0,574,575,1,0,0,0, + 575,576,6,55,7,0,576,118,1,0,0,0,577,578,5,47,0,0,578,579,5,115,0,0,579, + 580,5,112,0,0,580,581,5,97,0,0,581,582,5,110,0,0,582,583,5,62,0,0,583, + 584,1,0,0,0,584,585,6,56,4,0,585,120,1,0,0,0,586,587,7,1,0,0,587,588,1, + 0,0,0,588,589,6,57,3,0,589,122,1,0,0,0,590,591,5,60,0,0,591,592,1,0,0, + 0,592,593,6,58,4,0,593,124,1,0,0,0,594,596,8,9,0,0,595,594,1,0,0,0,596, + 597,1,0,0,0,597,595,1,0,0,0,597,598,1,0,0,0,598,126,1,0,0,0,599,601,5, + 32,0,0,600,599,1,0,0,0,601,604,1,0,0,0,602,600,1,0,0,0,602,603,1,0,0,0, + 603,605,1,0,0,0,604,602,1,0,0,0,605,606,3,129,61,0,606,607,1,0,0,0,607, + 608,6,60,4,0,608,128,1,0,0,0,609,615,3,139,66,0,610,615,3,141,67,0,611, + 615,3,131,62,0,612,615,3,135,64,0,613,615,3,137,65,0,614,609,1,0,0,0,614, + 610,1,0,0,0,614,611,1,0,0,0,614,612,1,0,0,0,614,613,1,0,0,0,615,130,1, + 0,0,0,616,618,3,133,63,0,617,616,1,0,0,0,618,619,1,0,0,0,619,617,1,0,0, + 0,619,620,1,0,0,0,620,622,1,0,0,0,621,623,5,32,0,0,622,621,1,0,0,0,622, + 623,1,0,0,0,623,132,1,0,0,0,624,626,7,10,0,0,625,624,1,0,0,0,626,134,1, + 0,0,0,627,629,5,35,0,0,628,630,7,11,0,0,629,628,1,0,0,0,630,631,1,0,0, + 0,631,629,1,0,0,0,631,632,1,0,0,0,632,136,1,0,0,0,633,635,7,2,0,0,634, + 633,1,0,0,0,635,636,1,0,0,0,636,634,1,0,0,0,636,637,1,0,0,0,637,639,1, + 0,0,0,638,640,5,37,0,0,639,638,1,0,0,0,639,640,1,0,0,0,640,138,1,0,0,0, + 641,645,5,34,0,0,642,644,8,12,0,0,643,642,1,0,0,0,644,647,1,0,0,0,645, + 643,1,0,0,0,645,646,1,0,0,0,646,648,1,0,0,0,647,645,1,0,0,0,648,649,5, + 34,0,0,649,140,1,0,0,0,650,654,5,39,0,0,651,653,8,13,0,0,652,651,1,0,0, + 0,653,656,1,0,0,0,654,652,1,0,0,0,654,655,1,0,0,0,655,657,1,0,0,0,656, + 654,1,0,0,0,657,658,5,39,0,0,658,142,1,0,0,0,46,0,1,2,3,4,5,6,151,164, + 181,185,204,214,221,239,252,269,273,296,327,334,339,375,385,405,429,468, + 488,529,537,541,546,552,558,570,597,602,614,619,622,625,631,636,639,645, + 654,8,5,3,0,5,1,0,5,2,0,6,0,0,4,0,0,5,4,0,5,5,0,5,6,0 + }; + + public static readonly ATN _ATN = + new ATNDeserializer().Deserialize(_serializedATN); + + +} +} // namespace Arcweave.Interpreter diff --git a/CSharp/Interpreter/Generated/ArcscriptParser.cs b/CSharp/Interpreter/Generated/ArcscriptParser.cs new file mode 100644 index 0000000..64e57d7 --- /dev/null +++ b/CSharp/Interpreter/Generated/ArcscriptParser.cs @@ -0,0 +1,2634 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// ANTLR Version: 4.13.1 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +// Generated from ArcscriptParser.g4 by ANTLR 4.13.1 + +// Unreachable code detected +#pragma warning disable 0162 +// The variable '...' is assigned but its value is never used +#pragma warning disable 0219 +// Missing XML comment for publicly visible type or member '...' +#pragma warning disable 1591 +// Ambiguous reference in cref attribute +#pragma warning disable 419 + +namespace Arcweave.Interpreter { +using System; +using System.IO; +using System.Text; +using System.Diagnostics; +using System.Collections.Generic; +using Antlr4.Runtime; +using Antlr4.Runtime.Atn; +using Antlr4.Runtime.Misc; +using Antlr4.Runtime.Tree; +using DFA = Antlr4.Runtime.Dfa.DFA; + +[System.CodeDom.Compiler.GeneratedCode("ANTLR", "4.13.1")] +[System.CLSCompliant(false)] +public partial class ArcscriptParser : ArcscriptParserBase { + protected static DFA[] decisionToDFA; + protected static PredictionContextCache sharedContextCache = new PredictionContextCache(); + public const int + CODESTART=1, PARAGRAPHSTART=2, BLOCKQUOTESTART=3, NORMAL_WHITESPACE=4, + PARAGRAPHEND=5, BQ_CODESTART=6, BQ_PARAGRAPHSTART=7, BLOCKQUOTEEND=8, + BQ_WHITESPACE=9, CODEEND=10, MENTION_TAG_OPEN=11, FLOAT=12, INTEGER=13, + DIGIT=14, LPAREN=15, RPAREN=16, ASSIGNMUL=17, ASSIGNDIV=18, ASSIGNADD=19, + ASSIGNSUB=20, MUL=21, DIV=22, ADD=23, SUB=24, GE=25, GT=26, LE=27, LT=28, + EQ=29, NE=30, AND=31, OR=32, ASSIGN=33, NEG=34, COMMA=35, LBRACE=36, RBRACE=37, + BOOLEAN=38, FNAME=39, VFNAME=40, VFNAMEVARS=41, IFKEYWORD=42, ELSEKEYWORD=43, + ELSEIFKEYWORD=44, ENDIFKEYWORD=45, ANDKEYWORD=46, ORKEYWORD=47, ISKEYWORD=48, + NOTKEYWORD=49, STRING=50, VARIABLE=51, WHITESPACE=52, TAG_CLOSE=53, ATTR_NAME=54, + TAG_EQUALS=55, MENTION_TAG_CLOSE=56, TAG_WHITESPACE=57, TAG_OPEN=58, MENTION_LABEL=59, + ATTR_VALUE=60, ATTRIBUTE=61; + public const int + RULE_input = 0, RULE_script = 1, RULE_script_section = 2, RULE_blockquote = 3, + RULE_paragraph = 4, RULE_paragraph_start = 5, RULE_codestart = 6, RULE_codeend = 7, + RULE_assignment_segment = 8, RULE_function_call_segment = 9, RULE_conditional_section = 10, + RULE_if_section = 11, RULE_else_if_section = 12, RULE_else_section = 13, + RULE_if_clause = 14, RULE_else_if_clause = 15, RULE_endif_segment = 16, + RULE_statement_assignment = 17, RULE_statement_function_call = 18, RULE_argument_list = 19, + RULE_argument = 20, RULE_mention = 21, RULE_mention_attributes = 22, RULE_additive_numeric_expression = 23, + RULE_multiplicative_numeric_expression = 24, RULE_signed_unary_numeric_expression = 25, + RULE_unary_numeric_expression = 26, RULE_function_call = 27, RULE_void_function_call = 28, + RULE_sign = 29, RULE_variable_list = 30, RULE_compound_condition_or = 31, + RULE_compound_condition_and = 32, RULE_negated_unary_condition = 33, RULE_unary_condition = 34, + RULE_condition = 35, RULE_conditional_operator = 36, RULE_expression = 37; + public static readonly string[] ruleNames = { + "input", "script", "script_section", "blockquote", "paragraph", "paragraph_start", + "codestart", "codeend", "assignment_segment", "function_call_segment", + "conditional_section", "if_section", "else_if_section", "else_section", + "if_clause", "else_if_clause", "endif_segment", "statement_assignment", + "statement_function_call", "argument_list", "argument", "mention", "mention_attributes", + "additive_numeric_expression", "multiplicative_numeric_expression", "signed_unary_numeric_expression", + "unary_numeric_expression", "function_call", "void_function_call", "sign", + "variable_list", "compound_condition_or", "compound_condition_and", "negated_unary_condition", + "unary_condition", "condition", "conditional_operator", "expression" + }; + + private static readonly string[] _LiteralNames = { + null, null, null, null, null, null, null, null, "''", null, + "''", "''", null, null, "'/span>'", + null, "'<'" + }; + private static readonly string[] _SymbolicNames = { + null, "CODESTART", "PARAGRAPHSTART", "BLOCKQUOTESTART", "NORMAL_WHITESPACE", + "PARAGRAPHEND", "BQ_CODESTART", "BQ_PARAGRAPHSTART", "BLOCKQUOTEEND", + "BQ_WHITESPACE", "CODEEND", "MENTION_TAG_OPEN", "FLOAT", "INTEGER", "DIGIT", + "LPAREN", "RPAREN", "ASSIGNMUL", "ASSIGNDIV", "ASSIGNADD", "ASSIGNSUB", + "MUL", "DIV", "ADD", "SUB", "GE", "GT", "LE", "LT", "EQ", "NE", "AND", + "OR", "ASSIGN", "NEG", "COMMA", "LBRACE", "RBRACE", "BOOLEAN", "FNAME", + "VFNAME", "VFNAMEVARS", "IFKEYWORD", "ELSEKEYWORD", "ELSEIFKEYWORD", "ENDIFKEYWORD", + "ANDKEYWORD", "ORKEYWORD", "ISKEYWORD", "NOTKEYWORD", "STRING", "VARIABLE", + "WHITESPACE", "TAG_CLOSE", "ATTR_NAME", "TAG_EQUALS", "MENTION_TAG_CLOSE", + "TAG_WHITESPACE", "TAG_OPEN", "MENTION_LABEL", "ATTR_VALUE", "ATTRIBUTE" + }; + public static readonly IVocabulary DefaultVocabulary = new Vocabulary(_LiteralNames, _SymbolicNames); + + [NotNull] + public override IVocabulary Vocabulary + { + get + { + return DefaultVocabulary; + } + } + + public override string GrammarFileName { get { return "ArcscriptParser.g4"; } } + + public override string[] RuleNames { get { return ruleNames; } } + + public override int[] SerializedAtn { get { return _serializedATN; } } + + static ArcscriptParser() { + decisionToDFA = new DFA[_ATN.NumberOfDecisions]; + for (int i = 0; i < _ATN.NumberOfDecisions; i++) { + decisionToDFA[i] = new DFA(_ATN.GetDecisionState(i), i); + } + } + + public ArcscriptParser(ITokenStream input) : this(input, Console.Out, Console.Error) { } + + public ArcscriptParser(ITokenStream input, TextWriter output, TextWriter errorOutput) + : base(input, output, errorOutput) + { + Interpreter = new ParserATNSimulator(this, _ATN, decisionToDFA, sharedContextCache); + } + + public partial class InputContext : ParserRuleContext { + [System.Diagnostics.DebuggerNonUserCode] public ScriptContext script() { + return GetRuleContext(0); + } + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode Eof() { return GetToken(ArcscriptParser.Eof, 0); } + [System.Diagnostics.DebuggerNonUserCode] public CodestartContext codestart() { + return GetRuleContext(0); + } + [System.Diagnostics.DebuggerNonUserCode] public Compound_condition_orContext compound_condition_or() { + return GetRuleContext(0); + } + [System.Diagnostics.DebuggerNonUserCode] public CodeendContext codeend() { + return GetRuleContext(0); + } + public InputContext(ParserRuleContext parent, int invokingState) + : base(parent, invokingState) + { + } + public override int RuleIndex { get { return RULE_input; } } + [System.Diagnostics.DebuggerNonUserCode] + public override TResult Accept(IParseTreeVisitor visitor) { + IArcscriptParserVisitor typedVisitor = visitor as IArcscriptParserVisitor; + if (typedVisitor != null) return typedVisitor.VisitInput(this); + else return visitor.VisitChildren(this); + } + } + + [RuleVersion(0)] + public InputContext input() { + InputContext _localctx = new InputContext(Context, State); + EnterRule(_localctx, 0, RULE_input); + try { + State = 84; + ErrorHandler.Sync(this); + switch ( Interpreter.AdaptivePredict(TokenStream,0,Context) ) { + case 1: + EnterOuterAlt(_localctx, 1); + { + State = 76; + script(); + State = 77; + Match(Eof); + } + break; + case 2: + EnterOuterAlt(_localctx, 2); + { + State = 79; + codestart(); + State = 80; + compound_condition_or(); + State = 81; + codeend(); + State = 82; + Match(Eof); + } + break; + } + } + catch (RecognitionException re) { + _localctx.exception = re; + ErrorHandler.ReportError(this, re); + ErrorHandler.Recover(this, re); + } + finally { + ExitRule(); + } + return _localctx; + } + + public partial class ScriptContext : ParserRuleContext { + [System.Diagnostics.DebuggerNonUserCode] public Script_sectionContext[] script_section() { + return GetRuleContexts(); + } + [System.Diagnostics.DebuggerNonUserCode] public Script_sectionContext script_section(int i) { + return GetRuleContext(i); + } + public ScriptContext(ParserRuleContext parent, int invokingState) + : base(parent, invokingState) + { + } + public override int RuleIndex { get { return RULE_script; } } + [System.Diagnostics.DebuggerNonUserCode] + public override TResult Accept(IParseTreeVisitor visitor) { + IArcscriptParserVisitor typedVisitor = visitor as IArcscriptParserVisitor; + if (typedVisitor != null) return typedVisitor.VisitScript(this); + else return visitor.VisitChildren(this); + } + } + + [RuleVersion(0)] + public ScriptContext script() { + ScriptContext _localctx = new ScriptContext(Context, State); + EnterRule(_localctx, 2, RULE_script); + try { + int _alt; + EnterOuterAlt(_localctx, 1); + { + State = 87; + ErrorHandler.Sync(this); + _alt = 1; + do { + switch (_alt) { + case 1: + { + { + State = 86; + script_section(); + } + } + break; + default: + throw new NoViableAltException(this); + } + State = 89; + ErrorHandler.Sync(this); + _alt = Interpreter.AdaptivePredict(TokenStream,1,Context); + } while ( _alt!=2 && _alt!=global::Antlr4.Runtime.Atn.ATN.INVALID_ALT_NUMBER ); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + ErrorHandler.ReportError(this, re); + ErrorHandler.Recover(this, re); + } + finally { + ExitRule(); + } + return _localctx; + } + + public partial class Script_sectionContext : ParserRuleContext { + [System.Diagnostics.DebuggerNonUserCode] public BlockquoteContext[] blockquote() { + return GetRuleContexts(); + } + [System.Diagnostics.DebuggerNonUserCode] public BlockquoteContext blockquote(int i) { + return GetRuleContext(i); + } + [System.Diagnostics.DebuggerNonUserCode] public ParagraphContext[] paragraph() { + return GetRuleContexts(); + } + [System.Diagnostics.DebuggerNonUserCode] public ParagraphContext paragraph(int i) { + return GetRuleContext(i); + } + [System.Diagnostics.DebuggerNonUserCode] public Assignment_segmentContext assignment_segment() { + return GetRuleContext(0); + } + [System.Diagnostics.DebuggerNonUserCode] public Function_call_segmentContext function_call_segment() { + return GetRuleContext(0); + } + [System.Diagnostics.DebuggerNonUserCode] public Conditional_sectionContext conditional_section() { + return GetRuleContext(0); + } + public Script_sectionContext(ParserRuleContext parent, int invokingState) + : base(parent, invokingState) + { + } + public override int RuleIndex { get { return RULE_script_section; } } + [System.Diagnostics.DebuggerNonUserCode] + public override TResult Accept(IParseTreeVisitor visitor) { + IArcscriptParserVisitor typedVisitor = visitor as IArcscriptParserVisitor; + if (typedVisitor != null) return typedVisitor.VisitScript_section(this); + else return visitor.VisitChildren(this); + } + } + + [RuleVersion(0)] + public Script_sectionContext script_section() { + Script_sectionContext _localctx = new Script_sectionContext(Context, State); + EnterRule(_localctx, 4, RULE_script_section); + try { + int _alt; + State = 104; + ErrorHandler.Sync(this); + switch ( Interpreter.AdaptivePredict(TokenStream,4,Context) ) { + case 1: + EnterOuterAlt(_localctx, 1); + { + State = 92; + ErrorHandler.Sync(this); + _alt = 1+1; + do { + switch (_alt) { + case 1+1: + { + { + State = 91; + blockquote(); + } + } + break; + default: + throw new NoViableAltException(this); + } + State = 94; + ErrorHandler.Sync(this); + _alt = Interpreter.AdaptivePredict(TokenStream,2,Context); + } while ( _alt!=1 && _alt!=global::Antlr4.Runtime.Atn.ATN.INVALID_ALT_NUMBER ); + } + break; + case 2: + EnterOuterAlt(_localctx, 2); + { + State = 97; + ErrorHandler.Sync(this); + _alt = 1+1; + do { + switch (_alt) { + case 1+1: + { + { + State = 96; + paragraph(); + } + } + break; + default: + throw new NoViableAltException(this); + } + State = 99; + ErrorHandler.Sync(this); + _alt = Interpreter.AdaptivePredict(TokenStream,3,Context); + } while ( _alt!=1 && _alt!=global::Antlr4.Runtime.Atn.ATN.INVALID_ALT_NUMBER ); + } + break; + case 3: + EnterOuterAlt(_localctx, 3); + { + State = 101; + assignment_segment(); + } + break; + case 4: + EnterOuterAlt(_localctx, 4); + { + State = 102; + function_call_segment(); + } + break; + case 5: + EnterOuterAlt(_localctx, 5); + { + State = 103; + conditional_section(); + } + break; + } + } + catch (RecognitionException re) { + _localctx.exception = re; + ErrorHandler.ReportError(this, re); + ErrorHandler.Recover(this, re); + } + finally { + ExitRule(); + } + return _localctx; + } + + public partial class BlockquoteContext : ParserRuleContext { + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode BLOCKQUOTESTART() { return GetToken(ArcscriptParser.BLOCKQUOTESTART, 0); } + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode BLOCKQUOTEEND() { return GetToken(ArcscriptParser.BLOCKQUOTEEND, 0); } + [System.Diagnostics.DebuggerNonUserCode] public ParagraphContext[] paragraph() { + return GetRuleContexts(); + } + [System.Diagnostics.DebuggerNonUserCode] public ParagraphContext paragraph(int i) { + return GetRuleContext(i); + } + [System.Diagnostics.DebuggerNonUserCode] public Assignment_segmentContext[] assignment_segment() { + return GetRuleContexts(); + } + [System.Diagnostics.DebuggerNonUserCode] public Assignment_segmentContext assignment_segment(int i) { + return GetRuleContext(i); + } + [System.Diagnostics.DebuggerNonUserCode] public Function_call_segmentContext[] function_call_segment() { + return GetRuleContexts(); + } + [System.Diagnostics.DebuggerNonUserCode] public Function_call_segmentContext function_call_segment(int i) { + return GetRuleContext(i); + } + public BlockquoteContext(ParserRuleContext parent, int invokingState) + : base(parent, invokingState) + { + } + public override int RuleIndex { get { return RULE_blockquote; } } + [System.Diagnostics.DebuggerNonUserCode] + public override TResult Accept(IParseTreeVisitor visitor) { + IArcscriptParserVisitor typedVisitor = visitor as IArcscriptParserVisitor; + if (typedVisitor != null) return typedVisitor.VisitBlockquote(this); + else return visitor.VisitChildren(this); + } + } + + [RuleVersion(0)] + public BlockquoteContext blockquote() { + BlockquoteContext _localctx = new BlockquoteContext(Context, State); + EnterRule(_localctx, 6, RULE_blockquote); + int _la; + try { + EnterOuterAlt(_localctx, 1); + { + State = 106; + Match(BLOCKQUOTESTART); + State = 112; + ErrorHandler.Sync(this); + _la = TokenStream.LA(1); + while ((((_la) & ~0x3f) == 0 && ((1L << _la) & 198L) != 0)) { + { + State = 110; + ErrorHandler.Sync(this); + switch ( Interpreter.AdaptivePredict(TokenStream,5,Context) ) { + case 1: + { + State = 107; + paragraph(); + } + break; + case 2: + { + State = 108; + assignment_segment(); + } + break; + case 3: + { + State = 109; + function_call_segment(); + } + break; + } + } + State = 114; + ErrorHandler.Sync(this); + _la = TokenStream.LA(1); + } + State = 115; + Match(BLOCKQUOTEEND); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + ErrorHandler.ReportError(this, re); + ErrorHandler.Recover(this, re); + } + finally { + ExitRule(); + } + return _localctx; + } + + public partial class ParagraphContext : ParserRuleContext { + [System.Diagnostics.DebuggerNonUserCode] public Paragraph_startContext paragraph_start() { + return GetRuleContext(0); + } + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode PARAGRAPHEND() { return GetToken(ArcscriptParser.PARAGRAPHEND, 0); } + public ParagraphContext(ParserRuleContext parent, int invokingState) + : base(parent, invokingState) + { + } + public override int RuleIndex { get { return RULE_paragraph; } } + [System.Diagnostics.DebuggerNonUserCode] + public override TResult Accept(IParseTreeVisitor visitor) { + IArcscriptParserVisitor typedVisitor = visitor as IArcscriptParserVisitor; + if (typedVisitor != null) return typedVisitor.VisitParagraph(this); + else return visitor.VisitChildren(this); + } + } + + [RuleVersion(0)] + public ParagraphContext paragraph() { + ParagraphContext _localctx = new ParagraphContext(Context, State); + EnterRule(_localctx, 8, RULE_paragraph); + try { + EnterOuterAlt(_localctx, 1); + { + State = 117; + paragraph_start(); + State = 118; + Match(PARAGRAPHEND); + this.currentLine++; + } + } + catch (RecognitionException re) { + _localctx.exception = re; + ErrorHandler.ReportError(this, re); + ErrorHandler.Recover(this, re); + } + finally { + ExitRule(); + } + return _localctx; + } + + public partial class Paragraph_startContext : ParserRuleContext { + public IToken _PARAGRAPHSTART; + public IToken _BQ_PARAGRAPHSTART; + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode PARAGRAPHSTART() { return GetToken(ArcscriptParser.PARAGRAPHSTART, 0); } + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode BQ_PARAGRAPHSTART() { return GetToken(ArcscriptParser.BQ_PARAGRAPHSTART, 0); } + public Paragraph_startContext(ParserRuleContext parent, int invokingState) + : base(parent, invokingState) + { + } + public override int RuleIndex { get { return RULE_paragraph_start; } } + [System.Diagnostics.DebuggerNonUserCode] + public override TResult Accept(IParseTreeVisitor visitor) { + IArcscriptParserVisitor typedVisitor = visitor as IArcscriptParserVisitor; + if (typedVisitor != null) return typedVisitor.VisitParagraph_start(this); + else return visitor.VisitChildren(this); + } + } + + [RuleVersion(0)] + public Paragraph_startContext paragraph_start() { + Paragraph_startContext _localctx = new Paragraph_startContext(Context, State); + EnterRule(_localctx, 10, RULE_paragraph_start); + try { + State = 125; + ErrorHandler.Sync(this); + switch (TokenStream.LA(1)) { + case PARAGRAPHSTART: + EnterOuterAlt(_localctx, 1); + { + State = 121; + _localctx._PARAGRAPHSTART = Match(PARAGRAPHSTART); + this.setLineStart(_localctx._PARAGRAPHSTART); + } + break; + case BQ_PARAGRAPHSTART: + EnterOuterAlt(_localctx, 2); + { + State = 123; + _localctx._BQ_PARAGRAPHSTART = Match(BQ_PARAGRAPHSTART); + this.setLineStart(_localctx._BQ_PARAGRAPHSTART); + } + break; + default: + throw new NoViableAltException(this); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + ErrorHandler.ReportError(this, re); + ErrorHandler.Recover(this, re); + } + finally { + ExitRule(); + } + return _localctx; + } + + public partial class CodestartContext : ParserRuleContext { + public IToken _CODESTART; + public IToken _BQ_CODESTART; + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode CODESTART() { return GetToken(ArcscriptParser.CODESTART, 0); } + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode BQ_CODESTART() { return GetToken(ArcscriptParser.BQ_CODESTART, 0); } + public CodestartContext(ParserRuleContext parent, int invokingState) + : base(parent, invokingState) + { + } + public override int RuleIndex { get { return RULE_codestart; } } + [System.Diagnostics.DebuggerNonUserCode] + public override TResult Accept(IParseTreeVisitor visitor) { + IArcscriptParserVisitor typedVisitor = visitor as IArcscriptParserVisitor; + if (typedVisitor != null) return typedVisitor.VisitCodestart(this); + else return visitor.VisitChildren(this); + } + } + + [RuleVersion(0)] + public CodestartContext codestart() { + CodestartContext _localctx = new CodestartContext(Context, State); + EnterRule(_localctx, 12, RULE_codestart); + try { + State = 131; + ErrorHandler.Sync(this); + switch (TokenStream.LA(1)) { + case CODESTART: + EnterOuterAlt(_localctx, 1); + { + State = 127; + _localctx._CODESTART = Match(CODESTART); + this.currentLine++; this.setLineStart(_localctx._CODESTART); + } + break; + case BQ_CODESTART: + EnterOuterAlt(_localctx, 2); + { + State = 129; + _localctx._BQ_CODESTART = Match(BQ_CODESTART); + this.currentLine++; this.setLineStart(_localctx._BQ_CODESTART); + } + break; + default: + throw new NoViableAltException(this); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + ErrorHandler.ReportError(this, re); + ErrorHandler.Recover(this, re); + } + finally { + ExitRule(); + } + return _localctx; + } + + public partial class CodeendContext : ParserRuleContext { + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode CODEEND() { return GetToken(ArcscriptParser.CODEEND, 0); } + public CodeendContext(ParserRuleContext parent, int invokingState) + : base(parent, invokingState) + { + } + public override int RuleIndex { get { return RULE_codeend; } } + [System.Diagnostics.DebuggerNonUserCode] + public override TResult Accept(IParseTreeVisitor visitor) { + IArcscriptParserVisitor typedVisitor = visitor as IArcscriptParserVisitor; + if (typedVisitor != null) return typedVisitor.VisitCodeend(this); + else return visitor.VisitChildren(this); + } + } + + [RuleVersion(0)] + public CodeendContext codeend() { + CodeendContext _localctx = new CodeendContext(Context, State); + EnterRule(_localctx, 14, RULE_codeend); + try { + EnterOuterAlt(_localctx, 1); + { + State = 133; + Match(CODEEND); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + ErrorHandler.ReportError(this, re); + ErrorHandler.Recover(this, re); + } + finally { + ExitRule(); + } + return _localctx; + } + + public partial class Assignment_segmentContext : ParserRuleContext { + [System.Diagnostics.DebuggerNonUserCode] public CodestartContext codestart() { + return GetRuleContext(0); + } + [System.Diagnostics.DebuggerNonUserCode] public Statement_assignmentContext statement_assignment() { + return GetRuleContext(0); + } + [System.Diagnostics.DebuggerNonUserCode] public CodeendContext codeend() { + return GetRuleContext(0); + } + public Assignment_segmentContext(ParserRuleContext parent, int invokingState) + : base(parent, invokingState) + { + } + public override int RuleIndex { get { return RULE_assignment_segment; } } + [System.Diagnostics.DebuggerNonUserCode] + public override TResult Accept(IParseTreeVisitor visitor) { + IArcscriptParserVisitor typedVisitor = visitor as IArcscriptParserVisitor; + if (typedVisitor != null) return typedVisitor.VisitAssignment_segment(this); + else return visitor.VisitChildren(this); + } + } + + [RuleVersion(0)] + public Assignment_segmentContext assignment_segment() { + Assignment_segmentContext _localctx = new Assignment_segmentContext(Context, State); + EnterRule(_localctx, 16, RULE_assignment_segment); + try { + EnterOuterAlt(_localctx, 1); + { + State = 135; + codestart(); + State = 136; + statement_assignment(); + State = 137; + codeend(); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + ErrorHandler.ReportError(this, re); + ErrorHandler.Recover(this, re); + } + finally { + ExitRule(); + } + return _localctx; + } + + public partial class Function_call_segmentContext : ParserRuleContext { + [System.Diagnostics.DebuggerNonUserCode] public CodestartContext codestart() { + return GetRuleContext(0); + } + [System.Diagnostics.DebuggerNonUserCode] public Statement_function_callContext statement_function_call() { + return GetRuleContext(0); + } + [System.Diagnostics.DebuggerNonUserCode] public CodeendContext codeend() { + return GetRuleContext(0); + } + public Function_call_segmentContext(ParserRuleContext parent, int invokingState) + : base(parent, invokingState) + { + } + public override int RuleIndex { get { return RULE_function_call_segment; } } + [System.Diagnostics.DebuggerNonUserCode] + public override TResult Accept(IParseTreeVisitor visitor) { + IArcscriptParserVisitor typedVisitor = visitor as IArcscriptParserVisitor; + if (typedVisitor != null) return typedVisitor.VisitFunction_call_segment(this); + else return visitor.VisitChildren(this); + } + } + + [RuleVersion(0)] + public Function_call_segmentContext function_call_segment() { + Function_call_segmentContext _localctx = new Function_call_segmentContext(Context, State); + EnterRule(_localctx, 18, RULE_function_call_segment); + try { + EnterOuterAlt(_localctx, 1); + { + State = 139; + codestart(); + State = 140; + statement_function_call(); + State = 141; + codeend(); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + ErrorHandler.ReportError(this, re); + ErrorHandler.Recover(this, re); + } + finally { + ExitRule(); + } + return _localctx; + } + + public partial class Conditional_sectionContext : ParserRuleContext { + [System.Diagnostics.DebuggerNonUserCode] public If_sectionContext if_section() { + return GetRuleContext(0); + } + [System.Diagnostics.DebuggerNonUserCode] public Endif_segmentContext endif_segment() { + return GetRuleContext(0); + } + [System.Diagnostics.DebuggerNonUserCode] public Else_if_sectionContext[] else_if_section() { + return GetRuleContexts(); + } + [System.Diagnostics.DebuggerNonUserCode] public Else_if_sectionContext else_if_section(int i) { + return GetRuleContext(i); + } + [System.Diagnostics.DebuggerNonUserCode] public Else_sectionContext else_section() { + return GetRuleContext(0); + } + public Conditional_sectionContext(ParserRuleContext parent, int invokingState) + : base(parent, invokingState) + { + } + public override int RuleIndex { get { return RULE_conditional_section; } } + [System.Diagnostics.DebuggerNonUserCode] + public override TResult Accept(IParseTreeVisitor visitor) { + IArcscriptParserVisitor typedVisitor = visitor as IArcscriptParserVisitor; + if (typedVisitor != null) return typedVisitor.VisitConditional_section(this); + else return visitor.VisitChildren(this); + } + } + + [RuleVersion(0)] + public Conditional_sectionContext conditional_section() { + Conditional_sectionContext _localctx = new Conditional_sectionContext(Context, State); + EnterRule(_localctx, 20, RULE_conditional_section); + try { + int _alt; + EnterOuterAlt(_localctx, 1); + { + State = 143; + if_section(); + State = 147; + ErrorHandler.Sync(this); + _alt = Interpreter.AdaptivePredict(TokenStream,9,Context); + while ( _alt!=2 && _alt!=global::Antlr4.Runtime.Atn.ATN.INVALID_ALT_NUMBER ) { + if ( _alt==1 ) { + { + { + State = 144; + else_if_section(); + } + } + } + State = 149; + ErrorHandler.Sync(this); + _alt = Interpreter.AdaptivePredict(TokenStream,9,Context); + } + State = 151; + ErrorHandler.Sync(this); + switch ( Interpreter.AdaptivePredict(TokenStream,10,Context) ) { + case 1: + { + State = 150; + else_section(); + } + break; + } + State = 153; + endif_segment(); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + ErrorHandler.ReportError(this, re); + ErrorHandler.Recover(this, re); + } + finally { + ExitRule(); + } + return _localctx; + } + + public partial class If_sectionContext : ParserRuleContext { + [System.Diagnostics.DebuggerNonUserCode] public CodestartContext codestart() { + return GetRuleContext(0); + } + [System.Diagnostics.DebuggerNonUserCode] public If_clauseContext if_clause() { + return GetRuleContext(0); + } + [System.Diagnostics.DebuggerNonUserCode] public CodeendContext codeend() { + return GetRuleContext(0); + } + [System.Diagnostics.DebuggerNonUserCode] public ScriptContext script() { + return GetRuleContext(0); + } + public If_sectionContext(ParserRuleContext parent, int invokingState) + : base(parent, invokingState) + { + } + public override int RuleIndex { get { return RULE_if_section; } } + [System.Diagnostics.DebuggerNonUserCode] + public override TResult Accept(IParseTreeVisitor visitor) { + IArcscriptParserVisitor typedVisitor = visitor as IArcscriptParserVisitor; + if (typedVisitor != null) return typedVisitor.VisitIf_section(this); + else return visitor.VisitChildren(this); + } + } + + [RuleVersion(0)] + public If_sectionContext if_section() { + If_sectionContext _localctx = new If_sectionContext(Context, State); + EnterRule(_localctx, 22, RULE_if_section); + try { + EnterOuterAlt(_localctx, 1); + { + State = 155; + codestart(); + State = 156; + if_clause(); + State = 157; + codeend(); + State = 158; + script(); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + ErrorHandler.ReportError(this, re); + ErrorHandler.Recover(this, re); + } + finally { + ExitRule(); + } + return _localctx; + } + + public partial class Else_if_sectionContext : ParserRuleContext { + [System.Diagnostics.DebuggerNonUserCode] public CodestartContext codestart() { + return GetRuleContext(0); + } + [System.Diagnostics.DebuggerNonUserCode] public Else_if_clauseContext else_if_clause() { + return GetRuleContext(0); + } + [System.Diagnostics.DebuggerNonUserCode] public CodeendContext codeend() { + return GetRuleContext(0); + } + [System.Diagnostics.DebuggerNonUserCode] public ScriptContext script() { + return GetRuleContext(0); + } + public Else_if_sectionContext(ParserRuleContext parent, int invokingState) + : base(parent, invokingState) + { + } + public override int RuleIndex { get { return RULE_else_if_section; } } + [System.Diagnostics.DebuggerNonUserCode] + public override TResult Accept(IParseTreeVisitor visitor) { + IArcscriptParserVisitor typedVisitor = visitor as IArcscriptParserVisitor; + if (typedVisitor != null) return typedVisitor.VisitElse_if_section(this); + else return visitor.VisitChildren(this); + } + } + + [RuleVersion(0)] + public Else_if_sectionContext else_if_section() { + Else_if_sectionContext _localctx = new Else_if_sectionContext(Context, State); + EnterRule(_localctx, 24, RULE_else_if_section); + try { + EnterOuterAlt(_localctx, 1); + { + State = 160; + codestart(); + State = 161; + else_if_clause(); + State = 162; + codeend(); + State = 163; + script(); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + ErrorHandler.ReportError(this, re); + ErrorHandler.Recover(this, re); + } + finally { + ExitRule(); + } + return _localctx; + } + + public partial class Else_sectionContext : ParserRuleContext { + [System.Diagnostics.DebuggerNonUserCode] public CodestartContext codestart() { + return GetRuleContext(0); + } + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode ELSEKEYWORD() { return GetToken(ArcscriptParser.ELSEKEYWORD, 0); } + [System.Diagnostics.DebuggerNonUserCode] public CodeendContext codeend() { + return GetRuleContext(0); + } + [System.Diagnostics.DebuggerNonUserCode] public ScriptContext script() { + return GetRuleContext(0); + } + public Else_sectionContext(ParserRuleContext parent, int invokingState) + : base(parent, invokingState) + { + } + public override int RuleIndex { get { return RULE_else_section; } } + [System.Diagnostics.DebuggerNonUserCode] + public override TResult Accept(IParseTreeVisitor visitor) { + IArcscriptParserVisitor typedVisitor = visitor as IArcscriptParserVisitor; + if (typedVisitor != null) return typedVisitor.VisitElse_section(this); + else return visitor.VisitChildren(this); + } + } + + [RuleVersion(0)] + public Else_sectionContext else_section() { + Else_sectionContext _localctx = new Else_sectionContext(Context, State); + EnterRule(_localctx, 26, RULE_else_section); + try { + EnterOuterAlt(_localctx, 1); + { + State = 165; + codestart(); + State = 166; + Match(ELSEKEYWORD); + State = 167; + codeend(); + State = 168; + script(); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + ErrorHandler.ReportError(this, re); + ErrorHandler.Recover(this, re); + } + finally { + ExitRule(); + } + return _localctx; + } + + public partial class If_clauseContext : ParserRuleContext { + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode IFKEYWORD() { return GetToken(ArcscriptParser.IFKEYWORD, 0); } + [System.Diagnostics.DebuggerNonUserCode] public Compound_condition_orContext compound_condition_or() { + return GetRuleContext(0); + } + public If_clauseContext(ParserRuleContext parent, int invokingState) + : base(parent, invokingState) + { + } + public override int RuleIndex { get { return RULE_if_clause; } } + [System.Diagnostics.DebuggerNonUserCode] + public override TResult Accept(IParseTreeVisitor visitor) { + IArcscriptParserVisitor typedVisitor = visitor as IArcscriptParserVisitor; + if (typedVisitor != null) return typedVisitor.VisitIf_clause(this); + else return visitor.VisitChildren(this); + } + } + + [RuleVersion(0)] + public If_clauseContext if_clause() { + If_clauseContext _localctx = new If_clauseContext(Context, State); + EnterRule(_localctx, 28, RULE_if_clause); + try { + EnterOuterAlt(_localctx, 1); + { + State = 170; + Match(IFKEYWORD); + State = 171; + compound_condition_or(); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + ErrorHandler.ReportError(this, re); + ErrorHandler.Recover(this, re); + } + finally { + ExitRule(); + } + return _localctx; + } + + public partial class Else_if_clauseContext : ParserRuleContext { + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode ELSEIFKEYWORD() { return GetToken(ArcscriptParser.ELSEIFKEYWORD, 0); } + [System.Diagnostics.DebuggerNonUserCode] public Compound_condition_orContext compound_condition_or() { + return GetRuleContext(0); + } + public Else_if_clauseContext(ParserRuleContext parent, int invokingState) + : base(parent, invokingState) + { + } + public override int RuleIndex { get { return RULE_else_if_clause; } } + [System.Diagnostics.DebuggerNonUserCode] + public override TResult Accept(IParseTreeVisitor visitor) { + IArcscriptParserVisitor typedVisitor = visitor as IArcscriptParserVisitor; + if (typedVisitor != null) return typedVisitor.VisitElse_if_clause(this); + else return visitor.VisitChildren(this); + } + } + + [RuleVersion(0)] + public Else_if_clauseContext else_if_clause() { + Else_if_clauseContext _localctx = new Else_if_clauseContext(Context, State); + EnterRule(_localctx, 30, RULE_else_if_clause); + try { + EnterOuterAlt(_localctx, 1); + { + State = 173; + Match(ELSEIFKEYWORD); + State = 174; + compound_condition_or(); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + ErrorHandler.ReportError(this, re); + ErrorHandler.Recover(this, re); + } + finally { + ExitRule(); + } + return _localctx; + } + + public partial class Endif_segmentContext : ParserRuleContext { + [System.Diagnostics.DebuggerNonUserCode] public CodestartContext codestart() { + return GetRuleContext(0); + } + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode ENDIFKEYWORD() { return GetToken(ArcscriptParser.ENDIFKEYWORD, 0); } + [System.Diagnostics.DebuggerNonUserCode] public CodeendContext codeend() { + return GetRuleContext(0); + } + public Endif_segmentContext(ParserRuleContext parent, int invokingState) + : base(parent, invokingState) + { + } + public override int RuleIndex { get { return RULE_endif_segment; } } + [System.Diagnostics.DebuggerNonUserCode] + public override TResult Accept(IParseTreeVisitor visitor) { + IArcscriptParserVisitor typedVisitor = visitor as IArcscriptParserVisitor; + if (typedVisitor != null) return typedVisitor.VisitEndif_segment(this); + else return visitor.VisitChildren(this); + } + } + + [RuleVersion(0)] + public Endif_segmentContext endif_segment() { + Endif_segmentContext _localctx = new Endif_segmentContext(Context, State); + EnterRule(_localctx, 32, RULE_endif_segment); + try { + EnterOuterAlt(_localctx, 1); + { + State = 176; + codestart(); + State = 177; + Match(ENDIFKEYWORD); + State = 178; + codeend(); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + ErrorHandler.ReportError(this, re); + ErrorHandler.Recover(this, re); + } + finally { + ExitRule(); + } + return _localctx; + } + + public partial class Statement_assignmentContext : ParserRuleContext { + public IToken _VARIABLE; + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode VARIABLE() { return GetToken(ArcscriptParser.VARIABLE, 0); } + [System.Diagnostics.DebuggerNonUserCode] public Compound_condition_orContext compound_condition_or() { + return GetRuleContext(0); + } + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode ASSIGNADD() { return GetToken(ArcscriptParser.ASSIGNADD, 0); } + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode ASSIGNSUB() { return GetToken(ArcscriptParser.ASSIGNSUB, 0); } + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode ASSIGNMUL() { return GetToken(ArcscriptParser.ASSIGNMUL, 0); } + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode ASSIGNDIV() { return GetToken(ArcscriptParser.ASSIGNDIV, 0); } + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode ASSIGN() { return GetToken(ArcscriptParser.ASSIGN, 0); } + public Statement_assignmentContext(ParserRuleContext parent, int invokingState) + : base(parent, invokingState) + { + } + public override int RuleIndex { get { return RULE_statement_assignment; } } + [System.Diagnostics.DebuggerNonUserCode] + public override TResult Accept(IParseTreeVisitor visitor) { + IArcscriptParserVisitor typedVisitor = visitor as IArcscriptParserVisitor; + if (typedVisitor != null) return typedVisitor.VisitStatement_assignment(this); + else return visitor.VisitChildren(this); + } + } + + [RuleVersion(0)] + public Statement_assignmentContext statement_assignment() { + Statement_assignmentContext _localctx = new Statement_assignmentContext(Context, State); + EnterRule(_localctx, 34, RULE_statement_assignment); + int _la; + try { + EnterOuterAlt(_localctx, 1); + { + State = 180; + _localctx._VARIABLE = Match(VARIABLE); + State = 181; + _la = TokenStream.LA(1); + if ( !((((_la) & ~0x3f) == 0 && ((1L << _la) & 8591900672L) != 0)) ) { + ErrorHandler.RecoverInline(this); + } + else { + ErrorHandler.ReportMatch(this); + Consume(); + } + State = 182; + compound_condition_or(); + this.assertVariable(_localctx._VARIABLE); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + ErrorHandler.ReportError(this, re); + ErrorHandler.Recover(this, re); + } + finally { + ExitRule(); + } + return _localctx; + } + + public partial class Statement_function_callContext : ParserRuleContext { + [System.Diagnostics.DebuggerNonUserCode] public Void_function_callContext void_function_call() { + return GetRuleContext(0); + } + public Statement_function_callContext(ParserRuleContext parent, int invokingState) + : base(parent, invokingState) + { + } + public override int RuleIndex { get { return RULE_statement_function_call; } } + [System.Diagnostics.DebuggerNonUserCode] + public override TResult Accept(IParseTreeVisitor visitor) { + IArcscriptParserVisitor typedVisitor = visitor as IArcscriptParserVisitor; + if (typedVisitor != null) return typedVisitor.VisitStatement_function_call(this); + else return visitor.VisitChildren(this); + } + } + + [RuleVersion(0)] + public Statement_function_callContext statement_function_call() { + Statement_function_callContext _localctx = new Statement_function_callContext(Context, State); + EnterRule(_localctx, 36, RULE_statement_function_call); + try { + EnterOuterAlt(_localctx, 1); + { + State = 185; + void_function_call(); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + ErrorHandler.ReportError(this, re); + ErrorHandler.Recover(this, re); + } + finally { + ExitRule(); + } + return _localctx; + } + + public partial class Argument_listContext : ParserRuleContext { + [System.Diagnostics.DebuggerNonUserCode] public ArgumentContext[] argument() { + return GetRuleContexts(); + } + [System.Diagnostics.DebuggerNonUserCode] public ArgumentContext argument(int i) { + return GetRuleContext(i); + } + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode[] COMMA() { return GetTokens(ArcscriptParser.COMMA); } + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode COMMA(int i) { + return GetToken(ArcscriptParser.COMMA, i); + } + public Argument_listContext(ParserRuleContext parent, int invokingState) + : base(parent, invokingState) + { + } + public override int RuleIndex { get { return RULE_argument_list; } } + [System.Diagnostics.DebuggerNonUserCode] + public override TResult Accept(IParseTreeVisitor visitor) { + IArcscriptParserVisitor typedVisitor = visitor as IArcscriptParserVisitor; + if (typedVisitor != null) return typedVisitor.VisitArgument_list(this); + else return visitor.VisitChildren(this); + } + } + + [RuleVersion(0)] + public Argument_listContext argument_list() { + Argument_listContext _localctx = new Argument_listContext(Context, State); + EnterRule(_localctx, 38, RULE_argument_list); + int _la; + try { + EnterOuterAlt(_localctx, 1); + { + State = 187; + argument(); + State = 192; + ErrorHandler.Sync(this); + _la = TokenStream.LA(1); + while (_la==COMMA) { + { + { + State = 188; + Match(COMMA); + State = 189; + argument(); + } + } + State = 194; + ErrorHandler.Sync(this); + _la = TokenStream.LA(1); + } + } + } + catch (RecognitionException re) { + _localctx.exception = re; + ErrorHandler.ReportError(this, re); + ErrorHandler.Recover(this, re); + } + finally { + ExitRule(); + } + return _localctx; + } + + public partial class ArgumentContext : ParserRuleContext { + [System.Diagnostics.DebuggerNonUserCode] public Additive_numeric_expressionContext additive_numeric_expression() { + return GetRuleContext(0); + } + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode STRING() { return GetToken(ArcscriptParser.STRING, 0); } + [System.Diagnostics.DebuggerNonUserCode] public MentionContext mention() { + return GetRuleContext(0); + } + public ArgumentContext(ParserRuleContext parent, int invokingState) + : base(parent, invokingState) + { + } + public override int RuleIndex { get { return RULE_argument; } } + [System.Diagnostics.DebuggerNonUserCode] + public override TResult Accept(IParseTreeVisitor visitor) { + IArcscriptParserVisitor typedVisitor = visitor as IArcscriptParserVisitor; + if (typedVisitor != null) return typedVisitor.VisitArgument(this); + else return visitor.VisitChildren(this); + } + } + + [RuleVersion(0)] + public ArgumentContext argument() { + ArgumentContext _localctx = new ArgumentContext(Context, State); + EnterRule(_localctx, 40, RULE_argument); + try { + State = 198; + ErrorHandler.Sync(this); + switch (TokenStream.LA(1)) { + case FLOAT: + case INTEGER: + case LPAREN: + case ADD: + case SUB: + case FNAME: + case VARIABLE: + EnterOuterAlt(_localctx, 1); + { + State = 195; + additive_numeric_expression(); + } + break; + case STRING: + EnterOuterAlt(_localctx, 2); + { + State = 196; + Match(STRING); + } + break; + case MENTION_TAG_OPEN: + EnterOuterAlt(_localctx, 3); + { + State = 197; + mention(); + } + break; + default: + throw new NoViableAltException(this); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + ErrorHandler.ReportError(this, re); + ErrorHandler.Recover(this, re); + } + finally { + ExitRule(); + } + return _localctx; + } + + public partial class MentionContext : ParserRuleContext { + public Mention_attributesContext _mention_attributes; + public IList _attr = new List(); + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode MENTION_TAG_OPEN() { return GetToken(ArcscriptParser.MENTION_TAG_OPEN, 0); } + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode TAG_CLOSE() { return GetToken(ArcscriptParser.TAG_CLOSE, 0); } + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode TAG_OPEN() { return GetToken(ArcscriptParser.TAG_OPEN, 0); } + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode MENTION_TAG_CLOSE() { return GetToken(ArcscriptParser.MENTION_TAG_CLOSE, 0); } + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode MENTION_LABEL() { return GetToken(ArcscriptParser.MENTION_LABEL, 0); } + [System.Diagnostics.DebuggerNonUserCode] public Mention_attributesContext[] mention_attributes() { + return GetRuleContexts(); + } + [System.Diagnostics.DebuggerNonUserCode] public Mention_attributesContext mention_attributes(int i) { + return GetRuleContext(i); + } + public MentionContext(ParserRuleContext parent, int invokingState) + : base(parent, invokingState) + { + } + public override int RuleIndex { get { return RULE_mention; } } + [System.Diagnostics.DebuggerNonUserCode] + public override TResult Accept(IParseTreeVisitor visitor) { + IArcscriptParserVisitor typedVisitor = visitor as IArcscriptParserVisitor; + if (typedVisitor != null) return typedVisitor.VisitMention(this); + else return visitor.VisitChildren(this); + } + } + + [RuleVersion(0)] + public MentionContext mention() { + MentionContext _localctx = new MentionContext(Context, State); + EnterRule(_localctx, 42, RULE_mention); + int _la; + try { + EnterOuterAlt(_localctx, 1); + { + State = 200; + Match(MENTION_TAG_OPEN); + State = 204; + ErrorHandler.Sync(this); + _la = TokenStream.LA(1); + while (_la==ATTR_NAME) { + { + { + State = 201; + _localctx._mention_attributes = mention_attributes(); + _localctx._attr.Add(_localctx._mention_attributes); + } + } + State = 206; + ErrorHandler.Sync(this); + _la = TokenStream.LA(1); + } + State = 207; + Match(TAG_CLOSE); + State = 209; + ErrorHandler.Sync(this); + _la = TokenStream.LA(1); + if (_la==MENTION_LABEL) { + { + State = 208; + Match(MENTION_LABEL); + } + } + + State = 211; + Match(TAG_OPEN); + State = 212; + Match(MENTION_TAG_CLOSE); + State = 213; + if (!(this.assertMention(_localctx._attr))) throw new FailedPredicateException(this, "this.assertMention($attr)"); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + ErrorHandler.ReportError(this, re); + ErrorHandler.Recover(this, re); + } + finally { + ExitRule(); + } + return _localctx; + } + + public partial class Mention_attributesContext : ParserRuleContext { + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode ATTR_NAME() { return GetToken(ArcscriptParser.ATTR_NAME, 0); } + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode TAG_EQUALS() { return GetToken(ArcscriptParser.TAG_EQUALS, 0); } + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode ATTR_VALUE() { return GetToken(ArcscriptParser.ATTR_VALUE, 0); } + public Mention_attributesContext(ParserRuleContext parent, int invokingState) + : base(parent, invokingState) + { + } + public override int RuleIndex { get { return RULE_mention_attributes; } } + [System.Diagnostics.DebuggerNonUserCode] + public override TResult Accept(IParseTreeVisitor visitor) { + IArcscriptParserVisitor typedVisitor = visitor as IArcscriptParserVisitor; + if (typedVisitor != null) return typedVisitor.VisitMention_attributes(this); + else return visitor.VisitChildren(this); + } + } + + [RuleVersion(0)] + public Mention_attributesContext mention_attributes() { + Mention_attributesContext _localctx = new Mention_attributesContext(Context, State); + EnterRule(_localctx, 44, RULE_mention_attributes); + int _la; + try { + EnterOuterAlt(_localctx, 1); + { + State = 215; + Match(ATTR_NAME); + State = 218; + ErrorHandler.Sync(this); + _la = TokenStream.LA(1); + if (_la==TAG_EQUALS) { + { + State = 216; + Match(TAG_EQUALS); + State = 217; + Match(ATTR_VALUE); + } + } + + } + } + catch (RecognitionException re) { + _localctx.exception = re; + ErrorHandler.ReportError(this, re); + ErrorHandler.Recover(this, re); + } + finally { + ExitRule(); + } + return _localctx; + } + + public partial class Additive_numeric_expressionContext : ParserRuleContext { + [System.Diagnostics.DebuggerNonUserCode] public Multiplicative_numeric_expressionContext multiplicative_numeric_expression() { + return GetRuleContext(0); + } + [System.Diagnostics.DebuggerNonUserCode] public Additive_numeric_expressionContext additive_numeric_expression() { + return GetRuleContext(0); + } + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode ADD() { return GetToken(ArcscriptParser.ADD, 0); } + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode SUB() { return GetToken(ArcscriptParser.SUB, 0); } + public Additive_numeric_expressionContext(ParserRuleContext parent, int invokingState) + : base(parent, invokingState) + { + } + public override int RuleIndex { get { return RULE_additive_numeric_expression; } } + [System.Diagnostics.DebuggerNonUserCode] + public override TResult Accept(IParseTreeVisitor visitor) { + IArcscriptParserVisitor typedVisitor = visitor as IArcscriptParserVisitor; + if (typedVisitor != null) return typedVisitor.VisitAdditive_numeric_expression(this); + else return visitor.VisitChildren(this); + } + } + + [RuleVersion(0)] + public Additive_numeric_expressionContext additive_numeric_expression() { + Additive_numeric_expressionContext _localctx = new Additive_numeric_expressionContext(Context, State); + EnterRule(_localctx, 46, RULE_additive_numeric_expression); + int _la; + try { + EnterOuterAlt(_localctx, 1); + { + State = 220; + multiplicative_numeric_expression(); + State = 223; + ErrorHandler.Sync(this); + _la = TokenStream.LA(1); + if (_la==ADD || _la==SUB) { + { + State = 221; + _la = TokenStream.LA(1); + if ( !(_la==ADD || _la==SUB) ) { + ErrorHandler.RecoverInline(this); + } + else { + ErrorHandler.ReportMatch(this); + Consume(); + } + State = 222; + additive_numeric_expression(); + } + } + + } + } + catch (RecognitionException re) { + _localctx.exception = re; + ErrorHandler.ReportError(this, re); + ErrorHandler.Recover(this, re); + } + finally { + ExitRule(); + } + return _localctx; + } + + public partial class Multiplicative_numeric_expressionContext : ParserRuleContext { + [System.Diagnostics.DebuggerNonUserCode] public Signed_unary_numeric_expressionContext signed_unary_numeric_expression() { + return GetRuleContext(0); + } + [System.Diagnostics.DebuggerNonUserCode] public Multiplicative_numeric_expressionContext multiplicative_numeric_expression() { + return GetRuleContext(0); + } + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode MUL() { return GetToken(ArcscriptParser.MUL, 0); } + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode DIV() { return GetToken(ArcscriptParser.DIV, 0); } + public Multiplicative_numeric_expressionContext(ParserRuleContext parent, int invokingState) + : base(parent, invokingState) + { + } + public override int RuleIndex { get { return RULE_multiplicative_numeric_expression; } } + [System.Diagnostics.DebuggerNonUserCode] + public override TResult Accept(IParseTreeVisitor visitor) { + IArcscriptParserVisitor typedVisitor = visitor as IArcscriptParserVisitor; + if (typedVisitor != null) return typedVisitor.VisitMultiplicative_numeric_expression(this); + else return visitor.VisitChildren(this); + } + } + + [RuleVersion(0)] + public Multiplicative_numeric_expressionContext multiplicative_numeric_expression() { + Multiplicative_numeric_expressionContext _localctx = new Multiplicative_numeric_expressionContext(Context, State); + EnterRule(_localctx, 48, RULE_multiplicative_numeric_expression); + int _la; + try { + EnterOuterAlt(_localctx, 1); + { + State = 225; + signed_unary_numeric_expression(); + State = 228; + ErrorHandler.Sync(this); + _la = TokenStream.LA(1); + if (_la==MUL || _la==DIV) { + { + State = 226; + _la = TokenStream.LA(1); + if ( !(_la==MUL || _la==DIV) ) { + ErrorHandler.RecoverInline(this); + } + else { + ErrorHandler.ReportMatch(this); + Consume(); + } + State = 227; + multiplicative_numeric_expression(); + } + } + + } + } + catch (RecognitionException re) { + _localctx.exception = re; + ErrorHandler.ReportError(this, re); + ErrorHandler.Recover(this, re); + } + finally { + ExitRule(); + } + return _localctx; + } + + public partial class Signed_unary_numeric_expressionContext : ParserRuleContext { + [System.Diagnostics.DebuggerNonUserCode] public SignContext sign() { + return GetRuleContext(0); + } + [System.Diagnostics.DebuggerNonUserCode] public Unary_numeric_expressionContext unary_numeric_expression() { + return GetRuleContext(0); + } + public Signed_unary_numeric_expressionContext(ParserRuleContext parent, int invokingState) + : base(parent, invokingState) + { + } + public override int RuleIndex { get { return RULE_signed_unary_numeric_expression; } } + [System.Diagnostics.DebuggerNonUserCode] + public override TResult Accept(IParseTreeVisitor visitor) { + IArcscriptParserVisitor typedVisitor = visitor as IArcscriptParserVisitor; + if (typedVisitor != null) return typedVisitor.VisitSigned_unary_numeric_expression(this); + else return visitor.VisitChildren(this); + } + } + + [RuleVersion(0)] + public Signed_unary_numeric_expressionContext signed_unary_numeric_expression() { + Signed_unary_numeric_expressionContext _localctx = new Signed_unary_numeric_expressionContext(Context, State); + EnterRule(_localctx, 50, RULE_signed_unary_numeric_expression); + try { + State = 234; + ErrorHandler.Sync(this); + switch (TokenStream.LA(1)) { + case ADD: + case SUB: + EnterOuterAlt(_localctx, 1); + { + State = 230; + sign(); + State = 231; + unary_numeric_expression(); + } + break; + case FLOAT: + case INTEGER: + case LPAREN: + case FNAME: + case VARIABLE: + EnterOuterAlt(_localctx, 2); + { + State = 233; + unary_numeric_expression(); + } + break; + default: + throw new NoViableAltException(this); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + ErrorHandler.ReportError(this, re); + ErrorHandler.Recover(this, re); + } + finally { + ExitRule(); + } + return _localctx; + } + + public partial class Unary_numeric_expressionContext : ParserRuleContext { + public IToken _VARIABLE; + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode FLOAT() { return GetToken(ArcscriptParser.FLOAT, 0); } + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode VARIABLE() { return GetToken(ArcscriptParser.VARIABLE, 0); } + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode INTEGER() { return GetToken(ArcscriptParser.INTEGER, 0); } + [System.Diagnostics.DebuggerNonUserCode] public Function_callContext function_call() { + return GetRuleContext(0); + } + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode LPAREN() { return GetToken(ArcscriptParser.LPAREN, 0); } + [System.Diagnostics.DebuggerNonUserCode] public Compound_condition_orContext compound_condition_or() { + return GetRuleContext(0); + } + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode RPAREN() { return GetToken(ArcscriptParser.RPAREN, 0); } + public Unary_numeric_expressionContext(ParserRuleContext parent, int invokingState) + : base(parent, invokingState) + { + } + public override int RuleIndex { get { return RULE_unary_numeric_expression; } } + [System.Diagnostics.DebuggerNonUserCode] + public override TResult Accept(IParseTreeVisitor visitor) { + IArcscriptParserVisitor typedVisitor = visitor as IArcscriptParserVisitor; + if (typedVisitor != null) return typedVisitor.VisitUnary_numeric_expression(this); + else return visitor.VisitChildren(this); + } + } + + [RuleVersion(0)] + public Unary_numeric_expressionContext unary_numeric_expression() { + Unary_numeric_expressionContext _localctx = new Unary_numeric_expressionContext(Context, State); + EnterRule(_localctx, 52, RULE_unary_numeric_expression); + try { + State = 245; + ErrorHandler.Sync(this); + switch (TokenStream.LA(1)) { + case FLOAT: + EnterOuterAlt(_localctx, 1); + { + State = 236; + Match(FLOAT); + } + break; + case VARIABLE: + EnterOuterAlt(_localctx, 2); + { + State = 237; + _localctx._VARIABLE = Match(VARIABLE); + this.assertVariable(_localctx._VARIABLE); + } + break; + case INTEGER: + EnterOuterAlt(_localctx, 3); + { + State = 239; + Match(INTEGER); + } + break; + case FNAME: + EnterOuterAlt(_localctx, 4); + { + State = 240; + function_call(); + } + break; + case LPAREN: + EnterOuterAlt(_localctx, 5); + { + State = 241; + Match(LPAREN); + State = 242; + compound_condition_or(); + State = 243; + Match(RPAREN); + } + break; + default: + throw new NoViableAltException(this); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + ErrorHandler.ReportError(this, re); + ErrorHandler.Recover(this, re); + } + finally { + ExitRule(); + } + return _localctx; + } + + public partial class Function_callContext : ParserRuleContext { + public IToken _FNAME; + public Argument_listContext _argument_list; + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode FNAME() { return GetToken(ArcscriptParser.FNAME, 0); } + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode LPAREN() { return GetToken(ArcscriptParser.LPAREN, 0); } + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode RPAREN() { return GetToken(ArcscriptParser.RPAREN, 0); } + [System.Diagnostics.DebuggerNonUserCode] public Argument_listContext argument_list() { + return GetRuleContext(0); + } + public Function_callContext(ParserRuleContext parent, int invokingState) + : base(parent, invokingState) + { + } + public override int RuleIndex { get { return RULE_function_call; } } + [System.Diagnostics.DebuggerNonUserCode] + public override TResult Accept(IParseTreeVisitor visitor) { + IArcscriptParserVisitor typedVisitor = visitor as IArcscriptParserVisitor; + if (typedVisitor != null) return typedVisitor.VisitFunction_call(this); + else return visitor.VisitChildren(this); + } + } + + [RuleVersion(0)] + public Function_callContext function_call() { + Function_callContext _localctx = new Function_callContext(Context, State); + EnterRule(_localctx, 54, RULE_function_call); + int _la; + try { + EnterOuterAlt(_localctx, 1); + { + State = 247; + _localctx._FNAME = Match(FNAME); + State = 248; + Match(LPAREN); + State = 250; + ErrorHandler.Sync(this); + _la = TokenStream.LA(1); + if ((((_la) & ~0x3f) == 0 && ((1L << _la) & 3378249501554688L) != 0)) { + { + State = 249; + _localctx._argument_list = argument_list(); + } + } + + State = 252; + Match(RPAREN); + this.assertFunctionArguments(_localctx._FNAME, _localctx._argument_list); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + ErrorHandler.ReportError(this, re); + ErrorHandler.Recover(this, re); + } + finally { + ExitRule(); + } + return _localctx; + } + + public partial class Void_function_callContext : ParserRuleContext { + public IToken _VFNAME; + public Argument_listContext _argument_list; + public IToken _VFNAMEVARS; + public Variable_listContext _variable_list; + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode VFNAME() { return GetToken(ArcscriptParser.VFNAME, 0); } + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode LPAREN() { return GetToken(ArcscriptParser.LPAREN, 0); } + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode RPAREN() { return GetToken(ArcscriptParser.RPAREN, 0); } + [System.Diagnostics.DebuggerNonUserCode] public Argument_listContext argument_list() { + return GetRuleContext(0); + } + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode VFNAMEVARS() { return GetToken(ArcscriptParser.VFNAMEVARS, 0); } + [System.Diagnostics.DebuggerNonUserCode] public Variable_listContext variable_list() { + return GetRuleContext(0); + } + public Void_function_callContext(ParserRuleContext parent, int invokingState) + : base(parent, invokingState) + { + } + public override int RuleIndex { get { return RULE_void_function_call; } } + [System.Diagnostics.DebuggerNonUserCode] + public override TResult Accept(IParseTreeVisitor visitor) { + IArcscriptParserVisitor typedVisitor = visitor as IArcscriptParserVisitor; + if (typedVisitor != null) return typedVisitor.VisitVoid_function_call(this); + else return visitor.VisitChildren(this); + } + } + + [RuleVersion(0)] + public Void_function_callContext void_function_call() { + Void_function_callContext _localctx = new Void_function_callContext(Context, State); + EnterRule(_localctx, 56, RULE_void_function_call); + int _la; + try { + State = 269; + ErrorHandler.Sync(this); + switch (TokenStream.LA(1)) { + case VFNAME: + EnterOuterAlt(_localctx, 1); + { + State = 255; + _localctx._VFNAME = Match(VFNAME); + State = 256; + Match(LPAREN); + State = 258; + ErrorHandler.Sync(this); + _la = TokenStream.LA(1); + if ((((_la) & ~0x3f) == 0 && ((1L << _la) & 3378249501554688L) != 0)) { + { + State = 257; + _localctx._argument_list = argument_list(); + } + } + + State = 260; + Match(RPAREN); + this.assertFunctionArguments(_localctx._VFNAME, _localctx._argument_list); + } + break; + case VFNAMEVARS: + EnterOuterAlt(_localctx, 2); + { + State = 262; + _localctx._VFNAMEVARS = Match(VFNAMEVARS); + State = 263; + Match(LPAREN); + State = 265; + ErrorHandler.Sync(this); + _la = TokenStream.LA(1); + if (_la==VARIABLE) { + { + State = 264; + _localctx._variable_list = variable_list(); + } + } + + State = 267; + Match(RPAREN); + this.assertFunctionArguments(_localctx._VFNAMEVARS, _localctx._variable_list); + } + break; + default: + throw new NoViableAltException(this); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + ErrorHandler.ReportError(this, re); + ErrorHandler.Recover(this, re); + } + finally { + ExitRule(); + } + return _localctx; + } + + public partial class SignContext : ParserRuleContext { + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode ADD() { return GetToken(ArcscriptParser.ADD, 0); } + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode SUB() { return GetToken(ArcscriptParser.SUB, 0); } + public SignContext(ParserRuleContext parent, int invokingState) + : base(parent, invokingState) + { + } + public override int RuleIndex { get { return RULE_sign; } } + [System.Diagnostics.DebuggerNonUserCode] + public override TResult Accept(IParseTreeVisitor visitor) { + IArcscriptParserVisitor typedVisitor = visitor as IArcscriptParserVisitor; + if (typedVisitor != null) return typedVisitor.VisitSign(this); + else return visitor.VisitChildren(this); + } + } + + [RuleVersion(0)] + public SignContext sign() { + SignContext _localctx = new SignContext(Context, State); + EnterRule(_localctx, 58, RULE_sign); + int _la; + try { + EnterOuterAlt(_localctx, 1); + { + State = 271; + _la = TokenStream.LA(1); + if ( !(_la==ADD || _la==SUB) ) { + ErrorHandler.RecoverInline(this); + } + else { + ErrorHandler.ReportMatch(this); + Consume(); + } + } + } + catch (RecognitionException re) { + _localctx.exception = re; + ErrorHandler.ReportError(this, re); + ErrorHandler.Recover(this, re); + } + finally { + ExitRule(); + } + return _localctx; + } + + public partial class Variable_listContext : ParserRuleContext { + public IToken _VARIABLE; + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode[] VARIABLE() { return GetTokens(ArcscriptParser.VARIABLE); } + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode VARIABLE(int i) { + return GetToken(ArcscriptParser.VARIABLE, i); + } + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode[] COMMA() { return GetTokens(ArcscriptParser.COMMA); } + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode COMMA(int i) { + return GetToken(ArcscriptParser.COMMA, i); + } + public Variable_listContext(ParserRuleContext parent, int invokingState) + : base(parent, invokingState) + { + } + public override int RuleIndex { get { return RULE_variable_list; } } + [System.Diagnostics.DebuggerNonUserCode] + public override TResult Accept(IParseTreeVisitor visitor) { + IArcscriptParserVisitor typedVisitor = visitor as IArcscriptParserVisitor; + if (typedVisitor != null) return typedVisitor.VisitVariable_list(this); + else return visitor.VisitChildren(this); + } + } + + [RuleVersion(0)] + public Variable_listContext variable_list() { + Variable_listContext _localctx = new Variable_listContext(Context, State); + EnterRule(_localctx, 60, RULE_variable_list); + int _la; + try { + EnterOuterAlt(_localctx, 1); + { + State = 273; + _localctx._VARIABLE = Match(VARIABLE); + State = 278; + ErrorHandler.Sync(this); + _la = TokenStream.LA(1); + while (_la==COMMA) { + { + { + State = 274; + Match(COMMA); + State = 275; + _localctx._VARIABLE = Match(VARIABLE); + } + } + State = 280; + ErrorHandler.Sync(this); + _la = TokenStream.LA(1); + } + this.assertVariable(_localctx._VARIABLE); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + ErrorHandler.ReportError(this, re); + ErrorHandler.Recover(this, re); + } + finally { + ExitRule(); + } + return _localctx; + } + + public partial class Compound_condition_orContext : ParserRuleContext { + [System.Diagnostics.DebuggerNonUserCode] public Compound_condition_andContext compound_condition_and() { + return GetRuleContext(0); + } + [System.Diagnostics.DebuggerNonUserCode] public Compound_condition_orContext compound_condition_or() { + return GetRuleContext(0); + } + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode OR() { return GetToken(ArcscriptParser.OR, 0); } + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode ORKEYWORD() { return GetToken(ArcscriptParser.ORKEYWORD, 0); } + public Compound_condition_orContext(ParserRuleContext parent, int invokingState) + : base(parent, invokingState) + { + } + public override int RuleIndex { get { return RULE_compound_condition_or; } } + [System.Diagnostics.DebuggerNonUserCode] + public override TResult Accept(IParseTreeVisitor visitor) { + IArcscriptParserVisitor typedVisitor = visitor as IArcscriptParserVisitor; + if (typedVisitor != null) return typedVisitor.VisitCompound_condition_or(this); + else return visitor.VisitChildren(this); + } + } + + [RuleVersion(0)] + public Compound_condition_orContext compound_condition_or() { + Compound_condition_orContext _localctx = new Compound_condition_orContext(Context, State); + EnterRule(_localctx, 62, RULE_compound_condition_or); + int _la; + try { + EnterOuterAlt(_localctx, 1); + { + State = 283; + compound_condition_and(); + State = 286; + ErrorHandler.Sync(this); + _la = TokenStream.LA(1); + if (_la==OR || _la==ORKEYWORD) { + { + State = 284; + _la = TokenStream.LA(1); + if ( !(_la==OR || _la==ORKEYWORD) ) { + ErrorHandler.RecoverInline(this); + } + else { + ErrorHandler.ReportMatch(this); + Consume(); + } + State = 285; + compound_condition_or(); + } + } + + } + } + catch (RecognitionException re) { + _localctx.exception = re; + ErrorHandler.ReportError(this, re); + ErrorHandler.Recover(this, re); + } + finally { + ExitRule(); + } + return _localctx; + } + + public partial class Compound_condition_andContext : ParserRuleContext { + [System.Diagnostics.DebuggerNonUserCode] public Negated_unary_conditionContext negated_unary_condition() { + return GetRuleContext(0); + } + [System.Diagnostics.DebuggerNonUserCode] public Compound_condition_andContext compound_condition_and() { + return GetRuleContext(0); + } + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode AND() { return GetToken(ArcscriptParser.AND, 0); } + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode ANDKEYWORD() { return GetToken(ArcscriptParser.ANDKEYWORD, 0); } + public Compound_condition_andContext(ParserRuleContext parent, int invokingState) + : base(parent, invokingState) + { + } + public override int RuleIndex { get { return RULE_compound_condition_and; } } + [System.Diagnostics.DebuggerNonUserCode] + public override TResult Accept(IParseTreeVisitor visitor) { + IArcscriptParserVisitor typedVisitor = visitor as IArcscriptParserVisitor; + if (typedVisitor != null) return typedVisitor.VisitCompound_condition_and(this); + else return visitor.VisitChildren(this); + } + } + + [RuleVersion(0)] + public Compound_condition_andContext compound_condition_and() { + Compound_condition_andContext _localctx = new Compound_condition_andContext(Context, State); + EnterRule(_localctx, 64, RULE_compound_condition_and); + int _la; + try { + EnterOuterAlt(_localctx, 1); + { + State = 288; + negated_unary_condition(); + State = 291; + ErrorHandler.Sync(this); + _la = TokenStream.LA(1); + if (_la==AND || _la==ANDKEYWORD) { + { + State = 289; + _la = TokenStream.LA(1); + if ( !(_la==AND || _la==ANDKEYWORD) ) { + ErrorHandler.RecoverInline(this); + } + else { + ErrorHandler.ReportMatch(this); + Consume(); + } + State = 290; + compound_condition_and(); + } + } + + } + } + catch (RecognitionException re) { + _localctx.exception = re; + ErrorHandler.ReportError(this, re); + ErrorHandler.Recover(this, re); + } + finally { + ExitRule(); + } + return _localctx; + } + + public partial class Negated_unary_conditionContext : ParserRuleContext { + [System.Diagnostics.DebuggerNonUserCode] public Unary_conditionContext unary_condition() { + return GetRuleContext(0); + } + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode NEG() { return GetToken(ArcscriptParser.NEG, 0); } + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode NOTKEYWORD() { return GetToken(ArcscriptParser.NOTKEYWORD, 0); } + public Negated_unary_conditionContext(ParserRuleContext parent, int invokingState) + : base(parent, invokingState) + { + } + public override int RuleIndex { get { return RULE_negated_unary_condition; } } + [System.Diagnostics.DebuggerNonUserCode] + public override TResult Accept(IParseTreeVisitor visitor) { + IArcscriptParserVisitor typedVisitor = visitor as IArcscriptParserVisitor; + if (typedVisitor != null) return typedVisitor.VisitNegated_unary_condition(this); + else return visitor.VisitChildren(this); + } + } + + [RuleVersion(0)] + public Negated_unary_conditionContext negated_unary_condition() { + Negated_unary_conditionContext _localctx = new Negated_unary_conditionContext(Context, State); + EnterRule(_localctx, 66, RULE_negated_unary_condition); + int _la; + try { + EnterOuterAlt(_localctx, 1); + { + State = 294; + ErrorHandler.Sync(this); + _la = TokenStream.LA(1); + if (_la==NEG || _la==NOTKEYWORD) { + { + State = 293; + _la = TokenStream.LA(1); + if ( !(_la==NEG || _la==NOTKEYWORD) ) { + ErrorHandler.RecoverInline(this); + } + else { + ErrorHandler.ReportMatch(this); + Consume(); + } + } + } + + State = 296; + unary_condition(); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + ErrorHandler.ReportError(this, re); + ErrorHandler.Recover(this, re); + } + finally { + ExitRule(); + } + return _localctx; + } + + public partial class Unary_conditionContext : ParserRuleContext { + [System.Diagnostics.DebuggerNonUserCode] public ConditionContext condition() { + return GetRuleContext(0); + } + public Unary_conditionContext(ParserRuleContext parent, int invokingState) + : base(parent, invokingState) + { + } + public override int RuleIndex { get { return RULE_unary_condition; } } + [System.Diagnostics.DebuggerNonUserCode] + public override TResult Accept(IParseTreeVisitor visitor) { + IArcscriptParserVisitor typedVisitor = visitor as IArcscriptParserVisitor; + if (typedVisitor != null) return typedVisitor.VisitUnary_condition(this); + else return visitor.VisitChildren(this); + } + } + + [RuleVersion(0)] + public Unary_conditionContext unary_condition() { + Unary_conditionContext _localctx = new Unary_conditionContext(Context, State); + EnterRule(_localctx, 68, RULE_unary_condition); + try { + EnterOuterAlt(_localctx, 1); + { + State = 298; + condition(); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + ErrorHandler.ReportError(this, re); + ErrorHandler.Recover(this, re); + } + finally { + ExitRule(); + } + return _localctx; + } + + public partial class ConditionContext : ParserRuleContext { + [System.Diagnostics.DebuggerNonUserCode] public ExpressionContext[] expression() { + return GetRuleContexts(); + } + [System.Diagnostics.DebuggerNonUserCode] public ExpressionContext expression(int i) { + return GetRuleContext(i); + } + [System.Diagnostics.DebuggerNonUserCode] public Conditional_operatorContext conditional_operator() { + return GetRuleContext(0); + } + public ConditionContext(ParserRuleContext parent, int invokingState) + : base(parent, invokingState) + { + } + public override int RuleIndex { get { return RULE_condition; } } + [System.Diagnostics.DebuggerNonUserCode] + public override TResult Accept(IParseTreeVisitor visitor) { + IArcscriptParserVisitor typedVisitor = visitor as IArcscriptParserVisitor; + if (typedVisitor != null) return typedVisitor.VisitCondition(this); + else return visitor.VisitChildren(this); + } + } + + [RuleVersion(0)] + public ConditionContext condition() { + ConditionContext _localctx = new ConditionContext(Context, State); + EnterRule(_localctx, 70, RULE_condition); + int _la; + try { + EnterOuterAlt(_localctx, 1); + { + State = 300; + expression(); + State = 304; + ErrorHandler.Sync(this); + _la = TokenStream.LA(1); + if ((((_la) & ~0x3f) == 0 && ((1L << _la) & 281477090639872L) != 0)) { + { + State = 301; + conditional_operator(); + State = 302; + expression(); + } + } + + } + } + catch (RecognitionException re) { + _localctx.exception = re; + ErrorHandler.ReportError(this, re); + ErrorHandler.Recover(this, re); + } + finally { + ExitRule(); + } + return _localctx; + } + + public partial class Conditional_operatorContext : ParserRuleContext { + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode GT() { return GetToken(ArcscriptParser.GT, 0); } + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode GE() { return GetToken(ArcscriptParser.GE, 0); } + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode LT() { return GetToken(ArcscriptParser.LT, 0); } + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode LE() { return GetToken(ArcscriptParser.LE, 0); } + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode EQ() { return GetToken(ArcscriptParser.EQ, 0); } + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode NE() { return GetToken(ArcscriptParser.NE, 0); } + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode ISKEYWORD() { return GetToken(ArcscriptParser.ISKEYWORD, 0); } + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode NOTKEYWORD() { return GetToken(ArcscriptParser.NOTKEYWORD, 0); } + public Conditional_operatorContext(ParserRuleContext parent, int invokingState) + : base(parent, invokingState) + { + } + public override int RuleIndex { get { return RULE_conditional_operator; } } + [System.Diagnostics.DebuggerNonUserCode] + public override TResult Accept(IParseTreeVisitor visitor) { + IArcscriptParserVisitor typedVisitor = visitor as IArcscriptParserVisitor; + if (typedVisitor != null) return typedVisitor.VisitConditional_operator(this); + else return visitor.VisitChildren(this); + } + } + + [RuleVersion(0)] + public Conditional_operatorContext conditional_operator() { + Conditional_operatorContext _localctx = new Conditional_operatorContext(Context, State); + EnterRule(_localctx, 72, RULE_conditional_operator); + try { + State = 315; + ErrorHandler.Sync(this); + switch ( Interpreter.AdaptivePredict(TokenStream,29,Context) ) { + case 1: + EnterOuterAlt(_localctx, 1); + { + State = 306; + Match(GT); + } + break; + case 2: + EnterOuterAlt(_localctx, 2); + { + State = 307; + Match(GE); + } + break; + case 3: + EnterOuterAlt(_localctx, 3); + { + State = 308; + Match(LT); + } + break; + case 4: + EnterOuterAlt(_localctx, 4); + { + State = 309; + Match(LE); + } + break; + case 5: + EnterOuterAlt(_localctx, 5); + { + State = 310; + Match(EQ); + } + break; + case 6: + EnterOuterAlt(_localctx, 6); + { + State = 311; + Match(NE); + } + break; + case 7: + EnterOuterAlt(_localctx, 7); + { + State = 312; + Match(ISKEYWORD); + } + break; + case 8: + EnterOuterAlt(_localctx, 8); + { + State = 313; + Match(ISKEYWORD); + State = 314; + Match(NOTKEYWORD); + } + break; + } + } + catch (RecognitionException re) { + _localctx.exception = re; + ErrorHandler.ReportError(this, re); + ErrorHandler.Recover(this, re); + } + finally { + ExitRule(); + } + return _localctx; + } + + public partial class ExpressionContext : ParserRuleContext { + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode STRING() { return GetToken(ArcscriptParser.STRING, 0); } + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode BOOLEAN() { return GetToken(ArcscriptParser.BOOLEAN, 0); } + [System.Diagnostics.DebuggerNonUserCode] public Additive_numeric_expressionContext additive_numeric_expression() { + return GetRuleContext(0); + } + public ExpressionContext(ParserRuleContext parent, int invokingState) + : base(parent, invokingState) + { + } + public override int RuleIndex { get { return RULE_expression; } } + [System.Diagnostics.DebuggerNonUserCode] + public override TResult Accept(IParseTreeVisitor visitor) { + IArcscriptParserVisitor typedVisitor = visitor as IArcscriptParserVisitor; + if (typedVisitor != null) return typedVisitor.VisitExpression(this); + else return visitor.VisitChildren(this); + } + } + + [RuleVersion(0)] + public ExpressionContext expression() { + ExpressionContext _localctx = new ExpressionContext(Context, State); + EnterRule(_localctx, 74, RULE_expression); + try { + State = 320; + ErrorHandler.Sync(this); + switch (TokenStream.LA(1)) { + case STRING: + EnterOuterAlt(_localctx, 1); + { + State = 317; + Match(STRING); + } + break; + case BOOLEAN: + EnterOuterAlt(_localctx, 2); + { + State = 318; + Match(BOOLEAN); + } + break; + case FLOAT: + case INTEGER: + case LPAREN: + case ADD: + case SUB: + case FNAME: + case VARIABLE: + EnterOuterAlt(_localctx, 3); + { + State = 319; + additive_numeric_expression(); + } + break; + default: + throw new NoViableAltException(this); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + ErrorHandler.ReportError(this, re); + ErrorHandler.Recover(this, re); + } + finally { + ExitRule(); + } + return _localctx; + } + + public override bool Sempred(RuleContext _localctx, int ruleIndex, int predIndex) { + switch (ruleIndex) { + case 21: return mention_sempred((MentionContext)_localctx, predIndex); + } + return true; + } + private bool mention_sempred(MentionContext _localctx, int predIndex) { + switch (predIndex) { + case 0: return this.assertMention(_localctx._attr); + } + return true; + } + + private static int[] _serializedATN = { + 4,1,61,323,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,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,3,0,85,8,0,1,1,4,1, + 88,8,1,11,1,12,1,89,1,2,4,2,93,8,2,11,2,12,2,94,1,2,4,2,98,8,2,11,2,12, + 2,99,1,2,1,2,1,2,3,2,105,8,2,1,3,1,3,1,3,1,3,5,3,111,8,3,10,3,12,3,114, + 9,3,1,3,1,3,1,4,1,4,1,4,1,4,1,5,1,5,1,5,1,5,3,5,126,8,5,1,6,1,6,1,6,1, + 6,3,6,132,8,6,1,7,1,7,1,8,1,8,1,8,1,8,1,9,1,9,1,9,1,9,1,10,1,10,5,10,146, + 8,10,10,10,12,10,149,9,10,1,10,3,10,152,8,10,1,10,1,10,1,11,1,11,1,11, + 1,11,1,11,1,12,1,12,1,12,1,12,1,12,1,13,1,13,1,13,1,13,1,13,1,14,1,14, + 1,14,1,15,1,15,1,15,1,16,1,16,1,16,1,16,1,17,1,17,1,17,1,17,1,17,1,18, + 1,18,1,19,1,19,1,19,5,19,191,8,19,10,19,12,19,194,9,19,1,20,1,20,1,20, + 3,20,199,8,20,1,21,1,21,5,21,203,8,21,10,21,12,21,206,9,21,1,21,1,21,3, + 21,210,8,21,1,21,1,21,1,21,1,21,1,22,1,22,1,22,3,22,219,8,22,1,23,1,23, + 1,23,3,23,224,8,23,1,24,1,24,1,24,3,24,229,8,24,1,25,1,25,1,25,1,25,3, + 25,235,8,25,1,26,1,26,1,26,1,26,1,26,1,26,1,26,1,26,1,26,3,26,246,8,26, + 1,27,1,27,1,27,3,27,251,8,27,1,27,1,27,1,27,1,28,1,28,1,28,3,28,259,8, + 28,1,28,1,28,1,28,1,28,1,28,3,28,266,8,28,1,28,1,28,3,28,270,8,28,1,29, + 1,29,1,30,1,30,1,30,5,30,277,8,30,10,30,12,30,280,9,30,1,30,1,30,1,31, + 1,31,1,31,3,31,287,8,31,1,32,1,32,1,32,3,32,292,8,32,1,33,3,33,295,8,33, + 1,33,1,33,1,34,1,34,1,35,1,35,1,35,1,35,3,35,305,8,35,1,36,1,36,1,36,1, + 36,1,36,1,36,1,36,1,36,1,36,3,36,316,8,36,1,37,1,37,1,37,3,37,321,8,37, + 1,37,2,94,99,0,38,0,2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32,34,36, + 38,40,42,44,46,48,50,52,54,56,58,60,62,64,66,68,70,72,74,0,6,2,0,17,20, + 33,33,1,0,23,24,1,0,21,22,2,0,32,32,47,47,2,0,31,31,46,46,2,0,34,34,49, + 49,330,0,84,1,0,0,0,2,87,1,0,0,0,4,104,1,0,0,0,6,106,1,0,0,0,8,117,1,0, + 0,0,10,125,1,0,0,0,12,131,1,0,0,0,14,133,1,0,0,0,16,135,1,0,0,0,18,139, + 1,0,0,0,20,143,1,0,0,0,22,155,1,0,0,0,24,160,1,0,0,0,26,165,1,0,0,0,28, + 170,1,0,0,0,30,173,1,0,0,0,32,176,1,0,0,0,34,180,1,0,0,0,36,185,1,0,0, + 0,38,187,1,0,0,0,40,198,1,0,0,0,42,200,1,0,0,0,44,215,1,0,0,0,46,220,1, + 0,0,0,48,225,1,0,0,0,50,234,1,0,0,0,52,245,1,0,0,0,54,247,1,0,0,0,56,269, + 1,0,0,0,58,271,1,0,0,0,60,273,1,0,0,0,62,283,1,0,0,0,64,288,1,0,0,0,66, + 294,1,0,0,0,68,298,1,0,0,0,70,300,1,0,0,0,72,315,1,0,0,0,74,320,1,0,0, + 0,76,77,3,2,1,0,77,78,5,0,0,1,78,85,1,0,0,0,79,80,3,12,6,0,80,81,3,62, + 31,0,81,82,3,14,7,0,82,83,5,0,0,1,83,85,1,0,0,0,84,76,1,0,0,0,84,79,1, + 0,0,0,85,1,1,0,0,0,86,88,3,4,2,0,87,86,1,0,0,0,88,89,1,0,0,0,89,87,1,0, + 0,0,89,90,1,0,0,0,90,3,1,0,0,0,91,93,3,6,3,0,92,91,1,0,0,0,93,94,1,0,0, + 0,94,95,1,0,0,0,94,92,1,0,0,0,95,105,1,0,0,0,96,98,3,8,4,0,97,96,1,0,0, + 0,98,99,1,0,0,0,99,100,1,0,0,0,99,97,1,0,0,0,100,105,1,0,0,0,101,105,3, + 16,8,0,102,105,3,18,9,0,103,105,3,20,10,0,104,92,1,0,0,0,104,97,1,0,0, + 0,104,101,1,0,0,0,104,102,1,0,0,0,104,103,1,0,0,0,105,5,1,0,0,0,106,112, + 5,3,0,0,107,111,3,8,4,0,108,111,3,16,8,0,109,111,3,18,9,0,110,107,1,0, + 0,0,110,108,1,0,0,0,110,109,1,0,0,0,111,114,1,0,0,0,112,110,1,0,0,0,112, + 113,1,0,0,0,113,115,1,0,0,0,114,112,1,0,0,0,115,116,5,8,0,0,116,7,1,0, + 0,0,117,118,3,10,5,0,118,119,5,5,0,0,119,120,6,4,-1,0,120,9,1,0,0,0,121, + 122,5,2,0,0,122,126,6,5,-1,0,123,124,5,7,0,0,124,126,6,5,-1,0,125,121, + 1,0,0,0,125,123,1,0,0,0,126,11,1,0,0,0,127,128,5,1,0,0,128,132,6,6,-1, + 0,129,130,5,6,0,0,130,132,6,6,-1,0,131,127,1,0,0,0,131,129,1,0,0,0,132, + 13,1,0,0,0,133,134,5,10,0,0,134,15,1,0,0,0,135,136,3,12,6,0,136,137,3, + 34,17,0,137,138,3,14,7,0,138,17,1,0,0,0,139,140,3,12,6,0,140,141,3,36, + 18,0,141,142,3,14,7,0,142,19,1,0,0,0,143,147,3,22,11,0,144,146,3,24,12, + 0,145,144,1,0,0,0,146,149,1,0,0,0,147,145,1,0,0,0,147,148,1,0,0,0,148, + 151,1,0,0,0,149,147,1,0,0,0,150,152,3,26,13,0,151,150,1,0,0,0,151,152, + 1,0,0,0,152,153,1,0,0,0,153,154,3,32,16,0,154,21,1,0,0,0,155,156,3,12, + 6,0,156,157,3,28,14,0,157,158,3,14,7,0,158,159,3,2,1,0,159,23,1,0,0,0, + 160,161,3,12,6,0,161,162,3,30,15,0,162,163,3,14,7,0,163,164,3,2,1,0,164, + 25,1,0,0,0,165,166,3,12,6,0,166,167,5,43,0,0,167,168,3,14,7,0,168,169, + 3,2,1,0,169,27,1,0,0,0,170,171,5,42,0,0,171,172,3,62,31,0,172,29,1,0,0, + 0,173,174,5,44,0,0,174,175,3,62,31,0,175,31,1,0,0,0,176,177,3,12,6,0,177, + 178,5,45,0,0,178,179,3,14,7,0,179,33,1,0,0,0,180,181,5,51,0,0,181,182, + 7,0,0,0,182,183,3,62,31,0,183,184,6,17,-1,0,184,35,1,0,0,0,185,186,3,56, + 28,0,186,37,1,0,0,0,187,192,3,40,20,0,188,189,5,35,0,0,189,191,3,40,20, + 0,190,188,1,0,0,0,191,194,1,0,0,0,192,190,1,0,0,0,192,193,1,0,0,0,193, + 39,1,0,0,0,194,192,1,0,0,0,195,199,3,46,23,0,196,199,5,50,0,0,197,199, + 3,42,21,0,198,195,1,0,0,0,198,196,1,0,0,0,198,197,1,0,0,0,199,41,1,0,0, + 0,200,204,5,11,0,0,201,203,3,44,22,0,202,201,1,0,0,0,203,206,1,0,0,0,204, + 202,1,0,0,0,204,205,1,0,0,0,205,207,1,0,0,0,206,204,1,0,0,0,207,209,5, + 53,0,0,208,210,5,59,0,0,209,208,1,0,0,0,209,210,1,0,0,0,210,211,1,0,0, + 0,211,212,5,58,0,0,212,213,5,56,0,0,213,214,4,21,0,1,214,43,1,0,0,0,215, + 218,5,54,0,0,216,217,5,55,0,0,217,219,5,60,0,0,218,216,1,0,0,0,218,219, + 1,0,0,0,219,45,1,0,0,0,220,223,3,48,24,0,221,222,7,1,0,0,222,224,3,46, + 23,0,223,221,1,0,0,0,223,224,1,0,0,0,224,47,1,0,0,0,225,228,3,50,25,0, + 226,227,7,2,0,0,227,229,3,48,24,0,228,226,1,0,0,0,228,229,1,0,0,0,229, + 49,1,0,0,0,230,231,3,58,29,0,231,232,3,52,26,0,232,235,1,0,0,0,233,235, + 3,52,26,0,234,230,1,0,0,0,234,233,1,0,0,0,235,51,1,0,0,0,236,246,5,12, + 0,0,237,238,5,51,0,0,238,246,6,26,-1,0,239,246,5,13,0,0,240,246,3,54,27, + 0,241,242,5,15,0,0,242,243,3,62,31,0,243,244,5,16,0,0,244,246,1,0,0,0, + 245,236,1,0,0,0,245,237,1,0,0,0,245,239,1,0,0,0,245,240,1,0,0,0,245,241, + 1,0,0,0,246,53,1,0,0,0,247,248,5,39,0,0,248,250,5,15,0,0,249,251,3,38, + 19,0,250,249,1,0,0,0,250,251,1,0,0,0,251,252,1,0,0,0,252,253,5,16,0,0, + 253,254,6,27,-1,0,254,55,1,0,0,0,255,256,5,40,0,0,256,258,5,15,0,0,257, + 259,3,38,19,0,258,257,1,0,0,0,258,259,1,0,0,0,259,260,1,0,0,0,260,261, + 5,16,0,0,261,270,6,28,-1,0,262,263,5,41,0,0,263,265,5,15,0,0,264,266,3, + 60,30,0,265,264,1,0,0,0,265,266,1,0,0,0,266,267,1,0,0,0,267,268,5,16,0, + 0,268,270,6,28,-1,0,269,255,1,0,0,0,269,262,1,0,0,0,270,57,1,0,0,0,271, + 272,7,1,0,0,272,59,1,0,0,0,273,278,5,51,0,0,274,275,5,35,0,0,275,277,5, + 51,0,0,276,274,1,0,0,0,277,280,1,0,0,0,278,276,1,0,0,0,278,279,1,0,0,0, + 279,281,1,0,0,0,280,278,1,0,0,0,281,282,6,30,-1,0,282,61,1,0,0,0,283,286, + 3,64,32,0,284,285,7,3,0,0,285,287,3,62,31,0,286,284,1,0,0,0,286,287,1, + 0,0,0,287,63,1,0,0,0,288,291,3,66,33,0,289,290,7,4,0,0,290,292,3,64,32, + 0,291,289,1,0,0,0,291,292,1,0,0,0,292,65,1,0,0,0,293,295,7,5,0,0,294,293, + 1,0,0,0,294,295,1,0,0,0,295,296,1,0,0,0,296,297,3,68,34,0,297,67,1,0,0, + 0,298,299,3,70,35,0,299,69,1,0,0,0,300,304,3,74,37,0,301,302,3,72,36,0, + 302,303,3,74,37,0,303,305,1,0,0,0,304,301,1,0,0,0,304,305,1,0,0,0,305, + 71,1,0,0,0,306,316,5,26,0,0,307,316,5,25,0,0,308,316,5,28,0,0,309,316, + 5,27,0,0,310,316,5,29,0,0,311,316,5,30,0,0,312,316,5,48,0,0,313,314,5, + 48,0,0,314,316,5,49,0,0,315,306,1,0,0,0,315,307,1,0,0,0,315,308,1,0,0, + 0,315,309,1,0,0,0,315,310,1,0,0,0,315,311,1,0,0,0,315,312,1,0,0,0,315, + 313,1,0,0,0,316,73,1,0,0,0,317,321,5,50,0,0,318,321,5,38,0,0,319,321,3, + 46,23,0,320,317,1,0,0,0,320,318,1,0,0,0,320,319,1,0,0,0,321,75,1,0,0,0, + 31,84,89,94,99,104,110,112,125,131,147,151,192,198,204,209,218,223,228, + 234,245,250,258,265,269,278,286,291,294,304,315,320 + }; + + public static readonly ATN _ATN = + new ATNDeserializer().Deserialize(_serializedATN); + + +} +} // namespace Arcweave.Interpreter diff --git a/CSharp/Interpreter/Generated/ArcscriptParserBaseVisitor.cs b/CSharp/Interpreter/Generated/ArcscriptParserBaseVisitor.cs new file mode 100644 index 0000000..f3cb7c1 --- /dev/null +++ b/CSharp/Interpreter/Generated/ArcscriptParserBaseVisitor.cs @@ -0,0 +1,419 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// ANTLR Version: 4.13.1 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +// Generated from ArcscriptParser.g4 by ANTLR 4.13.1 + +// Unreachable code detected +#pragma warning disable 0162 +// The variable '...' is assigned but its value is never used +#pragma warning disable 0219 +// Missing XML comment for publicly visible type or member '...' +#pragma warning disable 1591 +// Ambiguous reference in cref attribute +#pragma warning disable 419 + +namespace Arcweave.Interpreter { +using Antlr4.Runtime.Misc; +using Antlr4.Runtime.Tree; +using IToken = Antlr4.Runtime.IToken; +using ParserRuleContext = Antlr4.Runtime.ParserRuleContext; + +/// +/// This class provides an empty implementation of , +/// which can be extended to create a visitor which only needs to handle a subset +/// of the available methods. +/// +/// The return type of the visit operation. +[System.CodeDom.Compiler.GeneratedCode("ANTLR", "4.13.1")] +[System.Diagnostics.DebuggerNonUserCode] +[System.CLSCompliant(false)] +public partial class ArcscriptParserBaseVisitor : AbstractParseTreeVisitor, IArcscriptParserVisitor { + /// + /// Visit a parse tree produced by . + /// + /// The default implementation returns the result of calling + /// on . + /// + /// + /// The parse tree. + /// The visitor result. + public virtual Result VisitInput([NotNull] ArcscriptParser.InputContext context) { return VisitChildren(context); } + /// + /// Visit a parse tree produced by . + /// + /// The default implementation returns the result of calling + /// on . + /// + /// + /// The parse tree. + /// The visitor result. + public virtual Result VisitScript([NotNull] ArcscriptParser.ScriptContext context) { return VisitChildren(context); } + /// + /// Visit a parse tree produced by . + /// + /// The default implementation returns the result of calling + /// on . + /// + /// + /// The parse tree. + /// The visitor result. + public virtual Result VisitScript_section([NotNull] ArcscriptParser.Script_sectionContext context) { return VisitChildren(context); } + /// + /// Visit a parse tree produced by . + /// + /// The default implementation returns the result of calling + /// on . + /// + /// + /// The parse tree. + /// The visitor result. + public virtual Result VisitBlockquote([NotNull] ArcscriptParser.BlockquoteContext context) { return VisitChildren(context); } + /// + /// Visit a parse tree produced by . + /// + /// The default implementation returns the result of calling + /// on . + /// + /// + /// The parse tree. + /// The visitor result. + public virtual Result VisitParagraph([NotNull] ArcscriptParser.ParagraphContext context) { return VisitChildren(context); } + /// + /// Visit a parse tree produced by . + /// + /// The default implementation returns the result of calling + /// on . + /// + /// + /// The parse tree. + /// The visitor result. + public virtual Result VisitParagraph_start([NotNull] ArcscriptParser.Paragraph_startContext context) { return VisitChildren(context); } + /// + /// Visit a parse tree produced by . + /// + /// The default implementation returns the result of calling + /// on . + /// + /// + /// The parse tree. + /// The visitor result. + public virtual Result VisitCodestart([NotNull] ArcscriptParser.CodestartContext context) { return VisitChildren(context); } + /// + /// Visit a parse tree produced by . + /// + /// The default implementation returns the result of calling + /// on . + /// + /// + /// The parse tree. + /// The visitor result. + public virtual Result VisitCodeend([NotNull] ArcscriptParser.CodeendContext context) { return VisitChildren(context); } + /// + /// Visit a parse tree produced by . + /// + /// The default implementation returns the result of calling + /// on . + /// + /// + /// The parse tree. + /// The visitor result. + public virtual Result VisitAssignment_segment([NotNull] ArcscriptParser.Assignment_segmentContext context) { return VisitChildren(context); } + /// + /// Visit a parse tree produced by . + /// + /// The default implementation returns the result of calling + /// on . + /// + /// + /// The parse tree. + /// The visitor result. + public virtual Result VisitFunction_call_segment([NotNull] ArcscriptParser.Function_call_segmentContext context) { return VisitChildren(context); } + /// + /// Visit a parse tree produced by . + /// + /// The default implementation returns the result of calling + /// on . + /// + /// + /// The parse tree. + /// The visitor result. + public virtual Result VisitConditional_section([NotNull] ArcscriptParser.Conditional_sectionContext context) { return VisitChildren(context); } + /// + /// Visit a parse tree produced by . + /// + /// The default implementation returns the result of calling + /// on . + /// + /// + /// The parse tree. + /// The visitor result. + public virtual Result VisitIf_section([NotNull] ArcscriptParser.If_sectionContext context) { return VisitChildren(context); } + /// + /// Visit a parse tree produced by . + /// + /// The default implementation returns the result of calling + /// on . + /// + /// + /// The parse tree. + /// The visitor result. + public virtual Result VisitElse_if_section([NotNull] ArcscriptParser.Else_if_sectionContext context) { return VisitChildren(context); } + /// + /// Visit a parse tree produced by . + /// + /// The default implementation returns the result of calling + /// on . + /// + /// + /// The parse tree. + /// The visitor result. + public virtual Result VisitElse_section([NotNull] ArcscriptParser.Else_sectionContext context) { return VisitChildren(context); } + /// + /// Visit a parse tree produced by . + /// + /// The default implementation returns the result of calling + /// on . + /// + /// + /// The parse tree. + /// The visitor result. + public virtual Result VisitIf_clause([NotNull] ArcscriptParser.If_clauseContext context) { return VisitChildren(context); } + /// + /// Visit a parse tree produced by . + /// + /// The default implementation returns the result of calling + /// on . + /// + /// + /// The parse tree. + /// The visitor result. + public virtual Result VisitElse_if_clause([NotNull] ArcscriptParser.Else_if_clauseContext context) { return VisitChildren(context); } + /// + /// Visit a parse tree produced by . + /// + /// The default implementation returns the result of calling + /// on . + /// + /// + /// The parse tree. + /// The visitor result. + public virtual Result VisitEndif_segment([NotNull] ArcscriptParser.Endif_segmentContext context) { return VisitChildren(context); } + /// + /// Visit a parse tree produced by . + /// + /// The default implementation returns the result of calling + /// on . + /// + /// + /// The parse tree. + /// The visitor result. + public virtual Result VisitStatement_assignment([NotNull] ArcscriptParser.Statement_assignmentContext context) { return VisitChildren(context); } + /// + /// Visit a parse tree produced by . + /// + /// The default implementation returns the result of calling + /// on . + /// + /// + /// The parse tree. + /// The visitor result. + public virtual Result VisitStatement_function_call([NotNull] ArcscriptParser.Statement_function_callContext context) { return VisitChildren(context); } + /// + /// Visit a parse tree produced by . + /// + /// The default implementation returns the result of calling + /// on . + /// + /// + /// The parse tree. + /// The visitor result. + public virtual Result VisitArgument_list([NotNull] ArcscriptParser.Argument_listContext context) { return VisitChildren(context); } + /// + /// Visit a parse tree produced by . + /// + /// The default implementation returns the result of calling + /// on . + /// + /// + /// The parse tree. + /// The visitor result. + public virtual Result VisitArgument([NotNull] ArcscriptParser.ArgumentContext context) { return VisitChildren(context); } + /// + /// Visit a parse tree produced by . + /// + /// The default implementation returns the result of calling + /// on . + /// + /// + /// The parse tree. + /// The visitor result. + public virtual Result VisitMention([NotNull] ArcscriptParser.MentionContext context) { return VisitChildren(context); } + /// + /// Visit a parse tree produced by . + /// + /// The default implementation returns the result of calling + /// on . + /// + /// + /// The parse tree. + /// The visitor result. + public virtual Result VisitMention_attributes([NotNull] ArcscriptParser.Mention_attributesContext context) { return VisitChildren(context); } + /// + /// Visit a parse tree produced by . + /// + /// The default implementation returns the result of calling + /// on . + /// + /// + /// The parse tree. + /// The visitor result. + public virtual Result VisitAdditive_numeric_expression([NotNull] ArcscriptParser.Additive_numeric_expressionContext context) { return VisitChildren(context); } + /// + /// Visit a parse tree produced by . + /// + /// The default implementation returns the result of calling + /// on . + /// + /// + /// The parse tree. + /// The visitor result. + public virtual Result VisitMultiplicative_numeric_expression([NotNull] ArcscriptParser.Multiplicative_numeric_expressionContext context) { return VisitChildren(context); } + /// + /// Visit a parse tree produced by . + /// + /// The default implementation returns the result of calling + /// on . + /// + /// + /// The parse tree. + /// The visitor result. + public virtual Result VisitSigned_unary_numeric_expression([NotNull] ArcscriptParser.Signed_unary_numeric_expressionContext context) { return VisitChildren(context); } + /// + /// Visit a parse tree produced by . + /// + /// The default implementation returns the result of calling + /// on . + /// + /// + /// The parse tree. + /// The visitor result. + public virtual Result VisitUnary_numeric_expression([NotNull] ArcscriptParser.Unary_numeric_expressionContext context) { return VisitChildren(context); } + /// + /// Visit a parse tree produced by . + /// + /// The default implementation returns the result of calling + /// on . + /// + /// + /// The parse tree. + /// The visitor result. + public virtual Result VisitFunction_call([NotNull] ArcscriptParser.Function_callContext context) { return VisitChildren(context); } + /// + /// Visit a parse tree produced by . + /// + /// The default implementation returns the result of calling + /// on . + /// + /// + /// The parse tree. + /// The visitor result. + public virtual Result VisitVoid_function_call([NotNull] ArcscriptParser.Void_function_callContext context) { return VisitChildren(context); } + /// + /// Visit a parse tree produced by . + /// + /// The default implementation returns the result of calling + /// on . + /// + /// + /// The parse tree. + /// The visitor result. + public virtual Result VisitSign([NotNull] ArcscriptParser.SignContext context) { return VisitChildren(context); } + /// + /// Visit a parse tree produced by . + /// + /// The default implementation returns the result of calling + /// on . + /// + /// + /// The parse tree. + /// The visitor result. + public virtual Result VisitVariable_list([NotNull] ArcscriptParser.Variable_listContext context) { return VisitChildren(context); } + /// + /// Visit a parse tree produced by . + /// + /// The default implementation returns the result of calling + /// on . + /// + /// + /// The parse tree. + /// The visitor result. + public virtual Result VisitCompound_condition_or([NotNull] ArcscriptParser.Compound_condition_orContext context) { return VisitChildren(context); } + /// + /// Visit a parse tree produced by . + /// + /// The default implementation returns the result of calling + /// on . + /// + /// + /// The parse tree. + /// The visitor result. + public virtual Result VisitCompound_condition_and([NotNull] ArcscriptParser.Compound_condition_andContext context) { return VisitChildren(context); } + /// + /// Visit a parse tree produced by . + /// + /// The default implementation returns the result of calling + /// on . + /// + /// + /// The parse tree. + /// The visitor result. + public virtual Result VisitNegated_unary_condition([NotNull] ArcscriptParser.Negated_unary_conditionContext context) { return VisitChildren(context); } + /// + /// Visit a parse tree produced by . + /// + /// The default implementation returns the result of calling + /// on . + /// + /// + /// The parse tree. + /// The visitor result. + public virtual Result VisitUnary_condition([NotNull] ArcscriptParser.Unary_conditionContext context) { return VisitChildren(context); } + /// + /// Visit a parse tree produced by . + /// + /// The default implementation returns the result of calling + /// on . + /// + /// + /// The parse tree. + /// The visitor result. + public virtual Result VisitCondition([NotNull] ArcscriptParser.ConditionContext context) { return VisitChildren(context); } + /// + /// Visit a parse tree produced by . + /// + /// The default implementation returns the result of calling + /// on . + /// + /// + /// The parse tree. + /// The visitor result. + public virtual Result VisitConditional_operator([NotNull] ArcscriptParser.Conditional_operatorContext context) { return VisitChildren(context); } + /// + /// Visit a parse tree produced by . + /// + /// The default implementation returns the result of calling + /// on . + /// + /// + /// The parse tree. + /// The visitor result. + public virtual Result VisitExpression([NotNull] ArcscriptParser.ExpressionContext context) { return VisitChildren(context); } +} +} // namespace Arcweave.Interpreter diff --git a/CSharp/Interpreter/Generated/ArcscriptParserVisitor.cs b/CSharp/Interpreter/Generated/ArcscriptParserVisitor.cs new file mode 100644 index 0000000..51ce141 --- /dev/null +++ b/CSharp/Interpreter/Generated/ArcscriptParserVisitor.cs @@ -0,0 +1,264 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// ANTLR Version: 4.13.1 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +// Generated from ArcscriptParser.g4 by ANTLR 4.13.1 + +// Unreachable code detected +#pragma warning disable 0162 +// The variable '...' is assigned but its value is never used +#pragma warning disable 0219 +// Missing XML comment for publicly visible type or member '...' +#pragma warning disable 1591 +// Ambiguous reference in cref attribute +#pragma warning disable 419 + +namespace Arcweave.Interpreter { +using Antlr4.Runtime.Misc; +using Antlr4.Runtime.Tree; +using IToken = Antlr4.Runtime.IToken; + +/// +/// This interface defines a complete generic visitor for a parse tree produced +/// by . +/// +/// The return type of the visit operation. +[System.CodeDom.Compiler.GeneratedCode("ANTLR", "4.13.1")] +[System.CLSCompliant(false)] +public interface IArcscriptParserVisitor : IParseTreeVisitor { + /// + /// Visit a parse tree produced by . + /// + /// The parse tree. + /// The visitor result. + Result VisitInput([NotNull] ArcscriptParser.InputContext context); + /// + /// Visit a parse tree produced by . + /// + /// The parse tree. + /// The visitor result. + Result VisitScript([NotNull] ArcscriptParser.ScriptContext context); + /// + /// Visit a parse tree produced by . + /// + /// The parse tree. + /// The visitor result. + Result VisitScript_section([NotNull] ArcscriptParser.Script_sectionContext context); + /// + /// Visit a parse tree produced by . + /// + /// The parse tree. + /// The visitor result. + Result VisitBlockquote([NotNull] ArcscriptParser.BlockquoteContext context); + /// + /// Visit a parse tree produced by . + /// + /// The parse tree. + /// The visitor result. + Result VisitParagraph([NotNull] ArcscriptParser.ParagraphContext context); + /// + /// Visit a parse tree produced by . + /// + /// The parse tree. + /// The visitor result. + Result VisitParagraph_start([NotNull] ArcscriptParser.Paragraph_startContext context); + /// + /// Visit a parse tree produced by . + /// + /// The parse tree. + /// The visitor result. + Result VisitCodestart([NotNull] ArcscriptParser.CodestartContext context); + /// + /// Visit a parse tree produced by . + /// + /// The parse tree. + /// The visitor result. + Result VisitCodeend([NotNull] ArcscriptParser.CodeendContext context); + /// + /// Visit a parse tree produced by . + /// + /// The parse tree. + /// The visitor result. + Result VisitAssignment_segment([NotNull] ArcscriptParser.Assignment_segmentContext context); + /// + /// Visit a parse tree produced by . + /// + /// The parse tree. + /// The visitor result. + Result VisitFunction_call_segment([NotNull] ArcscriptParser.Function_call_segmentContext context); + /// + /// Visit a parse tree produced by . + /// + /// The parse tree. + /// The visitor result. + Result VisitConditional_section([NotNull] ArcscriptParser.Conditional_sectionContext context); + /// + /// Visit a parse tree produced by . + /// + /// The parse tree. + /// The visitor result. + Result VisitIf_section([NotNull] ArcscriptParser.If_sectionContext context); + /// + /// Visit a parse tree produced by . + /// + /// The parse tree. + /// The visitor result. + Result VisitElse_if_section([NotNull] ArcscriptParser.Else_if_sectionContext context); + /// + /// Visit a parse tree produced by . + /// + /// The parse tree. + /// The visitor result. + Result VisitElse_section([NotNull] ArcscriptParser.Else_sectionContext context); + /// + /// Visit a parse tree produced by . + /// + /// The parse tree. + /// The visitor result. + Result VisitIf_clause([NotNull] ArcscriptParser.If_clauseContext context); + /// + /// Visit a parse tree produced by . + /// + /// The parse tree. + /// The visitor result. + Result VisitElse_if_clause([NotNull] ArcscriptParser.Else_if_clauseContext context); + /// + /// Visit a parse tree produced by . + /// + /// The parse tree. + /// The visitor result. + Result VisitEndif_segment([NotNull] ArcscriptParser.Endif_segmentContext context); + /// + /// Visit a parse tree produced by . + /// + /// The parse tree. + /// The visitor result. + Result VisitStatement_assignment([NotNull] ArcscriptParser.Statement_assignmentContext context); + /// + /// Visit a parse tree produced by . + /// + /// The parse tree. + /// The visitor result. + Result VisitStatement_function_call([NotNull] ArcscriptParser.Statement_function_callContext context); + /// + /// Visit a parse tree produced by . + /// + /// The parse tree. + /// The visitor result. + Result VisitArgument_list([NotNull] ArcscriptParser.Argument_listContext context); + /// + /// Visit a parse tree produced by . + /// + /// The parse tree. + /// The visitor result. + Result VisitArgument([NotNull] ArcscriptParser.ArgumentContext context); + /// + /// Visit a parse tree produced by . + /// + /// The parse tree. + /// The visitor result. + Result VisitMention([NotNull] ArcscriptParser.MentionContext context); + /// + /// Visit a parse tree produced by . + /// + /// The parse tree. + /// The visitor result. + Result VisitMention_attributes([NotNull] ArcscriptParser.Mention_attributesContext context); + /// + /// Visit a parse tree produced by . + /// + /// The parse tree. + /// The visitor result. + Result VisitAdditive_numeric_expression([NotNull] ArcscriptParser.Additive_numeric_expressionContext context); + /// + /// Visit a parse tree produced by . + /// + /// The parse tree. + /// The visitor result. + Result VisitMultiplicative_numeric_expression([NotNull] ArcscriptParser.Multiplicative_numeric_expressionContext context); + /// + /// Visit a parse tree produced by . + /// + /// The parse tree. + /// The visitor result. + Result VisitSigned_unary_numeric_expression([NotNull] ArcscriptParser.Signed_unary_numeric_expressionContext context); + /// + /// Visit a parse tree produced by . + /// + /// The parse tree. + /// The visitor result. + Result VisitUnary_numeric_expression([NotNull] ArcscriptParser.Unary_numeric_expressionContext context); + /// + /// Visit a parse tree produced by . + /// + /// The parse tree. + /// The visitor result. + Result VisitFunction_call([NotNull] ArcscriptParser.Function_callContext context); + /// + /// Visit a parse tree produced by . + /// + /// The parse tree. + /// The visitor result. + Result VisitVoid_function_call([NotNull] ArcscriptParser.Void_function_callContext context); + /// + /// Visit a parse tree produced by . + /// + /// The parse tree. + /// The visitor result. + Result VisitSign([NotNull] ArcscriptParser.SignContext context); + /// + /// Visit a parse tree produced by . + /// + /// The parse tree. + /// The visitor result. + Result VisitVariable_list([NotNull] ArcscriptParser.Variable_listContext context); + /// + /// Visit a parse tree produced by . + /// + /// The parse tree. + /// The visitor result. + Result VisitCompound_condition_or([NotNull] ArcscriptParser.Compound_condition_orContext context); + /// + /// Visit a parse tree produced by . + /// + /// The parse tree. + /// The visitor result. + Result VisitCompound_condition_and([NotNull] ArcscriptParser.Compound_condition_andContext context); + /// + /// Visit a parse tree produced by . + /// + /// The parse tree. + /// The visitor result. + Result VisitNegated_unary_condition([NotNull] ArcscriptParser.Negated_unary_conditionContext context); + /// + /// Visit a parse tree produced by . + /// + /// The parse tree. + /// The visitor result. + Result VisitUnary_condition([NotNull] ArcscriptParser.Unary_conditionContext context); + /// + /// Visit a parse tree produced by . + /// + /// The parse tree. + /// The visitor result. + Result VisitCondition([NotNull] ArcscriptParser.ConditionContext context); + /// + /// Visit a parse tree produced by . + /// + /// The parse tree. + /// The visitor result. + Result VisitConditional_operator([NotNull] ArcscriptParser.Conditional_operatorContext context); + /// + /// Visit a parse tree produced by . + /// + /// The parse tree. + /// The visitor result. + Result VisitExpression([NotNull] ArcscriptParser.ExpressionContext context); +} +} // namespace Arcweave.Interpreter diff --git a/CSharp/Interpreter/Generated/AssemblyInfo.cs b/CSharp/Interpreter/Generated/AssemblyInfo.cs new file mode 100644 index 0000000..345f41d --- /dev/null +++ b/CSharp/Interpreter/Generated/AssemblyInfo.cs @@ -0,0 +1,3 @@ +using System; + +[assembly: CLSCompliant(false)] \ No newline at end of file diff --git a/CSharp/Interpreter/INodes/IAttribute.cs b/CSharp/Interpreter/INodes/IAttribute.cs new file mode 100644 index 0000000..2023d33 --- /dev/null +++ b/CSharp/Interpreter/INodes/IAttribute.cs @@ -0,0 +1,29 @@ +namespace Arcweave.Interpreter.INodes +{ + public interface IAttribute + { + public enum DataType + { + Undefined, + StringPlainText, + StringRichText, + ComponentList, + } + + public enum ContainerType + { + Undefined, + Component, + Element, + } + + public string Name { get; } + + public DataType Type { get; } + + public ContainerType containerType { get; } + + public string containerId { get; } + + } +} diff --git a/CSharp/Interpreter/INodes/IBoard.cs b/CSharp/Interpreter/INodes/IBoard.cs new file mode 100644 index 0000000..94faf57 --- /dev/null +++ b/CSharp/Interpreter/INodes/IBoard.cs @@ -0,0 +1,6 @@ +namespace Arcweave.Interpreter.INodes +{ + public interface IBoard + { + } +} diff --git a/CSharp/Interpreter/INodes/IComponent.cs b/CSharp/Interpreter/INodes/IComponent.cs new file mode 100644 index 0000000..8e4efe8 --- /dev/null +++ b/CSharp/Interpreter/INodes/IComponent.cs @@ -0,0 +1,6 @@ +namespace Arcweave.Interpreter.INodes +{ + public interface IComponent : IHasAttributes + { + } +} diff --git a/CSharp/Interpreter/INodes/IConnection.cs b/CSharp/Interpreter/INodes/IConnection.cs new file mode 100644 index 0000000..68d7517 --- /dev/null +++ b/CSharp/Interpreter/INodes/IConnection.cs @@ -0,0 +1,20 @@ +namespace Arcweave.Interpreter.INodes +{ + public interface IConnection + { + public string Id { get; } + public string RawLabel { get; } + public string RuntimeLabel { get; } + + public INode Source { get; } + public INode Target { get; } + + public Arcweave.Project.Project Project { get; } + + public void Set(string label, INode source, INode target); + + public void RunLabelScript(); + + public Arcweave.Project.Path ResolvePath(Arcweave.Project.Path p); + } +} diff --git a/CSharp/Interpreter/INodes/IElement.cs b/CSharp/Interpreter/INodes/IElement.cs new file mode 100644 index 0000000..2e45d8a --- /dev/null +++ b/CSharp/Interpreter/INodes/IElement.cs @@ -0,0 +1,24 @@ +#if GODOT +using Godot.Collections; +#else +using System.Collections.Generic; +#endif +namespace Arcweave.Interpreter.INodes +{ + public interface IElement : INode, IHasAttributes + { + public int Visits { get; set; } + + public string Title { get; } + public string RawContent { get; } + +#if GODOT + public Array Outputs { get; } +#else + public List Outputs { get; } +#endif + public void RunContentScript(); + + public Arcweave.Project.Options GetOptions(); + } +} diff --git a/CSharp/Interpreter/INodes/IHasAttributes.cs b/CSharp/Interpreter/INodes/IHasAttributes.cs new file mode 100644 index 0000000..2a06a67 --- /dev/null +++ b/CSharp/Interpreter/INodes/IHasAttributes.cs @@ -0,0 +1,19 @@ +#if GODOT +using Godot.Collections; +#else +using System.Collections.Generic; +#endif + +namespace Arcweave.Interpreter.INodes +{ + public interface IHasAttributes + { +#if GODOT + Array Attributes { get; } +#else + List Attributes { get; } +#endif + + public void AddAttribute(Arcweave.Project.Attribute attribute); + } +} diff --git a/CSharp/Interpreter/INodes/IHelperClasses.cs b/CSharp/Interpreter/INodes/IHelperClasses.cs new file mode 100644 index 0000000..94ea149 --- /dev/null +++ b/CSharp/Interpreter/INodes/IHelperClasses.cs @@ -0,0 +1,37 @@ +#if GODOT +using Godot.Collections; +#else +using System.Collections.Generic; +#endif +namespace Arcweave.Interpreter.INodes +{ + public interface IOptions + { + public Arcweave.Project.Element Element { get; set; } +#if GODOT + public Array Paths { get; set; } +#else + public List Paths { get; set; } +#endif + public bool HasPaths => Paths != null; + public bool HasOptions => HasPaths && ( Paths.Count > 1 || !string.IsNullOrEmpty(Paths[0].label) ); + } + + public interface IPath + { + public string label { get; set; } + public Arcweave.Project.Element TargetElement { get; set; } +#if GODOT + public Array _connections { get; set; } +#else + public List _connections { get; set; } +#endif + internal bool IsValid => TargetElement != null; + + internal static IPath Invalid => default(IPath); + + public void AppendConnection(Arcweave.Project.Connection connection); + + public void ExecuteAppendedConnectionLabels(); + } +} diff --git a/CSharp/Interpreter/INodes/INode.cs b/CSharp/Interpreter/INodes/INode.cs new file mode 100644 index 0000000..d877dbd --- /dev/null +++ b/CSharp/Interpreter/INodes/INode.cs @@ -0,0 +1,10 @@ +namespace Arcweave.Interpreter.INodes +{ + public partial interface INode + { + string Id { get; } + Arcweave.Project.Project Project { get; } + + Arcweave.Project.Path ResolvePath(Arcweave.Project.Path path); + } +} diff --git a/CSharp/Interpreter/INodes/IProject.cs b/CSharp/Interpreter/INodes/IProject.cs new file mode 100644 index 0000000..b732008 --- /dev/null +++ b/CSharp/Interpreter/INodes/IProject.cs @@ -0,0 +1,20 @@ +#if GODOT +using Godot.Collections; +#else +using System.Collections.Generic; +#endif + +namespace Arcweave.Interpreter.INodes +{ + public interface IProject + { +#if GODOT + public Array Variables { get; } +#else + public List Variables { get; } +#endif + public Arcweave.Project.Element ElementWithId(string id); + + public Arcweave.Project.Variable GetVariable(string name); + } +} diff --git a/CSharp/Interpreter/INodes/IVariable.cs b/CSharp/Interpreter/INodes/IVariable.cs new file mode 100644 index 0000000..b6ec4d6 --- /dev/null +++ b/CSharp/Interpreter/INodes/IVariable.cs @@ -0,0 +1,23 @@ +#if GODOT +using Godot; +#endif + +namespace Arcweave.Interpreter.INodes +{ + public interface IVariable + { + public string Name { get; set; } +#if GODOT + Variant Value { get; } + Variant DefaultValue { get; } +#else + object Value { get; } + object DefaultValue { get; } +#endif + public object ObjectValue { get; } + + System.Type Type { get; } + + public void ResetToDefaultValue(); + } +} diff --git a/CSharp/Interpreter/Nodes.cs b/CSharp/Interpreter/Nodes.cs new file mode 100644 index 0000000..a7a99a0 --- /dev/null +++ b/CSharp/Interpreter/Nodes.cs @@ -0,0 +1,31 @@ +#if GODOT +using Godot; +#endif + +using Arcweave.Interpreter.INodes; + +namespace Arcweave.Project +{ +#if GODOT + public partial class Attribute : GodotObject, IAttribute { } + public partial class Board : GodotObject, IBoard { } + public partial class Component : GodotObject, IComponent { } + public partial class Connection : GodotObject, IConnection { } + public partial class Element : GodotObject, IElement { } + public partial class Project : GodotObject, IProject { } + public partial class Variable : GodotObject, IVariable { } + public partial class Options : GodotObject, IOptions { } + public partial class Path : GodotObject, IPath { } +#else + public partial class Attribute : IAttribute { } + public partial class Board : IBoard { } + public partial class Component : IComponent { } + public partial class Connection : IConnection { } + public partial class Element : IElement { } + public partial class Project : IProject { } + public partial class Variable : IVariable { } + public partial class Options : IOptions { } + public partial class Path : IPath { } +#endif +} + diff --git a/CSharp/Interpreter/Utils.cs b/CSharp/Interpreter/Utils.cs new file mode 100644 index 0000000..a479da2 --- /dev/null +++ b/CSharp/Interpreter/Utils.cs @@ -0,0 +1,27 @@ +namespace Arcweave.Interpreter +{ + public class Utils + { + public static readonly string CODE_HEX_COLOR = "#27b7f5"; + public static string CleanString(string s) + { + if (!string.IsNullOrEmpty(s)) + { + s = s.Replace("", "{bold}").Replace("", "{/bold}"); + s = s.Replace("", "{italic}").Replace("", "{/italic}"); + s = s.Replace("<", string.Empty).Replace(">", string.Empty); + s = s.Replace("

", "\n\n"); + s = s.Replace("", "{code}"); + s = s.Replace("", "{/code}"); + s = System.Text.RegularExpressions.Regex.Replace(s, @"<[^>]*>", string.Empty); + s = s.Replace("{bold}", "[b]").Replace("{/bold}", "[/b]"); + s = s.Replace("{italic}", "[i]").Replace("{/italic}", "[/i]"); + s = s.Replace("{code}", string.Format("", CODE_HEX_COLOR)); + s = s.Replace("{/code}", "\n"); + s = s.TrimEnd(); + return s; + } + return s; + } + } +} diff --git a/CSharp/Project/Attribute.cs b/CSharp/Project/Attribute.cs new file mode 100644 index 0000000..0857d12 --- /dev/null +++ b/CSharp/Project/Attribute.cs @@ -0,0 +1,11 @@ +using Arcweave.Interpreter.INodes; + +namespace Arcweave.Project; + +public partial class Attribute +{ + public string Name { get; } + public IAttribute.DataType Type { get; } + public IAttribute.ContainerType containerType { get; } + public string containerId { get; } +} \ No newline at end of file diff --git a/CSharp/Project/Component.cs b/CSharp/Project/Component.cs new file mode 100644 index 0000000..35d4a43 --- /dev/null +++ b/CSharp/Project/Component.cs @@ -0,0 +1,10 @@ +namespace Arcweave.Project; + +public partial class Component +{ + public List Attributes { get; } + public void AddAttribute(Attribute attribute) + { + throw new NotImplementedException(); + } +} \ No newline at end of file diff --git a/CSharp/Project/Connection.cs b/CSharp/Project/Connection.cs new file mode 100644 index 0000000..24d9127 --- /dev/null +++ b/CSharp/Project/Connection.cs @@ -0,0 +1,27 @@ +using Arcweave.Interpreter.INodes; + +namespace Arcweave.Project; + +public partial class Connection +{ + public string Id { get; } + public string RawLabel { get; } + public string RuntimeLabel { get; } + public INode Source { get; } + public INode Target { get; } + public Project Project { get; } + public void Set(string label, INode source, INode target) + { + throw new NotImplementedException(); + } + + public void RunLabelScript() + { + throw new NotImplementedException(); + } + + public Path ResolvePath(Path p) + { + throw new NotImplementedException(); + } +} \ No newline at end of file diff --git a/CSharp/Project/Element.cs b/CSharp/Project/Element.cs new file mode 100644 index 0000000..e25204b --- /dev/null +++ b/CSharp/Project/Element.cs @@ -0,0 +1,32 @@ +namespace Arcweave.Project; + +public partial class Element +{ + public string Id { get; } + public Project Project { get; } + + public Path ResolvePath(Path path) + { + throw new NotImplementedException(); + } + + public List Attributes { get; } + public void AddAttribute(Attribute attribute) + { + throw new NotImplementedException(); + } + + public int Visits { get; set; } + public string Title { get; } + public string RawContent { get; } + public List Outputs { get; } + public void RunContentScript() + { + throw new NotImplementedException(); + } + + public Options GetOptions() + { + throw new NotImplementedException(); + } +} \ No newline at end of file diff --git a/CSharp/Project/HelperClasses.cs b/CSharp/Project/HelperClasses.cs new file mode 100644 index 0000000..8356bc8 --- /dev/null +++ b/CSharp/Project/HelperClasses.cs @@ -0,0 +1,23 @@ +namespace Arcweave.Project; + +public partial class Options +{ + public Element Element { get; set; } + public List Paths { get; set; } +} + +public partial class Path +{ + public string label { get; set; } + public Element TargetElement { get; set; } + public List _connections { get; set; } + public void AppendConnection(Connection connection) + { + throw new NotImplementedException(); + } + + public void ExecuteAppendedConnectionLabels() + { + throw new NotImplementedException(); + } +} \ No newline at end of file diff --git a/CSharp/Project/Project.cs b/CSharp/Project/Project.cs new file mode 100644 index 0000000..6a61f85 --- /dev/null +++ b/CSharp/Project/Project.cs @@ -0,0 +1,26 @@ +namespace Arcweave.Project; + +public partial class Project +{ + public List Variables { get; } + public Dictionary Elements; + public Project(List variables, Dictionary elements) + { + Variables = variables; + Elements = elements; + } + public Element ElementWithId(string id) + { + if (Elements.ContainsKey(id)) + { + return Elements[id]; + } + + return null; + } + + public Variable GetVariable(string name) + { + return Variables.FirstOrDefault(variable => variable.Name == name); + } +} \ No newline at end of file diff --git a/CSharp/Project/Variable.cs b/CSharp/Project/Variable.cs new file mode 100644 index 0000000..40455b4 --- /dev/null +++ b/CSharp/Project/Variable.cs @@ -0,0 +1,22 @@ +namespace Arcweave.Project; + +public partial class Variable +{ + public string Name { get; set; } + public object Value { get; set; } + public object ObjectValue => Value; + public Type Type { get; } + private object _defaultValue; + public object DefaultValue => _defaultValue; + public Variable(string name, object value) + { + Name = name; + Value = value; + _defaultValue = value; + Type = value.GetType(); + } + public void ResetToDefaultValue() + { + Value = _defaultValue; + } +} \ No newline at end of file diff --git a/CSharp/TestObjects.cs b/CSharp/TestObjects.cs new file mode 100644 index 0000000..4e0a77f --- /dev/null +++ b/CSharp/TestObjects.cs @@ -0,0 +1,25 @@ +namespace Arcweave; + +public struct TestVariable +{ + public string id; + public string name; + public string type; + public object value; +} + +public struct TestCase +{ + public string code; + public Dictionary changes; + public string? output; + public string elementId; + public object result; + public Dictionary? visits; +} + +public struct TestFile +{ + public Dictionary initialVars; + public List cases; +} \ No newline at end of file diff --git a/CSharp/UnitTests.cs b/CSharp/UnitTests.cs new file mode 100644 index 0000000..83c9cfe --- /dev/null +++ b/CSharp/UnitTests.cs @@ -0,0 +1,134 @@ +using NUnit.Framework; +using Newtonsoft.Json; +using Arcweave.Interpreter; +using Arcweave.Project; + +namespace Arcweave; + +public class Tests +{ + struct TestData + { + public readonly Dictionary Variables; + public readonly List Cases; + + public TestData(Dictionary variables, List cases) + { + Variables = variables; + Cases = cases; + } + } + + private static IEnumerable GetValidTestData() + { + var tests = LoadJson("../../../__tests__/valid.json"); + + foreach (var testCase in tests.Cases) + { + yield return new TestCaseData(tests.Variables, testCase); + } + } + + private static IEnumerable GetConditionsTestData() + { + var tests = LoadJson("../../../__tests__/conditions.json"); + + foreach (var validTestsCase in tests.Cases) + { + yield return new TestCaseData(tests.Variables, validTestsCase); + } + } + + private static TestData LoadJson(string filePath) + { + using var r = new StreamReader(filePath); + var json = r.ReadToEnd(); + var testFile = JsonConvert.DeserializeObject(json); + var variables = new Dictionary(); + + foreach (var variable in testFile.initialVars.Values) + { + if (variable.value is long l) + { + variables[variable.id] = new Variable(variable.name, (int) l); + } + else + { + variables[variable.id] = new Variable(variable.name, variable.value); + } + } + + return new TestData(variables, testFile.cases); + } + + private static Dictionary? ChangesByName(Dictionary variables, + Dictionary? changes) + { + if (changes == null || changes.Count == 0) + { + return null; + } + var changesByName = new Dictionary(); + foreach (var varChange in changes) + { + changesByName[variables[varChange.Key].Name] = varChange.Value; + } + + return changesByName; + } + + [Test] + [TestCaseSource(nameof(GetValidTestData))] + public void ValidTests(Dictionary variables, TestCase testCase) + { + var elements = new Dictionary(); + if (testCase.visits != null) + { + foreach (var kvp in testCase.visits) + { + elements[kvp.Key] = new Element + { + Visits = kvp.Value + }; + } + } + Console.WriteLine("Testing Case: " + testCase.code); + var project = new Project.Project(variables.Values.ToList(), elements); + var i = new AwInterpreter(project, testCase.elementId); + var output = i.RunScript(testCase.code); + + if (testCase.output != null) + { + Assert.That(output.Output, Is.EqualTo(testCase.output)); + } + + var changesByName = ChangesByName(variables, testCase.changes); + if (changesByName != null) + { + Assert.That(output.Changes, Is.EqualTo(changesByName)); + } + } + + [Test] + [TestCaseSource(nameof(GetConditionsTestData))] + public void ConditionTests(Dictionary variables, TestCase testCase) + { + var elements = new Dictionary(); + if (testCase.visits != null) + { + foreach (var kvp in testCase.visits) + { + elements[kvp.Key] = new Element + { + Visits = kvp.Value + }; + } + } + Console.WriteLine("Testing Case: " + testCase.code); + var project = new Project.Project(variables.Values.ToList(), elements); + var i = new AwInterpreter(project, testCase.elementId); + var output = i.RunScript(testCase.code); + + Assert.That(output.Result, Is.EqualTo(testCase.result)); + } +} \ No newline at end of file diff --git a/CSharp/__tests__/conditions.json b/CSharp/__tests__/conditions.json new file mode 100644 index 0000000..88331f1 --- /dev/null +++ b/CSharp/__tests__/conditions.json @@ -0,0 +1,100 @@ +{ + "initialVars": { + "var1": { + "id": "var1", + "name": "x", + "type": "integer", + "value": 14 + }, + "var2": { + "id": "var2", + "name": "y", + "type": "integer", + "value": 15 + }, + "var3": { + "id": "var3", + "name": "z", + "type": "integer", + "value": 0 + }, + "var4": { + "id": "var4", + "name": "w", + "type": "string", + "value": "Dummy text" + }, + "var5": { + "id": "var5", + "name": "$c5", + "type": "integer", + "value": 0 + }, + "var6": { + "id": "var6", + "name": "_a", + "type": "boolean", + "value": false + }, + "var7": { + "id": "var7", + "name": "xy", + "type": "integer", + "value": -1 + } + }, + "cases": [ + { + "code": "
x >= 14
", + "result": true + }, + { + "code": "
x == 14
", + "result": true + }, + { + "code": "
x is 14
", + "result": true + }, + { + "code": "
x == 45
", + "result": false + }, + { + "code": "
x is 45
", + "result": false + }, + { + "code": "
x == 14 && y == 15
", + "result": true + }, + { + "code": "
x == 14 and y == 15
", + "result": true + }, + { + "code": "
x == 3 || y != 0
", + "result": true + }, + { + "code": "
x == 3 or y != 0
", + "result": true + }, + { + "code": "
w == \"Dummy text\"
", + "result": true + }, + { + "code": "
w != \"Dummy text\"
", + "result": false + }, + { + "code": "
w is not \"Dummy text\"
", + "result": false + }, + { + "code": "
x is not \"Dummy text\"
", + "result": true + } + ] +} \ No newline at end of file diff --git a/CSharp/__tests__/parseErrors.json b/CSharp/__tests__/parseErrors.json new file mode 100644 index 0000000..07d79d9 --- /dev/null +++ b/CSharp/__tests__/parseErrors.json @@ -0,0 +1,96 @@ +{ + "initialVars": { + "var1": { + "id": "var1", + "name": "x", + "type": "integer", + "value": 14 + }, + "var2": { + "id": "var2", + "name": "y", + "type": "integer", + "value": 15 + }, + "var3": { + "id": "var3", + "name": "z", + "type": "integer", + "value": 0 + }, + "var4": { + "id": "var4", + "name": "w", + "type": "string", + "value": "Dummy text" + }, + "var5": { + "id": "var5", + "name": "$c5", + "type": "integer", + "value": 0 + }, + "var6": { + "id": "var6", + "name": "_a", + "type": "boolean", + "value": false + }, + "var7": { + "id": "var7", + "name": "xy", + "type": "integer", + "value": -1 + } + }, + "cases": [ + { + "code": "
p = 1
", + "error": "parse" + }, + { + "code": "
x = p
", + "error": "parse" + }, + { + "code": "
show(x, y, z, abc)
", + "error": "parse" + }, + { + "code": "
testFunction(x, y)
", + "error": "parse" + }, + { + "code": "
x = 1;
", + "error": "parse" + }, + { + "code": "
We want to be friends
", + "error": "parse" + }, + { + "code": "
x = sqr()
", + "error": "parse" + }, + { + "code": "
x = random(2)
", + "error": "parse" + }, + { + "code": "
y = 33
reset(13)
", + "error": "parse" + }, + { + "code": "
ελληνικά
", + "error": "parse" + }, + { + "code": "
visits(Untitled Comp) == 9
", + "error": "parse" + }, + { + "code": "

Test

if true

inside

endif

this

", + "error": "parse" + } + ] +} \ No newline at end of file diff --git a/CSharp/__tests__/replaceVariables.json b/CSharp/__tests__/replaceVariables.json new file mode 100644 index 0000000..d4815e1 --- /dev/null +++ b/CSharp/__tests__/replaceVariables.json @@ -0,0 +1,62 @@ +{ + "initialVars": { + "var1": { + "id": "var1", + "name": "x", + "type": "integer", + "value": 14 + }, + "var2": { + "id": "var2", + "name": "y", + "type": "integer", + "value": 15 + }, + "var3": { + "id": "var3", + "name": "z", + "type": "integer", + "value": 0 + }, + "var4": { + "id": "var4", + "name": "w", + "type": "string", + "value": "Dummy text" + }, + "var5": { + "id": "var5", + "name": "$c5", + "type": "integer", + "value": 0 + }, + "var6": { + "id": "var6", + "name": "_a", + "type": "boolean", + "value": false + }, + "var7": { + "id": "var7", + "name": "xy", + "type": "integer", + "value": -1 + } + }, + "cases": [ + { + "code": "
x = x + 2 * sqrt(x)
y = 5 + x
", + "variableChanges": { + "var1": "zed" + }, + "result": "
zed = zed + 2 * sqrt(zed)
y = 5 + zed
" + }, + { + "code": "
x = \"x marks the spot\"
xy = 5 + x
", + "variableChanges": { + "var1": "zed" + }, + "result": "
zed = \"x marks the spot\"
xy = 5 + zed
" + } + ] +} \ No newline at end of file diff --git a/CSharp/__tests__/runtimeErrors.json b/CSharp/__tests__/runtimeErrors.json new file mode 100644 index 0000000..d0b6382 --- /dev/null +++ b/CSharp/__tests__/runtimeErrors.json @@ -0,0 +1,60 @@ +{ + "initialVars": { + "var1": { + "id": "var1", + "name": "x", + "type": "integer", + "value": 14 + }, + "var2": { + "id": "var2", + "name": "y", + "type": "integer", + "value": 15 + }, + "var3": { + "id": "var3", + "name": "z", + "type": "integer", + "value": 0 + }, + "var4": { + "id": "var4", + "name": "w", + "type": "string", + "value": "Dummy text" + }, + "var5": { + "id": "var5", + "name": "$c5", + "type": "integer", + "value": 0 + }, + "var6": { + "id": "var6", + "name": "_a", + "type": "boolean", + "value": false + }, + "var7": { + "id": "var7", + "name": "xy", + "type": "integer", + "value": -1 + } + }, + "cases": [ + { + "code": "
x = sqrt(-3)
", + "error": "runtime" + }, + { + "code": "
x = 3 / 0
", + "error": "runtime" + }, + { + "code": "
x = roll(\"2\")
", + "error": "runtime" + } + ] +} \ No newline at end of file diff --git a/CSharp/__tests__/valid.json b/CSharp/__tests__/valid.json new file mode 100644 index 0000000..d5179aa --- /dev/null +++ b/CSharp/__tests__/valid.json @@ -0,0 +1,446 @@ +{ + "initialVars": { + "var1": { + "id": "var1", + "name": "x", + "type": "integer", + "value": 14 + }, + "var2": { + "id": "var2", + "name": "y", + "type": "integer", + "value": 15 + }, + "var3": { + "id": "var3", + "name": "z", + "type": "integer", + "value": 0 + }, + "var4": { + "id": "var4", + "name": "w", + "type": "string", + "value": "Dummy text" + }, + "var5": { + "id": "var5", + "name": "$c5", + "type": "integer", + "value": 0 + }, + "var6": { + "id": "var6", + "name": "_a", + "type": "boolean", + "value": false + }, + "var7": { + "id": "var7", + "name": "xy", + "type": "integer", + "value": -1 + }, + "var8": { + "id": "var8", + "name": "man", + "type": "string", + "value": "Different Text" + } + }, + "cases": [ + { + "code": "
x=5
", + "changes": { + "var1": 5 + } + }, + { + "code": "
x=-5
", + "changes": { + "var1": -5 + } + }, + { + "code": "
x=5.23
", + "changes": { + "var1": 5.23 + } + }, + { + "code": "
x=3
y=2
", + "changes": { + "var1": 3, + "var2": 2 + } + }, + { + "code": "
x=\"test\"
", + "changes": { + "var1": "test" + } + }, + { + "code": "
x=true
", + "changes": { + "var1": true + } + }, + { + "code": "
x = y
", + "changes": { + "var1": 15 + } + }, + { + "code": "
x = 5 + 3
", + "changes": { + "var1": 8 + } + }, + { + "code": "
x = sqr(2)
", + "changes": { + "var1": 4 + } + }, + { + "code": "
x = 3 > 2
", + "changes": { + "var1": true + } + }, + { + "code": "
x = 3 >= 2
", + "changes": { + "var1": true + } + }, + { + "code": "
x = 3 < 2
", + "changes": { + "var1": false + } + }, + { + "code": "
x = 3 <= 2
", + "changes": { + "var1": false + } + }, + { + "code": "
x = 3 == 2
", + "changes": { + "var1": false + } + }, + { + "code": "
x = 3 != 2
", + "changes": { + "var1": true + } + }, + { + "code": "
_a = !(3 == 2)
", + "changes": { + "var6": true + } + }, + { + "code": "
_a = not (3 == 2)
", + "changes": { + "var6": true + } + }, + { + "code": "
x = !0
", + "changes": { + "var1": true + } + }, + { + "code": "
x = true || false
", + "changes": { + "var1": true + } + }, + { + "code": "
x = true && false
", + "changes": { + "var1": false + } + }, + { + "code": "
x = -3
y = y + 3
z = sqr(x)
", + "changes": { + "var1": -3, + "var2": 18, + "var3": 9 + } + }, + { + "code": "
x = sqrt(y + 2)
", + "changes": { + "var1": 4.123105625617661 + } + }, + { + "code": "
x = z + 12 == 4 * 3
", + "changes": { + "var1": true + } + }, + { + "code": "
x = y == 15 && !(z == 1)
", + "changes": { + "var1": true + } + }, + { + "code": "
x = (x*x + 3)/y
", + "changes": { + "var1": 13.266666666666667 + } + }, + { + "code": "
x = x*(x + 1)/y
", + "changes": { + "var1": 14 + } + }, + { + "code": "
x += 2
", + "changes": { + "var1": 16 + } + }, + { + "code": "
x -= 2
", + "changes": { + "var1": 12 + } + }, + { + "code": "
x *= 2
", + "changes": { + "var1": 28 + } + }, + { + "code": "
x /= 2
", + "changes": { + "var1": 7 + } + }, + { + "code": "
x = abs(-6)
", + "changes": { + "var1": 6 + } + }, + { + "code": "
x = min(5, -y, 2.3)
", + "changes": { + "var1": -15 + } + }, + { + "code": "
x = max(5, -y, 2.3)
", + "changes": { + "var1": 5 + } + }, + { + "code": "
x = random()
", + "changes": {} + }, + { + "code": "
x = roll(6)
", + "changes": {} + }, + { + "code": "
x = roll(6, 5)
", + "changes": {} + }, + { + "code": "
x = roll(y)
", + "changes": {} + }, + { + "code": "
x = round(2.65)
", + "changes": { + "var1": 3 + } + }, + { + "code": "
show(\"x is \", x)
", + "changes": {}, + "output": "

x is 14

" + }, + { + "code": "
y = 33
reset(y)
", + "changes": { + "var2": 15 + } + }, + { + "code": "
x = 16
y = 33
resetAll(y)
", + "changes": { + "var1": 14, + "var2": 33, + "var3": 0, + "var4": "Dummy text", + "var5": 0, + "var6": false, + "var7": -1, + "var8": "Different Text" + } + }, + { + "code": "
$c5 = x
", + "changes": { + "var5": 14 + } + }, + { + "code": "
if (x==14) 
x=5
endif
", + "changes": { + "var1": 5 + } + }, + { + "code": "
if (x==11)
x=5
else
x=7
endif
", + "changes": { + "var1": 7 + } + }, + { + "code": "
if x==3
x=5
elseif x==14
x=2
else
x = 0
endif
", + "changes": { + "var1": 2 + } + }, + { + "code": "

Mein gott!

x = 1

What is that?

", + "changes": { + "var1": 1 + }, + "output": "

Mein gott! What is that?

" + }, + { + "code": "

Hello my dear

if x == 1

We might ride to the mountains.

endif
", + "changes": {}, + "output": "

Hello my dear

" + }, + { + "code": "

You carry

if x == 12

a small knife

elseif y == 12

a large sword

elseif z == 1

just a rotten tomato

else

nothing really

endif
", + "changes": {}, + "output": "

You carry nothing really

" + }, + { + "code": "

How are you?

x = 1

I am fine, thank you.

", + "changes": {}, + "output": "

How are you?

I am fine, thank you.

" + }, + { + "code": "
show(\"Hello friends:\", x)
", + "changes": {}, + "output": "

Hello friends:14

" + }, + { + "code": "
_a = true
if (((_a)))
x = 1
endif
", + "changes": { + "var1": 1, + "var6": true + } + }, + { + "code": "
visits() == 1
", + "visits": { + "a": 1, + "b": 1, + "c": 0 + }, + "elementId": "b", + "result": true + }, + { + "code": "
visits(Untitled Comp) == 9
", + "visits": { + "a": 1, + "b": 1, + "c": 0 + }, + "elementId": "b", + "result": false + }, + { + "code": "

this

text

must

not

be

in

one

paragraph

", + "output": "

this

text

must

not

be

in

one

paragraph

" + }, + { + "code": "

three

separate

lines

just

show(\"one\")
show(\"and\")
show(\"single\")

line

three

more

lines

", + "output": "

three

separate

lines

just one and single line

three

more

lines

" + }, + { + "code": "

This is a blockquote

if x

This is a separate line

endif

This is another blockquote

", + "output": "

This is a blockquote

This is a separate line

This is another blockquote

" + }, + { + "code": "

This is a blockquote

show(x)

test

", + "output": "

This is a blockquote 14

test

" + }, + { + "code": "

This is a blockquote

show(x)

test

", + "output": "

This is a blockquote 14 test

" + }, + { + "code": "

one

if true

two

endif

three

", + "output": "

one

two

three

" + }, + { + "code": "

one

if true

two

endif

three

", + "output": "

one two

three

" + }, + { + "code": "

one

if true

two

endif

three

", + "output": "

one two

three

" + }, + { + "code": "

one

if true
show(x)
endif

three

", + "output": "

one 14

three

" + }, + { + "code": "

one

if true

two

test

four

endif

three

", + "output": "

one two

test

four

three

" + }, + { + "code": "

one

if true

two

test

show(\"four\")
endif

three

", + "output": "

one two

test four

three

" + }, + { + "code": "

one

if false

two

endif

three

", + "output": "

one

three

" + }, + { + "code": "

This is a blockquote

if true

Second blockquote

Separate Line

endif

Outside blockquote

", + "output": "

This is a blockquote

Second blockquote

Separate Line

Outside blockquote

" + }, + { + "code": "

Test

_a = true

this

", + "output": "

Test this

", + "changes": { + "var6": true + } + }, + { + "code": "

Test

show(x)

this

", + "output": "

Test 14 this

" + }, + { + "code": "

this is a test

show(x)

continue

testing

", + "output": "

this is a test

14 continue

testing

" + } + ] +} \ No newline at end of file From 18948c999e73f9e6b4094c01720d84dc111a122b Mon Sep 17 00:00:00 2001 From: Emmanouil Dermitzakis Date: Mon, 19 Feb 2024 21:08:52 +0200 Subject: [PATCH 02/13] fix: Fixes from Godot --- CSharp/Interpreter/ArcscriptExpression.cs | 2 +- CSharp/Interpreter/ArcscriptOutputs.cs | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/CSharp/Interpreter/ArcscriptExpression.cs b/CSharp/Interpreter/ArcscriptExpression.cs index b56042c..017f2eb 100644 --- a/CSharp/Interpreter/ArcscriptExpression.cs +++ b/CSharp/Interpreter/ArcscriptExpression.cs @@ -96,7 +96,7 @@ public class Expression : IComparable return false; } - public int CompareTo(object? other) + public int CompareTo(object other) { Expression o = (Expression)other; DoubleValues fValues = GetDoubleValues(this.Value, o.Value); diff --git a/CSharp/Interpreter/ArcscriptOutputs.cs b/CSharp/Interpreter/ArcscriptOutputs.cs index 90964b1..1f8d6e5 100644 --- a/CSharp/Interpreter/ArcscriptOutputs.cs +++ b/CSharp/Interpreter/ArcscriptOutputs.cs @@ -1,4 +1,8 @@ -namespace Arcweave.Interpreter; +#nullable enable +using System.Collections.Generic; +using System.Linq; + +namespace Arcweave.Interpreter; public interface IOutputNode { From fc5bc34f72fab548f154885a2a2c703b9af4f370 Mon Sep 17 00:00:00 2001 From: Emmanouil Dermitzakis Date: Mon, 19 Feb 2024 21:42:39 +0200 Subject: [PATCH 03/13] chore: Unity changes --- CSharp/Interpreter/ArcscriptOutputs.cs | 210 +++++++++++++------------ 1 file changed, 106 insertions(+), 104 deletions(-) diff --git a/CSharp/Interpreter/ArcscriptOutputs.cs b/CSharp/Interpreter/ArcscriptOutputs.cs index 1f8d6e5..d59e069 100644 --- a/CSharp/Interpreter/ArcscriptOutputs.cs +++ b/CSharp/Interpreter/ArcscriptOutputs.cs @@ -2,151 +2,153 @@ using System.Collections.Generic; using System.Linq; -namespace Arcweave.Interpreter; - -public interface IOutputNode +namespace Arcweave.Interpreter { - public string GetText(); - public void MergeScriptOutput(string text); -} - -public interface IHasParagraphs -{ - public void AppendParagraph(string text); -} - -public class Paragraph : IOutputNode -{ - private string _text; - - public Paragraph(string text) + public interface IOutputNode { - _text = text; + public string GetText(); + public void MergeScriptOutput(string text); } - public void MergeScriptOutput(string text) + public interface IHasParagraphs { - if (text.Length > 0) - { - this._text += ' ' + text; - } + public void AppendParagraph(string text); } - public string GetText() + public class Paragraph : IOutputNode { - return "

" + _text + "

"; - } -} - -public class Blockquote : IHasParagraphs, IOutputNode -{ - public List Paragraphs { get; set; } = new(); + private string _text; - public void AppendParagraph(string text) - { - Paragraphs.Add(new Paragraph(text)); - } - - public void MergeScriptOutput(string text) - { - if (Paragraphs.Count == 0) + public Paragraph(string text) { - AppendParagraph(text); - return; + _text = text; } - - Paragraphs.Last().MergeScriptOutput(text); - } - public string GetText() - { - var output = ""; - foreach (var p in Paragraphs) + public void MergeScriptOutput(string text) { - output += p.GetText(); + if (text.Length > 0) + { + this._text += ' ' + text; + } } - return "
" + output + "
"; + public string GetText() + { + return "

" + _text + "

"; + } } -} - -public class ArcscriptOutputs : IHasParagraphs -{ - private List Outputs { get; } = new(); - private IHasParagraphs? _currentNode; - private bool _addedScript; - public void AppendParagraph(string text) + public class Blockquote : IHasParagraphs, IOutputNode { - Outputs.Add(new Paragraph(text)); - } - - public void AddParagraph(string text) - { - _currentNode ??= this; + public List Paragraphs { get; set; } = new(); - if (_addedScript) + public void AppendParagraph(string text) + { + Paragraphs.Add(new Paragraph(text)); + } + + public void MergeScriptOutput(string text) { - if (Outputs.Count > 0 && Outputs.Last() is Blockquote && _currentNode is not Blockquote) + if (Paragraphs.Count == 0) { AppendParagraph(text); + return; } - else + + Paragraphs.Last().MergeScriptOutput(text); + } + + public string GetText() + { + var output = ""; + foreach (var p in Paragraphs) { - AddScriptOutput(text); + output += p.GetText(); } - _addedScript = false; - return; + + return "
" + output + "
"; } - _currentNode.AppendParagraph(text); } - public void AddBlockquote() + public class ArcscriptOutputs : IHasParagraphs { - if (_addedScript && Outputs.Count > 0) + private List Outputs { get; } = new(); + private IHasParagraphs? _currentNode; + private bool _addedScript; + + public void AppendParagraph(string text) { - IOutputNode n = Outputs.Last(); - if (n is Blockquote blockquote) + Outputs.Add(new Paragraph(text)); + } + + public void AddParagraph(string text) + { + _currentNode ??= this; + + if (_addedScript) { - _currentNode = blockquote; + if (Outputs.Count > 0 && Outputs.Last() is Blockquote && _currentNode is not Blockquote) + { + AppendParagraph(text); + } + else + { + AddScriptOutput(text); + } + _addedScript = false; return; } + _currentNode.AppendParagraph(text); } - Blockquote b = new Blockquote(); - Outputs.Add(b); - _currentNode = b; - } - public void AddScriptOutput(string? text) - { - _addedScript = true; - if (text == null) - { - return; - } - if (Outputs.Count == 0) + public void AddBlockquote() { - Outputs.Add(new Paragraph(text)); - return; + if (_addedScript && Outputs.Count > 0) + { + IOutputNode n = Outputs.Last(); + if (n is Blockquote blockquote) + { + _currentNode = blockquote; + return; + } + } + Blockquote b = new Blockquote(); + Outputs.Add(b); + _currentNode = b; } - var n = Outputs.Last(); - n.MergeScriptOutput(text); - } + public void AddScriptOutput(string? text) + { + _addedScript = true; + if (text == null) + { + return; + } + if (Outputs.Count == 0) + { + Outputs.Add(new Paragraph(text)); + return; + } - public void ExitBlockquote() - { - _currentNode = this; - } + var n = Outputs.Last(); + n.MergeScriptOutput(text); + } - public string GetText() - { - var output = ""; - foreach (var o in Outputs) + public void ExitBlockquote() { - output += o.GetText(); + _currentNode = this; } - return output; + public string GetText() + { + var output = ""; + foreach (var o in Outputs) + { + output += o.GetText(); + } + + return output; + } } -} \ No newline at end of file +} + From e093f00d18ed65c00873186d197cbb00243073f0 Mon Sep 17 00:00:00 2001 From: Emmanouil Dermitzakis Date: Tue, 20 Feb 2024 10:40:54 +0200 Subject: [PATCH 04/13] fix: empty element content case --- CSharp/Interpreter/ArcscriptTranspiler.cs | 20 +++++++++++--------- CSharp/__tests__/valid.json | 4 ++++ 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/CSharp/Interpreter/ArcscriptTranspiler.cs b/CSharp/Interpreter/ArcscriptTranspiler.cs index 85a6073..6ba9de4 100644 --- a/CSharp/Interpreter/ArcscriptTranspiler.cs +++ b/CSharp/Interpreter/ArcscriptTranspiler.cs @@ -30,21 +30,16 @@ private ArcscriptParser.InputContext GetParseTree(string code) public TranspilerOutput RunScript(string code) { + if (string.IsNullOrEmpty(code)) + { + return new TranspilerOutput(); + } ArcscriptParser.InputContext tree = this.GetParseTree(code); ArcscriptVisitor visitor = new ArcscriptVisitor(this.ElementId, this.Project); object result = tree.Accept(visitor); // List outputs = visitor.state.outputs; var outputResult = visitor.state.Outputs.GetText(); - // if (outputs.Count > 0) - // { - // foreach (var t in outputs) - // { - // outputResult += t.Trim(); - // } - // - // //outputResult = Utils.CleanString(outputResult); - // } var isCondition = tree.script() != null; @@ -58,6 +53,13 @@ public class TranspilerOutput public object Result { get; private set; } public bool IsCondition { get; private set; } + public TranspilerOutput() + { + Result = false; + Output = ""; + Changes = new Dictionary(); + IsCondition = false; + } public TranspilerOutput(string output, Dictionary changes, object result, bool isCondition = false) { diff --git a/CSharp/__tests__/valid.json b/CSharp/__tests__/valid.json index d5179aa..00f634b 100644 --- a/CSharp/__tests__/valid.json +++ b/CSharp/__tests__/valid.json @@ -441,6 +441,10 @@ { "code": "

this is a test

show(x)

continue

testing

", "output": "

this is a test

14 continue

testing

" + }, + { + "code": "", + "changes": {} } ] } \ No newline at end of file From 966786d2ef4cede1c306032daff154f8d718b2bd Mon Sep 17 00:00:00 2001 From: Emmanouil Dermitzakis Date: Mon, 7 Jul 2025 14:19:18 +0300 Subject: [PATCH 05/13] (csharp) fix: interpreter tests & issues --- CSharp/.idea/.idea.CSharp/.idea/.gitignore | 13 + .../.idea/.idea.CSharp/.idea/indexLayout.xml | 8 + CSharp/.idea/.idea.CSharp/.idea/vcs.xml | 6 + CSharp/Interpreter/ArcscriptExpression.cs | 10 +- CSharp/Interpreter/ArcscriptFunctions.cs | 16 +- CSharp/Interpreter/ArcscriptOutputs.cs | 10 +- CSharp/Interpreter/ArcscriptVisitor.cs | 20 +- .../Interpreter/Generated/ArcscriptParser.cs | 526 +++++----- CSharp/UnitTests.cs | 42 + CSharp/__tests__/runtimeErrors.json | 12 + CSharp/__tests__/stringConcat.json | 132 +++ CSharp/__tests__/valid.json | 926 +++++++++--------- generate.ps1 | 33 + 13 files changed, 1070 insertions(+), 684 deletions(-) create mode 100644 CSharp/.idea/.idea.CSharp/.idea/.gitignore create mode 100644 CSharp/.idea/.idea.CSharp/.idea/indexLayout.xml create mode 100644 CSharp/.idea/.idea.CSharp/.idea/vcs.xml create mode 100644 CSharp/__tests__/stringConcat.json create mode 100644 generate.ps1 diff --git a/CSharp/.idea/.idea.CSharp/.idea/.gitignore b/CSharp/.idea/.idea.CSharp/.idea/.gitignore new file mode 100644 index 0000000..9726b8d --- /dev/null +++ b/CSharp/.idea/.idea.CSharp/.idea/.gitignore @@ -0,0 +1,13 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Rider ignored files +/contentModel.xml +/projectSettingsUpdater.xml +/.idea.CSharp.iml +/modules.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/CSharp/.idea/.idea.CSharp/.idea/indexLayout.xml b/CSharp/.idea/.idea.CSharp/.idea/indexLayout.xml new file mode 100644 index 0000000..7b08163 --- /dev/null +++ b/CSharp/.idea/.idea.CSharp/.idea/indexLayout.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/CSharp/.idea/.idea.CSharp/.idea/vcs.xml b/CSharp/.idea/.idea.CSharp/.idea/vcs.xml new file mode 100644 index 0000000..6c0b863 --- /dev/null +++ b/CSharp/.idea/.idea.CSharp/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/CSharp/Interpreter/ArcscriptExpression.cs b/CSharp/Interpreter/ArcscriptExpression.cs index 017f2eb..4f2f24f 100644 --- a/CSharp/Interpreter/ArcscriptExpression.cs +++ b/CSharp/Interpreter/ArcscriptExpression.cs @@ -30,7 +30,7 @@ public class Expression : IComparable { if (first.Type() == typeof(string) || second.Type() == typeof(string)) { - return new Expression(first.Value.ToString() + second.Value.ToString()); + return new Expression(first.ToString() + second.ToString()); } var doubleValues = GetDoubleValues(first.Value, second.Value); if (!doubleValues.HasDouble) @@ -288,6 +288,14 @@ public static bool operator false(Expression e) public override string ToString() { + if (Value.GetType() == typeof(bool)) + { + if ((bool)Value) + { + return "true"; + } + return "false"; + } return Value.ToString(); } diff --git a/CSharp/Interpreter/ArcscriptFunctions.cs b/CSharp/Interpreter/ArcscriptFunctions.cs index 284c9c0..8a72deb 100644 --- a/CSharp/Interpreter/ArcscriptFunctions.cs +++ b/CSharp/Interpreter/ArcscriptFunctions.cs @@ -124,11 +124,21 @@ public object Roll(IList args) { public object Show(IList args) { List results = new List(); foreach (Expression arg in args ) { - results.Add(arg.Value.ToString()); + results.Add(arg.ToString()); } string result = String.Join("", results.ToArray()); - //UnityEngine.Debug.Log(result); - // this.state.outputs.Add(result); + // Replace escaped sequences with their actual characters + result = result + .Replace("\\a", "\a") + .Replace("\\b", "\b") + .Replace("\\f", "\f") + .Replace("\\n", "\n") + .Replace("\\r", "\r") + .Replace("\\t", "\t") + .Replace("\\v", "\v") + .Replace("\\'", "'") + .Replace("\\\"", "\"") + .Replace("\\\\", "\\"); this.state.Outputs.AddScriptOutput(result); return null; } diff --git a/CSharp/Interpreter/ArcscriptOutputs.cs b/CSharp/Interpreter/ArcscriptOutputs.cs index d59e069..fe658a2 100644 --- a/CSharp/Interpreter/ArcscriptOutputs.cs +++ b/CSharp/Interpreter/ArcscriptOutputs.cs @@ -28,7 +28,15 @@ public void MergeScriptOutput(string text) { if (text.Length > 0) { - this._text += ' ' + text; + if (_text.Length > 0) + { + this._text += ' ' + text; + } + else + { + this._text = text; + } + } } diff --git a/CSharp/Interpreter/ArcscriptVisitor.cs b/CSharp/Interpreter/ArcscriptVisitor.cs index 9b20627..0648694 100644 --- a/CSharp/Interpreter/ArcscriptVisitor.cs +++ b/CSharp/Interpreter/ArcscriptVisitor.cs @@ -267,10 +267,10 @@ public override object VisitAdditive_numeric_expression([NotNull] ArcscriptParse if ( context.additive_numeric_expression() != null ) { Expression result = (Expression)this.VisitAdditive_numeric_expression(context.additive_numeric_expression()); if ( context.ADD() != null ) { - return mult_num_expression + result; + return result + mult_num_expression; } // Else MINUS - return mult_num_expression - result; + return result - mult_num_expression; } return mult_num_expression; @@ -282,10 +282,10 @@ public override object VisitMultiplicative_numeric_expression([NotNull] Arcscrip if ( context.multiplicative_numeric_expression() != null ) { Expression result = (Expression)this.VisitMultiplicative_numeric_expression(context.multiplicative_numeric_expression()); if ( context.MUL() != null ) { - return signed_unary_num_expr * result; + return result * signed_unary_num_expr; } // Else DIV - return signed_unary_num_expr / result; + return result / signed_unary_num_expr; } return signed_unary_num_expr; @@ -312,6 +312,18 @@ public override object VisitUnary_numeric_expression([NotNull] ArcscriptParser.U if ( context.INTEGER() != null ) { return new Expression(int.Parse(context.INTEGER().GetText())); } + + if (context.STRING() != null) + { + string result = context.STRING().GetText(); + result = result.Substring(1, result.Length - 2); + return new Expression(result); + } + + if (context.BOOLEAN() != null) + { + return new Expression(context.BOOLEAN().GetText() == "true"); + } if ( context.VARIABLE() != null ) { string variableName = context.VARIABLE().GetText(); return new Expression(this.state.GetVarValue(variableName)); diff --git a/CSharp/Interpreter/Generated/ArcscriptParser.cs b/CSharp/Interpreter/Generated/ArcscriptParser.cs index 64e57d7..f8a1225 100644 --- a/CSharp/Interpreter/Generated/ArcscriptParser.cs +++ b/CSharp/Interpreter/Generated/ArcscriptParser.cs @@ -1328,36 +1328,28 @@ public ArgumentContext argument() { try { State = 198; ErrorHandler.Sync(this); - switch (TokenStream.LA(1)) { - case FLOAT: - case INTEGER: - case LPAREN: - case ADD: - case SUB: - case FNAME: - case VARIABLE: + switch ( Interpreter.AdaptivePredict(TokenStream,12,Context) ) { + case 1: EnterOuterAlt(_localctx, 1); { State = 195; - additive_numeric_expression(); + additive_numeric_expression(0); } break; - case STRING: + case 2: EnterOuterAlt(_localctx, 2); { State = 196; Match(STRING); } break; - case MENTION_TAG_OPEN: + case 3: EnterOuterAlt(_localctx, 3); { State = 197; mention(); } break; - default: - throw new NoViableAltException(this); } } catch (RecognitionException re) { @@ -1440,7 +1432,8 @@ public MentionContext mention() { State = 212; Match(MENTION_TAG_CLOSE); State = 213; - if (!(this.assertMention(_localctx._attr))) throw new FailedPredicateException(this, "this.assertMention($attr)"); + if (!(this.assertMention(_localctx._attr) + )) throw new FailedPredicateException(this, "this.assertMention($attr)\r\n\t\t"); } } catch (RecognitionException re) { @@ -1530,33 +1523,58 @@ public override TResult Accept(IParseTreeVisitor visitor) { [RuleVersion(0)] public Additive_numeric_expressionContext additive_numeric_expression() { - Additive_numeric_expressionContext _localctx = new Additive_numeric_expressionContext(Context, State); - EnterRule(_localctx, 46, RULE_additive_numeric_expression); + return additive_numeric_expression(0); + } + + private Additive_numeric_expressionContext additive_numeric_expression(int _p) { + ParserRuleContext _parentctx = Context; + int _parentState = State; + Additive_numeric_expressionContext _localctx = new Additive_numeric_expressionContext(Context, _parentState); + Additive_numeric_expressionContext _prevctx = _localctx; + int _startState = 46; + EnterRecursionRule(_localctx, 46, RULE_additive_numeric_expression, _p); int _la; try { + int _alt; EnterOuterAlt(_localctx, 1); { - State = 220; - multiplicative_numeric_expression(); - State = 223; + { + State = 221; + multiplicative_numeric_expression(0); + } + Context.Stop = TokenStream.LT(-1); + State = 228; ErrorHandler.Sync(this); - _la = TokenStream.LA(1); - if (_la==ADD || _la==SUB) { - { - State = 221; - _la = TokenStream.LA(1); - if ( !(_la==ADD || _la==SUB) ) { - ErrorHandler.RecoverInline(this); - } - else { - ErrorHandler.ReportMatch(this); - Consume(); - } - State = 222; - additive_numeric_expression(); + _alt = Interpreter.AdaptivePredict(TokenStream,16,Context); + while ( _alt!=2 && _alt!=global::Antlr4.Runtime.Atn.ATN.INVALID_ALT_NUMBER ) { + if ( _alt==1 ) { + if ( ParseListeners!=null ) + TriggerExitRuleEvent(); + _prevctx = _localctx; + { + { + _localctx = new Additive_numeric_expressionContext(_parentctx, _parentState); + PushNewRecursionContext(_localctx, _startState, RULE_additive_numeric_expression); + State = 223; + if (!(Precpred(Context, 1))) throw new FailedPredicateException(this, "Precpred(Context, 1)"); + State = 224; + _la = TokenStream.LA(1); + if ( !(_la==ADD || _la==SUB) ) { + ErrorHandler.RecoverInline(this); + } + else { + ErrorHandler.ReportMatch(this); + Consume(); + } + State = 225; + multiplicative_numeric_expression(0); + } + } } + State = 230; + ErrorHandler.Sync(this); + _alt = Interpreter.AdaptivePredict(TokenStream,16,Context); } - } } catch (RecognitionException re) { @@ -1565,7 +1583,7 @@ public Additive_numeric_expressionContext additive_numeric_expression() { ErrorHandler.Recover(this, re); } finally { - ExitRule(); + UnrollRecursionContexts(_parentctx); } return _localctx; } @@ -1594,33 +1612,58 @@ public override TResult Accept(IParseTreeVisitor visitor) { [RuleVersion(0)] public Multiplicative_numeric_expressionContext multiplicative_numeric_expression() { - Multiplicative_numeric_expressionContext _localctx = new Multiplicative_numeric_expressionContext(Context, State); - EnterRule(_localctx, 48, RULE_multiplicative_numeric_expression); + return multiplicative_numeric_expression(0); + } + + private Multiplicative_numeric_expressionContext multiplicative_numeric_expression(int _p) { + ParserRuleContext _parentctx = Context; + int _parentState = State; + Multiplicative_numeric_expressionContext _localctx = new Multiplicative_numeric_expressionContext(Context, _parentState); + Multiplicative_numeric_expressionContext _prevctx = _localctx; + int _startState = 48; + EnterRecursionRule(_localctx, 48, RULE_multiplicative_numeric_expression, _p); int _la; try { + int _alt; EnterOuterAlt(_localctx, 1); { - State = 225; + { + State = 232; signed_unary_numeric_expression(); - State = 228; + } + Context.Stop = TokenStream.LT(-1); + State = 239; ErrorHandler.Sync(this); - _la = TokenStream.LA(1); - if (_la==MUL || _la==DIV) { - { - State = 226; - _la = TokenStream.LA(1); - if ( !(_la==MUL || _la==DIV) ) { - ErrorHandler.RecoverInline(this); - } - else { - ErrorHandler.ReportMatch(this); - Consume(); - } - State = 227; - multiplicative_numeric_expression(); + _alt = Interpreter.AdaptivePredict(TokenStream,17,Context); + while ( _alt!=2 && _alt!=global::Antlr4.Runtime.Atn.ATN.INVALID_ALT_NUMBER ) { + if ( _alt==1 ) { + if ( ParseListeners!=null ) + TriggerExitRuleEvent(); + _prevctx = _localctx; + { + { + _localctx = new Multiplicative_numeric_expressionContext(_parentctx, _parentState); + PushNewRecursionContext(_localctx, _startState, RULE_multiplicative_numeric_expression); + State = 234; + if (!(Precpred(Context, 1))) throw new FailedPredicateException(this, "Precpred(Context, 1)"); + State = 235; + _la = TokenStream.LA(1); + if ( !(_la==MUL || _la==DIV) ) { + ErrorHandler.RecoverInline(this); + } + else { + ErrorHandler.ReportMatch(this); + Consume(); + } + State = 236; + signed_unary_numeric_expression(); + } + } } + State = 241; + ErrorHandler.Sync(this); + _alt = Interpreter.AdaptivePredict(TokenStream,17,Context); } - } } catch (RecognitionException re) { @@ -1629,7 +1672,7 @@ public Multiplicative_numeric_expressionContext multiplicative_numeric_expressio ErrorHandler.Recover(this, re); } finally { - ExitRule(); + UnrollRecursionContexts(_parentctx); } return _localctx; } @@ -1659,27 +1702,29 @@ public Signed_unary_numeric_expressionContext signed_unary_numeric_expression() Signed_unary_numeric_expressionContext _localctx = new Signed_unary_numeric_expressionContext(Context, State); EnterRule(_localctx, 50, RULE_signed_unary_numeric_expression); try { - State = 234; + State = 246; ErrorHandler.Sync(this); switch (TokenStream.LA(1)) { case ADD: case SUB: EnterOuterAlt(_localctx, 1); { - State = 230; + State = 242; sign(); - State = 231; + State = 243; unary_numeric_expression(); } break; case FLOAT: case INTEGER: case LPAREN: + case BOOLEAN: case FNAME: + case STRING: case VARIABLE: EnterOuterAlt(_localctx, 2); { - State = 233; + State = 245; unary_numeric_expression(); } break; @@ -1703,6 +1748,8 @@ public partial class Unary_numeric_expressionContext : ParserRuleContext { [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode FLOAT() { return GetToken(ArcscriptParser.FLOAT, 0); } [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode VARIABLE() { return GetToken(ArcscriptParser.VARIABLE, 0); } [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode INTEGER() { return GetToken(ArcscriptParser.INTEGER, 0); } + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode STRING() { return GetToken(ArcscriptParser.STRING, 0); } + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode BOOLEAN() { return GetToken(ArcscriptParser.BOOLEAN, 0); } [System.Diagnostics.DebuggerNonUserCode] public Function_callContext function_call() { return GetRuleContext(0); } @@ -1729,20 +1776,20 @@ public Unary_numeric_expressionContext unary_numeric_expression() { Unary_numeric_expressionContext _localctx = new Unary_numeric_expressionContext(Context, State); EnterRule(_localctx, 52, RULE_unary_numeric_expression); try { - State = 245; + State = 259; ErrorHandler.Sync(this); switch (TokenStream.LA(1)) { case FLOAT: EnterOuterAlt(_localctx, 1); { - State = 236; + State = 248; Match(FLOAT); } break; case VARIABLE: EnterOuterAlt(_localctx, 2); { - State = 237; + State = 249; _localctx._VARIABLE = Match(VARIABLE); this.assertVariable(_localctx._VARIABLE); } @@ -1750,25 +1797,39 @@ public Unary_numeric_expressionContext unary_numeric_expression() { case INTEGER: EnterOuterAlt(_localctx, 3); { - State = 239; + State = 251; Match(INTEGER); } break; - case FNAME: + case STRING: EnterOuterAlt(_localctx, 4); { - State = 240; + State = 252; + Match(STRING); + } + break; + case BOOLEAN: + EnterOuterAlt(_localctx, 5); + { + State = 253; + Match(BOOLEAN); + } + break; + case FNAME: + EnterOuterAlt(_localctx, 6); + { + State = 254; function_call(); } break; case LPAREN: - EnterOuterAlt(_localctx, 5); + EnterOuterAlt(_localctx, 7); { - State = 241; + State = 255; Match(LPAREN); - State = 242; + State = 256; compound_condition_or(); - State = 243; + State = 257; Match(RPAREN); } break; @@ -1817,21 +1878,21 @@ public Function_callContext function_call() { try { EnterOuterAlt(_localctx, 1); { - State = 247; + State = 261; _localctx._FNAME = Match(FNAME); - State = 248; + State = 262; Match(LPAREN); - State = 250; + State = 264; ErrorHandler.Sync(this); _la = TokenStream.LA(1); - if ((((_la) & ~0x3f) == 0 && ((1L << _la) & 3378249501554688L) != 0)) { + if ((((_la) & ~0x3f) == 0 && ((1L << _la) & 3378524379461632L) != 0)) { { - State = 249; + State = 263; _localctx._argument_list = argument_list(); } } - State = 252; + State = 266; Match(RPAREN); this.assertFunctionArguments(_localctx._FNAME, _localctx._argument_list); } @@ -1881,27 +1942,27 @@ public Void_function_callContext void_function_call() { EnterRule(_localctx, 56, RULE_void_function_call); int _la; try { - State = 269; + State = 283; ErrorHandler.Sync(this); switch (TokenStream.LA(1)) { case VFNAME: EnterOuterAlt(_localctx, 1); { - State = 255; + State = 269; _localctx._VFNAME = Match(VFNAME); - State = 256; + State = 270; Match(LPAREN); - State = 258; + State = 272; ErrorHandler.Sync(this); _la = TokenStream.LA(1); - if ((((_la) & ~0x3f) == 0 && ((1L << _la) & 3378249501554688L) != 0)) { + if ((((_la) & ~0x3f) == 0 && ((1L << _la) & 3378524379461632L) != 0)) { { - State = 257; + State = 271; _localctx._argument_list = argument_list(); } } - State = 260; + State = 274; Match(RPAREN); this.assertFunctionArguments(_localctx._VFNAME, _localctx._argument_list); } @@ -1909,23 +1970,24 @@ public Void_function_callContext void_function_call() { case VFNAMEVARS: EnterOuterAlt(_localctx, 2); { - State = 262; + State = 276; _localctx._VFNAMEVARS = Match(VFNAMEVARS); - State = 263; + State = 277; Match(LPAREN); - State = 265; + State = 279; ErrorHandler.Sync(this); _la = TokenStream.LA(1); if (_la==VARIABLE) { { - State = 264; + State = 278; _localctx._variable_list = variable_list(); } } - State = 267; + State = 281; Match(RPAREN); this.assertFunctionArguments(_localctx._VFNAMEVARS, _localctx._variable_list); + } break; default: @@ -1967,7 +2029,7 @@ public SignContext sign() { try { EnterOuterAlt(_localctx, 1); { - State = 271; + State = 285; _la = TokenStream.LA(1); if ( !(_la==ADD || _la==SUB) ) { ErrorHandler.RecoverInline(this); @@ -2020,21 +2082,21 @@ public Variable_listContext variable_list() { try { EnterOuterAlt(_localctx, 1); { - State = 273; + State = 287; _localctx._VARIABLE = Match(VARIABLE); - State = 278; + State = 292; ErrorHandler.Sync(this); _la = TokenStream.LA(1); while (_la==COMMA) { { { - State = 274; + State = 288; Match(COMMA); - State = 275; + State = 289; _localctx._VARIABLE = Match(VARIABLE); } } - State = 280; + State = 294; ErrorHandler.Sync(this); _la = TokenStream.LA(1); } @@ -2082,14 +2144,14 @@ public Compound_condition_orContext compound_condition_or() { try { EnterOuterAlt(_localctx, 1); { - State = 283; + State = 297; compound_condition_and(); - State = 286; + State = 300; ErrorHandler.Sync(this); _la = TokenStream.LA(1); if (_la==OR || _la==ORKEYWORD) { { - State = 284; + State = 298; _la = TokenStream.LA(1); if ( !(_la==OR || _la==ORKEYWORD) ) { ErrorHandler.RecoverInline(this); @@ -2098,7 +2160,7 @@ public Compound_condition_orContext compound_condition_or() { ErrorHandler.ReportMatch(this); Consume(); } - State = 285; + State = 299; compound_condition_or(); } } @@ -2146,14 +2208,14 @@ public Compound_condition_andContext compound_condition_and() { try { EnterOuterAlt(_localctx, 1); { - State = 288; + State = 302; negated_unary_condition(); - State = 291; + State = 305; ErrorHandler.Sync(this); _la = TokenStream.LA(1); if (_la==AND || _la==ANDKEYWORD) { { - State = 289; + State = 303; _la = TokenStream.LA(1); if ( !(_la==AND || _la==ANDKEYWORD) ) { ErrorHandler.RecoverInline(this); @@ -2162,7 +2224,7 @@ public Compound_condition_andContext compound_condition_and() { ErrorHandler.ReportMatch(this); Consume(); } - State = 290; + State = 304; compound_condition_and(); } } @@ -2207,12 +2269,12 @@ public Negated_unary_conditionContext negated_unary_condition() { try { EnterOuterAlt(_localctx, 1); { - State = 294; + State = 308; ErrorHandler.Sync(this); _la = TokenStream.LA(1); if (_la==NEG || _la==NOTKEYWORD) { { - State = 293; + State = 307; _la = TokenStream.LA(1); if ( !(_la==NEG || _la==NOTKEYWORD) ) { ErrorHandler.RecoverInline(this); @@ -2224,7 +2286,7 @@ public Negated_unary_conditionContext negated_unary_condition() { } } - State = 296; + State = 310; unary_condition(); } } @@ -2263,7 +2325,7 @@ public Unary_conditionContext unary_condition() { try { EnterOuterAlt(_localctx, 1); { - State = 298; + State = 312; condition(); } } @@ -2309,16 +2371,16 @@ public ConditionContext condition() { try { EnterOuterAlt(_localctx, 1); { - State = 300; + State = 314; expression(); - State = 304; + State = 318; ErrorHandler.Sync(this); _la = TokenStream.LA(1); if ((((_la) & ~0x3f) == 0 && ((1L << _la) & 281477090639872L) != 0)) { { - State = 301; + State = 315; conditional_operator(); - State = 302; + State = 316; expression(); } } @@ -2363,64 +2425,64 @@ public Conditional_operatorContext conditional_operator() { Conditional_operatorContext _localctx = new Conditional_operatorContext(Context, State); EnterRule(_localctx, 72, RULE_conditional_operator); try { - State = 315; + State = 329; ErrorHandler.Sync(this); switch ( Interpreter.AdaptivePredict(TokenStream,29,Context) ) { case 1: EnterOuterAlt(_localctx, 1); { - State = 306; + State = 320; Match(GT); } break; case 2: EnterOuterAlt(_localctx, 2); { - State = 307; + State = 321; Match(GE); } break; case 3: EnterOuterAlt(_localctx, 3); { - State = 308; + State = 322; Match(LT); } break; case 4: EnterOuterAlt(_localctx, 4); { - State = 309; + State = 323; Match(LE); } break; case 5: EnterOuterAlt(_localctx, 5); { - State = 310; + State = 324; Match(EQ); } break; case 6: EnterOuterAlt(_localctx, 6); { - State = 311; + State = 325; Match(NE); } break; case 7: EnterOuterAlt(_localctx, 7); { - State = 312; + State = 326; Match(ISKEYWORD); } break; case 8: EnterOuterAlt(_localctx, 8); { - State = 313; + State = 327; Match(ISKEYWORD); - State = 314; + State = 328; Match(NOTKEYWORD); } break; @@ -2461,38 +2523,30 @@ public ExpressionContext expression() { ExpressionContext _localctx = new ExpressionContext(Context, State); EnterRule(_localctx, 74, RULE_expression); try { - State = 320; + State = 334; ErrorHandler.Sync(this); - switch (TokenStream.LA(1)) { - case STRING: + switch ( Interpreter.AdaptivePredict(TokenStream,30,Context) ) { + case 1: EnterOuterAlt(_localctx, 1); { - State = 317; + State = 331; Match(STRING); } break; - case BOOLEAN: + case 2: EnterOuterAlt(_localctx, 2); { - State = 318; + State = 332; Match(BOOLEAN); } break; - case FLOAT: - case INTEGER: - case LPAREN: - case ADD: - case SUB: - case FNAME: - case VARIABLE: + case 3: EnterOuterAlt(_localctx, 3); { - State = 319; - additive_numeric_expression(); + State = 333; + additive_numeric_expression(0); } break; - default: - throw new NoViableAltException(this); } } catch (RecognitionException re) { @@ -2509,18 +2563,33 @@ public ExpressionContext expression() { public override bool Sempred(RuleContext _localctx, int ruleIndex, int predIndex) { switch (ruleIndex) { case 21: return mention_sempred((MentionContext)_localctx, predIndex); + case 23: return additive_numeric_expression_sempred((Additive_numeric_expressionContext)_localctx, predIndex); + case 24: return multiplicative_numeric_expression_sempred((Multiplicative_numeric_expressionContext)_localctx, predIndex); } return true; } private bool mention_sempred(MentionContext _localctx, int predIndex) { switch (predIndex) { - case 0: return this.assertMention(_localctx._attr); + case 0: return this.assertMention(_localctx._attr) + ; + } + return true; + } + private bool additive_numeric_expression_sempred(Additive_numeric_expressionContext _localctx, int predIndex) { + switch (predIndex) { + case 1: return Precpred(Context, 1); + } + return true; + } + private bool multiplicative_numeric_expression_sempred(Multiplicative_numeric_expressionContext _localctx, int predIndex) { + switch (predIndex) { + case 2: return Precpred(Context, 1); } return true; } private static int[] _serializedATN = { - 4,1,61,323,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, + 4,1,61,337,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, @@ -2536,94 +2605,99 @@ private bool mention_sempred(MentionContext _localctx, int predIndex) { 1,18,1,19,1,19,1,19,5,19,191,8,19,10,19,12,19,194,9,19,1,20,1,20,1,20, 3,20,199,8,20,1,21,1,21,5,21,203,8,21,10,21,12,21,206,9,21,1,21,1,21,3, 21,210,8,21,1,21,1,21,1,21,1,21,1,22,1,22,1,22,3,22,219,8,22,1,23,1,23, - 1,23,3,23,224,8,23,1,24,1,24,1,24,3,24,229,8,24,1,25,1,25,1,25,1,25,3, - 25,235,8,25,1,26,1,26,1,26,1,26,1,26,1,26,1,26,1,26,1,26,3,26,246,8,26, - 1,27,1,27,1,27,3,27,251,8,27,1,27,1,27,1,27,1,28,1,28,1,28,3,28,259,8, - 28,1,28,1,28,1,28,1,28,1,28,3,28,266,8,28,1,28,1,28,3,28,270,8,28,1,29, - 1,29,1,30,1,30,1,30,5,30,277,8,30,10,30,12,30,280,9,30,1,30,1,30,1,31, - 1,31,1,31,3,31,287,8,31,1,32,1,32,1,32,3,32,292,8,32,1,33,3,33,295,8,33, - 1,33,1,33,1,34,1,34,1,35,1,35,1,35,1,35,3,35,305,8,35,1,36,1,36,1,36,1, - 36,1,36,1,36,1,36,1,36,1,36,3,36,316,8,36,1,37,1,37,1,37,3,37,321,8,37, - 1,37,2,94,99,0,38,0,2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32,34,36, - 38,40,42,44,46,48,50,52,54,56,58,60,62,64,66,68,70,72,74,0,6,2,0,17,20, - 33,33,1,0,23,24,1,0,21,22,2,0,32,32,47,47,2,0,31,31,46,46,2,0,34,34,49, - 49,330,0,84,1,0,0,0,2,87,1,0,0,0,4,104,1,0,0,0,6,106,1,0,0,0,8,117,1,0, - 0,0,10,125,1,0,0,0,12,131,1,0,0,0,14,133,1,0,0,0,16,135,1,0,0,0,18,139, - 1,0,0,0,20,143,1,0,0,0,22,155,1,0,0,0,24,160,1,0,0,0,26,165,1,0,0,0,28, - 170,1,0,0,0,30,173,1,0,0,0,32,176,1,0,0,0,34,180,1,0,0,0,36,185,1,0,0, - 0,38,187,1,0,0,0,40,198,1,0,0,0,42,200,1,0,0,0,44,215,1,0,0,0,46,220,1, - 0,0,0,48,225,1,0,0,0,50,234,1,0,0,0,52,245,1,0,0,0,54,247,1,0,0,0,56,269, - 1,0,0,0,58,271,1,0,0,0,60,273,1,0,0,0,62,283,1,0,0,0,64,288,1,0,0,0,66, - 294,1,0,0,0,68,298,1,0,0,0,70,300,1,0,0,0,72,315,1,0,0,0,74,320,1,0,0, - 0,76,77,3,2,1,0,77,78,5,0,0,1,78,85,1,0,0,0,79,80,3,12,6,0,80,81,3,62, - 31,0,81,82,3,14,7,0,82,83,5,0,0,1,83,85,1,0,0,0,84,76,1,0,0,0,84,79,1, - 0,0,0,85,1,1,0,0,0,86,88,3,4,2,0,87,86,1,0,0,0,88,89,1,0,0,0,89,87,1,0, - 0,0,89,90,1,0,0,0,90,3,1,0,0,0,91,93,3,6,3,0,92,91,1,0,0,0,93,94,1,0,0, - 0,94,95,1,0,0,0,94,92,1,0,0,0,95,105,1,0,0,0,96,98,3,8,4,0,97,96,1,0,0, - 0,98,99,1,0,0,0,99,100,1,0,0,0,99,97,1,0,0,0,100,105,1,0,0,0,101,105,3, - 16,8,0,102,105,3,18,9,0,103,105,3,20,10,0,104,92,1,0,0,0,104,97,1,0,0, - 0,104,101,1,0,0,0,104,102,1,0,0,0,104,103,1,0,0,0,105,5,1,0,0,0,106,112, - 5,3,0,0,107,111,3,8,4,0,108,111,3,16,8,0,109,111,3,18,9,0,110,107,1,0, - 0,0,110,108,1,0,0,0,110,109,1,0,0,0,111,114,1,0,0,0,112,110,1,0,0,0,112, - 113,1,0,0,0,113,115,1,0,0,0,114,112,1,0,0,0,115,116,5,8,0,0,116,7,1,0, - 0,0,117,118,3,10,5,0,118,119,5,5,0,0,119,120,6,4,-1,0,120,9,1,0,0,0,121, - 122,5,2,0,0,122,126,6,5,-1,0,123,124,5,7,0,0,124,126,6,5,-1,0,125,121, - 1,0,0,0,125,123,1,0,0,0,126,11,1,0,0,0,127,128,5,1,0,0,128,132,6,6,-1, - 0,129,130,5,6,0,0,130,132,6,6,-1,0,131,127,1,0,0,0,131,129,1,0,0,0,132, - 13,1,0,0,0,133,134,5,10,0,0,134,15,1,0,0,0,135,136,3,12,6,0,136,137,3, - 34,17,0,137,138,3,14,7,0,138,17,1,0,0,0,139,140,3,12,6,0,140,141,3,36, - 18,0,141,142,3,14,7,0,142,19,1,0,0,0,143,147,3,22,11,0,144,146,3,24,12, - 0,145,144,1,0,0,0,146,149,1,0,0,0,147,145,1,0,0,0,147,148,1,0,0,0,148, - 151,1,0,0,0,149,147,1,0,0,0,150,152,3,26,13,0,151,150,1,0,0,0,151,152, - 1,0,0,0,152,153,1,0,0,0,153,154,3,32,16,0,154,21,1,0,0,0,155,156,3,12, - 6,0,156,157,3,28,14,0,157,158,3,14,7,0,158,159,3,2,1,0,159,23,1,0,0,0, - 160,161,3,12,6,0,161,162,3,30,15,0,162,163,3,14,7,0,163,164,3,2,1,0,164, - 25,1,0,0,0,165,166,3,12,6,0,166,167,5,43,0,0,167,168,3,14,7,0,168,169, - 3,2,1,0,169,27,1,0,0,0,170,171,5,42,0,0,171,172,3,62,31,0,172,29,1,0,0, - 0,173,174,5,44,0,0,174,175,3,62,31,0,175,31,1,0,0,0,176,177,3,12,6,0,177, - 178,5,45,0,0,178,179,3,14,7,0,179,33,1,0,0,0,180,181,5,51,0,0,181,182, - 7,0,0,0,182,183,3,62,31,0,183,184,6,17,-1,0,184,35,1,0,0,0,185,186,3,56, - 28,0,186,37,1,0,0,0,187,192,3,40,20,0,188,189,5,35,0,0,189,191,3,40,20, - 0,190,188,1,0,0,0,191,194,1,0,0,0,192,190,1,0,0,0,192,193,1,0,0,0,193, - 39,1,0,0,0,194,192,1,0,0,0,195,199,3,46,23,0,196,199,5,50,0,0,197,199, - 3,42,21,0,198,195,1,0,0,0,198,196,1,0,0,0,198,197,1,0,0,0,199,41,1,0,0, - 0,200,204,5,11,0,0,201,203,3,44,22,0,202,201,1,0,0,0,203,206,1,0,0,0,204, - 202,1,0,0,0,204,205,1,0,0,0,205,207,1,0,0,0,206,204,1,0,0,0,207,209,5, - 53,0,0,208,210,5,59,0,0,209,208,1,0,0,0,209,210,1,0,0,0,210,211,1,0,0, - 0,211,212,5,58,0,0,212,213,5,56,0,0,213,214,4,21,0,1,214,43,1,0,0,0,215, - 218,5,54,0,0,216,217,5,55,0,0,217,219,5,60,0,0,218,216,1,0,0,0,218,219, - 1,0,0,0,219,45,1,0,0,0,220,223,3,48,24,0,221,222,7,1,0,0,222,224,3,46, - 23,0,223,221,1,0,0,0,223,224,1,0,0,0,224,47,1,0,0,0,225,228,3,50,25,0, - 226,227,7,2,0,0,227,229,3,48,24,0,228,226,1,0,0,0,228,229,1,0,0,0,229, - 49,1,0,0,0,230,231,3,58,29,0,231,232,3,52,26,0,232,235,1,0,0,0,233,235, - 3,52,26,0,234,230,1,0,0,0,234,233,1,0,0,0,235,51,1,0,0,0,236,246,5,12, - 0,0,237,238,5,51,0,0,238,246,6,26,-1,0,239,246,5,13,0,0,240,246,3,54,27, - 0,241,242,5,15,0,0,242,243,3,62,31,0,243,244,5,16,0,0,244,246,1,0,0,0, - 245,236,1,0,0,0,245,237,1,0,0,0,245,239,1,0,0,0,245,240,1,0,0,0,245,241, - 1,0,0,0,246,53,1,0,0,0,247,248,5,39,0,0,248,250,5,15,0,0,249,251,3,38, - 19,0,250,249,1,0,0,0,250,251,1,0,0,0,251,252,1,0,0,0,252,253,5,16,0,0, - 253,254,6,27,-1,0,254,55,1,0,0,0,255,256,5,40,0,0,256,258,5,15,0,0,257, - 259,3,38,19,0,258,257,1,0,0,0,258,259,1,0,0,0,259,260,1,0,0,0,260,261, - 5,16,0,0,261,270,6,28,-1,0,262,263,5,41,0,0,263,265,5,15,0,0,264,266,3, - 60,30,0,265,264,1,0,0,0,265,266,1,0,0,0,266,267,1,0,0,0,267,268,5,16,0, - 0,268,270,6,28,-1,0,269,255,1,0,0,0,269,262,1,0,0,0,270,57,1,0,0,0,271, - 272,7,1,0,0,272,59,1,0,0,0,273,278,5,51,0,0,274,275,5,35,0,0,275,277,5, - 51,0,0,276,274,1,0,0,0,277,280,1,0,0,0,278,276,1,0,0,0,278,279,1,0,0,0, - 279,281,1,0,0,0,280,278,1,0,0,0,281,282,6,30,-1,0,282,61,1,0,0,0,283,286, - 3,64,32,0,284,285,7,3,0,0,285,287,3,62,31,0,286,284,1,0,0,0,286,287,1, - 0,0,0,287,63,1,0,0,0,288,291,3,66,33,0,289,290,7,4,0,0,290,292,3,64,32, - 0,291,289,1,0,0,0,291,292,1,0,0,0,292,65,1,0,0,0,293,295,7,5,0,0,294,293, - 1,0,0,0,294,295,1,0,0,0,295,296,1,0,0,0,296,297,3,68,34,0,297,67,1,0,0, - 0,298,299,3,70,35,0,299,69,1,0,0,0,300,304,3,74,37,0,301,302,3,72,36,0, - 302,303,3,74,37,0,303,305,1,0,0,0,304,301,1,0,0,0,304,305,1,0,0,0,305, - 71,1,0,0,0,306,316,5,26,0,0,307,316,5,25,0,0,308,316,5,28,0,0,309,316, - 5,27,0,0,310,316,5,29,0,0,311,316,5,30,0,0,312,316,5,48,0,0,313,314,5, - 48,0,0,314,316,5,49,0,0,315,306,1,0,0,0,315,307,1,0,0,0,315,308,1,0,0, - 0,315,309,1,0,0,0,315,310,1,0,0,0,315,311,1,0,0,0,315,312,1,0,0,0,315, - 313,1,0,0,0,316,73,1,0,0,0,317,321,5,50,0,0,318,321,5,38,0,0,319,321,3, - 46,23,0,320,317,1,0,0,0,320,318,1,0,0,0,320,319,1,0,0,0,321,75,1,0,0,0, - 31,84,89,94,99,104,110,112,125,131,147,151,192,198,204,209,218,223,228, - 234,245,250,258,265,269,278,286,291,294,304,315,320 + 1,23,1,23,1,23,1,23,5,23,227,8,23,10,23,12,23,230,9,23,1,24,1,24,1,24, + 1,24,1,24,1,24,5,24,238,8,24,10,24,12,24,241,9,24,1,25,1,25,1,25,1,25, + 3,25,247,8,25,1,26,1,26,1,26,1,26,1,26,1,26,1,26,1,26,1,26,1,26,1,26,3, + 26,260,8,26,1,27,1,27,1,27,3,27,265,8,27,1,27,1,27,1,27,1,28,1,28,1,28, + 3,28,273,8,28,1,28,1,28,1,28,1,28,1,28,3,28,280,8,28,1,28,1,28,3,28,284, + 8,28,1,29,1,29,1,30,1,30,1,30,5,30,291,8,30,10,30,12,30,294,9,30,1,30, + 1,30,1,31,1,31,1,31,3,31,301,8,31,1,32,1,32,1,32,3,32,306,8,32,1,33,3, + 33,309,8,33,1,33,1,33,1,34,1,34,1,35,1,35,1,35,1,35,3,35,319,8,35,1,36, + 1,36,1,36,1,36,1,36,1,36,1,36,1,36,1,36,3,36,330,8,36,1,37,1,37,1,37,3, + 37,335,8,37,1,37,2,94,99,2,46,48,38,0,2,4,6,8,10,12,14,16,18,20,22,24, + 26,28,30,32,34,36,38,40,42,44,46,48,50,52,54,56,58,60,62,64,66,68,70,72, + 74,0,6,2,0,17,20,33,33,1,0,23,24,1,0,21,22,2,0,32,32,47,47,2,0,31,31,46, + 46,2,0,34,34,49,49,346,0,84,1,0,0,0,2,87,1,0,0,0,4,104,1,0,0,0,6,106,1, + 0,0,0,8,117,1,0,0,0,10,125,1,0,0,0,12,131,1,0,0,0,14,133,1,0,0,0,16,135, + 1,0,0,0,18,139,1,0,0,0,20,143,1,0,0,0,22,155,1,0,0,0,24,160,1,0,0,0,26, + 165,1,0,0,0,28,170,1,0,0,0,30,173,1,0,0,0,32,176,1,0,0,0,34,180,1,0,0, + 0,36,185,1,0,0,0,38,187,1,0,0,0,40,198,1,0,0,0,42,200,1,0,0,0,44,215,1, + 0,0,0,46,220,1,0,0,0,48,231,1,0,0,0,50,246,1,0,0,0,52,259,1,0,0,0,54,261, + 1,0,0,0,56,283,1,0,0,0,58,285,1,0,0,0,60,287,1,0,0,0,62,297,1,0,0,0,64, + 302,1,0,0,0,66,308,1,0,0,0,68,312,1,0,0,0,70,314,1,0,0,0,72,329,1,0,0, + 0,74,334,1,0,0,0,76,77,3,2,1,0,77,78,5,0,0,1,78,85,1,0,0,0,79,80,3,12, + 6,0,80,81,3,62,31,0,81,82,3,14,7,0,82,83,5,0,0,1,83,85,1,0,0,0,84,76,1, + 0,0,0,84,79,1,0,0,0,85,1,1,0,0,0,86,88,3,4,2,0,87,86,1,0,0,0,88,89,1,0, + 0,0,89,87,1,0,0,0,89,90,1,0,0,0,90,3,1,0,0,0,91,93,3,6,3,0,92,91,1,0,0, + 0,93,94,1,0,0,0,94,95,1,0,0,0,94,92,1,0,0,0,95,105,1,0,0,0,96,98,3,8,4, + 0,97,96,1,0,0,0,98,99,1,0,0,0,99,100,1,0,0,0,99,97,1,0,0,0,100,105,1,0, + 0,0,101,105,3,16,8,0,102,105,3,18,9,0,103,105,3,20,10,0,104,92,1,0,0,0, + 104,97,1,0,0,0,104,101,1,0,0,0,104,102,1,0,0,0,104,103,1,0,0,0,105,5,1, + 0,0,0,106,112,5,3,0,0,107,111,3,8,4,0,108,111,3,16,8,0,109,111,3,18,9, + 0,110,107,1,0,0,0,110,108,1,0,0,0,110,109,1,0,0,0,111,114,1,0,0,0,112, + 110,1,0,0,0,112,113,1,0,0,0,113,115,1,0,0,0,114,112,1,0,0,0,115,116,5, + 8,0,0,116,7,1,0,0,0,117,118,3,10,5,0,118,119,5,5,0,0,119,120,6,4,-1,0, + 120,9,1,0,0,0,121,122,5,2,0,0,122,126,6,5,-1,0,123,124,5,7,0,0,124,126, + 6,5,-1,0,125,121,1,0,0,0,125,123,1,0,0,0,126,11,1,0,0,0,127,128,5,1,0, + 0,128,132,6,6,-1,0,129,130,5,6,0,0,130,132,6,6,-1,0,131,127,1,0,0,0,131, + 129,1,0,0,0,132,13,1,0,0,0,133,134,5,10,0,0,134,15,1,0,0,0,135,136,3,12, + 6,0,136,137,3,34,17,0,137,138,3,14,7,0,138,17,1,0,0,0,139,140,3,12,6,0, + 140,141,3,36,18,0,141,142,3,14,7,0,142,19,1,0,0,0,143,147,3,22,11,0,144, + 146,3,24,12,0,145,144,1,0,0,0,146,149,1,0,0,0,147,145,1,0,0,0,147,148, + 1,0,0,0,148,151,1,0,0,0,149,147,1,0,0,0,150,152,3,26,13,0,151,150,1,0, + 0,0,151,152,1,0,0,0,152,153,1,0,0,0,153,154,3,32,16,0,154,21,1,0,0,0,155, + 156,3,12,6,0,156,157,3,28,14,0,157,158,3,14,7,0,158,159,3,2,1,0,159,23, + 1,0,0,0,160,161,3,12,6,0,161,162,3,30,15,0,162,163,3,14,7,0,163,164,3, + 2,1,0,164,25,1,0,0,0,165,166,3,12,6,0,166,167,5,43,0,0,167,168,3,14,7, + 0,168,169,3,2,1,0,169,27,1,0,0,0,170,171,5,42,0,0,171,172,3,62,31,0,172, + 29,1,0,0,0,173,174,5,44,0,0,174,175,3,62,31,0,175,31,1,0,0,0,176,177,3, + 12,6,0,177,178,5,45,0,0,178,179,3,14,7,0,179,33,1,0,0,0,180,181,5,51,0, + 0,181,182,7,0,0,0,182,183,3,62,31,0,183,184,6,17,-1,0,184,35,1,0,0,0,185, + 186,3,56,28,0,186,37,1,0,0,0,187,192,3,40,20,0,188,189,5,35,0,0,189,191, + 3,40,20,0,190,188,1,0,0,0,191,194,1,0,0,0,192,190,1,0,0,0,192,193,1,0, + 0,0,193,39,1,0,0,0,194,192,1,0,0,0,195,199,3,46,23,0,196,199,5,50,0,0, + 197,199,3,42,21,0,198,195,1,0,0,0,198,196,1,0,0,0,198,197,1,0,0,0,199, + 41,1,0,0,0,200,204,5,11,0,0,201,203,3,44,22,0,202,201,1,0,0,0,203,206, + 1,0,0,0,204,202,1,0,0,0,204,205,1,0,0,0,205,207,1,0,0,0,206,204,1,0,0, + 0,207,209,5,53,0,0,208,210,5,59,0,0,209,208,1,0,0,0,209,210,1,0,0,0,210, + 211,1,0,0,0,211,212,5,58,0,0,212,213,5,56,0,0,213,214,4,21,0,1,214,43, + 1,0,0,0,215,218,5,54,0,0,216,217,5,55,0,0,217,219,5,60,0,0,218,216,1,0, + 0,0,218,219,1,0,0,0,219,45,1,0,0,0,220,221,6,23,-1,0,221,222,3,48,24,0, + 222,228,1,0,0,0,223,224,10,1,0,0,224,225,7,1,0,0,225,227,3,48,24,0,226, + 223,1,0,0,0,227,230,1,0,0,0,228,226,1,0,0,0,228,229,1,0,0,0,229,47,1,0, + 0,0,230,228,1,0,0,0,231,232,6,24,-1,0,232,233,3,50,25,0,233,239,1,0,0, + 0,234,235,10,1,0,0,235,236,7,2,0,0,236,238,3,50,25,0,237,234,1,0,0,0,238, + 241,1,0,0,0,239,237,1,0,0,0,239,240,1,0,0,0,240,49,1,0,0,0,241,239,1,0, + 0,0,242,243,3,58,29,0,243,244,3,52,26,0,244,247,1,0,0,0,245,247,3,52,26, + 0,246,242,1,0,0,0,246,245,1,0,0,0,247,51,1,0,0,0,248,260,5,12,0,0,249, + 250,5,51,0,0,250,260,6,26,-1,0,251,260,5,13,0,0,252,260,5,50,0,0,253,260, + 5,38,0,0,254,260,3,54,27,0,255,256,5,15,0,0,256,257,3,62,31,0,257,258, + 5,16,0,0,258,260,1,0,0,0,259,248,1,0,0,0,259,249,1,0,0,0,259,251,1,0,0, + 0,259,252,1,0,0,0,259,253,1,0,0,0,259,254,1,0,0,0,259,255,1,0,0,0,260, + 53,1,0,0,0,261,262,5,39,0,0,262,264,5,15,0,0,263,265,3,38,19,0,264,263, + 1,0,0,0,264,265,1,0,0,0,265,266,1,0,0,0,266,267,5,16,0,0,267,268,6,27, + -1,0,268,55,1,0,0,0,269,270,5,40,0,0,270,272,5,15,0,0,271,273,3,38,19, + 0,272,271,1,0,0,0,272,273,1,0,0,0,273,274,1,0,0,0,274,275,5,16,0,0,275, + 284,6,28,-1,0,276,277,5,41,0,0,277,279,5,15,0,0,278,280,3,60,30,0,279, + 278,1,0,0,0,279,280,1,0,0,0,280,281,1,0,0,0,281,282,5,16,0,0,282,284,6, + 28,-1,0,283,269,1,0,0,0,283,276,1,0,0,0,284,57,1,0,0,0,285,286,7,1,0,0, + 286,59,1,0,0,0,287,292,5,51,0,0,288,289,5,35,0,0,289,291,5,51,0,0,290, + 288,1,0,0,0,291,294,1,0,0,0,292,290,1,0,0,0,292,293,1,0,0,0,293,295,1, + 0,0,0,294,292,1,0,0,0,295,296,6,30,-1,0,296,61,1,0,0,0,297,300,3,64,32, + 0,298,299,7,3,0,0,299,301,3,62,31,0,300,298,1,0,0,0,300,301,1,0,0,0,301, + 63,1,0,0,0,302,305,3,66,33,0,303,304,7,4,0,0,304,306,3,64,32,0,305,303, + 1,0,0,0,305,306,1,0,0,0,306,65,1,0,0,0,307,309,7,5,0,0,308,307,1,0,0,0, + 308,309,1,0,0,0,309,310,1,0,0,0,310,311,3,68,34,0,311,67,1,0,0,0,312,313, + 3,70,35,0,313,69,1,0,0,0,314,318,3,74,37,0,315,316,3,72,36,0,316,317,3, + 74,37,0,317,319,1,0,0,0,318,315,1,0,0,0,318,319,1,0,0,0,319,71,1,0,0,0, + 320,330,5,26,0,0,321,330,5,25,0,0,322,330,5,28,0,0,323,330,5,27,0,0,324, + 330,5,29,0,0,325,330,5,30,0,0,326,330,5,48,0,0,327,328,5,48,0,0,328,330, + 5,49,0,0,329,320,1,0,0,0,329,321,1,0,0,0,329,322,1,0,0,0,329,323,1,0,0, + 0,329,324,1,0,0,0,329,325,1,0,0,0,329,326,1,0,0,0,329,327,1,0,0,0,330, + 73,1,0,0,0,331,335,5,50,0,0,332,335,5,38,0,0,333,335,3,46,23,0,334,331, + 1,0,0,0,334,332,1,0,0,0,334,333,1,0,0,0,335,75,1,0,0,0,31,84,89,94,99, + 104,110,112,125,131,147,151,192,198,204,209,218,228,239,246,259,264,272, + 279,283,292,300,305,308,318,329,334 }; public static readonly ATN _ATN = diff --git a/CSharp/UnitTests.cs b/CSharp/UnitTests.cs index 83c9cfe..b137842 100644 --- a/CSharp/UnitTests.cs +++ b/CSharp/UnitTests.cs @@ -38,6 +38,16 @@ private static IEnumerable GetConditionsTestData() yield return new TestCaseData(tests.Variables, validTestsCase); } } + + private static IEnumerable GetStringConcatTestData() + { + var tests = LoadJson("../../../__tests__/stringConcat.json"); + + foreach (var stringConcatTestCase in tests.Cases) + { + yield return new TestCaseData(tests.Variables, stringConcatTestCase); + } + } private static TestData LoadJson(string filePath) { @@ -131,4 +141,36 @@ public void ConditionTests(Dictionary variables, TestCase test Assert.That(output.Result, Is.EqualTo(testCase.result)); } + + [Test] + [TestCaseSource(nameof(GetStringConcatTestData))] + public void StringConcatTests(Dictionary variables, TestCase testCase) + { + var elements = new Dictionary(); + if (testCase.visits != null) + { + foreach (var kvp in testCase.visits) + { + elements[kvp.Key] = new Element + { + Visits = kvp.Value + }; + } + } + Console.WriteLine("Testing Case: " + testCase.code); + var project = new Project.Project(variables.Values.ToList(), elements); + var i = new AwInterpreter(project, testCase.elementId); + var output = i.RunScript(testCase.code); + + if (testCase.output != null) + { + Assert.That(output.Output, Is.EqualTo(testCase.output)); + } + + var changesByName = ChangesByName(variables, testCase.changes); + if (changesByName != null) + { + Assert.That(output.Changes, Is.EqualTo(changesByName)); + } + } } \ No newline at end of file diff --git a/CSharp/__tests__/runtimeErrors.json b/CSharp/__tests__/runtimeErrors.json index d0b6382..2f4924a 100644 --- a/CSharp/__tests__/runtimeErrors.json +++ b/CSharp/__tests__/runtimeErrors.json @@ -55,6 +55,18 @@ { "code": "
x = roll(\"2\")
", "error": "runtime" + }, + { + "code": "
w = \"2\" - \"test\"
", + "error": "runtime" + }, + { + "code": "
w = w - \"test\"
", + "error": "runtime" + }, + { + "code": "
w -= _a
", + "error": "runtime" } ] } \ No newline at end of file diff --git a/CSharp/__tests__/stringConcat.json b/CSharp/__tests__/stringConcat.json new file mode 100644 index 0000000..d9b3503 --- /dev/null +++ b/CSharp/__tests__/stringConcat.json @@ -0,0 +1,132 @@ +{ + "initialVars": { + "var1": { + "id": "var1", + "name": "x", + "type": "integer", + "value": 14 + }, + "var2": { + "id": "var2", + "name": "y", + "type": "integer", + "value": 15 + }, + "var3": { + "id": "var3", + "name": "z", + "type": "integer", + "value": 0 + }, + "var4": { + "id": "var4", + "name": "w", + "type": "string", + "value": "Dummy text" + }, + "var5": { + "id": "var5", + "name": "$c5", + "type": "integer", + "value": 0 + }, + "var6": { + "id": "var6", + "name": "_a", + "type": "boolean", + "value": false + }, + "var7": { + "id": "var7", + "name": "xy", + "type": "integer", + "value": -1 + }, + "var8": { + "id": "var8", + "name": "man", + "type": "string", + "value": "Different Text" + } + }, + "cases": [ + { + "code": "
w = \"test\"
w = w + \"ing\"
", + "changes": { + "var4": "testing" + } + }, + { + "code": "
w = \"test\" + \"ing\"
", + "changes": { + "var4": "testing" + } + }, + { + "code": "
w = 0.42 + \"ing\"
", + "changes": { + "var4": "0.42ing" + } + }, + { + "code": "
w = 0.42 + \"\"
", + "changes": { + "var4": "0.42" + } + }, + { + "code": "
w = \"test\" + 44
", + "changes": { + "var4": "test44" + } + }, + { + "code": "
w = \"test\" + false
", + "changes": { + "var4": "testfalse" + } + }, + { + "code": "
w = \"test\" + true + true
", + "changes": { + "var4": "testtruetrue" + } + }, + { + "code": "
w = true + true + \"test\"
", + "changes": { + "var4": "2test" + } + }, + { + "code": "
w += \" test\"
", + "changes": { + "var4": "Dummy text test" + } + }, + { + "code": "
x += \"test\"
", + "changes": { + "var1": "14test" + } + }, + { + "code": "
w += 42
", + "changes": { + "var4": "Dummy text42" + } + }, + { + "code": "
w += _a
", + "changes": { + "var4": "Dummy textfalse" + } + }, + { + "code": "
w += man
", + "changes": { + "var4": "Dummy textDifferent Text" + } + } + ] +} \ No newline at end of file diff --git a/CSharp/__tests__/valid.json b/CSharp/__tests__/valid.json index 00f634b..6df3bb8 100644 --- a/CSharp/__tests__/valid.json +++ b/CSharp/__tests__/valid.json @@ -1,450 +1,478 @@ -{ - "initialVars": { - "var1": { - "id": "var1", - "name": "x", - "type": "integer", - "value": 14 - }, - "var2": { - "id": "var2", - "name": "y", - "type": "integer", - "value": 15 - }, - "var3": { - "id": "var3", - "name": "z", - "type": "integer", - "value": 0 - }, - "var4": { - "id": "var4", - "name": "w", - "type": "string", - "value": "Dummy text" - }, - "var5": { - "id": "var5", - "name": "$c5", - "type": "integer", - "value": 0 - }, - "var6": { - "id": "var6", - "name": "_a", - "type": "boolean", - "value": false - }, - "var7": { - "id": "var7", - "name": "xy", - "type": "integer", - "value": -1 - }, - "var8": { - "id": "var8", - "name": "man", - "type": "string", - "value": "Different Text" - } - }, - "cases": [ - { - "code": "
x=5
", - "changes": { - "var1": 5 - } - }, - { - "code": "
x=-5
", - "changes": { - "var1": -5 - } - }, - { - "code": "
x=5.23
", - "changes": { - "var1": 5.23 - } - }, - { - "code": "
x=3
y=2
", - "changes": { - "var1": 3, - "var2": 2 - } - }, - { - "code": "
x=\"test\"
", - "changes": { - "var1": "test" - } - }, - { - "code": "
x=true
", - "changes": { - "var1": true - } - }, - { - "code": "
x = y
", - "changes": { - "var1": 15 - } - }, - { - "code": "
x = 5 + 3
", - "changes": { - "var1": 8 - } - }, - { - "code": "
x = sqr(2)
", - "changes": { - "var1": 4 - } - }, - { - "code": "
x = 3 > 2
", - "changes": { - "var1": true - } - }, - { - "code": "
x = 3 >= 2
", - "changes": { - "var1": true - } - }, - { - "code": "
x = 3 < 2
", - "changes": { - "var1": false - } - }, - { - "code": "
x = 3 <= 2
", - "changes": { - "var1": false - } - }, - { - "code": "
x = 3 == 2
", - "changes": { - "var1": false - } - }, - { - "code": "
x = 3 != 2
", - "changes": { - "var1": true - } - }, - { - "code": "
_a = !(3 == 2)
", - "changes": { - "var6": true - } - }, - { - "code": "
_a = not (3 == 2)
", - "changes": { - "var6": true - } - }, - { - "code": "
x = !0
", - "changes": { - "var1": true - } - }, - { - "code": "
x = true || false
", - "changes": { - "var1": true - } - }, - { - "code": "
x = true && false
", - "changes": { - "var1": false - } - }, - { - "code": "
x = -3
y = y + 3
z = sqr(x)
", - "changes": { - "var1": -3, - "var2": 18, - "var3": 9 - } - }, - { - "code": "
x = sqrt(y + 2)
", - "changes": { - "var1": 4.123105625617661 - } - }, - { - "code": "
x = z + 12 == 4 * 3
", - "changes": { - "var1": true - } - }, - { - "code": "
x = y == 15 && !(z == 1)
", - "changes": { - "var1": true - } - }, - { - "code": "
x = (x*x + 3)/y
", - "changes": { - "var1": 13.266666666666667 - } - }, - { - "code": "
x = x*(x + 1)/y
", - "changes": { - "var1": 14 - } - }, - { - "code": "
x += 2
", - "changes": { - "var1": 16 - } - }, - { - "code": "
x -= 2
", - "changes": { - "var1": 12 - } - }, - { - "code": "
x *= 2
", - "changes": { - "var1": 28 - } - }, - { - "code": "
x /= 2
", - "changes": { - "var1": 7 - } - }, - { - "code": "
x = abs(-6)
", - "changes": { - "var1": 6 - } - }, - { - "code": "
x = min(5, -y, 2.3)
", - "changes": { - "var1": -15 - } - }, - { - "code": "
x = max(5, -y, 2.3)
", - "changes": { - "var1": 5 - } - }, - { - "code": "
x = random()
", - "changes": {} - }, - { - "code": "
x = roll(6)
", - "changes": {} - }, - { - "code": "
x = roll(6, 5)
", - "changes": {} - }, - { - "code": "
x = roll(y)
", - "changes": {} - }, - { - "code": "
x = round(2.65)
", - "changes": { - "var1": 3 - } - }, - { - "code": "
show(\"x is \", x)
", - "changes": {}, - "output": "

x is 14

" - }, - { - "code": "
y = 33
reset(y)
", - "changes": { - "var2": 15 - } - }, - { - "code": "
x = 16
y = 33
resetAll(y)
", - "changes": { - "var1": 14, - "var2": 33, - "var3": 0, - "var4": "Dummy text", - "var5": 0, - "var6": false, - "var7": -1, - "var8": "Different Text" - } - }, - { - "code": "
$c5 = x
", - "changes": { - "var5": 14 - } - }, - { - "code": "
if (x==14) 
x=5
endif
", - "changes": { - "var1": 5 - } - }, - { - "code": "
if (x==11)
x=5
else
x=7
endif
", - "changes": { - "var1": 7 - } - }, - { - "code": "
if x==3
x=5
elseif x==14
x=2
else
x = 0
endif
", - "changes": { - "var1": 2 - } - }, - { - "code": "

Mein gott!

x = 1

What is that?

", - "changes": { - "var1": 1 - }, - "output": "

Mein gott! What is that?

" - }, - { - "code": "

Hello my dear

if x == 1

We might ride to the mountains.

endif
", - "changes": {}, - "output": "

Hello my dear

" - }, - { - "code": "

You carry

if x == 12

a small knife

elseif y == 12

a large sword

elseif z == 1

just a rotten tomato

else

nothing really

endif
", - "changes": {}, - "output": "

You carry nothing really

" - }, - { - "code": "

How are you?

x = 1

I am fine, thank you.

", - "changes": {}, - "output": "

How are you?

I am fine, thank you.

" - }, - { - "code": "
show(\"Hello friends:\", x)
", - "changes": {}, - "output": "

Hello friends:14

" - }, - { - "code": "
_a = true
if (((_a)))
x = 1
endif
", - "changes": { - "var1": 1, - "var6": true - } - }, - { - "code": "
visits() == 1
", - "visits": { - "a": 1, - "b": 1, - "c": 0 - }, - "elementId": "b", - "result": true - }, - { - "code": "
visits(Untitled Comp) == 9
", - "visits": { - "a": 1, - "b": 1, - "c": 0 - }, - "elementId": "b", - "result": false - }, - { - "code": "

this

text

must

not

be

in

one

paragraph

", - "output": "

this

text

must

not

be

in

one

paragraph

" - }, - { - "code": "

three

separate

lines

just

show(\"one\")
show(\"and\")
show(\"single\")

line

three

more

lines

", - "output": "

three

separate

lines

just one and single line

three

more

lines

" - }, - { - "code": "

This is a blockquote

if x

This is a separate line

endif

This is another blockquote

", - "output": "

This is a blockquote

This is a separate line

This is another blockquote

" - }, - { - "code": "

This is a blockquote

show(x)

test

", - "output": "

This is a blockquote 14

test

" - }, - { - "code": "

This is a blockquote

show(x)

test

", - "output": "

This is a blockquote 14 test

" - }, - { - "code": "

one

if true

two

endif

three

", - "output": "

one

two

three

" - }, - { - "code": "

one

if true

two

endif

three

", - "output": "

one two

three

" - }, - { - "code": "

one

if true

two

endif

three

", - "output": "

one two

three

" - }, - { - "code": "

one

if true
show(x)
endif

three

", - "output": "

one 14

three

" - }, - { - "code": "

one

if true

two

test

four

endif

three

", - "output": "

one two

test

four

three

" - }, - { - "code": "

one

if true

two

test

show(\"four\")
endif

three

", - "output": "

one two

test four

three

" - }, - { - "code": "

one

if false

two

endif

three

", - "output": "

one

three

" - }, - { - "code": "

This is a blockquote

if true

Second blockquote

Separate Line

endif

Outside blockquote

", - "output": "

This is a blockquote

Second blockquote

Separate Line

Outside blockquote

" - }, - { - "code": "

Test

_a = true

this

", - "output": "

Test this

", - "changes": { - "var6": true - } - }, - { - "code": "

Test

show(x)

this

", - "output": "

Test 14 this

" - }, - { - "code": "

this is a test

show(x)

continue

testing

", - "output": "

this is a test

14 continue

testing

" - }, - { - "code": "", - "changes": {} - } - ] +{ + "initialVars": { + "var1": { + "id": "var1", + "name": "x", + "type": "integer", + "value": 14 + }, + "var2": { + "id": "var2", + "name": "y", + "type": "integer", + "value": 15 + }, + "var3": { + "id": "var3", + "name": "z", + "type": "integer", + "value": 0 + }, + "var4": { + "id": "var4", + "name": "w", + "type": "string", + "value": "Dummy text" + }, + "var5": { + "id": "var5", + "name": "$c5", + "type": "integer", + "value": 0 + }, + "var6": { + "id": "var6", + "name": "_a", + "type": "boolean", + "value": false + }, + "var7": { + "id": "var7", + "name": "xy", + "type": "integer", + "value": -1 + }, + "var8": { + "id": "var8", + "name": "man", + "type": "string", + "value": "Different Text" + } + }, + "cases": [ + { + "code": "
x=5
", + "changes": { + "var1": 5 + } + }, + { + "code": "
x=-5
", + "changes": { + "var1": -5 + } + }, + { + "code": "
x=5.23
", + "changes": { + "var1": 5.23 + } + }, + { + "code": "
x=3
y=2
", + "changes": { + "var1": 3, + "var2": 2 + } + }, + { + "code": "
x=\"test\"
", + "changes": { + "var1": "test" + } + }, + { + "code": "
x=true
", + "changes": { + "var1": true + } + }, + { + "code": "
x = y
", + "changes": { + "var1": 15 + } + }, + { + "code": "
x = 5 + 3
", + "changes": { + "var1": 8 + } + }, + { + "code": "
x = 3 / 4 * 5
", + "changes": { + "var1": 3.75 + } + }, + { + "code": "
x = 3 + 4 * 5
", + "changes": { + "var1": 23 + } + }, + { + "code": "
x = 3 * 4 + 5
", + "changes": { + "var1": 17 + } + }, + { + "code": "
x = 3 / 4 / 5
", + "changes": { + "var1": 0.15 + } + }, + { + "code": "
x = sqr(2)
", + "changes": { + "var1": 4 + } + }, + { + "code": "
x = 3 > 2
", + "changes": { + "var1": true + } + }, + { + "code": "
x = 3 >= 2
", + "changes": { + "var1": true + } + }, + { + "code": "
x = 3 < 2
", + "changes": { + "var1": false + } + }, + { + "code": "
x = 3 <= 2
", + "changes": { + "var1": false + } + }, + { + "code": "
x = 3 == 2
", + "changes": { + "var1": false + } + }, + { + "code": "
x = 3 != 2
", + "changes": { + "var1": true + } + }, + { + "code": "
_a = !(3 == 2)
", + "changes": { + "var6": true + } + }, + { + "code": "
_a = not (3 == 2)
", + "changes": { + "var6": true + } + }, + { + "code": "
x = !0
", + "changes": { + "var1": true + } + }, + { + "code": "
x = true || false
", + "changes": { + "var1": true + } + }, + { + "code": "
x = true && false
", + "changes": { + "var1": false + } + }, + { + "code": "
x = -3
y = y + 3
z = sqr(x)
", + "changes": { + "var1": -3, + "var2": 18, + "var3": 9 + } + }, + { + "code": "
x = sqrt(y + 2)
", + "changes": { + "var1": 4.123105625617661 + } + }, + { + "code": "
x = z + 12 == 4 * 3
", + "changes": { + "var1": true + } + }, + { + "code": "
x = y == 15 && !(z == 1)
", + "changes": { + "var1": true + } + }, + { + "code": "
x = (x*x + 3)/y
", + "changes": { + "var1": 13.266666666666667 + } + }, + { + "code": "
x = x*(x + 1)/y
", + "changes": { + "var1": 14 + } + }, + { + "code": "
x += 2
", + "changes": { + "var1": 16 + } + }, + { + "code": "
x -= 2
", + "changes": { + "var1": 12 + } + }, + { + "code": "
x *= 2
", + "changes": { + "var1": 28 + } + }, + { + "code": "
x /= 2
", + "changes": { + "var1": 7 + } + }, + { + "code": "
x = abs(-6)
", + "changes": { + "var1": 6 + } + }, + { + "code": "
x = min(5, -y, 2.3)
", + "changes": { + "var1": -15 + } + }, + { + "code": "
x = max(5, -y, 2.3)
", + "changes": { + "var1": 5 + } + }, + { + "code": "
x = random()
", + "changes": {} + }, + { + "code": "
x = roll(6)
", + "changes": {} + }, + { + "code": "
x = roll(6, 5)
", + "changes": {} + }, + { + "code": "
x = roll(y)
", + "changes": {} + }, + { + "code": "
x = round(2.65)
", + "changes": { + "var1": 3 + } + }, + { + "code": "
show(\"x is \", x)
", + "changes": {}, + "output": "

x is 14

" + }, + { + "code": "
y = 33
reset(y)
", + "changes": { + "var2": 15 + } + }, + { + "code": "
x = 16
y = 33
resetAll(y)
", + "changes": { + "var1": 14, + "var2": 33, + "var3": 0, + "var4": "Dummy text", + "var5": 0, + "var6": false, + "var7": -1, + "var8": "Different Text" + } + }, + { + "code": "
$c5 = x
", + "changes": { + "var5": 14 + } + }, + { + "code": "
if (x==14) 
x=5
endif
", + "changes": { + "var1": 5 + } + }, + { + "code": "
if (x==11)
x=5
else
x=7
endif
", + "changes": { + "var1": 7 + } + }, + { + "code": "
if x==3
x=5
elseif x==14
x=2
else
x = 0
endif
", + "changes": { + "var1": 2 + } + }, + { + "code": "

Mein gott!

x = 1

What is that?

", + "changes": { + "var1": 1 + }, + "output": "

Mein gott! What is that?

" + }, + { + "code": "

Hello my dear

if x == 1

We might ride to the mountains.

endif
", + "changes": {}, + "output": "

Hello my dear

" + }, + { + "code": "

You carry

if x == 12

a small knife

elseif y == 12

a large sword

elseif z == 1

just a rotten tomato

else

nothing really

endif
", + "changes": {}, + "output": "

You carry nothing really

" + }, + { + "code": "

How are you?

x = 1

I am fine, thank you.

", + "changes": {}, + "output": "

How are you?

I am fine, thank you.

" + }, + { + "code": "
show(\"Hello friends:\", x)
", + "changes": {}, + "output": "

Hello friends:14

" + }, + { + "code": "
_a = true
if (((_a)))
x = 1
endif
", + "changes": { + "var1": 1, + "var6": true + } + }, + { + "code": "
visits() == 1
", + "visits": { + "a": 1, + "b": 1, + "c": 0 + }, + "elementId": "b", + "result": true + }, + { + "code": "
visits(Untitled Comp) == 9
", + "visits": { + "a": 1, + "b": 1, + "c": 0 + }, + "elementId": "b", + "result": false + }, + { + "code": "

this

text

must

not

be

in

one

paragraph

", + "output": "

this

text

must

not

be

in

one

paragraph

" + }, + { + "code": "

three

separate

lines

just

show(\"one\")
show(\"and\")
show(\"single\")

line

three

more

lines

", + "output": "

three

separate

lines

just one and single line

three

more

lines

" + }, + { + "code": "

This is a blockquote

if x

This is a separate line

endif

This is another blockquote

", + "output": "

This is a blockquote

This is a separate line

This is another blockquote

" + }, + { + "code": "

This is a blockquote

show(x)

test

", + "output": "

This is a blockquote 14

test

" + }, + { + "code": "

This is a blockquote

show(x)

test

", + "output": "

This is a blockquote 14 test

" + }, + { + "code": "

one

if true

two

endif

three

", + "output": "

one

two

three

" + }, + { + "code": "

one

if true

two

endif

three

", + "output": "

one two

three

" + }, + { + "code": "

one

if true

two

endif

three

", + "output": "

one two

three

" + }, + { + "code": "

one

if true
show(x)
endif

three

", + "output": "

one 14

three

" + }, + { + "code": "

one

if true

two

test

four

endif

three

", + "output": "

one two

test

four

three

" + }, + { + "code": "

one

if true

two

test

show(\"four\")
endif

three

", + "output": "

one two

test four

three

" + }, + { + "code": "

one

if false

two

endif

three

", + "output": "

one

three

" + }, + { + "code": "

This is a blockquote

if true

Second blockquote

Separate Line

endif

Outside blockquote

", + "output": "

This is a blockquote

Second blockquote

Separate Line

Outside blockquote

" + }, + { + "code": "

Test

_a = true

this

", + "output": "

Test this

", + "changes": { + "var6": true + } + }, + { + "code": "

Test

show(x)

this

", + "output": "

Test 14 this

" + }, + { + "code": "

this is a test

show(x)

continue

testing

", + "output": "

this is a test

14 continue

testing

" + }, + { + "code": "

This is a test

Manolis

inside blockquotes

if true

John

endif
", + "output": "

This is a test

Manolis

inside blockquotes

John

" + }, + { + "code": "
w = \"String with \\\"quotes\\\" \\t tabs and \\n new lines\"
show(w)
", + "output": "

String with \"quotes\" \t tabs and \n new lines

" + } + ] } \ No newline at end of file diff --git a/generate.ps1 b/generate.ps1 new file mode 100644 index 0000000..593c942 --- /dev/null +++ b/generate.ps1 @@ -0,0 +1,33 @@ +# Download antlr4.jar if it doesn't exist +if (-Not (Test-Path "./antlr4.jar")) { + Invoke-WebRequest -Uri "https://www.antlr.org/download/antlr-4.13.1-complete.jar" -OutFile "antlr4.jar" +} + +Set-Location "grammar" + +# JavaScript generation +java -Xmx500M -cp ../antlr4.jar org.antlr.v4.Tool -Dlanguage=JavaScript ArcscriptLexer.g4 ArcscriptParser.g4 -visitor -no-listener -o ./JavaScript +New-Item -ItemType Directory -Force -Path ../JavaScript/src/Generated | Out-Null +Copy-Item JavaScript\*.js ../JavaScript/src/Generated\ +Remove-Item -Recurse -Force ./JavaScript + +# Copy grammar files for Cpp +Copy-Item Arcscript*.g4 ./Cpp/ +Set-Location "Cpp" +python transformGrammar.py +java -Xmx500M -cp ../../antlr4.jar org.antlr.v4.Tool -Dlanguage=Cpp ArcscriptLexer.g4 ArcscriptParser.g4 -visitor -no-listener -o ./Generated -package Arcweave +New-Item -ItemType Directory -Force -Path ../../Cpp/src/Generated/ArcscriptLexer | Out-Null +New-Item -ItemType Directory -Force -Path ../../Cpp/src/Generated/ArcscriptParser | Out-Null +Copy-Item Generated\*Lexer*.cpp ../../Cpp/src/Generated/ArcscriptLexer +Copy-Item Generated\*Lexer*.h ../../Cpp/src/Generated/ArcscriptLexer +Copy-Item Generated\*Parser*.cpp ../../Cpp/src/Generated/ArcscriptParser +Copy-Item Generated\*Parser*.h ../../Cpp/src/Generated/ArcscriptParser +Remove-Item -Recurse -Force ./Generated +Remove-Item *.g4,*.g4.bak -Force +Set-Location .. + +# CSharp generation +java -Xmx500M -cp ../antlr4.jar org.antlr.v4.Tool -Dlanguage=CSharp ArcscriptLexer.g4 ArcscriptParser.g4 -visitor -no-listener -o ./CSharp -package Arcweave.Interpreter +New-Item -ItemType Directory -Force -Path ../CSharp/src/Generated | Out-Null +Copy-Item CSharp\*.cs ../CSharp/src/Generated\ +Remove-Item -Recurse -Force ./CSharp \ No newline at end of file From d4b191eeea4722d8e0f6a9289dd4ae0f12025ff9 Mon Sep 17 00:00:00 2001 From: Manolis Dermitzakis Date: Sat, 24 Jan 2026 11:39:12 +0200 Subject: [PATCH 06/13] fix: double to string using dot notation instead of comma --- CSharp/Interpreter/ArcscriptExpression.cs | 7 ++++++- CSharp/Interpreter/ArcscriptExpressionBase.cs | 16 ++++++++++++++++ CSharp/Interpreter/ArcscriptVisitor.cs | 15 ++++++--------- 3 files changed, 28 insertions(+), 10 deletions(-) create mode 100644 CSharp/Interpreter/ArcscriptExpressionBase.cs diff --git a/CSharp/Interpreter/ArcscriptExpression.cs b/CSharp/Interpreter/ArcscriptExpression.cs index 4f2f24f..8fb8a32 100644 --- a/CSharp/Interpreter/ArcscriptExpression.cs +++ b/CSharp/Interpreter/ArcscriptExpression.cs @@ -4,7 +4,7 @@ namespace Arcweave.Interpreter { - public class Expression : IComparable + public class Expression : ArcscriptExpressionBase, IComparable { public object Value { get; set; } public Expression() { Value = null; } @@ -296,6 +296,11 @@ public override string ToString() } return "false"; } + + if (Value.GetType() == typeof(double)) + { + return ((double)Value).ToString(NumberFormat); + } return Value.ToString(); } diff --git a/CSharp/Interpreter/ArcscriptExpressionBase.cs b/CSharp/Interpreter/ArcscriptExpressionBase.cs new file mode 100644 index 0000000..8dc0958 --- /dev/null +++ b/CSharp/Interpreter/ArcscriptExpressionBase.cs @@ -0,0 +1,16 @@ +using System.Globalization; + +namespace Arcweave.Interpreter; + +public class ArcscriptExpressionBase +{ + public NumberFormatInfo NumberFormat { get; private set; } + public ArcscriptExpressionBase() + { + NumberFormat = new NumberFormatInfo + { + NumberDecimalSeparator = ".", + NumberGroupSeparator = "," + }; + } +} \ No newline at end of file diff --git a/CSharp/Interpreter/ArcscriptVisitor.cs b/CSharp/Interpreter/ArcscriptVisitor.cs index 0648694..741050a 100644 --- a/CSharp/Interpreter/ArcscriptVisitor.cs +++ b/CSharp/Interpreter/ArcscriptVisitor.cs @@ -1,6 +1,5 @@ using Antlr4.Runtime.Misc; -using System.Collections.Generic; -using System; +using System.Globalization; using Antlr4.Runtime.Tree; using Arcweave.Interpreter.INodes; @@ -262,10 +261,9 @@ public override object VisitExpression([NotNull] ArcscriptParser.ExpressionConte } public override object VisitAdditive_numeric_expression([NotNull] ArcscriptParser.Additive_numeric_expressionContext context) { - Expression mult_num_expression = (Expression)this.VisitMultiplicative_numeric_expression(context.multiplicative_numeric_expression()); - if ( context.additive_numeric_expression() != null ) { Expression result = (Expression)this.VisitAdditive_numeric_expression(context.additive_numeric_expression()); + Expression mult_num_expression = (Expression)this.VisitMultiplicative_numeric_expression(context.multiplicative_numeric_expression()); if ( context.ADD() != null ) { return result + mult_num_expression; } @@ -273,14 +271,13 @@ public override object VisitAdditive_numeric_expression([NotNull] ArcscriptParse return result - mult_num_expression; } - return mult_num_expression; + return (Expression)this.VisitMultiplicative_numeric_expression(context.multiplicative_numeric_expression()); } public override object VisitMultiplicative_numeric_expression([NotNull] ArcscriptParser.Multiplicative_numeric_expressionContext context) { - Expression signed_unary_num_expr = (Expression)this.VisitSigned_unary_numeric_expression(context.signed_unary_numeric_expression()); - if ( context.multiplicative_numeric_expression() != null ) { Expression result = (Expression)this.VisitMultiplicative_numeric_expression(context.multiplicative_numeric_expression()); + Expression signed_unary_num_expr = (Expression)this.VisitSigned_unary_numeric_expression(context.signed_unary_numeric_expression()); if ( context.MUL() != null ) { return result * signed_unary_num_expr; } @@ -288,7 +285,7 @@ public override object VisitMultiplicative_numeric_expression([NotNull] Arcscrip return result / signed_unary_num_expr; } - return signed_unary_num_expr; + return (Expression)this.VisitSigned_unary_numeric_expression(context.signed_unary_numeric_expression()); } public override object VisitSigned_unary_numeric_expression([NotNull] ArcscriptParser.Signed_unary_numeric_expressionContext context) { @@ -307,7 +304,7 @@ public override object VisitSigned_unary_numeric_expression([NotNull] ArcscriptP public override object VisitUnary_numeric_expression([NotNull] ArcscriptParser.Unary_numeric_expressionContext context) { if ( context.FLOAT() != null ) { - return new Expression(double.Parse(context.FLOAT().GetText())); + return new Expression(double.Parse(context.FLOAT().GetText(), CultureInfo.InvariantCulture)); } if ( context.INTEGER() != null ) { return new Expression(int.Parse(context.INTEGER().GetText())); From 6983b470db21afe7329acfd47000293fe5a4c64a Mon Sep 17 00:00:00 2001 From: Manolis Dermitzakis Date: Sat, 24 Jan 2026 11:51:43 +0200 Subject: [PATCH 07/13] chore: remove Generated files --- CSharp/.gitignore | 2 +- .../Interpreter/Generated/ArcscriptLexer.cs | 363 --- .../Interpreter/Generated/ArcscriptParser.cs | 2708 ----------------- .../Generated/ArcscriptParserBaseVisitor.cs | 419 --- .../Generated/ArcscriptParserVisitor.cs | 264 -- CSharp/Interpreter/Generated/AssemblyInfo.cs | 3 - CSharp/__tests__/replaceVariables.json | 7 + generate.sh | 4 +- 8 files changed, 10 insertions(+), 3760 deletions(-) delete mode 100644 CSharp/Interpreter/Generated/ArcscriptLexer.cs delete mode 100644 CSharp/Interpreter/Generated/ArcscriptParser.cs delete mode 100644 CSharp/Interpreter/Generated/ArcscriptParserBaseVisitor.cs delete mode 100644 CSharp/Interpreter/Generated/ArcscriptParserVisitor.cs delete mode 100644 CSharp/Interpreter/Generated/AssemblyInfo.cs diff --git a/CSharp/.gitignore b/CSharp/.gitignore index 893d366..72c54b0 100644 --- a/CSharp/.gitignore +++ b/CSharp/.gitignore @@ -1,4 +1,4 @@ -src/Generated +Interpreter/Generated ## Ignore Visual Studio temporary files, build results, and ## files generated by popular Visual Studio add-ons. diff --git a/CSharp/Interpreter/Generated/ArcscriptLexer.cs b/CSharp/Interpreter/Generated/ArcscriptLexer.cs deleted file mode 100644 index 30146fc..0000000 --- a/CSharp/Interpreter/Generated/ArcscriptLexer.cs +++ /dev/null @@ -1,363 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// ANTLR Version: 4.13.1 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -// Generated from ArcscriptLexer.g4 by ANTLR 4.13.1 - -// Unreachable code detected -#pragma warning disable 0162 -// The variable '...' is assigned but its value is never used -#pragma warning disable 0219 -// Missing XML comment for publicly visible type or member '...' -#pragma warning disable 1591 -// Ambiguous reference in cref attribute -#pragma warning disable 419 - -namespace Arcweave.Interpreter { -using System; -using System.IO; -using System.Text; -using Antlr4.Runtime; -using Antlr4.Runtime.Atn; -using Antlr4.Runtime.Misc; -using DFA = Antlr4.Runtime.Dfa.DFA; - -[System.CodeDom.Compiler.GeneratedCode("ANTLR", "4.13.1")] -[System.CLSCompliant(false)] -public partial class ArcscriptLexer : Lexer { - protected static DFA[] decisionToDFA; - protected static PredictionContextCache sharedContextCache = new PredictionContextCache(); - public const int - CODESTART=1, PARAGRAPHSTART=2, BLOCKQUOTESTART=3, NORMAL_WHITESPACE=4, - PARAGRAPHEND=5, BQ_CODESTART=6, BQ_PARAGRAPHSTART=7, BLOCKQUOTEEND=8, - BQ_WHITESPACE=9, CODEEND=10, MENTION_TAG_OPEN=11, FLOAT=12, INTEGER=13, - DIGIT=14, LPAREN=15, RPAREN=16, ASSIGNMUL=17, ASSIGNDIV=18, ASSIGNADD=19, - ASSIGNSUB=20, MUL=21, DIV=22, ADD=23, SUB=24, GE=25, GT=26, LE=27, LT=28, - EQ=29, NE=30, AND=31, OR=32, ASSIGN=33, NEG=34, COMMA=35, LBRACE=36, RBRACE=37, - BOOLEAN=38, FNAME=39, VFNAME=40, VFNAMEVARS=41, IFKEYWORD=42, ELSEKEYWORD=43, - ELSEIFKEYWORD=44, ENDIFKEYWORD=45, ANDKEYWORD=46, ORKEYWORD=47, ISKEYWORD=48, - NOTKEYWORD=49, STRING=50, VARIABLE=51, WHITESPACE=52, TAG_CLOSE=53, ATTR_NAME=54, - TAG_EQUALS=55, MENTION_TAG_CLOSE=56, TAG_WHITESPACE=57, TAG_OPEN=58, MENTION_LABEL=59, - ATTR_VALUE=60, ATTRIBUTE=61; - public const int - PARAGRAPH=1, BLOCKQUOTE=2, CODESEGMENT=3, MENTIONSEGMENT=4, MENTIONLABELSEGMENT=5, - MENTION_ATTR_SEGMENT=6; - public static string[] channelNames = { - "DEFAULT_TOKEN_CHANNEL", "HIDDEN" - }; - - public static string[] modeNames = { - "DEFAULT_MODE", "PARAGRAPH", "BLOCKQUOTE", "CODESEGMENT", "MENTIONSEGMENT", - "MENTIONLABELSEGMENT", "MENTION_ATTR_SEGMENT" - }; - - public static readonly string[] ruleNames = { - "CODESTART", "PARAGRAPHSTART", "BLOCKQUOTESTART", "NORMAL_WHITESPACE", - "PARAGRAPHEND", "BQ_CODESTART", "BQ_PARAGRAPHSTART", "BLOCKQUOTEEND", - "BQ_WHITESPACE", "CODEEND", "MENTION_TAG_OPEN", "FLOAT", "INTEGER", "DIGIT", - "LPAREN", "RPAREN", "ASSIGNMUL", "ASSIGNDIV", "ASSIGNADD", "ASSIGNSUB", - "MUL", "DIV", "ADD", "SUB", "GE", "GT", "LE", "LT", "EQ", "NE", "AND", - "OR", "ASSIGN", "NEG", "COMMA", "LBRACE", "RBRACE", "BOOLEAN", "FNAME", - "VFNAME", "VFNAMEVARS", "IFKEYWORD", "ELSEKEYWORD", "ELSEIFKEYWORD", "ENDIFKEYWORD", - "ANDKEYWORD", "ORKEYWORD", "ISKEYWORD", "NOTKEYWORD", "STRING", "STRING_CONTENT", - "VARIABLE", "WHITESPACE", "TAG_CLOSE", "ATTR_NAME", "TAG_EQUALS", "MENTION_TAG_CLOSE", - "TAG_WHITESPACE", "TAG_OPEN", "MENTION_LABEL", "ATTR_VALUE", "ATTRIBUTE", - "ATTCHARS", "ATTCHAR", "HEXCHARS", "DECCHARS", "DOUBLE_QUOTE_STRING", - "SINGLE_QUOTE_STRING" - }; - - - public ArcscriptLexer(ICharStream input) - : this(input, Console.Out, Console.Error) { } - - public ArcscriptLexer(ICharStream input, TextWriter output, TextWriter errorOutput) - : base(input, output, errorOutput) - { - Interpreter = new LexerATNSimulator(this, _ATN, decisionToDFA, sharedContextCache); - } - - private static readonly string[] _LiteralNames = { - null, null, null, null, null, null, null, null, "''", null, - "''", "''", null, null, "'/span>'", - null, "'<'" - }; - private static readonly string[] _SymbolicNames = { - null, "CODESTART", "PARAGRAPHSTART", "BLOCKQUOTESTART", "NORMAL_WHITESPACE", - "PARAGRAPHEND", "BQ_CODESTART", "BQ_PARAGRAPHSTART", "BLOCKQUOTEEND", - "BQ_WHITESPACE", "CODEEND", "MENTION_TAG_OPEN", "FLOAT", "INTEGER", "DIGIT", - "LPAREN", "RPAREN", "ASSIGNMUL", "ASSIGNDIV", "ASSIGNADD", "ASSIGNSUB", - "MUL", "DIV", "ADD", "SUB", "GE", "GT", "LE", "LT", "EQ", "NE", "AND", - "OR", "ASSIGN", "NEG", "COMMA", "LBRACE", "RBRACE", "BOOLEAN", "FNAME", - "VFNAME", "VFNAMEVARS", "IFKEYWORD", "ELSEKEYWORD", "ELSEIFKEYWORD", "ENDIFKEYWORD", - "ANDKEYWORD", "ORKEYWORD", "ISKEYWORD", "NOTKEYWORD", "STRING", "VARIABLE", - "WHITESPACE", "TAG_CLOSE", "ATTR_NAME", "TAG_EQUALS", "MENTION_TAG_CLOSE", - "TAG_WHITESPACE", "TAG_OPEN", "MENTION_LABEL", "ATTR_VALUE", "ATTRIBUTE" - }; - public static readonly IVocabulary DefaultVocabulary = new Vocabulary(_LiteralNames, _SymbolicNames); - - [NotNull] - public override IVocabulary Vocabulary - { - get - { - return DefaultVocabulary; - } - } - - public override string GrammarFileName { get { return "ArcscriptLexer.g4"; } } - - public override string[] RuleNames { get { return ruleNames; } } - - public override string[] ChannelNames { get { return channelNames; } } - - public override string[] ModeNames { get { return modeNames; } } - - public override int[] SerializedAtn { get { return _serializedATN; } } - - static ArcscriptLexer() { - decisionToDFA = new DFA[_ATN.NumberOfDecisions]; - for (int i = 0; i < _ATN.NumberOfDecisions; i++) { - decisionToDFA[i] = new DFA(_ATN.GetDecisionState(i), i); - } - } - private static int[] _serializedATN = { - 4,0,61,659,6,-1,6,-1,6,-1,6,-1,6,-1,6,-1,6,-1,2,0,7,0,2,1,7,1,2,2,7,2, - 2,3,7,3,2,4,7,4,2,5,7,5,2,6,7,6,2,7,7,7,2,8,7,8,2,9,7,9,2,10,7,10,2,11, - 7,11,2,12,7,12,2,13,7,13,2,14,7,14,2,15,7,15,2,16,7,16,2,17,7,17,2,18, - 7,18,2,19,7,19,2,20,7,20,2,21,7,21,2,22,7,22,2,23,7,23,2,24,7,24,2,25, - 7,25,2,26,7,26,2,27,7,27,2,28,7,28,2,29,7,29,2,30,7,30,2,31,7,31,2,32, - 7,32,2,33,7,33,2,34,7,34,2,35,7,35,2,36,7,36,2,37,7,37,2,38,7,38,2,39, - 7,39,2,40,7,40,2,41,7,41,2,42,7,42,2,43,7,43,2,44,7,44,2,45,7,45,2,46, - 7,46,2,47,7,47,2,48,7,48,2,49,7,49,2,50,7,50,2,51,7,51,2,52,7,52,2,53, - 7,53,2,54,7,54,2,55,7,55,2,56,7,56,2,57,7,57,2,58,7,58,2,59,7,59,2,60, - 7,60,2,61,7,61,2,62,7,62,2,63,7,63,2,64,7,64,2,65,7,65,2,66,7,66,2,67, - 7,67,1,0,1,0,1,0,1,0,1,0,1,0,5,0,150,8,0,10,0,12,0,153,9,0,1,0,1,0,1,0, - 1,0,1,0,1,0,1,0,1,0,5,0,163,8,0,10,0,12,0,166,9,0,1,0,1,0,1,0,1,0,1,1, - 1,1,1,1,1,1,1,1,1,1,1,1,1,1,5,1,180,8,1,10,1,12,1,183,9,1,1,1,3,1,186, - 8,1,1,1,1,1,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,5,2,203, - 8,2,10,2,12,2,206,9,2,1,2,1,2,1,2,1,2,1,3,4,3,213,8,3,11,3,12,3,214,1, - 3,1,3,1,4,5,4,220,8,4,10,4,12,4,223,9,4,1,4,1,4,1,4,1,4,1,4,1,4,1,4,1, - 5,1,5,1,5,1,5,1,5,1,5,5,5,238,8,5,10,5,12,5,241,9,5,1,5,1,5,1,5,1,5,1, - 5,1,5,1,5,1,5,5,5,251,8,5,10,5,12,5,254,9,5,1,5,1,5,1,5,1,5,1,6,1,6,1, - 6,1,6,1,6,1,6,1,6,1,6,5,6,268,8,6,10,6,12,6,271,9,6,1,6,3,6,274,8,6,1, - 6,1,6,1,7,1,7,1,7,1,7,1,7,1,7,1,7,1,7,1,7,1,7,1,7,1,7,1,7,1,7,1,7,1,7, - 1,8,4,8,295,8,8,11,8,12,8,296,1,8,1,8,1,9,1,9,1,9,1,9,1,9,1,9,1,9,1,9, - 1,9,1,9,1,9,1,9,1,9,1,9,1,9,1,9,1,10,1,10,1,10,1,10,1,10,1,10,1,10,1,10, - 1,11,5,11,326,8,11,10,11,12,11,329,9,11,1,11,1,11,4,11,333,8,11,11,11, - 12,11,334,1,12,4,12,338,8,12,11,12,12,12,339,1,13,1,13,1,14,1,14,1,15, - 1,15,1,16,1,16,1,16,1,17,1,17,1,17,1,18,1,18,1,18,1,19,1,19,1,19,1,20, - 1,20,1,21,1,21,1,22,1,22,1,23,1,23,1,24,1,24,1,24,1,25,1,25,1,25,1,25, - 1,25,3,25,376,8,25,1,26,1,26,1,26,1,27,1,27,1,27,1,27,1,27,3,27,386,8, - 27,1,28,1,28,1,28,1,29,1,29,1,29,1,30,1,30,1,30,1,30,1,30,1,30,1,30,1, - 30,1,30,1,30,1,30,1,30,3,30,406,8,30,1,31,1,31,1,31,1,32,1,32,1,33,1,33, - 1,34,1,34,1,35,1,35,1,36,1,36,1,37,1,37,1,37,1,37,1,37,1,37,1,37,1,37, - 1,37,3,37,430,8,37,1,38,1,38,1,38,1,38,1,38,1,38,1,38,1,38,1,38,1,38,1, - 38,1,38,1,38,1,38,1,38,1,38,1,38,1,38,1,38,1,38,1,38,1,38,1,38,1,38,1, - 38,1,38,1,38,1,38,1,38,1,38,1,38,1,38,1,38,1,38,1,38,1,38,1,38,3,38,469, - 8,38,1,39,1,39,1,39,1,39,1,39,1,40,1,40,1,40,1,40,1,40,1,40,1,40,1,40, - 1,40,1,40,1,40,1,40,1,40,3,40,489,8,40,1,41,1,41,1,41,1,42,1,42,1,42,1, - 42,1,42,1,43,1,43,1,43,1,43,1,43,1,43,1,43,1,44,1,44,1,44,1,44,1,44,1, - 44,1,45,1,45,1,45,1,45,1,46,1,46,1,46,1,47,1,47,1,47,1,48,1,48,1,48,1, - 48,1,49,1,49,5,49,528,8,49,10,49,12,49,531,9,49,1,49,1,49,1,49,5,49,536, - 8,49,10,49,12,49,539,9,49,1,49,3,49,542,8,49,1,50,1,50,1,50,3,50,547,8, - 50,1,51,1,51,5,51,551,8,51,10,51,12,51,554,9,51,1,52,4,52,557,8,52,11, - 52,12,52,558,1,52,1,52,1,53,1,53,1,53,1,53,1,54,1,54,5,54,569,8,54,10, - 54,12,54,572,9,54,1,55,1,55,1,55,1,55,1,56,1,56,1,56,1,56,1,56,1,56,1, - 56,1,56,1,56,1,57,1,57,1,57,1,57,1,58,1,58,1,58,1,58,1,59,4,59,596,8,59, - 11,59,12,59,597,1,60,5,60,601,8,60,10,60,12,60,604,9,60,1,60,1,60,1,60, - 1,60,1,61,1,61,1,61,1,61,1,61,3,61,615,8,61,1,62,4,62,618,8,62,11,62,12, - 62,619,1,62,3,62,623,8,62,1,63,3,63,626,8,63,1,64,1,64,4,64,630,8,64,11, - 64,12,64,631,1,65,4,65,635,8,65,11,65,12,65,636,1,65,3,65,640,8,65,1,66, - 1,66,5,66,644,8,66,10,66,12,66,647,9,66,1,66,1,66,1,67,1,67,5,67,653,8, - 67,10,67,12,67,656,9,67,1,67,1,67,1,221,0,68,7,1,9,2,11,3,13,4,15,5,17, - 6,19,7,21,8,23,9,25,10,27,11,29,12,31,13,33,14,35,15,37,16,39,17,41,18, - 43,19,45,20,47,21,49,22,51,23,53,24,55,25,57,26,59,27,61,28,63,29,65,30, - 67,31,69,32,71,33,73,34,75,35,77,36,79,37,81,38,83,39,85,40,87,41,89,42, - 91,43,93,44,95,45,97,46,99,47,101,48,103,49,105,50,107,0,109,51,111,52, - 113,53,115,54,117,55,119,56,121,57,123,58,125,59,127,60,129,61,131,0,133, - 0,135,0,137,0,139,0,141,0,7,0,1,2,3,4,5,6,14,1,0,62,62,3,0,9,10,13,13, - 32,32,1,0,48,57,5,0,10,10,13,13,34,34,39,39,92,92,9,0,34,34,39,39,92,92, - 97,98,102,102,110,110,114,114,116,116,118,118,4,0,36,36,65,90,95,95,97, - 122,5,0,36,36,48,57,65,90,95,95,97,122,3,0,58,58,65,90,97,122,5,0,45,46, - 48,58,65,90,95,95,97,122,1,0,60,60,7,0,35,35,43,59,61,61,63,63,65,90,95, - 95,97,122,3,0,48,57,65,70,97,102,2,0,34,34,60,60,2,0,39,39,60,60,693,0, - 7,1,0,0,0,0,9,1,0,0,0,0,11,1,0,0,0,0,13,1,0,0,0,1,15,1,0,0,0,2,17,1,0, - 0,0,2,19,1,0,0,0,2,21,1,0,0,0,2,23,1,0,0,0,3,25,1,0,0,0,3,27,1,0,0,0,3, - 29,1,0,0,0,3,31,1,0,0,0,3,33,1,0,0,0,3,35,1,0,0,0,3,37,1,0,0,0,3,39,1, - 0,0,0,3,41,1,0,0,0,3,43,1,0,0,0,3,45,1,0,0,0,3,47,1,0,0,0,3,49,1,0,0,0, - 3,51,1,0,0,0,3,53,1,0,0,0,3,55,1,0,0,0,3,57,1,0,0,0,3,59,1,0,0,0,3,61, - 1,0,0,0,3,63,1,0,0,0,3,65,1,0,0,0,3,67,1,0,0,0,3,69,1,0,0,0,3,71,1,0,0, - 0,3,73,1,0,0,0,3,75,1,0,0,0,3,77,1,0,0,0,3,79,1,0,0,0,3,81,1,0,0,0,3,83, - 1,0,0,0,3,85,1,0,0,0,3,87,1,0,0,0,3,89,1,0,0,0,3,91,1,0,0,0,3,93,1,0,0, - 0,3,95,1,0,0,0,3,97,1,0,0,0,3,99,1,0,0,0,3,101,1,0,0,0,3,103,1,0,0,0,3, - 105,1,0,0,0,3,109,1,0,0,0,3,111,1,0,0,0,4,113,1,0,0,0,4,115,1,0,0,0,4, - 117,1,0,0,0,4,119,1,0,0,0,4,121,1,0,0,0,5,123,1,0,0,0,5,125,1,0,0,0,6, - 127,1,0,0,0,6,129,1,0,0,0,7,143,1,0,0,0,9,185,1,0,0,0,11,189,1,0,0,0,13, - 212,1,0,0,0,15,221,1,0,0,0,17,231,1,0,0,0,19,273,1,0,0,0,21,277,1,0,0, - 0,23,294,1,0,0,0,25,300,1,0,0,0,27,316,1,0,0,0,29,327,1,0,0,0,31,337,1, - 0,0,0,33,341,1,0,0,0,35,343,1,0,0,0,37,345,1,0,0,0,39,347,1,0,0,0,41,350, - 1,0,0,0,43,353,1,0,0,0,45,356,1,0,0,0,47,359,1,0,0,0,49,361,1,0,0,0,51, - 363,1,0,0,0,53,365,1,0,0,0,55,367,1,0,0,0,57,375,1,0,0,0,59,377,1,0,0, - 0,61,385,1,0,0,0,63,387,1,0,0,0,65,390,1,0,0,0,67,405,1,0,0,0,69,407,1, - 0,0,0,71,410,1,0,0,0,73,412,1,0,0,0,75,414,1,0,0,0,77,416,1,0,0,0,79,418, - 1,0,0,0,81,429,1,0,0,0,83,468,1,0,0,0,85,470,1,0,0,0,87,488,1,0,0,0,89, - 490,1,0,0,0,91,493,1,0,0,0,93,498,1,0,0,0,95,505,1,0,0,0,97,511,1,0,0, - 0,99,515,1,0,0,0,101,518,1,0,0,0,103,521,1,0,0,0,105,541,1,0,0,0,107,546, - 1,0,0,0,109,548,1,0,0,0,111,556,1,0,0,0,113,562,1,0,0,0,115,566,1,0,0, - 0,117,573,1,0,0,0,119,577,1,0,0,0,121,586,1,0,0,0,123,590,1,0,0,0,125, - 595,1,0,0,0,127,602,1,0,0,0,129,614,1,0,0,0,131,617,1,0,0,0,133,625,1, - 0,0,0,135,627,1,0,0,0,137,634,1,0,0,0,139,641,1,0,0,0,141,650,1,0,0,0, - 143,144,5,60,0,0,144,145,5,112,0,0,145,146,5,114,0,0,146,147,5,101,0,0, - 147,151,1,0,0,0,148,150,8,0,0,0,149,148,1,0,0,0,150,153,1,0,0,0,151,149, - 1,0,0,0,151,152,1,0,0,0,152,154,1,0,0,0,153,151,1,0,0,0,154,155,5,62,0, - 0,155,156,5,60,0,0,156,157,5,99,0,0,157,158,5,111,0,0,158,159,5,100,0, - 0,159,160,5,101,0,0,160,164,1,0,0,0,161,163,8,0,0,0,162,161,1,0,0,0,163, - 166,1,0,0,0,164,162,1,0,0,0,164,165,1,0,0,0,165,167,1,0,0,0,166,164,1, - 0,0,0,167,168,5,62,0,0,168,169,1,0,0,0,169,170,6,0,0,0,170,8,1,0,0,0,171, - 172,5,60,0,0,172,173,5,112,0,0,173,186,5,62,0,0,174,175,5,60,0,0,175,176, - 5,112,0,0,176,177,5,32,0,0,177,181,1,0,0,0,178,180,8,0,0,0,179,178,1,0, - 0,0,180,183,1,0,0,0,181,179,1,0,0,0,181,182,1,0,0,0,182,184,1,0,0,0,183, - 181,1,0,0,0,184,186,5,62,0,0,185,171,1,0,0,0,185,174,1,0,0,0,186,187,1, - 0,0,0,187,188,6,1,1,0,188,10,1,0,0,0,189,190,5,60,0,0,190,191,5,98,0,0, - 191,192,5,108,0,0,192,193,5,111,0,0,193,194,5,99,0,0,194,195,5,107,0,0, - 195,196,5,113,0,0,196,197,5,117,0,0,197,198,5,111,0,0,198,199,5,116,0, - 0,199,200,5,101,0,0,200,204,1,0,0,0,201,203,8,0,0,0,202,201,1,0,0,0,203, - 206,1,0,0,0,204,202,1,0,0,0,204,205,1,0,0,0,205,207,1,0,0,0,206,204,1, - 0,0,0,207,208,5,62,0,0,208,209,1,0,0,0,209,210,6,2,2,0,210,12,1,0,0,0, - 211,213,7,1,0,0,212,211,1,0,0,0,213,214,1,0,0,0,214,212,1,0,0,0,214,215, - 1,0,0,0,215,216,1,0,0,0,216,217,6,3,3,0,217,14,1,0,0,0,218,220,9,0,0,0, - 219,218,1,0,0,0,220,223,1,0,0,0,221,222,1,0,0,0,221,219,1,0,0,0,222,224, - 1,0,0,0,223,221,1,0,0,0,224,225,5,60,0,0,225,226,5,47,0,0,226,227,5,112, - 0,0,227,228,5,62,0,0,228,229,1,0,0,0,229,230,6,4,4,0,230,16,1,0,0,0,231, - 232,5,60,0,0,232,233,5,112,0,0,233,234,5,114,0,0,234,235,5,101,0,0,235, - 239,1,0,0,0,236,238,8,0,0,0,237,236,1,0,0,0,238,241,1,0,0,0,239,237,1, - 0,0,0,239,240,1,0,0,0,240,242,1,0,0,0,241,239,1,0,0,0,242,243,5,62,0,0, - 243,244,5,60,0,0,244,245,5,99,0,0,245,246,5,111,0,0,246,247,5,100,0,0, - 247,248,5,101,0,0,248,252,1,0,0,0,249,251,8,0,0,0,250,249,1,0,0,0,251, - 254,1,0,0,0,252,250,1,0,0,0,252,253,1,0,0,0,253,255,1,0,0,0,254,252,1, - 0,0,0,255,256,5,62,0,0,256,257,1,0,0,0,257,258,6,5,0,0,258,18,1,0,0,0, - 259,260,5,60,0,0,260,261,5,112,0,0,261,274,5,62,0,0,262,263,5,60,0,0,263, - 264,5,112,0,0,264,265,5,32,0,0,265,269,1,0,0,0,266,268,8,0,0,0,267,266, - 1,0,0,0,268,271,1,0,0,0,269,267,1,0,0,0,269,270,1,0,0,0,270,272,1,0,0, - 0,271,269,1,0,0,0,272,274,5,62,0,0,273,259,1,0,0,0,273,262,1,0,0,0,274, - 275,1,0,0,0,275,276,6,6,1,0,276,20,1,0,0,0,277,278,5,60,0,0,278,279,5, - 47,0,0,279,280,5,98,0,0,280,281,5,108,0,0,281,282,5,111,0,0,282,283,5, - 99,0,0,283,284,5,107,0,0,284,285,5,113,0,0,285,286,5,117,0,0,286,287,5, - 111,0,0,287,288,5,116,0,0,288,289,5,101,0,0,289,290,5,62,0,0,290,291,1, - 0,0,0,291,292,6,7,4,0,292,22,1,0,0,0,293,295,7,1,0,0,294,293,1,0,0,0,295, - 296,1,0,0,0,296,294,1,0,0,0,296,297,1,0,0,0,297,298,1,0,0,0,298,299,6, - 8,3,0,299,24,1,0,0,0,300,301,5,60,0,0,301,302,5,47,0,0,302,303,5,99,0, - 0,303,304,5,111,0,0,304,305,5,100,0,0,305,306,5,101,0,0,306,307,5,62,0, - 0,307,308,5,60,0,0,308,309,5,47,0,0,309,310,5,112,0,0,310,311,5,114,0, - 0,311,312,5,101,0,0,312,313,5,62,0,0,313,314,1,0,0,0,314,315,6,9,4,0,315, - 26,1,0,0,0,316,317,5,60,0,0,317,318,5,115,0,0,318,319,5,112,0,0,319,320, - 5,97,0,0,320,321,5,110,0,0,321,322,1,0,0,0,322,323,6,10,5,0,323,28,1,0, - 0,0,324,326,3,33,13,0,325,324,1,0,0,0,326,329,1,0,0,0,327,325,1,0,0,0, - 327,328,1,0,0,0,328,330,1,0,0,0,329,327,1,0,0,0,330,332,5,46,0,0,331,333, - 3,33,13,0,332,331,1,0,0,0,333,334,1,0,0,0,334,332,1,0,0,0,334,335,1,0, - 0,0,335,30,1,0,0,0,336,338,3,33,13,0,337,336,1,0,0,0,338,339,1,0,0,0,339, - 337,1,0,0,0,339,340,1,0,0,0,340,32,1,0,0,0,341,342,7,2,0,0,342,34,1,0, - 0,0,343,344,5,40,0,0,344,36,1,0,0,0,345,346,5,41,0,0,346,38,1,0,0,0,347, - 348,5,42,0,0,348,349,5,61,0,0,349,40,1,0,0,0,350,351,5,47,0,0,351,352, - 5,61,0,0,352,42,1,0,0,0,353,354,5,43,0,0,354,355,5,61,0,0,355,44,1,0,0, - 0,356,357,5,45,0,0,357,358,5,61,0,0,358,46,1,0,0,0,359,360,5,42,0,0,360, - 48,1,0,0,0,361,362,5,47,0,0,362,50,1,0,0,0,363,364,5,43,0,0,364,52,1,0, - 0,0,365,366,5,45,0,0,366,54,1,0,0,0,367,368,3,57,25,0,368,369,5,61,0,0, - 369,56,1,0,0,0,370,376,5,62,0,0,371,372,5,38,0,0,372,373,5,103,0,0,373, - 374,5,116,0,0,374,376,5,59,0,0,375,370,1,0,0,0,375,371,1,0,0,0,376,58, - 1,0,0,0,377,378,3,61,27,0,378,379,5,61,0,0,379,60,1,0,0,0,380,386,5,60, - 0,0,381,382,5,38,0,0,382,383,5,108,0,0,383,384,5,116,0,0,384,386,5,59, - 0,0,385,380,1,0,0,0,385,381,1,0,0,0,386,62,1,0,0,0,387,388,5,61,0,0,388, - 389,5,61,0,0,389,64,1,0,0,0,390,391,5,33,0,0,391,392,5,61,0,0,392,66,1, - 0,0,0,393,394,5,38,0,0,394,406,5,38,0,0,395,396,5,38,0,0,396,397,5,97, - 0,0,397,398,5,109,0,0,398,399,5,112,0,0,399,400,5,59,0,0,400,401,5,38, - 0,0,401,402,5,97,0,0,402,403,5,109,0,0,403,404,5,112,0,0,404,406,5,59, - 0,0,405,393,1,0,0,0,405,395,1,0,0,0,406,68,1,0,0,0,407,408,5,124,0,0,408, - 409,5,124,0,0,409,70,1,0,0,0,410,411,5,61,0,0,411,72,1,0,0,0,412,413,5, - 33,0,0,413,74,1,0,0,0,414,415,5,44,0,0,415,76,1,0,0,0,416,417,5,123,0, - 0,417,78,1,0,0,0,418,419,5,125,0,0,419,80,1,0,0,0,420,421,5,116,0,0,421, - 422,5,114,0,0,422,423,5,117,0,0,423,430,5,101,0,0,424,425,5,102,0,0,425, - 426,5,97,0,0,426,427,5,108,0,0,427,428,5,115,0,0,428,430,5,101,0,0,429, - 420,1,0,0,0,429,424,1,0,0,0,430,82,1,0,0,0,431,432,5,97,0,0,432,433,5, - 98,0,0,433,469,5,115,0,0,434,435,5,109,0,0,435,436,5,97,0,0,436,469,5, - 120,0,0,437,438,5,109,0,0,438,439,5,105,0,0,439,469,5,110,0,0,440,441, - 5,114,0,0,441,442,5,97,0,0,442,443,5,110,0,0,443,444,5,100,0,0,444,445, - 5,111,0,0,445,469,5,109,0,0,446,447,5,114,0,0,447,448,5,111,0,0,448,449, - 5,108,0,0,449,469,5,108,0,0,450,451,5,114,0,0,451,452,5,111,0,0,452,453, - 5,117,0,0,453,454,5,110,0,0,454,469,5,100,0,0,455,456,5,115,0,0,456,457, - 5,113,0,0,457,469,5,114,0,0,458,459,5,115,0,0,459,460,5,113,0,0,460,461, - 5,114,0,0,461,469,5,116,0,0,462,463,5,118,0,0,463,464,5,105,0,0,464,465, - 5,115,0,0,465,466,5,105,0,0,466,467,5,116,0,0,467,469,5,115,0,0,468,431, - 1,0,0,0,468,434,1,0,0,0,468,437,1,0,0,0,468,440,1,0,0,0,468,446,1,0,0, - 0,468,450,1,0,0,0,468,455,1,0,0,0,468,458,1,0,0,0,468,462,1,0,0,0,469, - 84,1,0,0,0,470,471,5,115,0,0,471,472,5,104,0,0,472,473,5,111,0,0,473,474, - 5,119,0,0,474,86,1,0,0,0,475,476,5,114,0,0,476,477,5,101,0,0,477,478,5, - 115,0,0,478,479,5,101,0,0,479,489,5,116,0,0,480,481,5,114,0,0,481,482, - 5,101,0,0,482,483,5,115,0,0,483,484,5,101,0,0,484,485,5,116,0,0,485,486, - 5,65,0,0,486,487,5,108,0,0,487,489,5,108,0,0,488,475,1,0,0,0,488,480,1, - 0,0,0,489,88,1,0,0,0,490,491,5,105,0,0,491,492,5,102,0,0,492,90,1,0,0, - 0,493,494,5,101,0,0,494,495,5,108,0,0,495,496,5,115,0,0,496,497,5,101, - 0,0,497,92,1,0,0,0,498,499,5,101,0,0,499,500,5,108,0,0,500,501,5,115,0, - 0,501,502,5,101,0,0,502,503,5,105,0,0,503,504,5,102,0,0,504,94,1,0,0,0, - 505,506,5,101,0,0,506,507,5,110,0,0,507,508,5,100,0,0,508,509,5,105,0, - 0,509,510,5,102,0,0,510,96,1,0,0,0,511,512,5,97,0,0,512,513,5,110,0,0, - 513,514,5,100,0,0,514,98,1,0,0,0,515,516,5,111,0,0,516,517,5,114,0,0,517, - 100,1,0,0,0,518,519,5,105,0,0,519,520,5,115,0,0,520,102,1,0,0,0,521,522, - 5,110,0,0,522,523,5,111,0,0,523,524,5,116,0,0,524,104,1,0,0,0,525,529, - 5,34,0,0,526,528,3,107,50,0,527,526,1,0,0,0,528,531,1,0,0,0,529,527,1, - 0,0,0,529,530,1,0,0,0,530,532,1,0,0,0,531,529,1,0,0,0,532,542,5,34,0,0, - 533,537,5,39,0,0,534,536,3,107,50,0,535,534,1,0,0,0,536,539,1,0,0,0,537, - 535,1,0,0,0,537,538,1,0,0,0,538,540,1,0,0,0,539,537,1,0,0,0,540,542,5, - 39,0,0,541,525,1,0,0,0,541,533,1,0,0,0,542,106,1,0,0,0,543,547,8,3,0,0, - 544,545,5,92,0,0,545,547,7,4,0,0,546,543,1,0,0,0,546,544,1,0,0,0,547,108, - 1,0,0,0,548,552,7,5,0,0,549,551,7,6,0,0,550,549,1,0,0,0,551,554,1,0,0, - 0,552,550,1,0,0,0,552,553,1,0,0,0,553,110,1,0,0,0,554,552,1,0,0,0,555, - 557,7,1,0,0,556,555,1,0,0,0,557,558,1,0,0,0,558,556,1,0,0,0,558,559,1, - 0,0,0,559,560,1,0,0,0,560,561,6,52,3,0,561,112,1,0,0,0,562,563,5,62,0, - 0,563,564,1,0,0,0,564,565,6,53,6,0,565,114,1,0,0,0,566,570,7,7,0,0,567, - 569,7,8,0,0,568,567,1,0,0,0,569,572,1,0,0,0,570,568,1,0,0,0,570,571,1, - 0,0,0,571,116,1,0,0,0,572,570,1,0,0,0,573,574,5,61,0,0,574,575,1,0,0,0, - 575,576,6,55,7,0,576,118,1,0,0,0,577,578,5,47,0,0,578,579,5,115,0,0,579, - 580,5,112,0,0,580,581,5,97,0,0,581,582,5,110,0,0,582,583,5,62,0,0,583, - 584,1,0,0,0,584,585,6,56,4,0,585,120,1,0,0,0,586,587,7,1,0,0,587,588,1, - 0,0,0,588,589,6,57,3,0,589,122,1,0,0,0,590,591,5,60,0,0,591,592,1,0,0, - 0,592,593,6,58,4,0,593,124,1,0,0,0,594,596,8,9,0,0,595,594,1,0,0,0,596, - 597,1,0,0,0,597,595,1,0,0,0,597,598,1,0,0,0,598,126,1,0,0,0,599,601,5, - 32,0,0,600,599,1,0,0,0,601,604,1,0,0,0,602,600,1,0,0,0,602,603,1,0,0,0, - 603,605,1,0,0,0,604,602,1,0,0,0,605,606,3,129,61,0,606,607,1,0,0,0,607, - 608,6,60,4,0,608,128,1,0,0,0,609,615,3,139,66,0,610,615,3,141,67,0,611, - 615,3,131,62,0,612,615,3,135,64,0,613,615,3,137,65,0,614,609,1,0,0,0,614, - 610,1,0,0,0,614,611,1,0,0,0,614,612,1,0,0,0,614,613,1,0,0,0,615,130,1, - 0,0,0,616,618,3,133,63,0,617,616,1,0,0,0,618,619,1,0,0,0,619,617,1,0,0, - 0,619,620,1,0,0,0,620,622,1,0,0,0,621,623,5,32,0,0,622,621,1,0,0,0,622, - 623,1,0,0,0,623,132,1,0,0,0,624,626,7,10,0,0,625,624,1,0,0,0,626,134,1, - 0,0,0,627,629,5,35,0,0,628,630,7,11,0,0,629,628,1,0,0,0,630,631,1,0,0, - 0,631,629,1,0,0,0,631,632,1,0,0,0,632,136,1,0,0,0,633,635,7,2,0,0,634, - 633,1,0,0,0,635,636,1,0,0,0,636,634,1,0,0,0,636,637,1,0,0,0,637,639,1, - 0,0,0,638,640,5,37,0,0,639,638,1,0,0,0,639,640,1,0,0,0,640,138,1,0,0,0, - 641,645,5,34,0,0,642,644,8,12,0,0,643,642,1,0,0,0,644,647,1,0,0,0,645, - 643,1,0,0,0,645,646,1,0,0,0,646,648,1,0,0,0,647,645,1,0,0,0,648,649,5, - 34,0,0,649,140,1,0,0,0,650,654,5,39,0,0,651,653,8,13,0,0,652,651,1,0,0, - 0,653,656,1,0,0,0,654,652,1,0,0,0,654,655,1,0,0,0,655,657,1,0,0,0,656, - 654,1,0,0,0,657,658,5,39,0,0,658,142,1,0,0,0,46,0,1,2,3,4,5,6,151,164, - 181,185,204,214,221,239,252,269,273,296,327,334,339,375,385,405,429,468, - 488,529,537,541,546,552,558,570,597,602,614,619,622,625,631,636,639,645, - 654,8,5,3,0,5,1,0,5,2,0,6,0,0,4,0,0,5,4,0,5,5,0,5,6,0 - }; - - public static readonly ATN _ATN = - new ATNDeserializer().Deserialize(_serializedATN); - - -} -} // namespace Arcweave.Interpreter diff --git a/CSharp/Interpreter/Generated/ArcscriptParser.cs b/CSharp/Interpreter/Generated/ArcscriptParser.cs deleted file mode 100644 index f8a1225..0000000 --- a/CSharp/Interpreter/Generated/ArcscriptParser.cs +++ /dev/null @@ -1,2708 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// ANTLR Version: 4.13.1 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -// Generated from ArcscriptParser.g4 by ANTLR 4.13.1 - -// Unreachable code detected -#pragma warning disable 0162 -// The variable '...' is assigned but its value is never used -#pragma warning disable 0219 -// Missing XML comment for publicly visible type or member '...' -#pragma warning disable 1591 -// Ambiguous reference in cref attribute -#pragma warning disable 419 - -namespace Arcweave.Interpreter { -using System; -using System.IO; -using System.Text; -using System.Diagnostics; -using System.Collections.Generic; -using Antlr4.Runtime; -using Antlr4.Runtime.Atn; -using Antlr4.Runtime.Misc; -using Antlr4.Runtime.Tree; -using DFA = Antlr4.Runtime.Dfa.DFA; - -[System.CodeDom.Compiler.GeneratedCode("ANTLR", "4.13.1")] -[System.CLSCompliant(false)] -public partial class ArcscriptParser : ArcscriptParserBase { - protected static DFA[] decisionToDFA; - protected static PredictionContextCache sharedContextCache = new PredictionContextCache(); - public const int - CODESTART=1, PARAGRAPHSTART=2, BLOCKQUOTESTART=3, NORMAL_WHITESPACE=4, - PARAGRAPHEND=5, BQ_CODESTART=6, BQ_PARAGRAPHSTART=7, BLOCKQUOTEEND=8, - BQ_WHITESPACE=9, CODEEND=10, MENTION_TAG_OPEN=11, FLOAT=12, INTEGER=13, - DIGIT=14, LPAREN=15, RPAREN=16, ASSIGNMUL=17, ASSIGNDIV=18, ASSIGNADD=19, - ASSIGNSUB=20, MUL=21, DIV=22, ADD=23, SUB=24, GE=25, GT=26, LE=27, LT=28, - EQ=29, NE=30, AND=31, OR=32, ASSIGN=33, NEG=34, COMMA=35, LBRACE=36, RBRACE=37, - BOOLEAN=38, FNAME=39, VFNAME=40, VFNAMEVARS=41, IFKEYWORD=42, ELSEKEYWORD=43, - ELSEIFKEYWORD=44, ENDIFKEYWORD=45, ANDKEYWORD=46, ORKEYWORD=47, ISKEYWORD=48, - NOTKEYWORD=49, STRING=50, VARIABLE=51, WHITESPACE=52, TAG_CLOSE=53, ATTR_NAME=54, - TAG_EQUALS=55, MENTION_TAG_CLOSE=56, TAG_WHITESPACE=57, TAG_OPEN=58, MENTION_LABEL=59, - ATTR_VALUE=60, ATTRIBUTE=61; - public const int - RULE_input = 0, RULE_script = 1, RULE_script_section = 2, RULE_blockquote = 3, - RULE_paragraph = 4, RULE_paragraph_start = 5, RULE_codestart = 6, RULE_codeend = 7, - RULE_assignment_segment = 8, RULE_function_call_segment = 9, RULE_conditional_section = 10, - RULE_if_section = 11, RULE_else_if_section = 12, RULE_else_section = 13, - RULE_if_clause = 14, RULE_else_if_clause = 15, RULE_endif_segment = 16, - RULE_statement_assignment = 17, RULE_statement_function_call = 18, RULE_argument_list = 19, - RULE_argument = 20, RULE_mention = 21, RULE_mention_attributes = 22, RULE_additive_numeric_expression = 23, - RULE_multiplicative_numeric_expression = 24, RULE_signed_unary_numeric_expression = 25, - RULE_unary_numeric_expression = 26, RULE_function_call = 27, RULE_void_function_call = 28, - RULE_sign = 29, RULE_variable_list = 30, RULE_compound_condition_or = 31, - RULE_compound_condition_and = 32, RULE_negated_unary_condition = 33, RULE_unary_condition = 34, - RULE_condition = 35, RULE_conditional_operator = 36, RULE_expression = 37; - public static readonly string[] ruleNames = { - "input", "script", "script_section", "blockquote", "paragraph", "paragraph_start", - "codestart", "codeend", "assignment_segment", "function_call_segment", - "conditional_section", "if_section", "else_if_section", "else_section", - "if_clause", "else_if_clause", "endif_segment", "statement_assignment", - "statement_function_call", "argument_list", "argument", "mention", "mention_attributes", - "additive_numeric_expression", "multiplicative_numeric_expression", "signed_unary_numeric_expression", - "unary_numeric_expression", "function_call", "void_function_call", "sign", - "variable_list", "compound_condition_or", "compound_condition_and", "negated_unary_condition", - "unary_condition", "condition", "conditional_operator", "expression" - }; - - private static readonly string[] _LiteralNames = { - null, null, null, null, null, null, null, null, "''", null, - "''", "''", null, null, "'/span>'", - null, "'<'" - }; - private static readonly string[] _SymbolicNames = { - null, "CODESTART", "PARAGRAPHSTART", "BLOCKQUOTESTART", "NORMAL_WHITESPACE", - "PARAGRAPHEND", "BQ_CODESTART", "BQ_PARAGRAPHSTART", "BLOCKQUOTEEND", - "BQ_WHITESPACE", "CODEEND", "MENTION_TAG_OPEN", "FLOAT", "INTEGER", "DIGIT", - "LPAREN", "RPAREN", "ASSIGNMUL", "ASSIGNDIV", "ASSIGNADD", "ASSIGNSUB", - "MUL", "DIV", "ADD", "SUB", "GE", "GT", "LE", "LT", "EQ", "NE", "AND", - "OR", "ASSIGN", "NEG", "COMMA", "LBRACE", "RBRACE", "BOOLEAN", "FNAME", - "VFNAME", "VFNAMEVARS", "IFKEYWORD", "ELSEKEYWORD", "ELSEIFKEYWORD", "ENDIFKEYWORD", - "ANDKEYWORD", "ORKEYWORD", "ISKEYWORD", "NOTKEYWORD", "STRING", "VARIABLE", - "WHITESPACE", "TAG_CLOSE", "ATTR_NAME", "TAG_EQUALS", "MENTION_TAG_CLOSE", - "TAG_WHITESPACE", "TAG_OPEN", "MENTION_LABEL", "ATTR_VALUE", "ATTRIBUTE" - }; - public static readonly IVocabulary DefaultVocabulary = new Vocabulary(_LiteralNames, _SymbolicNames); - - [NotNull] - public override IVocabulary Vocabulary - { - get - { - return DefaultVocabulary; - } - } - - public override string GrammarFileName { get { return "ArcscriptParser.g4"; } } - - public override string[] RuleNames { get { return ruleNames; } } - - public override int[] SerializedAtn { get { return _serializedATN; } } - - static ArcscriptParser() { - decisionToDFA = new DFA[_ATN.NumberOfDecisions]; - for (int i = 0; i < _ATN.NumberOfDecisions; i++) { - decisionToDFA[i] = new DFA(_ATN.GetDecisionState(i), i); - } - } - - public ArcscriptParser(ITokenStream input) : this(input, Console.Out, Console.Error) { } - - public ArcscriptParser(ITokenStream input, TextWriter output, TextWriter errorOutput) - : base(input, output, errorOutput) - { - Interpreter = new ParserATNSimulator(this, _ATN, decisionToDFA, sharedContextCache); - } - - public partial class InputContext : ParserRuleContext { - [System.Diagnostics.DebuggerNonUserCode] public ScriptContext script() { - return GetRuleContext(0); - } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode Eof() { return GetToken(ArcscriptParser.Eof, 0); } - [System.Diagnostics.DebuggerNonUserCode] public CodestartContext codestart() { - return GetRuleContext(0); - } - [System.Diagnostics.DebuggerNonUserCode] public Compound_condition_orContext compound_condition_or() { - return GetRuleContext(0); - } - [System.Diagnostics.DebuggerNonUserCode] public CodeendContext codeend() { - return GetRuleContext(0); - } - public InputContext(ParserRuleContext parent, int invokingState) - : base(parent, invokingState) - { - } - public override int RuleIndex { get { return RULE_input; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - IArcscriptParserVisitor typedVisitor = visitor as IArcscriptParserVisitor; - if (typedVisitor != null) return typedVisitor.VisitInput(this); - else return visitor.VisitChildren(this); - } - } - - [RuleVersion(0)] - public InputContext input() { - InputContext _localctx = new InputContext(Context, State); - EnterRule(_localctx, 0, RULE_input); - try { - State = 84; - ErrorHandler.Sync(this); - switch ( Interpreter.AdaptivePredict(TokenStream,0,Context) ) { - case 1: - EnterOuterAlt(_localctx, 1); - { - State = 76; - script(); - State = 77; - Match(Eof); - } - break; - case 2: - EnterOuterAlt(_localctx, 2); - { - State = 79; - codestart(); - State = 80; - compound_condition_or(); - State = 81; - codeend(); - State = 82; - Match(Eof); - } - break; - } - } - catch (RecognitionException re) { - _localctx.exception = re; - ErrorHandler.ReportError(this, re); - ErrorHandler.Recover(this, re); - } - finally { - ExitRule(); - } - return _localctx; - } - - public partial class ScriptContext : ParserRuleContext { - [System.Diagnostics.DebuggerNonUserCode] public Script_sectionContext[] script_section() { - return GetRuleContexts(); - } - [System.Diagnostics.DebuggerNonUserCode] public Script_sectionContext script_section(int i) { - return GetRuleContext(i); - } - public ScriptContext(ParserRuleContext parent, int invokingState) - : base(parent, invokingState) - { - } - public override int RuleIndex { get { return RULE_script; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - IArcscriptParserVisitor typedVisitor = visitor as IArcscriptParserVisitor; - if (typedVisitor != null) return typedVisitor.VisitScript(this); - else return visitor.VisitChildren(this); - } - } - - [RuleVersion(0)] - public ScriptContext script() { - ScriptContext _localctx = new ScriptContext(Context, State); - EnterRule(_localctx, 2, RULE_script); - try { - int _alt; - EnterOuterAlt(_localctx, 1); - { - State = 87; - ErrorHandler.Sync(this); - _alt = 1; - do { - switch (_alt) { - case 1: - { - { - State = 86; - script_section(); - } - } - break; - default: - throw new NoViableAltException(this); - } - State = 89; - ErrorHandler.Sync(this); - _alt = Interpreter.AdaptivePredict(TokenStream,1,Context); - } while ( _alt!=2 && _alt!=global::Antlr4.Runtime.Atn.ATN.INVALID_ALT_NUMBER ); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - ErrorHandler.ReportError(this, re); - ErrorHandler.Recover(this, re); - } - finally { - ExitRule(); - } - return _localctx; - } - - public partial class Script_sectionContext : ParserRuleContext { - [System.Diagnostics.DebuggerNonUserCode] public BlockquoteContext[] blockquote() { - return GetRuleContexts(); - } - [System.Diagnostics.DebuggerNonUserCode] public BlockquoteContext blockquote(int i) { - return GetRuleContext(i); - } - [System.Diagnostics.DebuggerNonUserCode] public ParagraphContext[] paragraph() { - return GetRuleContexts(); - } - [System.Diagnostics.DebuggerNonUserCode] public ParagraphContext paragraph(int i) { - return GetRuleContext(i); - } - [System.Diagnostics.DebuggerNonUserCode] public Assignment_segmentContext assignment_segment() { - return GetRuleContext(0); - } - [System.Diagnostics.DebuggerNonUserCode] public Function_call_segmentContext function_call_segment() { - return GetRuleContext(0); - } - [System.Diagnostics.DebuggerNonUserCode] public Conditional_sectionContext conditional_section() { - return GetRuleContext(0); - } - public Script_sectionContext(ParserRuleContext parent, int invokingState) - : base(parent, invokingState) - { - } - public override int RuleIndex { get { return RULE_script_section; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - IArcscriptParserVisitor typedVisitor = visitor as IArcscriptParserVisitor; - if (typedVisitor != null) return typedVisitor.VisitScript_section(this); - else return visitor.VisitChildren(this); - } - } - - [RuleVersion(0)] - public Script_sectionContext script_section() { - Script_sectionContext _localctx = new Script_sectionContext(Context, State); - EnterRule(_localctx, 4, RULE_script_section); - try { - int _alt; - State = 104; - ErrorHandler.Sync(this); - switch ( Interpreter.AdaptivePredict(TokenStream,4,Context) ) { - case 1: - EnterOuterAlt(_localctx, 1); - { - State = 92; - ErrorHandler.Sync(this); - _alt = 1+1; - do { - switch (_alt) { - case 1+1: - { - { - State = 91; - blockquote(); - } - } - break; - default: - throw new NoViableAltException(this); - } - State = 94; - ErrorHandler.Sync(this); - _alt = Interpreter.AdaptivePredict(TokenStream,2,Context); - } while ( _alt!=1 && _alt!=global::Antlr4.Runtime.Atn.ATN.INVALID_ALT_NUMBER ); - } - break; - case 2: - EnterOuterAlt(_localctx, 2); - { - State = 97; - ErrorHandler.Sync(this); - _alt = 1+1; - do { - switch (_alt) { - case 1+1: - { - { - State = 96; - paragraph(); - } - } - break; - default: - throw new NoViableAltException(this); - } - State = 99; - ErrorHandler.Sync(this); - _alt = Interpreter.AdaptivePredict(TokenStream,3,Context); - } while ( _alt!=1 && _alt!=global::Antlr4.Runtime.Atn.ATN.INVALID_ALT_NUMBER ); - } - break; - case 3: - EnterOuterAlt(_localctx, 3); - { - State = 101; - assignment_segment(); - } - break; - case 4: - EnterOuterAlt(_localctx, 4); - { - State = 102; - function_call_segment(); - } - break; - case 5: - EnterOuterAlt(_localctx, 5); - { - State = 103; - conditional_section(); - } - break; - } - } - catch (RecognitionException re) { - _localctx.exception = re; - ErrorHandler.ReportError(this, re); - ErrorHandler.Recover(this, re); - } - finally { - ExitRule(); - } - return _localctx; - } - - public partial class BlockquoteContext : ParserRuleContext { - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode BLOCKQUOTESTART() { return GetToken(ArcscriptParser.BLOCKQUOTESTART, 0); } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode BLOCKQUOTEEND() { return GetToken(ArcscriptParser.BLOCKQUOTEEND, 0); } - [System.Diagnostics.DebuggerNonUserCode] public ParagraphContext[] paragraph() { - return GetRuleContexts(); - } - [System.Diagnostics.DebuggerNonUserCode] public ParagraphContext paragraph(int i) { - return GetRuleContext(i); - } - [System.Diagnostics.DebuggerNonUserCode] public Assignment_segmentContext[] assignment_segment() { - return GetRuleContexts(); - } - [System.Diagnostics.DebuggerNonUserCode] public Assignment_segmentContext assignment_segment(int i) { - return GetRuleContext(i); - } - [System.Diagnostics.DebuggerNonUserCode] public Function_call_segmentContext[] function_call_segment() { - return GetRuleContexts(); - } - [System.Diagnostics.DebuggerNonUserCode] public Function_call_segmentContext function_call_segment(int i) { - return GetRuleContext(i); - } - public BlockquoteContext(ParserRuleContext parent, int invokingState) - : base(parent, invokingState) - { - } - public override int RuleIndex { get { return RULE_blockquote; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - IArcscriptParserVisitor typedVisitor = visitor as IArcscriptParserVisitor; - if (typedVisitor != null) return typedVisitor.VisitBlockquote(this); - else return visitor.VisitChildren(this); - } - } - - [RuleVersion(0)] - public BlockquoteContext blockquote() { - BlockquoteContext _localctx = new BlockquoteContext(Context, State); - EnterRule(_localctx, 6, RULE_blockquote); - int _la; - try { - EnterOuterAlt(_localctx, 1); - { - State = 106; - Match(BLOCKQUOTESTART); - State = 112; - ErrorHandler.Sync(this); - _la = TokenStream.LA(1); - while ((((_la) & ~0x3f) == 0 && ((1L << _la) & 198L) != 0)) { - { - State = 110; - ErrorHandler.Sync(this); - switch ( Interpreter.AdaptivePredict(TokenStream,5,Context) ) { - case 1: - { - State = 107; - paragraph(); - } - break; - case 2: - { - State = 108; - assignment_segment(); - } - break; - case 3: - { - State = 109; - function_call_segment(); - } - break; - } - } - State = 114; - ErrorHandler.Sync(this); - _la = TokenStream.LA(1); - } - State = 115; - Match(BLOCKQUOTEEND); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - ErrorHandler.ReportError(this, re); - ErrorHandler.Recover(this, re); - } - finally { - ExitRule(); - } - return _localctx; - } - - public partial class ParagraphContext : ParserRuleContext { - [System.Diagnostics.DebuggerNonUserCode] public Paragraph_startContext paragraph_start() { - return GetRuleContext(0); - } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode PARAGRAPHEND() { return GetToken(ArcscriptParser.PARAGRAPHEND, 0); } - public ParagraphContext(ParserRuleContext parent, int invokingState) - : base(parent, invokingState) - { - } - public override int RuleIndex { get { return RULE_paragraph; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - IArcscriptParserVisitor typedVisitor = visitor as IArcscriptParserVisitor; - if (typedVisitor != null) return typedVisitor.VisitParagraph(this); - else return visitor.VisitChildren(this); - } - } - - [RuleVersion(0)] - public ParagraphContext paragraph() { - ParagraphContext _localctx = new ParagraphContext(Context, State); - EnterRule(_localctx, 8, RULE_paragraph); - try { - EnterOuterAlt(_localctx, 1); - { - State = 117; - paragraph_start(); - State = 118; - Match(PARAGRAPHEND); - this.currentLine++; - } - } - catch (RecognitionException re) { - _localctx.exception = re; - ErrorHandler.ReportError(this, re); - ErrorHandler.Recover(this, re); - } - finally { - ExitRule(); - } - return _localctx; - } - - public partial class Paragraph_startContext : ParserRuleContext { - public IToken _PARAGRAPHSTART; - public IToken _BQ_PARAGRAPHSTART; - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode PARAGRAPHSTART() { return GetToken(ArcscriptParser.PARAGRAPHSTART, 0); } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode BQ_PARAGRAPHSTART() { return GetToken(ArcscriptParser.BQ_PARAGRAPHSTART, 0); } - public Paragraph_startContext(ParserRuleContext parent, int invokingState) - : base(parent, invokingState) - { - } - public override int RuleIndex { get { return RULE_paragraph_start; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - IArcscriptParserVisitor typedVisitor = visitor as IArcscriptParserVisitor; - if (typedVisitor != null) return typedVisitor.VisitParagraph_start(this); - else return visitor.VisitChildren(this); - } - } - - [RuleVersion(0)] - public Paragraph_startContext paragraph_start() { - Paragraph_startContext _localctx = new Paragraph_startContext(Context, State); - EnterRule(_localctx, 10, RULE_paragraph_start); - try { - State = 125; - ErrorHandler.Sync(this); - switch (TokenStream.LA(1)) { - case PARAGRAPHSTART: - EnterOuterAlt(_localctx, 1); - { - State = 121; - _localctx._PARAGRAPHSTART = Match(PARAGRAPHSTART); - this.setLineStart(_localctx._PARAGRAPHSTART); - } - break; - case BQ_PARAGRAPHSTART: - EnterOuterAlt(_localctx, 2); - { - State = 123; - _localctx._BQ_PARAGRAPHSTART = Match(BQ_PARAGRAPHSTART); - this.setLineStart(_localctx._BQ_PARAGRAPHSTART); - } - break; - default: - throw new NoViableAltException(this); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - ErrorHandler.ReportError(this, re); - ErrorHandler.Recover(this, re); - } - finally { - ExitRule(); - } - return _localctx; - } - - public partial class CodestartContext : ParserRuleContext { - public IToken _CODESTART; - public IToken _BQ_CODESTART; - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode CODESTART() { return GetToken(ArcscriptParser.CODESTART, 0); } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode BQ_CODESTART() { return GetToken(ArcscriptParser.BQ_CODESTART, 0); } - public CodestartContext(ParserRuleContext parent, int invokingState) - : base(parent, invokingState) - { - } - public override int RuleIndex { get { return RULE_codestart; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - IArcscriptParserVisitor typedVisitor = visitor as IArcscriptParserVisitor; - if (typedVisitor != null) return typedVisitor.VisitCodestart(this); - else return visitor.VisitChildren(this); - } - } - - [RuleVersion(0)] - public CodestartContext codestart() { - CodestartContext _localctx = new CodestartContext(Context, State); - EnterRule(_localctx, 12, RULE_codestart); - try { - State = 131; - ErrorHandler.Sync(this); - switch (TokenStream.LA(1)) { - case CODESTART: - EnterOuterAlt(_localctx, 1); - { - State = 127; - _localctx._CODESTART = Match(CODESTART); - this.currentLine++; this.setLineStart(_localctx._CODESTART); - } - break; - case BQ_CODESTART: - EnterOuterAlt(_localctx, 2); - { - State = 129; - _localctx._BQ_CODESTART = Match(BQ_CODESTART); - this.currentLine++; this.setLineStart(_localctx._BQ_CODESTART); - } - break; - default: - throw new NoViableAltException(this); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - ErrorHandler.ReportError(this, re); - ErrorHandler.Recover(this, re); - } - finally { - ExitRule(); - } - return _localctx; - } - - public partial class CodeendContext : ParserRuleContext { - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode CODEEND() { return GetToken(ArcscriptParser.CODEEND, 0); } - public CodeendContext(ParserRuleContext parent, int invokingState) - : base(parent, invokingState) - { - } - public override int RuleIndex { get { return RULE_codeend; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - IArcscriptParserVisitor typedVisitor = visitor as IArcscriptParserVisitor; - if (typedVisitor != null) return typedVisitor.VisitCodeend(this); - else return visitor.VisitChildren(this); - } - } - - [RuleVersion(0)] - public CodeendContext codeend() { - CodeendContext _localctx = new CodeendContext(Context, State); - EnterRule(_localctx, 14, RULE_codeend); - try { - EnterOuterAlt(_localctx, 1); - { - State = 133; - Match(CODEEND); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - ErrorHandler.ReportError(this, re); - ErrorHandler.Recover(this, re); - } - finally { - ExitRule(); - } - return _localctx; - } - - public partial class Assignment_segmentContext : ParserRuleContext { - [System.Diagnostics.DebuggerNonUserCode] public CodestartContext codestart() { - return GetRuleContext(0); - } - [System.Diagnostics.DebuggerNonUserCode] public Statement_assignmentContext statement_assignment() { - return GetRuleContext(0); - } - [System.Diagnostics.DebuggerNonUserCode] public CodeendContext codeend() { - return GetRuleContext(0); - } - public Assignment_segmentContext(ParserRuleContext parent, int invokingState) - : base(parent, invokingState) - { - } - public override int RuleIndex { get { return RULE_assignment_segment; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - IArcscriptParserVisitor typedVisitor = visitor as IArcscriptParserVisitor; - if (typedVisitor != null) return typedVisitor.VisitAssignment_segment(this); - else return visitor.VisitChildren(this); - } - } - - [RuleVersion(0)] - public Assignment_segmentContext assignment_segment() { - Assignment_segmentContext _localctx = new Assignment_segmentContext(Context, State); - EnterRule(_localctx, 16, RULE_assignment_segment); - try { - EnterOuterAlt(_localctx, 1); - { - State = 135; - codestart(); - State = 136; - statement_assignment(); - State = 137; - codeend(); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - ErrorHandler.ReportError(this, re); - ErrorHandler.Recover(this, re); - } - finally { - ExitRule(); - } - return _localctx; - } - - public partial class Function_call_segmentContext : ParserRuleContext { - [System.Diagnostics.DebuggerNonUserCode] public CodestartContext codestart() { - return GetRuleContext(0); - } - [System.Diagnostics.DebuggerNonUserCode] public Statement_function_callContext statement_function_call() { - return GetRuleContext(0); - } - [System.Diagnostics.DebuggerNonUserCode] public CodeendContext codeend() { - return GetRuleContext(0); - } - public Function_call_segmentContext(ParserRuleContext parent, int invokingState) - : base(parent, invokingState) - { - } - public override int RuleIndex { get { return RULE_function_call_segment; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - IArcscriptParserVisitor typedVisitor = visitor as IArcscriptParserVisitor; - if (typedVisitor != null) return typedVisitor.VisitFunction_call_segment(this); - else return visitor.VisitChildren(this); - } - } - - [RuleVersion(0)] - public Function_call_segmentContext function_call_segment() { - Function_call_segmentContext _localctx = new Function_call_segmentContext(Context, State); - EnterRule(_localctx, 18, RULE_function_call_segment); - try { - EnterOuterAlt(_localctx, 1); - { - State = 139; - codestart(); - State = 140; - statement_function_call(); - State = 141; - codeend(); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - ErrorHandler.ReportError(this, re); - ErrorHandler.Recover(this, re); - } - finally { - ExitRule(); - } - return _localctx; - } - - public partial class Conditional_sectionContext : ParserRuleContext { - [System.Diagnostics.DebuggerNonUserCode] public If_sectionContext if_section() { - return GetRuleContext(0); - } - [System.Diagnostics.DebuggerNonUserCode] public Endif_segmentContext endif_segment() { - return GetRuleContext(0); - } - [System.Diagnostics.DebuggerNonUserCode] public Else_if_sectionContext[] else_if_section() { - return GetRuleContexts(); - } - [System.Diagnostics.DebuggerNonUserCode] public Else_if_sectionContext else_if_section(int i) { - return GetRuleContext(i); - } - [System.Diagnostics.DebuggerNonUserCode] public Else_sectionContext else_section() { - return GetRuleContext(0); - } - public Conditional_sectionContext(ParserRuleContext parent, int invokingState) - : base(parent, invokingState) - { - } - public override int RuleIndex { get { return RULE_conditional_section; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - IArcscriptParserVisitor typedVisitor = visitor as IArcscriptParserVisitor; - if (typedVisitor != null) return typedVisitor.VisitConditional_section(this); - else return visitor.VisitChildren(this); - } - } - - [RuleVersion(0)] - public Conditional_sectionContext conditional_section() { - Conditional_sectionContext _localctx = new Conditional_sectionContext(Context, State); - EnterRule(_localctx, 20, RULE_conditional_section); - try { - int _alt; - EnterOuterAlt(_localctx, 1); - { - State = 143; - if_section(); - State = 147; - ErrorHandler.Sync(this); - _alt = Interpreter.AdaptivePredict(TokenStream,9,Context); - while ( _alt!=2 && _alt!=global::Antlr4.Runtime.Atn.ATN.INVALID_ALT_NUMBER ) { - if ( _alt==1 ) { - { - { - State = 144; - else_if_section(); - } - } - } - State = 149; - ErrorHandler.Sync(this); - _alt = Interpreter.AdaptivePredict(TokenStream,9,Context); - } - State = 151; - ErrorHandler.Sync(this); - switch ( Interpreter.AdaptivePredict(TokenStream,10,Context) ) { - case 1: - { - State = 150; - else_section(); - } - break; - } - State = 153; - endif_segment(); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - ErrorHandler.ReportError(this, re); - ErrorHandler.Recover(this, re); - } - finally { - ExitRule(); - } - return _localctx; - } - - public partial class If_sectionContext : ParserRuleContext { - [System.Diagnostics.DebuggerNonUserCode] public CodestartContext codestart() { - return GetRuleContext(0); - } - [System.Diagnostics.DebuggerNonUserCode] public If_clauseContext if_clause() { - return GetRuleContext(0); - } - [System.Diagnostics.DebuggerNonUserCode] public CodeendContext codeend() { - return GetRuleContext(0); - } - [System.Diagnostics.DebuggerNonUserCode] public ScriptContext script() { - return GetRuleContext(0); - } - public If_sectionContext(ParserRuleContext parent, int invokingState) - : base(parent, invokingState) - { - } - public override int RuleIndex { get { return RULE_if_section; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - IArcscriptParserVisitor typedVisitor = visitor as IArcscriptParserVisitor; - if (typedVisitor != null) return typedVisitor.VisitIf_section(this); - else return visitor.VisitChildren(this); - } - } - - [RuleVersion(0)] - public If_sectionContext if_section() { - If_sectionContext _localctx = new If_sectionContext(Context, State); - EnterRule(_localctx, 22, RULE_if_section); - try { - EnterOuterAlt(_localctx, 1); - { - State = 155; - codestart(); - State = 156; - if_clause(); - State = 157; - codeend(); - State = 158; - script(); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - ErrorHandler.ReportError(this, re); - ErrorHandler.Recover(this, re); - } - finally { - ExitRule(); - } - return _localctx; - } - - public partial class Else_if_sectionContext : ParserRuleContext { - [System.Diagnostics.DebuggerNonUserCode] public CodestartContext codestart() { - return GetRuleContext(0); - } - [System.Diagnostics.DebuggerNonUserCode] public Else_if_clauseContext else_if_clause() { - return GetRuleContext(0); - } - [System.Diagnostics.DebuggerNonUserCode] public CodeendContext codeend() { - return GetRuleContext(0); - } - [System.Diagnostics.DebuggerNonUserCode] public ScriptContext script() { - return GetRuleContext(0); - } - public Else_if_sectionContext(ParserRuleContext parent, int invokingState) - : base(parent, invokingState) - { - } - public override int RuleIndex { get { return RULE_else_if_section; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - IArcscriptParserVisitor typedVisitor = visitor as IArcscriptParserVisitor; - if (typedVisitor != null) return typedVisitor.VisitElse_if_section(this); - else return visitor.VisitChildren(this); - } - } - - [RuleVersion(0)] - public Else_if_sectionContext else_if_section() { - Else_if_sectionContext _localctx = new Else_if_sectionContext(Context, State); - EnterRule(_localctx, 24, RULE_else_if_section); - try { - EnterOuterAlt(_localctx, 1); - { - State = 160; - codestart(); - State = 161; - else_if_clause(); - State = 162; - codeend(); - State = 163; - script(); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - ErrorHandler.ReportError(this, re); - ErrorHandler.Recover(this, re); - } - finally { - ExitRule(); - } - return _localctx; - } - - public partial class Else_sectionContext : ParserRuleContext { - [System.Diagnostics.DebuggerNonUserCode] public CodestartContext codestart() { - return GetRuleContext(0); - } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode ELSEKEYWORD() { return GetToken(ArcscriptParser.ELSEKEYWORD, 0); } - [System.Diagnostics.DebuggerNonUserCode] public CodeendContext codeend() { - return GetRuleContext(0); - } - [System.Diagnostics.DebuggerNonUserCode] public ScriptContext script() { - return GetRuleContext(0); - } - public Else_sectionContext(ParserRuleContext parent, int invokingState) - : base(parent, invokingState) - { - } - public override int RuleIndex { get { return RULE_else_section; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - IArcscriptParserVisitor typedVisitor = visitor as IArcscriptParserVisitor; - if (typedVisitor != null) return typedVisitor.VisitElse_section(this); - else return visitor.VisitChildren(this); - } - } - - [RuleVersion(0)] - public Else_sectionContext else_section() { - Else_sectionContext _localctx = new Else_sectionContext(Context, State); - EnterRule(_localctx, 26, RULE_else_section); - try { - EnterOuterAlt(_localctx, 1); - { - State = 165; - codestart(); - State = 166; - Match(ELSEKEYWORD); - State = 167; - codeend(); - State = 168; - script(); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - ErrorHandler.ReportError(this, re); - ErrorHandler.Recover(this, re); - } - finally { - ExitRule(); - } - return _localctx; - } - - public partial class If_clauseContext : ParserRuleContext { - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode IFKEYWORD() { return GetToken(ArcscriptParser.IFKEYWORD, 0); } - [System.Diagnostics.DebuggerNonUserCode] public Compound_condition_orContext compound_condition_or() { - return GetRuleContext(0); - } - public If_clauseContext(ParserRuleContext parent, int invokingState) - : base(parent, invokingState) - { - } - public override int RuleIndex { get { return RULE_if_clause; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - IArcscriptParserVisitor typedVisitor = visitor as IArcscriptParserVisitor; - if (typedVisitor != null) return typedVisitor.VisitIf_clause(this); - else return visitor.VisitChildren(this); - } - } - - [RuleVersion(0)] - public If_clauseContext if_clause() { - If_clauseContext _localctx = new If_clauseContext(Context, State); - EnterRule(_localctx, 28, RULE_if_clause); - try { - EnterOuterAlt(_localctx, 1); - { - State = 170; - Match(IFKEYWORD); - State = 171; - compound_condition_or(); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - ErrorHandler.ReportError(this, re); - ErrorHandler.Recover(this, re); - } - finally { - ExitRule(); - } - return _localctx; - } - - public partial class Else_if_clauseContext : ParserRuleContext { - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode ELSEIFKEYWORD() { return GetToken(ArcscriptParser.ELSEIFKEYWORD, 0); } - [System.Diagnostics.DebuggerNonUserCode] public Compound_condition_orContext compound_condition_or() { - return GetRuleContext(0); - } - public Else_if_clauseContext(ParserRuleContext parent, int invokingState) - : base(parent, invokingState) - { - } - public override int RuleIndex { get { return RULE_else_if_clause; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - IArcscriptParserVisitor typedVisitor = visitor as IArcscriptParserVisitor; - if (typedVisitor != null) return typedVisitor.VisitElse_if_clause(this); - else return visitor.VisitChildren(this); - } - } - - [RuleVersion(0)] - public Else_if_clauseContext else_if_clause() { - Else_if_clauseContext _localctx = new Else_if_clauseContext(Context, State); - EnterRule(_localctx, 30, RULE_else_if_clause); - try { - EnterOuterAlt(_localctx, 1); - { - State = 173; - Match(ELSEIFKEYWORD); - State = 174; - compound_condition_or(); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - ErrorHandler.ReportError(this, re); - ErrorHandler.Recover(this, re); - } - finally { - ExitRule(); - } - return _localctx; - } - - public partial class Endif_segmentContext : ParserRuleContext { - [System.Diagnostics.DebuggerNonUserCode] public CodestartContext codestart() { - return GetRuleContext(0); - } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode ENDIFKEYWORD() { return GetToken(ArcscriptParser.ENDIFKEYWORD, 0); } - [System.Diagnostics.DebuggerNonUserCode] public CodeendContext codeend() { - return GetRuleContext(0); - } - public Endif_segmentContext(ParserRuleContext parent, int invokingState) - : base(parent, invokingState) - { - } - public override int RuleIndex { get { return RULE_endif_segment; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - IArcscriptParserVisitor typedVisitor = visitor as IArcscriptParserVisitor; - if (typedVisitor != null) return typedVisitor.VisitEndif_segment(this); - else return visitor.VisitChildren(this); - } - } - - [RuleVersion(0)] - public Endif_segmentContext endif_segment() { - Endif_segmentContext _localctx = new Endif_segmentContext(Context, State); - EnterRule(_localctx, 32, RULE_endif_segment); - try { - EnterOuterAlt(_localctx, 1); - { - State = 176; - codestart(); - State = 177; - Match(ENDIFKEYWORD); - State = 178; - codeend(); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - ErrorHandler.ReportError(this, re); - ErrorHandler.Recover(this, re); - } - finally { - ExitRule(); - } - return _localctx; - } - - public partial class Statement_assignmentContext : ParserRuleContext { - public IToken _VARIABLE; - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode VARIABLE() { return GetToken(ArcscriptParser.VARIABLE, 0); } - [System.Diagnostics.DebuggerNonUserCode] public Compound_condition_orContext compound_condition_or() { - return GetRuleContext(0); - } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode ASSIGNADD() { return GetToken(ArcscriptParser.ASSIGNADD, 0); } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode ASSIGNSUB() { return GetToken(ArcscriptParser.ASSIGNSUB, 0); } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode ASSIGNMUL() { return GetToken(ArcscriptParser.ASSIGNMUL, 0); } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode ASSIGNDIV() { return GetToken(ArcscriptParser.ASSIGNDIV, 0); } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode ASSIGN() { return GetToken(ArcscriptParser.ASSIGN, 0); } - public Statement_assignmentContext(ParserRuleContext parent, int invokingState) - : base(parent, invokingState) - { - } - public override int RuleIndex { get { return RULE_statement_assignment; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - IArcscriptParserVisitor typedVisitor = visitor as IArcscriptParserVisitor; - if (typedVisitor != null) return typedVisitor.VisitStatement_assignment(this); - else return visitor.VisitChildren(this); - } - } - - [RuleVersion(0)] - public Statement_assignmentContext statement_assignment() { - Statement_assignmentContext _localctx = new Statement_assignmentContext(Context, State); - EnterRule(_localctx, 34, RULE_statement_assignment); - int _la; - try { - EnterOuterAlt(_localctx, 1); - { - State = 180; - _localctx._VARIABLE = Match(VARIABLE); - State = 181; - _la = TokenStream.LA(1); - if ( !((((_la) & ~0x3f) == 0 && ((1L << _la) & 8591900672L) != 0)) ) { - ErrorHandler.RecoverInline(this); - } - else { - ErrorHandler.ReportMatch(this); - Consume(); - } - State = 182; - compound_condition_or(); - this.assertVariable(_localctx._VARIABLE); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - ErrorHandler.ReportError(this, re); - ErrorHandler.Recover(this, re); - } - finally { - ExitRule(); - } - return _localctx; - } - - public partial class Statement_function_callContext : ParserRuleContext { - [System.Diagnostics.DebuggerNonUserCode] public Void_function_callContext void_function_call() { - return GetRuleContext(0); - } - public Statement_function_callContext(ParserRuleContext parent, int invokingState) - : base(parent, invokingState) - { - } - public override int RuleIndex { get { return RULE_statement_function_call; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - IArcscriptParserVisitor typedVisitor = visitor as IArcscriptParserVisitor; - if (typedVisitor != null) return typedVisitor.VisitStatement_function_call(this); - else return visitor.VisitChildren(this); - } - } - - [RuleVersion(0)] - public Statement_function_callContext statement_function_call() { - Statement_function_callContext _localctx = new Statement_function_callContext(Context, State); - EnterRule(_localctx, 36, RULE_statement_function_call); - try { - EnterOuterAlt(_localctx, 1); - { - State = 185; - void_function_call(); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - ErrorHandler.ReportError(this, re); - ErrorHandler.Recover(this, re); - } - finally { - ExitRule(); - } - return _localctx; - } - - public partial class Argument_listContext : ParserRuleContext { - [System.Diagnostics.DebuggerNonUserCode] public ArgumentContext[] argument() { - return GetRuleContexts(); - } - [System.Diagnostics.DebuggerNonUserCode] public ArgumentContext argument(int i) { - return GetRuleContext(i); - } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode[] COMMA() { return GetTokens(ArcscriptParser.COMMA); } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode COMMA(int i) { - return GetToken(ArcscriptParser.COMMA, i); - } - public Argument_listContext(ParserRuleContext parent, int invokingState) - : base(parent, invokingState) - { - } - public override int RuleIndex { get { return RULE_argument_list; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - IArcscriptParserVisitor typedVisitor = visitor as IArcscriptParserVisitor; - if (typedVisitor != null) return typedVisitor.VisitArgument_list(this); - else return visitor.VisitChildren(this); - } - } - - [RuleVersion(0)] - public Argument_listContext argument_list() { - Argument_listContext _localctx = new Argument_listContext(Context, State); - EnterRule(_localctx, 38, RULE_argument_list); - int _la; - try { - EnterOuterAlt(_localctx, 1); - { - State = 187; - argument(); - State = 192; - ErrorHandler.Sync(this); - _la = TokenStream.LA(1); - while (_la==COMMA) { - { - { - State = 188; - Match(COMMA); - State = 189; - argument(); - } - } - State = 194; - ErrorHandler.Sync(this); - _la = TokenStream.LA(1); - } - } - } - catch (RecognitionException re) { - _localctx.exception = re; - ErrorHandler.ReportError(this, re); - ErrorHandler.Recover(this, re); - } - finally { - ExitRule(); - } - return _localctx; - } - - public partial class ArgumentContext : ParserRuleContext { - [System.Diagnostics.DebuggerNonUserCode] public Additive_numeric_expressionContext additive_numeric_expression() { - return GetRuleContext(0); - } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode STRING() { return GetToken(ArcscriptParser.STRING, 0); } - [System.Diagnostics.DebuggerNonUserCode] public MentionContext mention() { - return GetRuleContext(0); - } - public ArgumentContext(ParserRuleContext parent, int invokingState) - : base(parent, invokingState) - { - } - public override int RuleIndex { get { return RULE_argument; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - IArcscriptParserVisitor typedVisitor = visitor as IArcscriptParserVisitor; - if (typedVisitor != null) return typedVisitor.VisitArgument(this); - else return visitor.VisitChildren(this); - } - } - - [RuleVersion(0)] - public ArgumentContext argument() { - ArgumentContext _localctx = new ArgumentContext(Context, State); - EnterRule(_localctx, 40, RULE_argument); - try { - State = 198; - ErrorHandler.Sync(this); - switch ( Interpreter.AdaptivePredict(TokenStream,12,Context) ) { - case 1: - EnterOuterAlt(_localctx, 1); - { - State = 195; - additive_numeric_expression(0); - } - break; - case 2: - EnterOuterAlt(_localctx, 2); - { - State = 196; - Match(STRING); - } - break; - case 3: - EnterOuterAlt(_localctx, 3); - { - State = 197; - mention(); - } - break; - } - } - catch (RecognitionException re) { - _localctx.exception = re; - ErrorHandler.ReportError(this, re); - ErrorHandler.Recover(this, re); - } - finally { - ExitRule(); - } - return _localctx; - } - - public partial class MentionContext : ParserRuleContext { - public Mention_attributesContext _mention_attributes; - public IList _attr = new List(); - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode MENTION_TAG_OPEN() { return GetToken(ArcscriptParser.MENTION_TAG_OPEN, 0); } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode TAG_CLOSE() { return GetToken(ArcscriptParser.TAG_CLOSE, 0); } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode TAG_OPEN() { return GetToken(ArcscriptParser.TAG_OPEN, 0); } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode MENTION_TAG_CLOSE() { return GetToken(ArcscriptParser.MENTION_TAG_CLOSE, 0); } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode MENTION_LABEL() { return GetToken(ArcscriptParser.MENTION_LABEL, 0); } - [System.Diagnostics.DebuggerNonUserCode] public Mention_attributesContext[] mention_attributes() { - return GetRuleContexts(); - } - [System.Diagnostics.DebuggerNonUserCode] public Mention_attributesContext mention_attributes(int i) { - return GetRuleContext(i); - } - public MentionContext(ParserRuleContext parent, int invokingState) - : base(parent, invokingState) - { - } - public override int RuleIndex { get { return RULE_mention; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - IArcscriptParserVisitor typedVisitor = visitor as IArcscriptParserVisitor; - if (typedVisitor != null) return typedVisitor.VisitMention(this); - else return visitor.VisitChildren(this); - } - } - - [RuleVersion(0)] - public MentionContext mention() { - MentionContext _localctx = new MentionContext(Context, State); - EnterRule(_localctx, 42, RULE_mention); - int _la; - try { - EnterOuterAlt(_localctx, 1); - { - State = 200; - Match(MENTION_TAG_OPEN); - State = 204; - ErrorHandler.Sync(this); - _la = TokenStream.LA(1); - while (_la==ATTR_NAME) { - { - { - State = 201; - _localctx._mention_attributes = mention_attributes(); - _localctx._attr.Add(_localctx._mention_attributes); - } - } - State = 206; - ErrorHandler.Sync(this); - _la = TokenStream.LA(1); - } - State = 207; - Match(TAG_CLOSE); - State = 209; - ErrorHandler.Sync(this); - _la = TokenStream.LA(1); - if (_la==MENTION_LABEL) { - { - State = 208; - Match(MENTION_LABEL); - } - } - - State = 211; - Match(TAG_OPEN); - State = 212; - Match(MENTION_TAG_CLOSE); - State = 213; - if (!(this.assertMention(_localctx._attr) - )) throw new FailedPredicateException(this, "this.assertMention($attr)\r\n\t\t"); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - ErrorHandler.ReportError(this, re); - ErrorHandler.Recover(this, re); - } - finally { - ExitRule(); - } - return _localctx; - } - - public partial class Mention_attributesContext : ParserRuleContext { - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode ATTR_NAME() { return GetToken(ArcscriptParser.ATTR_NAME, 0); } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode TAG_EQUALS() { return GetToken(ArcscriptParser.TAG_EQUALS, 0); } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode ATTR_VALUE() { return GetToken(ArcscriptParser.ATTR_VALUE, 0); } - public Mention_attributesContext(ParserRuleContext parent, int invokingState) - : base(parent, invokingState) - { - } - public override int RuleIndex { get { return RULE_mention_attributes; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - IArcscriptParserVisitor typedVisitor = visitor as IArcscriptParserVisitor; - if (typedVisitor != null) return typedVisitor.VisitMention_attributes(this); - else return visitor.VisitChildren(this); - } - } - - [RuleVersion(0)] - public Mention_attributesContext mention_attributes() { - Mention_attributesContext _localctx = new Mention_attributesContext(Context, State); - EnterRule(_localctx, 44, RULE_mention_attributes); - int _la; - try { - EnterOuterAlt(_localctx, 1); - { - State = 215; - Match(ATTR_NAME); - State = 218; - ErrorHandler.Sync(this); - _la = TokenStream.LA(1); - if (_la==TAG_EQUALS) { - { - State = 216; - Match(TAG_EQUALS); - State = 217; - Match(ATTR_VALUE); - } - } - - } - } - catch (RecognitionException re) { - _localctx.exception = re; - ErrorHandler.ReportError(this, re); - ErrorHandler.Recover(this, re); - } - finally { - ExitRule(); - } - return _localctx; - } - - public partial class Additive_numeric_expressionContext : ParserRuleContext { - [System.Diagnostics.DebuggerNonUserCode] public Multiplicative_numeric_expressionContext multiplicative_numeric_expression() { - return GetRuleContext(0); - } - [System.Diagnostics.DebuggerNonUserCode] public Additive_numeric_expressionContext additive_numeric_expression() { - return GetRuleContext(0); - } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode ADD() { return GetToken(ArcscriptParser.ADD, 0); } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode SUB() { return GetToken(ArcscriptParser.SUB, 0); } - public Additive_numeric_expressionContext(ParserRuleContext parent, int invokingState) - : base(parent, invokingState) - { - } - public override int RuleIndex { get { return RULE_additive_numeric_expression; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - IArcscriptParserVisitor typedVisitor = visitor as IArcscriptParserVisitor; - if (typedVisitor != null) return typedVisitor.VisitAdditive_numeric_expression(this); - else return visitor.VisitChildren(this); - } - } - - [RuleVersion(0)] - public Additive_numeric_expressionContext additive_numeric_expression() { - return additive_numeric_expression(0); - } - - private Additive_numeric_expressionContext additive_numeric_expression(int _p) { - ParserRuleContext _parentctx = Context; - int _parentState = State; - Additive_numeric_expressionContext _localctx = new Additive_numeric_expressionContext(Context, _parentState); - Additive_numeric_expressionContext _prevctx = _localctx; - int _startState = 46; - EnterRecursionRule(_localctx, 46, RULE_additive_numeric_expression, _p); - int _la; - try { - int _alt; - EnterOuterAlt(_localctx, 1); - { - { - State = 221; - multiplicative_numeric_expression(0); - } - Context.Stop = TokenStream.LT(-1); - State = 228; - ErrorHandler.Sync(this); - _alt = Interpreter.AdaptivePredict(TokenStream,16,Context); - while ( _alt!=2 && _alt!=global::Antlr4.Runtime.Atn.ATN.INVALID_ALT_NUMBER ) { - if ( _alt==1 ) { - if ( ParseListeners!=null ) - TriggerExitRuleEvent(); - _prevctx = _localctx; - { - { - _localctx = new Additive_numeric_expressionContext(_parentctx, _parentState); - PushNewRecursionContext(_localctx, _startState, RULE_additive_numeric_expression); - State = 223; - if (!(Precpred(Context, 1))) throw new FailedPredicateException(this, "Precpred(Context, 1)"); - State = 224; - _la = TokenStream.LA(1); - if ( !(_la==ADD || _la==SUB) ) { - ErrorHandler.RecoverInline(this); - } - else { - ErrorHandler.ReportMatch(this); - Consume(); - } - State = 225; - multiplicative_numeric_expression(0); - } - } - } - State = 230; - ErrorHandler.Sync(this); - _alt = Interpreter.AdaptivePredict(TokenStream,16,Context); - } - } - } - catch (RecognitionException re) { - _localctx.exception = re; - ErrorHandler.ReportError(this, re); - ErrorHandler.Recover(this, re); - } - finally { - UnrollRecursionContexts(_parentctx); - } - return _localctx; - } - - public partial class Multiplicative_numeric_expressionContext : ParserRuleContext { - [System.Diagnostics.DebuggerNonUserCode] public Signed_unary_numeric_expressionContext signed_unary_numeric_expression() { - return GetRuleContext(0); - } - [System.Diagnostics.DebuggerNonUserCode] public Multiplicative_numeric_expressionContext multiplicative_numeric_expression() { - return GetRuleContext(0); - } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode MUL() { return GetToken(ArcscriptParser.MUL, 0); } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode DIV() { return GetToken(ArcscriptParser.DIV, 0); } - public Multiplicative_numeric_expressionContext(ParserRuleContext parent, int invokingState) - : base(parent, invokingState) - { - } - public override int RuleIndex { get { return RULE_multiplicative_numeric_expression; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - IArcscriptParserVisitor typedVisitor = visitor as IArcscriptParserVisitor; - if (typedVisitor != null) return typedVisitor.VisitMultiplicative_numeric_expression(this); - else return visitor.VisitChildren(this); - } - } - - [RuleVersion(0)] - public Multiplicative_numeric_expressionContext multiplicative_numeric_expression() { - return multiplicative_numeric_expression(0); - } - - private Multiplicative_numeric_expressionContext multiplicative_numeric_expression(int _p) { - ParserRuleContext _parentctx = Context; - int _parentState = State; - Multiplicative_numeric_expressionContext _localctx = new Multiplicative_numeric_expressionContext(Context, _parentState); - Multiplicative_numeric_expressionContext _prevctx = _localctx; - int _startState = 48; - EnterRecursionRule(_localctx, 48, RULE_multiplicative_numeric_expression, _p); - int _la; - try { - int _alt; - EnterOuterAlt(_localctx, 1); - { - { - State = 232; - signed_unary_numeric_expression(); - } - Context.Stop = TokenStream.LT(-1); - State = 239; - ErrorHandler.Sync(this); - _alt = Interpreter.AdaptivePredict(TokenStream,17,Context); - while ( _alt!=2 && _alt!=global::Antlr4.Runtime.Atn.ATN.INVALID_ALT_NUMBER ) { - if ( _alt==1 ) { - if ( ParseListeners!=null ) - TriggerExitRuleEvent(); - _prevctx = _localctx; - { - { - _localctx = new Multiplicative_numeric_expressionContext(_parentctx, _parentState); - PushNewRecursionContext(_localctx, _startState, RULE_multiplicative_numeric_expression); - State = 234; - if (!(Precpred(Context, 1))) throw new FailedPredicateException(this, "Precpred(Context, 1)"); - State = 235; - _la = TokenStream.LA(1); - if ( !(_la==MUL || _la==DIV) ) { - ErrorHandler.RecoverInline(this); - } - else { - ErrorHandler.ReportMatch(this); - Consume(); - } - State = 236; - signed_unary_numeric_expression(); - } - } - } - State = 241; - ErrorHandler.Sync(this); - _alt = Interpreter.AdaptivePredict(TokenStream,17,Context); - } - } - } - catch (RecognitionException re) { - _localctx.exception = re; - ErrorHandler.ReportError(this, re); - ErrorHandler.Recover(this, re); - } - finally { - UnrollRecursionContexts(_parentctx); - } - return _localctx; - } - - public partial class Signed_unary_numeric_expressionContext : ParserRuleContext { - [System.Diagnostics.DebuggerNonUserCode] public SignContext sign() { - return GetRuleContext(0); - } - [System.Diagnostics.DebuggerNonUserCode] public Unary_numeric_expressionContext unary_numeric_expression() { - return GetRuleContext(0); - } - public Signed_unary_numeric_expressionContext(ParserRuleContext parent, int invokingState) - : base(parent, invokingState) - { - } - public override int RuleIndex { get { return RULE_signed_unary_numeric_expression; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - IArcscriptParserVisitor typedVisitor = visitor as IArcscriptParserVisitor; - if (typedVisitor != null) return typedVisitor.VisitSigned_unary_numeric_expression(this); - else return visitor.VisitChildren(this); - } - } - - [RuleVersion(0)] - public Signed_unary_numeric_expressionContext signed_unary_numeric_expression() { - Signed_unary_numeric_expressionContext _localctx = new Signed_unary_numeric_expressionContext(Context, State); - EnterRule(_localctx, 50, RULE_signed_unary_numeric_expression); - try { - State = 246; - ErrorHandler.Sync(this); - switch (TokenStream.LA(1)) { - case ADD: - case SUB: - EnterOuterAlt(_localctx, 1); - { - State = 242; - sign(); - State = 243; - unary_numeric_expression(); - } - break; - case FLOAT: - case INTEGER: - case LPAREN: - case BOOLEAN: - case FNAME: - case STRING: - case VARIABLE: - EnterOuterAlt(_localctx, 2); - { - State = 245; - unary_numeric_expression(); - } - break; - default: - throw new NoViableAltException(this); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - ErrorHandler.ReportError(this, re); - ErrorHandler.Recover(this, re); - } - finally { - ExitRule(); - } - return _localctx; - } - - public partial class Unary_numeric_expressionContext : ParserRuleContext { - public IToken _VARIABLE; - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode FLOAT() { return GetToken(ArcscriptParser.FLOAT, 0); } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode VARIABLE() { return GetToken(ArcscriptParser.VARIABLE, 0); } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode INTEGER() { return GetToken(ArcscriptParser.INTEGER, 0); } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode STRING() { return GetToken(ArcscriptParser.STRING, 0); } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode BOOLEAN() { return GetToken(ArcscriptParser.BOOLEAN, 0); } - [System.Diagnostics.DebuggerNonUserCode] public Function_callContext function_call() { - return GetRuleContext(0); - } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode LPAREN() { return GetToken(ArcscriptParser.LPAREN, 0); } - [System.Diagnostics.DebuggerNonUserCode] public Compound_condition_orContext compound_condition_or() { - return GetRuleContext(0); - } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode RPAREN() { return GetToken(ArcscriptParser.RPAREN, 0); } - public Unary_numeric_expressionContext(ParserRuleContext parent, int invokingState) - : base(parent, invokingState) - { - } - public override int RuleIndex { get { return RULE_unary_numeric_expression; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - IArcscriptParserVisitor typedVisitor = visitor as IArcscriptParserVisitor; - if (typedVisitor != null) return typedVisitor.VisitUnary_numeric_expression(this); - else return visitor.VisitChildren(this); - } - } - - [RuleVersion(0)] - public Unary_numeric_expressionContext unary_numeric_expression() { - Unary_numeric_expressionContext _localctx = new Unary_numeric_expressionContext(Context, State); - EnterRule(_localctx, 52, RULE_unary_numeric_expression); - try { - State = 259; - ErrorHandler.Sync(this); - switch (TokenStream.LA(1)) { - case FLOAT: - EnterOuterAlt(_localctx, 1); - { - State = 248; - Match(FLOAT); - } - break; - case VARIABLE: - EnterOuterAlt(_localctx, 2); - { - State = 249; - _localctx._VARIABLE = Match(VARIABLE); - this.assertVariable(_localctx._VARIABLE); - } - break; - case INTEGER: - EnterOuterAlt(_localctx, 3); - { - State = 251; - Match(INTEGER); - } - break; - case STRING: - EnterOuterAlt(_localctx, 4); - { - State = 252; - Match(STRING); - } - break; - case BOOLEAN: - EnterOuterAlt(_localctx, 5); - { - State = 253; - Match(BOOLEAN); - } - break; - case FNAME: - EnterOuterAlt(_localctx, 6); - { - State = 254; - function_call(); - } - break; - case LPAREN: - EnterOuterAlt(_localctx, 7); - { - State = 255; - Match(LPAREN); - State = 256; - compound_condition_or(); - State = 257; - Match(RPAREN); - } - break; - default: - throw new NoViableAltException(this); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - ErrorHandler.ReportError(this, re); - ErrorHandler.Recover(this, re); - } - finally { - ExitRule(); - } - return _localctx; - } - - public partial class Function_callContext : ParserRuleContext { - public IToken _FNAME; - public Argument_listContext _argument_list; - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode FNAME() { return GetToken(ArcscriptParser.FNAME, 0); } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode LPAREN() { return GetToken(ArcscriptParser.LPAREN, 0); } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode RPAREN() { return GetToken(ArcscriptParser.RPAREN, 0); } - [System.Diagnostics.DebuggerNonUserCode] public Argument_listContext argument_list() { - return GetRuleContext(0); - } - public Function_callContext(ParserRuleContext parent, int invokingState) - : base(parent, invokingState) - { - } - public override int RuleIndex { get { return RULE_function_call; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - IArcscriptParserVisitor typedVisitor = visitor as IArcscriptParserVisitor; - if (typedVisitor != null) return typedVisitor.VisitFunction_call(this); - else return visitor.VisitChildren(this); - } - } - - [RuleVersion(0)] - public Function_callContext function_call() { - Function_callContext _localctx = new Function_callContext(Context, State); - EnterRule(_localctx, 54, RULE_function_call); - int _la; - try { - EnterOuterAlt(_localctx, 1); - { - State = 261; - _localctx._FNAME = Match(FNAME); - State = 262; - Match(LPAREN); - State = 264; - ErrorHandler.Sync(this); - _la = TokenStream.LA(1); - if ((((_la) & ~0x3f) == 0 && ((1L << _la) & 3378524379461632L) != 0)) { - { - State = 263; - _localctx._argument_list = argument_list(); - } - } - - State = 266; - Match(RPAREN); - this.assertFunctionArguments(_localctx._FNAME, _localctx._argument_list); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - ErrorHandler.ReportError(this, re); - ErrorHandler.Recover(this, re); - } - finally { - ExitRule(); - } - return _localctx; - } - - public partial class Void_function_callContext : ParserRuleContext { - public IToken _VFNAME; - public Argument_listContext _argument_list; - public IToken _VFNAMEVARS; - public Variable_listContext _variable_list; - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode VFNAME() { return GetToken(ArcscriptParser.VFNAME, 0); } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode LPAREN() { return GetToken(ArcscriptParser.LPAREN, 0); } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode RPAREN() { return GetToken(ArcscriptParser.RPAREN, 0); } - [System.Diagnostics.DebuggerNonUserCode] public Argument_listContext argument_list() { - return GetRuleContext(0); - } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode VFNAMEVARS() { return GetToken(ArcscriptParser.VFNAMEVARS, 0); } - [System.Diagnostics.DebuggerNonUserCode] public Variable_listContext variable_list() { - return GetRuleContext(0); - } - public Void_function_callContext(ParserRuleContext parent, int invokingState) - : base(parent, invokingState) - { - } - public override int RuleIndex { get { return RULE_void_function_call; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - IArcscriptParserVisitor typedVisitor = visitor as IArcscriptParserVisitor; - if (typedVisitor != null) return typedVisitor.VisitVoid_function_call(this); - else return visitor.VisitChildren(this); - } - } - - [RuleVersion(0)] - public Void_function_callContext void_function_call() { - Void_function_callContext _localctx = new Void_function_callContext(Context, State); - EnterRule(_localctx, 56, RULE_void_function_call); - int _la; - try { - State = 283; - ErrorHandler.Sync(this); - switch (TokenStream.LA(1)) { - case VFNAME: - EnterOuterAlt(_localctx, 1); - { - State = 269; - _localctx._VFNAME = Match(VFNAME); - State = 270; - Match(LPAREN); - State = 272; - ErrorHandler.Sync(this); - _la = TokenStream.LA(1); - if ((((_la) & ~0x3f) == 0 && ((1L << _la) & 3378524379461632L) != 0)) { - { - State = 271; - _localctx._argument_list = argument_list(); - } - } - - State = 274; - Match(RPAREN); - this.assertFunctionArguments(_localctx._VFNAME, _localctx._argument_list); - } - break; - case VFNAMEVARS: - EnterOuterAlt(_localctx, 2); - { - State = 276; - _localctx._VFNAMEVARS = Match(VFNAMEVARS); - State = 277; - Match(LPAREN); - State = 279; - ErrorHandler.Sync(this); - _la = TokenStream.LA(1); - if (_la==VARIABLE) { - { - State = 278; - _localctx._variable_list = variable_list(); - } - } - - State = 281; - Match(RPAREN); - this.assertFunctionArguments(_localctx._VFNAMEVARS, _localctx._variable_list); - - } - break; - default: - throw new NoViableAltException(this); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - ErrorHandler.ReportError(this, re); - ErrorHandler.Recover(this, re); - } - finally { - ExitRule(); - } - return _localctx; - } - - public partial class SignContext : ParserRuleContext { - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode ADD() { return GetToken(ArcscriptParser.ADD, 0); } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode SUB() { return GetToken(ArcscriptParser.SUB, 0); } - public SignContext(ParserRuleContext parent, int invokingState) - : base(parent, invokingState) - { - } - public override int RuleIndex { get { return RULE_sign; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - IArcscriptParserVisitor typedVisitor = visitor as IArcscriptParserVisitor; - if (typedVisitor != null) return typedVisitor.VisitSign(this); - else return visitor.VisitChildren(this); - } - } - - [RuleVersion(0)] - public SignContext sign() { - SignContext _localctx = new SignContext(Context, State); - EnterRule(_localctx, 58, RULE_sign); - int _la; - try { - EnterOuterAlt(_localctx, 1); - { - State = 285; - _la = TokenStream.LA(1); - if ( !(_la==ADD || _la==SUB) ) { - ErrorHandler.RecoverInline(this); - } - else { - ErrorHandler.ReportMatch(this); - Consume(); - } - } - } - catch (RecognitionException re) { - _localctx.exception = re; - ErrorHandler.ReportError(this, re); - ErrorHandler.Recover(this, re); - } - finally { - ExitRule(); - } - return _localctx; - } - - public partial class Variable_listContext : ParserRuleContext { - public IToken _VARIABLE; - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode[] VARIABLE() { return GetTokens(ArcscriptParser.VARIABLE); } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode VARIABLE(int i) { - return GetToken(ArcscriptParser.VARIABLE, i); - } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode[] COMMA() { return GetTokens(ArcscriptParser.COMMA); } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode COMMA(int i) { - return GetToken(ArcscriptParser.COMMA, i); - } - public Variable_listContext(ParserRuleContext parent, int invokingState) - : base(parent, invokingState) - { - } - public override int RuleIndex { get { return RULE_variable_list; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - IArcscriptParserVisitor typedVisitor = visitor as IArcscriptParserVisitor; - if (typedVisitor != null) return typedVisitor.VisitVariable_list(this); - else return visitor.VisitChildren(this); - } - } - - [RuleVersion(0)] - public Variable_listContext variable_list() { - Variable_listContext _localctx = new Variable_listContext(Context, State); - EnterRule(_localctx, 60, RULE_variable_list); - int _la; - try { - EnterOuterAlt(_localctx, 1); - { - State = 287; - _localctx._VARIABLE = Match(VARIABLE); - State = 292; - ErrorHandler.Sync(this); - _la = TokenStream.LA(1); - while (_la==COMMA) { - { - { - State = 288; - Match(COMMA); - State = 289; - _localctx._VARIABLE = Match(VARIABLE); - } - } - State = 294; - ErrorHandler.Sync(this); - _la = TokenStream.LA(1); - } - this.assertVariable(_localctx._VARIABLE); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - ErrorHandler.ReportError(this, re); - ErrorHandler.Recover(this, re); - } - finally { - ExitRule(); - } - return _localctx; - } - - public partial class Compound_condition_orContext : ParserRuleContext { - [System.Diagnostics.DebuggerNonUserCode] public Compound_condition_andContext compound_condition_and() { - return GetRuleContext(0); - } - [System.Diagnostics.DebuggerNonUserCode] public Compound_condition_orContext compound_condition_or() { - return GetRuleContext(0); - } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode OR() { return GetToken(ArcscriptParser.OR, 0); } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode ORKEYWORD() { return GetToken(ArcscriptParser.ORKEYWORD, 0); } - public Compound_condition_orContext(ParserRuleContext parent, int invokingState) - : base(parent, invokingState) - { - } - public override int RuleIndex { get { return RULE_compound_condition_or; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - IArcscriptParserVisitor typedVisitor = visitor as IArcscriptParserVisitor; - if (typedVisitor != null) return typedVisitor.VisitCompound_condition_or(this); - else return visitor.VisitChildren(this); - } - } - - [RuleVersion(0)] - public Compound_condition_orContext compound_condition_or() { - Compound_condition_orContext _localctx = new Compound_condition_orContext(Context, State); - EnterRule(_localctx, 62, RULE_compound_condition_or); - int _la; - try { - EnterOuterAlt(_localctx, 1); - { - State = 297; - compound_condition_and(); - State = 300; - ErrorHandler.Sync(this); - _la = TokenStream.LA(1); - if (_la==OR || _la==ORKEYWORD) { - { - State = 298; - _la = TokenStream.LA(1); - if ( !(_la==OR || _la==ORKEYWORD) ) { - ErrorHandler.RecoverInline(this); - } - else { - ErrorHandler.ReportMatch(this); - Consume(); - } - State = 299; - compound_condition_or(); - } - } - - } - } - catch (RecognitionException re) { - _localctx.exception = re; - ErrorHandler.ReportError(this, re); - ErrorHandler.Recover(this, re); - } - finally { - ExitRule(); - } - return _localctx; - } - - public partial class Compound_condition_andContext : ParserRuleContext { - [System.Diagnostics.DebuggerNonUserCode] public Negated_unary_conditionContext negated_unary_condition() { - return GetRuleContext(0); - } - [System.Diagnostics.DebuggerNonUserCode] public Compound_condition_andContext compound_condition_and() { - return GetRuleContext(0); - } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode AND() { return GetToken(ArcscriptParser.AND, 0); } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode ANDKEYWORD() { return GetToken(ArcscriptParser.ANDKEYWORD, 0); } - public Compound_condition_andContext(ParserRuleContext parent, int invokingState) - : base(parent, invokingState) - { - } - public override int RuleIndex { get { return RULE_compound_condition_and; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - IArcscriptParserVisitor typedVisitor = visitor as IArcscriptParserVisitor; - if (typedVisitor != null) return typedVisitor.VisitCompound_condition_and(this); - else return visitor.VisitChildren(this); - } - } - - [RuleVersion(0)] - public Compound_condition_andContext compound_condition_and() { - Compound_condition_andContext _localctx = new Compound_condition_andContext(Context, State); - EnterRule(_localctx, 64, RULE_compound_condition_and); - int _la; - try { - EnterOuterAlt(_localctx, 1); - { - State = 302; - negated_unary_condition(); - State = 305; - ErrorHandler.Sync(this); - _la = TokenStream.LA(1); - if (_la==AND || _la==ANDKEYWORD) { - { - State = 303; - _la = TokenStream.LA(1); - if ( !(_la==AND || _la==ANDKEYWORD) ) { - ErrorHandler.RecoverInline(this); - } - else { - ErrorHandler.ReportMatch(this); - Consume(); - } - State = 304; - compound_condition_and(); - } - } - - } - } - catch (RecognitionException re) { - _localctx.exception = re; - ErrorHandler.ReportError(this, re); - ErrorHandler.Recover(this, re); - } - finally { - ExitRule(); - } - return _localctx; - } - - public partial class Negated_unary_conditionContext : ParserRuleContext { - [System.Diagnostics.DebuggerNonUserCode] public Unary_conditionContext unary_condition() { - return GetRuleContext(0); - } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode NEG() { return GetToken(ArcscriptParser.NEG, 0); } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode NOTKEYWORD() { return GetToken(ArcscriptParser.NOTKEYWORD, 0); } - public Negated_unary_conditionContext(ParserRuleContext parent, int invokingState) - : base(parent, invokingState) - { - } - public override int RuleIndex { get { return RULE_negated_unary_condition; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - IArcscriptParserVisitor typedVisitor = visitor as IArcscriptParserVisitor; - if (typedVisitor != null) return typedVisitor.VisitNegated_unary_condition(this); - else return visitor.VisitChildren(this); - } - } - - [RuleVersion(0)] - public Negated_unary_conditionContext negated_unary_condition() { - Negated_unary_conditionContext _localctx = new Negated_unary_conditionContext(Context, State); - EnterRule(_localctx, 66, RULE_negated_unary_condition); - int _la; - try { - EnterOuterAlt(_localctx, 1); - { - State = 308; - ErrorHandler.Sync(this); - _la = TokenStream.LA(1); - if (_la==NEG || _la==NOTKEYWORD) { - { - State = 307; - _la = TokenStream.LA(1); - if ( !(_la==NEG || _la==NOTKEYWORD) ) { - ErrorHandler.RecoverInline(this); - } - else { - ErrorHandler.ReportMatch(this); - Consume(); - } - } - } - - State = 310; - unary_condition(); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - ErrorHandler.ReportError(this, re); - ErrorHandler.Recover(this, re); - } - finally { - ExitRule(); - } - return _localctx; - } - - public partial class Unary_conditionContext : ParserRuleContext { - [System.Diagnostics.DebuggerNonUserCode] public ConditionContext condition() { - return GetRuleContext(0); - } - public Unary_conditionContext(ParserRuleContext parent, int invokingState) - : base(parent, invokingState) - { - } - public override int RuleIndex { get { return RULE_unary_condition; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - IArcscriptParserVisitor typedVisitor = visitor as IArcscriptParserVisitor; - if (typedVisitor != null) return typedVisitor.VisitUnary_condition(this); - else return visitor.VisitChildren(this); - } - } - - [RuleVersion(0)] - public Unary_conditionContext unary_condition() { - Unary_conditionContext _localctx = new Unary_conditionContext(Context, State); - EnterRule(_localctx, 68, RULE_unary_condition); - try { - EnterOuterAlt(_localctx, 1); - { - State = 312; - condition(); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - ErrorHandler.ReportError(this, re); - ErrorHandler.Recover(this, re); - } - finally { - ExitRule(); - } - return _localctx; - } - - public partial class ConditionContext : ParserRuleContext { - [System.Diagnostics.DebuggerNonUserCode] public ExpressionContext[] expression() { - return GetRuleContexts(); - } - [System.Diagnostics.DebuggerNonUserCode] public ExpressionContext expression(int i) { - return GetRuleContext(i); - } - [System.Diagnostics.DebuggerNonUserCode] public Conditional_operatorContext conditional_operator() { - return GetRuleContext(0); - } - public ConditionContext(ParserRuleContext parent, int invokingState) - : base(parent, invokingState) - { - } - public override int RuleIndex { get { return RULE_condition; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - IArcscriptParserVisitor typedVisitor = visitor as IArcscriptParserVisitor; - if (typedVisitor != null) return typedVisitor.VisitCondition(this); - else return visitor.VisitChildren(this); - } - } - - [RuleVersion(0)] - public ConditionContext condition() { - ConditionContext _localctx = new ConditionContext(Context, State); - EnterRule(_localctx, 70, RULE_condition); - int _la; - try { - EnterOuterAlt(_localctx, 1); - { - State = 314; - expression(); - State = 318; - ErrorHandler.Sync(this); - _la = TokenStream.LA(1); - if ((((_la) & ~0x3f) == 0 && ((1L << _la) & 281477090639872L) != 0)) { - { - State = 315; - conditional_operator(); - State = 316; - expression(); - } - } - - } - } - catch (RecognitionException re) { - _localctx.exception = re; - ErrorHandler.ReportError(this, re); - ErrorHandler.Recover(this, re); - } - finally { - ExitRule(); - } - return _localctx; - } - - public partial class Conditional_operatorContext : ParserRuleContext { - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode GT() { return GetToken(ArcscriptParser.GT, 0); } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode GE() { return GetToken(ArcscriptParser.GE, 0); } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode LT() { return GetToken(ArcscriptParser.LT, 0); } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode LE() { return GetToken(ArcscriptParser.LE, 0); } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode EQ() { return GetToken(ArcscriptParser.EQ, 0); } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode NE() { return GetToken(ArcscriptParser.NE, 0); } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode ISKEYWORD() { return GetToken(ArcscriptParser.ISKEYWORD, 0); } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode NOTKEYWORD() { return GetToken(ArcscriptParser.NOTKEYWORD, 0); } - public Conditional_operatorContext(ParserRuleContext parent, int invokingState) - : base(parent, invokingState) - { - } - public override int RuleIndex { get { return RULE_conditional_operator; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - IArcscriptParserVisitor typedVisitor = visitor as IArcscriptParserVisitor; - if (typedVisitor != null) return typedVisitor.VisitConditional_operator(this); - else return visitor.VisitChildren(this); - } - } - - [RuleVersion(0)] - public Conditional_operatorContext conditional_operator() { - Conditional_operatorContext _localctx = new Conditional_operatorContext(Context, State); - EnterRule(_localctx, 72, RULE_conditional_operator); - try { - State = 329; - ErrorHandler.Sync(this); - switch ( Interpreter.AdaptivePredict(TokenStream,29,Context) ) { - case 1: - EnterOuterAlt(_localctx, 1); - { - State = 320; - Match(GT); - } - break; - case 2: - EnterOuterAlt(_localctx, 2); - { - State = 321; - Match(GE); - } - break; - case 3: - EnterOuterAlt(_localctx, 3); - { - State = 322; - Match(LT); - } - break; - case 4: - EnterOuterAlt(_localctx, 4); - { - State = 323; - Match(LE); - } - break; - case 5: - EnterOuterAlt(_localctx, 5); - { - State = 324; - Match(EQ); - } - break; - case 6: - EnterOuterAlt(_localctx, 6); - { - State = 325; - Match(NE); - } - break; - case 7: - EnterOuterAlt(_localctx, 7); - { - State = 326; - Match(ISKEYWORD); - } - break; - case 8: - EnterOuterAlt(_localctx, 8); - { - State = 327; - Match(ISKEYWORD); - State = 328; - Match(NOTKEYWORD); - } - break; - } - } - catch (RecognitionException re) { - _localctx.exception = re; - ErrorHandler.ReportError(this, re); - ErrorHandler.Recover(this, re); - } - finally { - ExitRule(); - } - return _localctx; - } - - public partial class ExpressionContext : ParserRuleContext { - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode STRING() { return GetToken(ArcscriptParser.STRING, 0); } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode BOOLEAN() { return GetToken(ArcscriptParser.BOOLEAN, 0); } - [System.Diagnostics.DebuggerNonUserCode] public Additive_numeric_expressionContext additive_numeric_expression() { - return GetRuleContext(0); - } - public ExpressionContext(ParserRuleContext parent, int invokingState) - : base(parent, invokingState) - { - } - public override int RuleIndex { get { return RULE_expression; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - IArcscriptParserVisitor typedVisitor = visitor as IArcscriptParserVisitor; - if (typedVisitor != null) return typedVisitor.VisitExpression(this); - else return visitor.VisitChildren(this); - } - } - - [RuleVersion(0)] - public ExpressionContext expression() { - ExpressionContext _localctx = new ExpressionContext(Context, State); - EnterRule(_localctx, 74, RULE_expression); - try { - State = 334; - ErrorHandler.Sync(this); - switch ( Interpreter.AdaptivePredict(TokenStream,30,Context) ) { - case 1: - EnterOuterAlt(_localctx, 1); - { - State = 331; - Match(STRING); - } - break; - case 2: - EnterOuterAlt(_localctx, 2); - { - State = 332; - Match(BOOLEAN); - } - break; - case 3: - EnterOuterAlt(_localctx, 3); - { - State = 333; - additive_numeric_expression(0); - } - break; - } - } - catch (RecognitionException re) { - _localctx.exception = re; - ErrorHandler.ReportError(this, re); - ErrorHandler.Recover(this, re); - } - finally { - ExitRule(); - } - return _localctx; - } - - public override bool Sempred(RuleContext _localctx, int ruleIndex, int predIndex) { - switch (ruleIndex) { - case 21: return mention_sempred((MentionContext)_localctx, predIndex); - case 23: return additive_numeric_expression_sempred((Additive_numeric_expressionContext)_localctx, predIndex); - case 24: return multiplicative_numeric_expression_sempred((Multiplicative_numeric_expressionContext)_localctx, predIndex); - } - return true; - } - private bool mention_sempred(MentionContext _localctx, int predIndex) { - switch (predIndex) { - case 0: return this.assertMention(_localctx._attr) - ; - } - return true; - } - private bool additive_numeric_expression_sempred(Additive_numeric_expressionContext _localctx, int predIndex) { - switch (predIndex) { - case 1: return Precpred(Context, 1); - } - return true; - } - private bool multiplicative_numeric_expression_sempred(Multiplicative_numeric_expressionContext _localctx, int predIndex) { - switch (predIndex) { - case 2: return Precpred(Context, 1); - } - return true; - } - - private static int[] _serializedATN = { - 4,1,61,337,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,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,3,0,85,8,0,1,1,4,1, - 88,8,1,11,1,12,1,89,1,2,4,2,93,8,2,11,2,12,2,94,1,2,4,2,98,8,2,11,2,12, - 2,99,1,2,1,2,1,2,3,2,105,8,2,1,3,1,3,1,3,1,3,5,3,111,8,3,10,3,12,3,114, - 9,3,1,3,1,3,1,4,1,4,1,4,1,4,1,5,1,5,1,5,1,5,3,5,126,8,5,1,6,1,6,1,6,1, - 6,3,6,132,8,6,1,7,1,7,1,8,1,8,1,8,1,8,1,9,1,9,1,9,1,9,1,10,1,10,5,10,146, - 8,10,10,10,12,10,149,9,10,1,10,3,10,152,8,10,1,10,1,10,1,11,1,11,1,11, - 1,11,1,11,1,12,1,12,1,12,1,12,1,12,1,13,1,13,1,13,1,13,1,13,1,14,1,14, - 1,14,1,15,1,15,1,15,1,16,1,16,1,16,1,16,1,17,1,17,1,17,1,17,1,17,1,18, - 1,18,1,19,1,19,1,19,5,19,191,8,19,10,19,12,19,194,9,19,1,20,1,20,1,20, - 3,20,199,8,20,1,21,1,21,5,21,203,8,21,10,21,12,21,206,9,21,1,21,1,21,3, - 21,210,8,21,1,21,1,21,1,21,1,21,1,22,1,22,1,22,3,22,219,8,22,1,23,1,23, - 1,23,1,23,1,23,1,23,5,23,227,8,23,10,23,12,23,230,9,23,1,24,1,24,1,24, - 1,24,1,24,1,24,5,24,238,8,24,10,24,12,24,241,9,24,1,25,1,25,1,25,1,25, - 3,25,247,8,25,1,26,1,26,1,26,1,26,1,26,1,26,1,26,1,26,1,26,1,26,1,26,3, - 26,260,8,26,1,27,1,27,1,27,3,27,265,8,27,1,27,1,27,1,27,1,28,1,28,1,28, - 3,28,273,8,28,1,28,1,28,1,28,1,28,1,28,3,28,280,8,28,1,28,1,28,3,28,284, - 8,28,1,29,1,29,1,30,1,30,1,30,5,30,291,8,30,10,30,12,30,294,9,30,1,30, - 1,30,1,31,1,31,1,31,3,31,301,8,31,1,32,1,32,1,32,3,32,306,8,32,1,33,3, - 33,309,8,33,1,33,1,33,1,34,1,34,1,35,1,35,1,35,1,35,3,35,319,8,35,1,36, - 1,36,1,36,1,36,1,36,1,36,1,36,1,36,1,36,3,36,330,8,36,1,37,1,37,1,37,3, - 37,335,8,37,1,37,2,94,99,2,46,48,38,0,2,4,6,8,10,12,14,16,18,20,22,24, - 26,28,30,32,34,36,38,40,42,44,46,48,50,52,54,56,58,60,62,64,66,68,70,72, - 74,0,6,2,0,17,20,33,33,1,0,23,24,1,0,21,22,2,0,32,32,47,47,2,0,31,31,46, - 46,2,0,34,34,49,49,346,0,84,1,0,0,0,2,87,1,0,0,0,4,104,1,0,0,0,6,106,1, - 0,0,0,8,117,1,0,0,0,10,125,1,0,0,0,12,131,1,0,0,0,14,133,1,0,0,0,16,135, - 1,0,0,0,18,139,1,0,0,0,20,143,1,0,0,0,22,155,1,0,0,0,24,160,1,0,0,0,26, - 165,1,0,0,0,28,170,1,0,0,0,30,173,1,0,0,0,32,176,1,0,0,0,34,180,1,0,0, - 0,36,185,1,0,0,0,38,187,1,0,0,0,40,198,1,0,0,0,42,200,1,0,0,0,44,215,1, - 0,0,0,46,220,1,0,0,0,48,231,1,0,0,0,50,246,1,0,0,0,52,259,1,0,0,0,54,261, - 1,0,0,0,56,283,1,0,0,0,58,285,1,0,0,0,60,287,1,0,0,0,62,297,1,0,0,0,64, - 302,1,0,0,0,66,308,1,0,0,0,68,312,1,0,0,0,70,314,1,0,0,0,72,329,1,0,0, - 0,74,334,1,0,0,0,76,77,3,2,1,0,77,78,5,0,0,1,78,85,1,0,0,0,79,80,3,12, - 6,0,80,81,3,62,31,0,81,82,3,14,7,0,82,83,5,0,0,1,83,85,1,0,0,0,84,76,1, - 0,0,0,84,79,1,0,0,0,85,1,1,0,0,0,86,88,3,4,2,0,87,86,1,0,0,0,88,89,1,0, - 0,0,89,87,1,0,0,0,89,90,1,0,0,0,90,3,1,0,0,0,91,93,3,6,3,0,92,91,1,0,0, - 0,93,94,1,0,0,0,94,95,1,0,0,0,94,92,1,0,0,0,95,105,1,0,0,0,96,98,3,8,4, - 0,97,96,1,0,0,0,98,99,1,0,0,0,99,100,1,0,0,0,99,97,1,0,0,0,100,105,1,0, - 0,0,101,105,3,16,8,0,102,105,3,18,9,0,103,105,3,20,10,0,104,92,1,0,0,0, - 104,97,1,0,0,0,104,101,1,0,0,0,104,102,1,0,0,0,104,103,1,0,0,0,105,5,1, - 0,0,0,106,112,5,3,0,0,107,111,3,8,4,0,108,111,3,16,8,0,109,111,3,18,9, - 0,110,107,1,0,0,0,110,108,1,0,0,0,110,109,1,0,0,0,111,114,1,0,0,0,112, - 110,1,0,0,0,112,113,1,0,0,0,113,115,1,0,0,0,114,112,1,0,0,0,115,116,5, - 8,0,0,116,7,1,0,0,0,117,118,3,10,5,0,118,119,5,5,0,0,119,120,6,4,-1,0, - 120,9,1,0,0,0,121,122,5,2,0,0,122,126,6,5,-1,0,123,124,5,7,0,0,124,126, - 6,5,-1,0,125,121,1,0,0,0,125,123,1,0,0,0,126,11,1,0,0,0,127,128,5,1,0, - 0,128,132,6,6,-1,0,129,130,5,6,0,0,130,132,6,6,-1,0,131,127,1,0,0,0,131, - 129,1,0,0,0,132,13,1,0,0,0,133,134,5,10,0,0,134,15,1,0,0,0,135,136,3,12, - 6,0,136,137,3,34,17,0,137,138,3,14,7,0,138,17,1,0,0,0,139,140,3,12,6,0, - 140,141,3,36,18,0,141,142,3,14,7,0,142,19,1,0,0,0,143,147,3,22,11,0,144, - 146,3,24,12,0,145,144,1,0,0,0,146,149,1,0,0,0,147,145,1,0,0,0,147,148, - 1,0,0,0,148,151,1,0,0,0,149,147,1,0,0,0,150,152,3,26,13,0,151,150,1,0, - 0,0,151,152,1,0,0,0,152,153,1,0,0,0,153,154,3,32,16,0,154,21,1,0,0,0,155, - 156,3,12,6,0,156,157,3,28,14,0,157,158,3,14,7,0,158,159,3,2,1,0,159,23, - 1,0,0,0,160,161,3,12,6,0,161,162,3,30,15,0,162,163,3,14,7,0,163,164,3, - 2,1,0,164,25,1,0,0,0,165,166,3,12,6,0,166,167,5,43,0,0,167,168,3,14,7, - 0,168,169,3,2,1,0,169,27,1,0,0,0,170,171,5,42,0,0,171,172,3,62,31,0,172, - 29,1,0,0,0,173,174,5,44,0,0,174,175,3,62,31,0,175,31,1,0,0,0,176,177,3, - 12,6,0,177,178,5,45,0,0,178,179,3,14,7,0,179,33,1,0,0,0,180,181,5,51,0, - 0,181,182,7,0,0,0,182,183,3,62,31,0,183,184,6,17,-1,0,184,35,1,0,0,0,185, - 186,3,56,28,0,186,37,1,0,0,0,187,192,3,40,20,0,188,189,5,35,0,0,189,191, - 3,40,20,0,190,188,1,0,0,0,191,194,1,0,0,0,192,190,1,0,0,0,192,193,1,0, - 0,0,193,39,1,0,0,0,194,192,1,0,0,0,195,199,3,46,23,0,196,199,5,50,0,0, - 197,199,3,42,21,0,198,195,1,0,0,0,198,196,1,0,0,0,198,197,1,0,0,0,199, - 41,1,0,0,0,200,204,5,11,0,0,201,203,3,44,22,0,202,201,1,0,0,0,203,206, - 1,0,0,0,204,202,1,0,0,0,204,205,1,0,0,0,205,207,1,0,0,0,206,204,1,0,0, - 0,207,209,5,53,0,0,208,210,5,59,0,0,209,208,1,0,0,0,209,210,1,0,0,0,210, - 211,1,0,0,0,211,212,5,58,0,0,212,213,5,56,0,0,213,214,4,21,0,1,214,43, - 1,0,0,0,215,218,5,54,0,0,216,217,5,55,0,0,217,219,5,60,0,0,218,216,1,0, - 0,0,218,219,1,0,0,0,219,45,1,0,0,0,220,221,6,23,-1,0,221,222,3,48,24,0, - 222,228,1,0,0,0,223,224,10,1,0,0,224,225,7,1,0,0,225,227,3,48,24,0,226, - 223,1,0,0,0,227,230,1,0,0,0,228,226,1,0,0,0,228,229,1,0,0,0,229,47,1,0, - 0,0,230,228,1,0,0,0,231,232,6,24,-1,0,232,233,3,50,25,0,233,239,1,0,0, - 0,234,235,10,1,0,0,235,236,7,2,0,0,236,238,3,50,25,0,237,234,1,0,0,0,238, - 241,1,0,0,0,239,237,1,0,0,0,239,240,1,0,0,0,240,49,1,0,0,0,241,239,1,0, - 0,0,242,243,3,58,29,0,243,244,3,52,26,0,244,247,1,0,0,0,245,247,3,52,26, - 0,246,242,1,0,0,0,246,245,1,0,0,0,247,51,1,0,0,0,248,260,5,12,0,0,249, - 250,5,51,0,0,250,260,6,26,-1,0,251,260,5,13,0,0,252,260,5,50,0,0,253,260, - 5,38,0,0,254,260,3,54,27,0,255,256,5,15,0,0,256,257,3,62,31,0,257,258, - 5,16,0,0,258,260,1,0,0,0,259,248,1,0,0,0,259,249,1,0,0,0,259,251,1,0,0, - 0,259,252,1,0,0,0,259,253,1,0,0,0,259,254,1,0,0,0,259,255,1,0,0,0,260, - 53,1,0,0,0,261,262,5,39,0,0,262,264,5,15,0,0,263,265,3,38,19,0,264,263, - 1,0,0,0,264,265,1,0,0,0,265,266,1,0,0,0,266,267,5,16,0,0,267,268,6,27, - -1,0,268,55,1,0,0,0,269,270,5,40,0,0,270,272,5,15,0,0,271,273,3,38,19, - 0,272,271,1,0,0,0,272,273,1,0,0,0,273,274,1,0,0,0,274,275,5,16,0,0,275, - 284,6,28,-1,0,276,277,5,41,0,0,277,279,5,15,0,0,278,280,3,60,30,0,279, - 278,1,0,0,0,279,280,1,0,0,0,280,281,1,0,0,0,281,282,5,16,0,0,282,284,6, - 28,-1,0,283,269,1,0,0,0,283,276,1,0,0,0,284,57,1,0,0,0,285,286,7,1,0,0, - 286,59,1,0,0,0,287,292,5,51,0,0,288,289,5,35,0,0,289,291,5,51,0,0,290, - 288,1,0,0,0,291,294,1,0,0,0,292,290,1,0,0,0,292,293,1,0,0,0,293,295,1, - 0,0,0,294,292,1,0,0,0,295,296,6,30,-1,0,296,61,1,0,0,0,297,300,3,64,32, - 0,298,299,7,3,0,0,299,301,3,62,31,0,300,298,1,0,0,0,300,301,1,0,0,0,301, - 63,1,0,0,0,302,305,3,66,33,0,303,304,7,4,0,0,304,306,3,64,32,0,305,303, - 1,0,0,0,305,306,1,0,0,0,306,65,1,0,0,0,307,309,7,5,0,0,308,307,1,0,0,0, - 308,309,1,0,0,0,309,310,1,0,0,0,310,311,3,68,34,0,311,67,1,0,0,0,312,313, - 3,70,35,0,313,69,1,0,0,0,314,318,3,74,37,0,315,316,3,72,36,0,316,317,3, - 74,37,0,317,319,1,0,0,0,318,315,1,0,0,0,318,319,1,0,0,0,319,71,1,0,0,0, - 320,330,5,26,0,0,321,330,5,25,0,0,322,330,5,28,0,0,323,330,5,27,0,0,324, - 330,5,29,0,0,325,330,5,30,0,0,326,330,5,48,0,0,327,328,5,48,0,0,328,330, - 5,49,0,0,329,320,1,0,0,0,329,321,1,0,0,0,329,322,1,0,0,0,329,323,1,0,0, - 0,329,324,1,0,0,0,329,325,1,0,0,0,329,326,1,0,0,0,329,327,1,0,0,0,330, - 73,1,0,0,0,331,335,5,50,0,0,332,335,5,38,0,0,333,335,3,46,23,0,334,331, - 1,0,0,0,334,332,1,0,0,0,334,333,1,0,0,0,335,75,1,0,0,0,31,84,89,94,99, - 104,110,112,125,131,147,151,192,198,204,209,218,228,239,246,259,264,272, - 279,283,292,300,305,308,318,329,334 - }; - - public static readonly ATN _ATN = - new ATNDeserializer().Deserialize(_serializedATN); - - -} -} // namespace Arcweave.Interpreter diff --git a/CSharp/Interpreter/Generated/ArcscriptParserBaseVisitor.cs b/CSharp/Interpreter/Generated/ArcscriptParserBaseVisitor.cs deleted file mode 100644 index f3cb7c1..0000000 --- a/CSharp/Interpreter/Generated/ArcscriptParserBaseVisitor.cs +++ /dev/null @@ -1,419 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// ANTLR Version: 4.13.1 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -// Generated from ArcscriptParser.g4 by ANTLR 4.13.1 - -// Unreachable code detected -#pragma warning disable 0162 -// The variable '...' is assigned but its value is never used -#pragma warning disable 0219 -// Missing XML comment for publicly visible type or member '...' -#pragma warning disable 1591 -// Ambiguous reference in cref attribute -#pragma warning disable 419 - -namespace Arcweave.Interpreter { -using Antlr4.Runtime.Misc; -using Antlr4.Runtime.Tree; -using IToken = Antlr4.Runtime.IToken; -using ParserRuleContext = Antlr4.Runtime.ParserRuleContext; - -/// -/// This class provides an empty implementation of , -/// which can be extended to create a visitor which only needs to handle a subset -/// of the available methods. -/// -/// The return type of the visit operation. -[System.CodeDom.Compiler.GeneratedCode("ANTLR", "4.13.1")] -[System.Diagnostics.DebuggerNonUserCode] -[System.CLSCompliant(false)] -public partial class ArcscriptParserBaseVisitor : AbstractParseTreeVisitor, IArcscriptParserVisitor { - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitInput([NotNull] ArcscriptParser.InputContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitScript([NotNull] ArcscriptParser.ScriptContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitScript_section([NotNull] ArcscriptParser.Script_sectionContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitBlockquote([NotNull] ArcscriptParser.BlockquoteContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitParagraph([NotNull] ArcscriptParser.ParagraphContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitParagraph_start([NotNull] ArcscriptParser.Paragraph_startContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitCodestart([NotNull] ArcscriptParser.CodestartContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitCodeend([NotNull] ArcscriptParser.CodeendContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitAssignment_segment([NotNull] ArcscriptParser.Assignment_segmentContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitFunction_call_segment([NotNull] ArcscriptParser.Function_call_segmentContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitConditional_section([NotNull] ArcscriptParser.Conditional_sectionContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitIf_section([NotNull] ArcscriptParser.If_sectionContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitElse_if_section([NotNull] ArcscriptParser.Else_if_sectionContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitElse_section([NotNull] ArcscriptParser.Else_sectionContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitIf_clause([NotNull] ArcscriptParser.If_clauseContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitElse_if_clause([NotNull] ArcscriptParser.Else_if_clauseContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitEndif_segment([NotNull] ArcscriptParser.Endif_segmentContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitStatement_assignment([NotNull] ArcscriptParser.Statement_assignmentContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitStatement_function_call([NotNull] ArcscriptParser.Statement_function_callContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitArgument_list([NotNull] ArcscriptParser.Argument_listContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitArgument([NotNull] ArcscriptParser.ArgumentContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitMention([NotNull] ArcscriptParser.MentionContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitMention_attributes([NotNull] ArcscriptParser.Mention_attributesContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitAdditive_numeric_expression([NotNull] ArcscriptParser.Additive_numeric_expressionContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitMultiplicative_numeric_expression([NotNull] ArcscriptParser.Multiplicative_numeric_expressionContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitSigned_unary_numeric_expression([NotNull] ArcscriptParser.Signed_unary_numeric_expressionContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitUnary_numeric_expression([NotNull] ArcscriptParser.Unary_numeric_expressionContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitFunction_call([NotNull] ArcscriptParser.Function_callContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitVoid_function_call([NotNull] ArcscriptParser.Void_function_callContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitSign([NotNull] ArcscriptParser.SignContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitVariable_list([NotNull] ArcscriptParser.Variable_listContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitCompound_condition_or([NotNull] ArcscriptParser.Compound_condition_orContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitCompound_condition_and([NotNull] ArcscriptParser.Compound_condition_andContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitNegated_unary_condition([NotNull] ArcscriptParser.Negated_unary_conditionContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitUnary_condition([NotNull] ArcscriptParser.Unary_conditionContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitCondition([NotNull] ArcscriptParser.ConditionContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitConditional_operator([NotNull] ArcscriptParser.Conditional_operatorContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitExpression([NotNull] ArcscriptParser.ExpressionContext context) { return VisitChildren(context); } -} -} // namespace Arcweave.Interpreter diff --git a/CSharp/Interpreter/Generated/ArcscriptParserVisitor.cs b/CSharp/Interpreter/Generated/ArcscriptParserVisitor.cs deleted file mode 100644 index 51ce141..0000000 --- a/CSharp/Interpreter/Generated/ArcscriptParserVisitor.cs +++ /dev/null @@ -1,264 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// ANTLR Version: 4.13.1 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -// Generated from ArcscriptParser.g4 by ANTLR 4.13.1 - -// Unreachable code detected -#pragma warning disable 0162 -// The variable '...' is assigned but its value is never used -#pragma warning disable 0219 -// Missing XML comment for publicly visible type or member '...' -#pragma warning disable 1591 -// Ambiguous reference in cref attribute -#pragma warning disable 419 - -namespace Arcweave.Interpreter { -using Antlr4.Runtime.Misc; -using Antlr4.Runtime.Tree; -using IToken = Antlr4.Runtime.IToken; - -/// -/// This interface defines a complete generic visitor for a parse tree produced -/// by . -/// -/// The return type of the visit operation. -[System.CodeDom.Compiler.GeneratedCode("ANTLR", "4.13.1")] -[System.CLSCompliant(false)] -public interface IArcscriptParserVisitor : IParseTreeVisitor { - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitInput([NotNull] ArcscriptParser.InputContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitScript([NotNull] ArcscriptParser.ScriptContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitScript_section([NotNull] ArcscriptParser.Script_sectionContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitBlockquote([NotNull] ArcscriptParser.BlockquoteContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitParagraph([NotNull] ArcscriptParser.ParagraphContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitParagraph_start([NotNull] ArcscriptParser.Paragraph_startContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitCodestart([NotNull] ArcscriptParser.CodestartContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitCodeend([NotNull] ArcscriptParser.CodeendContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitAssignment_segment([NotNull] ArcscriptParser.Assignment_segmentContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitFunction_call_segment([NotNull] ArcscriptParser.Function_call_segmentContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitConditional_section([NotNull] ArcscriptParser.Conditional_sectionContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitIf_section([NotNull] ArcscriptParser.If_sectionContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitElse_if_section([NotNull] ArcscriptParser.Else_if_sectionContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitElse_section([NotNull] ArcscriptParser.Else_sectionContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitIf_clause([NotNull] ArcscriptParser.If_clauseContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitElse_if_clause([NotNull] ArcscriptParser.Else_if_clauseContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitEndif_segment([NotNull] ArcscriptParser.Endif_segmentContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitStatement_assignment([NotNull] ArcscriptParser.Statement_assignmentContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitStatement_function_call([NotNull] ArcscriptParser.Statement_function_callContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitArgument_list([NotNull] ArcscriptParser.Argument_listContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitArgument([NotNull] ArcscriptParser.ArgumentContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitMention([NotNull] ArcscriptParser.MentionContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitMention_attributes([NotNull] ArcscriptParser.Mention_attributesContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitAdditive_numeric_expression([NotNull] ArcscriptParser.Additive_numeric_expressionContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitMultiplicative_numeric_expression([NotNull] ArcscriptParser.Multiplicative_numeric_expressionContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitSigned_unary_numeric_expression([NotNull] ArcscriptParser.Signed_unary_numeric_expressionContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitUnary_numeric_expression([NotNull] ArcscriptParser.Unary_numeric_expressionContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitFunction_call([NotNull] ArcscriptParser.Function_callContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitVoid_function_call([NotNull] ArcscriptParser.Void_function_callContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitSign([NotNull] ArcscriptParser.SignContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitVariable_list([NotNull] ArcscriptParser.Variable_listContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitCompound_condition_or([NotNull] ArcscriptParser.Compound_condition_orContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitCompound_condition_and([NotNull] ArcscriptParser.Compound_condition_andContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitNegated_unary_condition([NotNull] ArcscriptParser.Negated_unary_conditionContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitUnary_condition([NotNull] ArcscriptParser.Unary_conditionContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitCondition([NotNull] ArcscriptParser.ConditionContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitConditional_operator([NotNull] ArcscriptParser.Conditional_operatorContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitExpression([NotNull] ArcscriptParser.ExpressionContext context); -} -} // namespace Arcweave.Interpreter diff --git a/CSharp/Interpreter/Generated/AssemblyInfo.cs b/CSharp/Interpreter/Generated/AssemblyInfo.cs deleted file mode 100644 index 345f41d..0000000 --- a/CSharp/Interpreter/Generated/AssemblyInfo.cs +++ /dev/null @@ -1,3 +0,0 @@ -using System; - -[assembly: CLSCompliant(false)] \ No newline at end of file diff --git a/CSharp/__tests__/replaceVariables.json b/CSharp/__tests__/replaceVariables.json index d4815e1..4fc89b0 100644 --- a/CSharp/__tests__/replaceVariables.json +++ b/CSharp/__tests__/replaceVariables.json @@ -57,6 +57,13 @@ "var1": "zed" }, "result": "
zed = \"x marks the spot\"
xy = 5 + zed
" + }, + { + "code": "
b = \"x marks the spot\"
xy = 5 + x
", + "variableChanges": { + "var1": "zed" + }, + "result": "
b = \"x marks the spot\"
xy = 5 + zed
" } ] } \ No newline at end of file diff --git a/generate.sh b/generate.sh index 7a66e68..5c253ec 100644 --- a/generate.sh +++ b/generate.sh @@ -23,6 +23,6 @@ rm -rf *.g4 *.g4.bak cd .. java -Xmx500M -cp ../antlr4.jar org.antlr.v4.Tool -Dlanguage=CSharp ArcscriptLexer.g4 ArcscriptParser.g4 -visitor -no-listener -o ./CSharp -package Arcweave.Interpreter -mkdir -p ../CSharp/src/Generated -cp CSharp/*.cs ../CSharp/src/Generated/. +mkdir -p ../CSharp/Interpreter/Generated +cp CSharp/*.cs ../CSharp/Interpreter/Generated/. rm -rf ./CSharp \ No newline at end of file From e4b301e1650eb8373d298bb7e6e5b80e00e097a8 Mon Sep 17 00:00:00 2001 From: Manolis Dermitzakis Date: Sat, 24 Jan 2026 11:58:08 +0200 Subject: [PATCH 08/13] chore: remove unused Utils --- CSharp/Interpreter/Utils.cs | 27 --------------------------- 1 file changed, 27 deletions(-) delete mode 100644 CSharp/Interpreter/Utils.cs diff --git a/CSharp/Interpreter/Utils.cs b/CSharp/Interpreter/Utils.cs deleted file mode 100644 index a479da2..0000000 --- a/CSharp/Interpreter/Utils.cs +++ /dev/null @@ -1,27 +0,0 @@ -namespace Arcweave.Interpreter -{ - public class Utils - { - public static readonly string CODE_HEX_COLOR = "#27b7f5"; - public static string CleanString(string s) - { - if (!string.IsNullOrEmpty(s)) - { - s = s.Replace("", "{bold}").Replace("", "{/bold}"); - s = s.Replace("", "{italic}").Replace("", "{/italic}"); - s = s.Replace("<", string.Empty).Replace(">", string.Empty); - s = s.Replace("

", "\n\n"); - s = s.Replace("", "{code}"); - s = s.Replace("", "{/code}"); - s = System.Text.RegularExpressions.Regex.Replace(s, @"<[^>]*>", string.Empty); - s = s.Replace("{bold}", "[b]").Replace("{/bold}", "[/b]"); - s = s.Replace("{italic}", "[i]").Replace("{/italic}", "[/i]"); - s = s.Replace("{code}", string.Format("", CODE_HEX_COLOR)); - s = s.Replace("{/code}", "\n"); - s = s.TrimEnd(); - return s; - } - return s; - } - } -} From fa8efaf574ac7032f7e5f578faeaa5b53b27c8f5 Mon Sep 17 00:00:00 2001 From: Manolis Dermitzakis Date: Sat, 24 Jan 2026 11:58:27 +0200 Subject: [PATCH 09/13] chore: add idea files --- .../.idea.CSharp/.idea/copilot.data.migration.agent.xml | 6 ++++++ .../.idea/.idea.CSharp/.idea/copilot.data.migration.ask.xml | 6 ++++++ .../.idea.CSharp/.idea/copilot.data.migration.ask2agent.xml | 6 ++++++ .../.idea.CSharp/.idea/copilot.data.migration.edit.xml | 6 ++++++ 4 files changed, 24 insertions(+) create mode 100644 CSharp/.idea/.idea.CSharp/.idea/copilot.data.migration.agent.xml create mode 100644 CSharp/.idea/.idea.CSharp/.idea/copilot.data.migration.ask.xml create mode 100644 CSharp/.idea/.idea.CSharp/.idea/copilot.data.migration.ask2agent.xml create mode 100644 CSharp/.idea/.idea.CSharp/.idea/copilot.data.migration.edit.xml diff --git a/CSharp/.idea/.idea.CSharp/.idea/copilot.data.migration.agent.xml b/CSharp/.idea/.idea.CSharp/.idea/copilot.data.migration.agent.xml new file mode 100644 index 0000000..4ea72a9 --- /dev/null +++ b/CSharp/.idea/.idea.CSharp/.idea/copilot.data.migration.agent.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/CSharp/.idea/.idea.CSharp/.idea/copilot.data.migration.ask.xml b/CSharp/.idea/.idea.CSharp/.idea/copilot.data.migration.ask.xml new file mode 100644 index 0000000..7ef04e2 --- /dev/null +++ b/CSharp/.idea/.idea.CSharp/.idea/copilot.data.migration.ask.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/CSharp/.idea/.idea.CSharp/.idea/copilot.data.migration.ask2agent.xml b/CSharp/.idea/.idea.CSharp/.idea/copilot.data.migration.ask2agent.xml new file mode 100644 index 0000000..1f2ea11 --- /dev/null +++ b/CSharp/.idea/.idea.CSharp/.idea/copilot.data.migration.ask2agent.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/CSharp/.idea/.idea.CSharp/.idea/copilot.data.migration.edit.xml b/CSharp/.idea/.idea.CSharp/.idea/copilot.data.migration.edit.xml new file mode 100644 index 0000000..8648f94 --- /dev/null +++ b/CSharp/.idea/.idea.CSharp/.idea/copilot.data.migration.edit.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file From dd94c1d758d79a316b14af61945b1c50199f76fa Mon Sep 17 00:00:00 2001 From: Manolis Dermitzakis Date: Sat, 24 Jan 2026 12:08:25 +0200 Subject: [PATCH 10/13] feat: github CI for CSharp --- .github/workflows/CSharp.yml | 38 ++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 .github/workflows/CSharp.yml diff --git a/.github/workflows/CSharp.yml b/.github/workflows/CSharp.yml new file mode 100644 index 0000000..710cdb4 --- /dev/null +++ b/.github/workflows/CSharp.yml @@ -0,0 +1,38 @@ +name: CI CSharp + +on: + push: + branches: ["main"] + paths: + - "CSharp/**" + - "grammar/*.g4" + pull_request: + branches: ["main"] + paths: + - "CSharp/**" + - "grammar/*.g4" + +jobs: + build-and-test: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Setup .NET + uses: actions/setup-dotnet@v4 + with: + dotnet-version: "6.0.x" + + - name: Generate ANTLR4 files + run: sh generate.sh + + - name: Restore + run: dotnet restore CSharp.sln + + - name: Build + run: dotnet build CSharp.sln --configuration Release --no-restore + + - name: Test + run: dotnet test CSharp.sln --configuration Release --no-build --verbosity normal From 23734f2ee5a47909f512790bf0d00691186767fc Mon Sep 17 00:00:00 2001 From: Manolis Dermitzakis Date: Sat, 24 Jan 2026 12:13:35 +0200 Subject: [PATCH 11/13] fix: github ci working dir --- .github/workflows/CSharp.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/CSharp.yml b/.github/workflows/CSharp.yml index 710cdb4..3436067 100644 --- a/.github/workflows/CSharp.yml +++ b/.github/workflows/CSharp.yml @@ -15,6 +15,9 @@ on: jobs: build-and-test: runs-on: ubuntu-latest + defaults: + run: + working-directory: ./CSharp steps: - name: Checkout repository @@ -27,6 +30,7 @@ jobs: - name: Generate ANTLR4 files run: sh generate.sh + working-directory: . - name: Restore run: dotnet restore CSharp.sln From 14dfd07556a9f95ec107e6230e88eefc68cb4af5 Mon Sep 17 00:00:00 2001 From: Manolis Dermitzakis Date: Sat, 24 Jan 2026 13:50:45 +0200 Subject: [PATCH 12/13] feat: add ErrorListener and test for Parse and Runtime exceptions --- CSharp/Interpreter/ArcscriptExceptions.cs | 23 ++++++ CSharp/Interpreter/ArcscriptExpression.cs | 19 ++++- CSharp/Interpreter/ArcscriptFunctions.cs | 7 +- CSharp/Interpreter/ArcscriptParserBase.cs | 4 +- CSharp/Interpreter/ArcscriptTranspiler.cs | 38 +++++++++- CSharp/Interpreter/ErrorListener.cs | 17 +++++ CSharp/TestObjects.cs | 1 + CSharp/UnitTests.cs | 92 ++++++++++++++++++++--- 8 files changed, 182 insertions(+), 19 deletions(-) create mode 100644 CSharp/Interpreter/ArcscriptExceptions.cs create mode 100644 CSharp/Interpreter/ErrorListener.cs diff --git a/CSharp/Interpreter/ArcscriptExceptions.cs b/CSharp/Interpreter/ArcscriptExceptions.cs new file mode 100644 index 0000000..b3bb46d --- /dev/null +++ b/CSharp/Interpreter/ArcscriptExceptions.cs @@ -0,0 +1,23 @@ +namespace Arcweave.Interpreter; + +public class RuntimeException : Exception +{ + public RuntimeException(string message) : base(message) + { + } + + public RuntimeException(string message, Exception innerException) : base(message, innerException) + { + } +} + +public class ParseException : Exception +{ + public ParseException(string message) : base(message) + { + } + + public ParseException(string message, Exception innerException) : base(message, innerException) + { + } +} \ No newline at end of file diff --git a/CSharp/Interpreter/ArcscriptExpression.cs b/CSharp/Interpreter/ArcscriptExpression.cs index 8fb8a32..bb9b67c 100644 --- a/CSharp/Interpreter/ArcscriptExpression.cs +++ b/CSharp/Interpreter/ArcscriptExpression.cs @@ -46,6 +46,10 @@ public class Expression : ArcscriptExpressionBase, IComparable public static Expression operator -(Expression first, Expression second) { + if (first.Type() == typeof(string) || second.Type() == typeof(string)) + { + throw new InvalidOperationException("Subtraction is not supported for string types."); + } var doubleValues = GetDoubleValues(first.Value, second.Value); if (!doubleValues.HasDouble) { @@ -59,6 +63,10 @@ public class Expression : ArcscriptExpressionBase, IComparable public static Expression operator *(Expression first, Expression second) { + if (first.Type() == typeof(string) || second.Type() == typeof(string)) + { + throw new InvalidOperationException("Multiplication is not supported for string types."); + } var doubleValues = GetDoubleValues(first.Value, second.Value); if (!doubleValues.HasDouble) { @@ -73,8 +81,17 @@ public class Expression : ArcscriptExpressionBase, IComparable public static Expression operator /(Expression first, Expression second) { + if (first.Type() == typeof(string) || second.Type() == typeof(string)) + { + throw new InvalidOperationException("Division is not supported for string types."); + } var doubleValues = GetDoubleValues(first.Value, second.Value); - return new Expression(doubleValues.Value1 / doubleValues.Value2); + var result = doubleValues.Value1 / doubleValues.Value2; + if (double.IsInfinity(result)) + { + throw new DivideByZeroException("Division by zero."); + } + return new Expression(result); } public static bool operator ==(Expression first, Expression second) diff --git a/CSharp/Interpreter/ArcscriptFunctions.cs b/CSharp/Interpreter/ArcscriptFunctions.cs index 8a72deb..20605e0 100644 --- a/CSharp/Interpreter/ArcscriptFunctions.cs +++ b/CSharp/Interpreter/ArcscriptFunctions.cs @@ -62,7 +62,12 @@ public object Sqrt(IList args) { { n = (double)e.Value; } - return Math.Sqrt(n); + var result = Math.Sqrt(n); + if (double.IsNaN(result)) + { + throw new InvalidOperationException("Cannot compute square root of a negative number."); + } + return result; } public object Sqr(IList args) { diff --git a/CSharp/Interpreter/ArcscriptParserBase.cs b/CSharp/Interpreter/ArcscriptParserBase.cs index 644a624..0640205 100644 --- a/CSharp/Interpreter/ArcscriptParserBase.cs +++ b/CSharp/Interpreter/ArcscriptParserBase.cs @@ -111,7 +111,7 @@ public bool assertFunctionArguments(IToken fname, ArcscriptParser.Argument_listC var min = this.ArcscriptFunctions[fname.Text].MinArgs; var max = this.ArcscriptFunctions[fname.Text].MaxArgs; if ( ( min != null && argListLength < min ) || ( max != null && argListLength > max ) ) { - return false; + throw new RecognitionException("Incorrect number of arguments for function " + fname.Text, this, this.InputStream, this.Context); } return true; } @@ -121,7 +121,7 @@ public bool assertFunctionArguments(IToken fname, ArcscriptParser.Variable_listC var min = this.ArcscriptFunctions[fname.Text].MinArgs; var max = this.ArcscriptFunctions[fname.Text].MaxArgs; if ( ( min != null && varListLength < min ) || ( max != null && varListLength > max ) ) { - return false; + throw new RecognitionException("Incorrect number of arguments for function " + fname.Text, this, this.InputStream, this.Context); } return true; } diff --git a/CSharp/Interpreter/ArcscriptTranspiler.cs b/CSharp/Interpreter/ArcscriptTranspiler.cs index 6ba9de4..2d22f7f 100644 --- a/CSharp/Interpreter/ArcscriptTranspiler.cs +++ b/CSharp/Interpreter/ArcscriptTranspiler.cs @@ -19,12 +19,26 @@ public AwInterpreter(IProject project, string elementId = "") private ArcscriptParser.InputContext GetParseTree(string code) { ICharStream stream = CharStreams.fromString(code); - ITokenSource lexer = new ArcscriptLexer(stream); + ArcscriptLexer lexer = new ArcscriptLexer(stream); + var lexerErrorListener = new ErrorListener(); + lexer.AddErrorListener(lexerErrorListener); ITokenStream tokens = new CommonTokenStream(lexer); + var parserErrorListener = new ErrorListener(); ArcscriptParser parser = new ArcscriptParser(tokens); + parser.AddErrorListener(parserErrorListener); parser.SetProject(Project); ArcscriptParser.InputContext tree = parser.input(); + + if (lexerErrorListener.HasErrors) + { + throw new ParseException("Lexing errors:\n" + string.Join("\n", lexerErrorListener.Errors)); + } + if (parserErrorListener.HasErrors) + { + throw new ParseException("Parsing errors:\n" + string.Join("\n", parserErrorListener.Errors)); + } + return tree; } @@ -34,9 +48,27 @@ public TranspilerOutput RunScript(string code) { return new TranspilerOutput(); } - ArcscriptParser.InputContext tree = this.GetParseTree(code); + + ArcscriptParser.InputContext tree; + try + { + tree = this.GetParseTree(code); + } + catch (Exception e) + { + throw new ParseException(e.Message, e); + } + ArcscriptVisitor visitor = new ArcscriptVisitor(this.ElementId, this.Project); - object result = tree.Accept(visitor); + object result; + try + { + result = tree.Accept(visitor); + } + catch (System.Exception e) + { + throw new RuntimeException($"Error interpreting Arcscript code: {e.Message}\nCode:\n{code}", e); + } // List outputs = visitor.state.outputs; var outputResult = visitor.state.Outputs.GetText(); diff --git a/CSharp/Interpreter/ErrorListener.cs b/CSharp/Interpreter/ErrorListener.cs new file mode 100644 index 0000000..397d2c1 --- /dev/null +++ b/CSharp/Interpreter/ErrorListener.cs @@ -0,0 +1,17 @@ +using Antlr4.Runtime; + +namespace Arcweave.Interpreter; + +public class ErrorListener: ConsoleErrorListener +{ + public bool HasErrors = false; + public List Errors = new List(); + + public override void SyntaxError(TextWriter output, IRecognizer recognizer, S offendingSymbol, int line, int charPositionInLine, + string msg, RecognitionException e) + { + HasErrors = true; + Errors.Add($"line {line}:{charPositionInLine} {msg}"); + base.SyntaxError(output, recognizer, offendingSymbol, line, charPositionInLine, msg, e); + } +} \ No newline at end of file diff --git a/CSharp/TestObjects.cs b/CSharp/TestObjects.cs index 4e0a77f..17736c3 100644 --- a/CSharp/TestObjects.cs +++ b/CSharp/TestObjects.cs @@ -15,6 +15,7 @@ public struct TestCase public string? output; public string elementId; public object result; + public string? error; public Dictionary? visits; } diff --git a/CSharp/UnitTests.cs b/CSharp/UnitTests.cs index b137842..83dbb53 100644 --- a/CSharp/UnitTests.cs +++ b/CSharp/UnitTests.cs @@ -18,37 +18,57 @@ public TestData(Dictionary variables, List cases) Cases = cases; } } - + private static IEnumerable GetValidTestData() { var tests = LoadJson("../../../__tests__/valid.json"); - + foreach (var testCase in tests.Cases) { yield return new TestCaseData(tests.Variables, testCase); } } - + private static IEnumerable GetConditionsTestData() { var tests = LoadJson("../../../__tests__/conditions.json"); - + foreach (var validTestsCase in tests.Cases) { yield return new TestCaseData(tests.Variables, validTestsCase); } } - + private static IEnumerable GetStringConcatTestData() { var tests = LoadJson("../../../__tests__/stringConcat.json"); - + foreach (var stringConcatTestCase in tests.Cases) { yield return new TestCaseData(tests.Variables, stringConcatTestCase); } } + private static IEnumerable GetRuntimeErrorTestData() + { + var tests = LoadJson("../../../__tests__/runtimeErrors.json"); + + foreach (var runtimeErrorTestCase in tests.Cases) + { + yield return new TestCaseData(tests.Variables, runtimeErrorTestCase); + } + } + + private static IEnumerable GetParseErrorTestData() + { + var tests = LoadJson("../../../__tests__/parseErrors.json"); + + foreach (var parseErrorTestCase in tests.Cases) + { + yield return new TestCaseData(tests.Variables, parseErrorTestCase); + } + } + private static TestData LoadJson(string filePath) { using var r = new StreamReader(filePath); @@ -60,7 +80,7 @@ private static TestData LoadJson(string filePath) { if (variable.value is long l) { - variables[variable.id] = new Variable(variable.name, (int) l); + variables[variable.id] = new Variable(variable.name, (int)l); } else { @@ -78,6 +98,7 @@ private static TestData LoadJson(string filePath) { return null; } + var changesByName = new Dictionary(); foreach (var varChange in changes) { @@ -86,7 +107,7 @@ private static TestData LoadJson(string filePath) return changesByName; } - + [Test] [TestCaseSource(nameof(GetValidTestData))] public void ValidTests(Dictionary variables, TestCase testCase) @@ -102,11 +123,12 @@ public void ValidTests(Dictionary variables, TestCase testCase }; } } + Console.WriteLine("Testing Case: " + testCase.code); var project = new Project.Project(variables.Values.ToList(), elements); var i = new AwInterpreter(project, testCase.elementId); var output = i.RunScript(testCase.code); - + if (testCase.output != null) { Assert.That(output.Output, Is.EqualTo(testCase.output)); @@ -134,14 +156,15 @@ public void ConditionTests(Dictionary variables, TestCase test }; } } + Console.WriteLine("Testing Case: " + testCase.code); var project = new Project.Project(variables.Values.ToList(), elements); var i = new AwInterpreter(project, testCase.elementId); var output = i.RunScript(testCase.code); - + Assert.That(output.Result, Is.EqualTo(testCase.result)); } - + [Test] [TestCaseSource(nameof(GetStringConcatTestData))] public void StringConcatTests(Dictionary variables, TestCase testCase) @@ -157,11 +180,12 @@ public void StringConcatTests(Dictionary variables, TestCase t }; } } + Console.WriteLine("Testing Case: " + testCase.code); var project = new Project.Project(variables.Values.ToList(), elements); var i = new AwInterpreter(project, testCase.elementId); var output = i.RunScript(testCase.code); - + if (testCase.output != null) { Assert.That(output.Output, Is.EqualTo(testCase.output)); @@ -173,4 +197,48 @@ public void StringConcatTests(Dictionary variables, TestCase t Assert.That(output.Changes, Is.EqualTo(changesByName)); } } + + [Test] + [TestCaseSource(nameof(GetRuntimeErrorTestData))] + public void RuntimeErrorTests(Dictionary variables, TestCase testCase) + { + var Elements = new Dictionary(); + if (testCase.visits != null) + { + foreach (var kvp in testCase.visits) + { + Elements[kvp.Key] = new Element + { + Visits = kvp.Value + }; + } + } + + Console.WriteLine("Testing Case: " + testCase.code); + var project = new Project.Project(variables.Values.ToList(), Elements); + var i = new AwInterpreter(project, testCase.elementId); + var ex = Assert.Throws(() => i.RunScript(testCase.code)); + } + + [Test] + [TestCaseSource(nameof(GetParseErrorTestData))] + public void ParseErrorTests(Dictionary variables, TestCase testCase) + { + var Elements = new Dictionary(); + if (testCase.visits != null) + { + foreach (var kvp in testCase.visits) + { + Elements[kvp.Key] = new Element + { + Visits = kvp.Value + }; + } + } + + Console.WriteLine("Testing Case: " + testCase.code); + var project = new Project.Project(variables.Values.ToList(), Elements); + var i = new AwInterpreter(project, testCase.elementId); + var ex = Assert.Throws(() => i.RunScript(testCase.code)); + } } \ No newline at end of file From 42f0de77d5841b709ebdb9e40f1b66c1e4910dec Mon Sep 17 00:00:00 2001 From: Manolis Dermitzakis Date: Sat, 24 Jan 2026 13:57:48 +0200 Subject: [PATCH 13/13] chore: remove .idea files --- CSharp/.gitignore | 2 ++ CSharp/.idea/.idea.CSharp/.idea/.gitignore | 13 ------------- .../.idea/copilot.data.migration.agent.xml | 6 ------ .../.idea/copilot.data.migration.ask.xml | 6 ------ .../.idea/copilot.data.migration.ask2agent.xml | 6 ------ .../.idea/copilot.data.migration.edit.xml | 6 ------ CSharp/.idea/.idea.CSharp/.idea/indexLayout.xml | 8 -------- CSharp/.idea/.idea.CSharp/.idea/vcs.xml | 6 ------ 8 files changed, 2 insertions(+), 51 deletions(-) delete mode 100644 CSharp/.idea/.idea.CSharp/.idea/.gitignore delete mode 100644 CSharp/.idea/.idea.CSharp/.idea/copilot.data.migration.agent.xml delete mode 100644 CSharp/.idea/.idea.CSharp/.idea/copilot.data.migration.ask.xml delete mode 100644 CSharp/.idea/.idea.CSharp/.idea/copilot.data.migration.ask2agent.xml delete mode 100644 CSharp/.idea/.idea.CSharp/.idea/copilot.data.migration.edit.xml delete mode 100644 CSharp/.idea/.idea.CSharp/.idea/indexLayout.xml delete mode 100644 CSharp/.idea/.idea.CSharp/.idea/vcs.xml diff --git a/CSharp/.gitignore b/CSharp/.gitignore index 72c54b0..9dd07fb 100644 --- a/CSharp/.gitignore +++ b/CSharp/.gitignore @@ -381,6 +381,8 @@ MigrationBackup/ .idea/**/gradle.xml .idea/**/libraries +.idea + # Gradle and Maven with auto-import # When using Gradle or Maven with auto-import, you should exclude module files, # since they will be recreated, and may cause churn. Uncomment if using diff --git a/CSharp/.idea/.idea.CSharp/.idea/.gitignore b/CSharp/.idea/.idea.CSharp/.idea/.gitignore deleted file mode 100644 index 9726b8d..0000000 --- a/CSharp/.idea/.idea.CSharp/.idea/.gitignore +++ /dev/null @@ -1,13 +0,0 @@ -# Default ignored files -/shelf/ -/workspace.xml -# Rider ignored files -/contentModel.xml -/projectSettingsUpdater.xml -/.idea.CSharp.iml -/modules.xml -# Editor-based HTTP Client requests -/httpRequests/ -# Datasource local storage ignored files -/dataSources/ -/dataSources.local.xml diff --git a/CSharp/.idea/.idea.CSharp/.idea/copilot.data.migration.agent.xml b/CSharp/.idea/.idea.CSharp/.idea/copilot.data.migration.agent.xml deleted file mode 100644 index 4ea72a9..0000000 --- a/CSharp/.idea/.idea.CSharp/.idea/copilot.data.migration.agent.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - \ No newline at end of file diff --git a/CSharp/.idea/.idea.CSharp/.idea/copilot.data.migration.ask.xml b/CSharp/.idea/.idea.CSharp/.idea/copilot.data.migration.ask.xml deleted file mode 100644 index 7ef04e2..0000000 --- a/CSharp/.idea/.idea.CSharp/.idea/copilot.data.migration.ask.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - \ No newline at end of file diff --git a/CSharp/.idea/.idea.CSharp/.idea/copilot.data.migration.ask2agent.xml b/CSharp/.idea/.idea.CSharp/.idea/copilot.data.migration.ask2agent.xml deleted file mode 100644 index 1f2ea11..0000000 --- a/CSharp/.idea/.idea.CSharp/.idea/copilot.data.migration.ask2agent.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - \ No newline at end of file diff --git a/CSharp/.idea/.idea.CSharp/.idea/copilot.data.migration.edit.xml b/CSharp/.idea/.idea.CSharp/.idea/copilot.data.migration.edit.xml deleted file mode 100644 index 8648f94..0000000 --- a/CSharp/.idea/.idea.CSharp/.idea/copilot.data.migration.edit.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - \ No newline at end of file diff --git a/CSharp/.idea/.idea.CSharp/.idea/indexLayout.xml b/CSharp/.idea/.idea.CSharp/.idea/indexLayout.xml deleted file mode 100644 index 7b08163..0000000 --- a/CSharp/.idea/.idea.CSharp/.idea/indexLayout.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/CSharp/.idea/.idea.CSharp/.idea/vcs.xml b/CSharp/.idea/.idea.CSharp/.idea/vcs.xml deleted file mode 100644 index 6c0b863..0000000 --- a/CSharp/.idea/.idea.CSharp/.idea/vcs.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file