├── .gitignore ├── CONTRIBUTING.md ├── LICENSE ├── Makefile ├── NOTES ├── NOTICE ├── README.md ├── docs ├── ARCHITECTURE.md ├── EXAMPLES.md ├── IDIOMS.md ├── OVERVIEW.md ├── PHILOSOPHY.md ├── SYNTAX.md ├── THREAT_MODEL.md ├── app-architecture.png ├── code-architecture.png ├── conf.py ├── index.md └── modules │ ├── cache_module.md │ ├── confluence_module.md │ ├── datasets_module.md │ ├── excel_module.md │ ├── gdoc_module.md │ ├── global_module.md │ ├── gsheet_module.md │ ├── html_module.md │ ├── isoweek_module.md │ ├── jinja_module.md │ ├── jira_module.md │ └── org_module.md ├── experimental ├── forthic-cpp │ ├── .gitignore │ ├── ForthicLib.sln │ ├── ForthicLib │ │ ├── Defines.h │ │ ├── ForthicLib.cpp │ │ ├── ForthicLib.h │ │ ├── ForthicLib.vcxproj │ │ ├── ForthicLib.vcxproj.filters │ │ ├── Interpreter.cpp │ │ ├── Interpreter.h │ │ ├── Modules │ │ │ ├── GlobalItemGetters.cpp │ │ │ ├── GlobalItemGetters.h │ │ │ ├── GlobalModule.cpp │ │ │ ├── GlobalModule.h │ │ │ ├── GlobalModuleWords.cpp │ │ │ ├── GlobalModuleWords.h │ │ │ ├── Module.cpp │ │ │ └── Module.h │ │ ├── StackItems │ │ │ ├── ArrayItem.cpp │ │ │ ├── ArrayItem.h │ │ │ ├── FloatItem.cpp │ │ │ ├── FloatItem.h │ │ │ ├── IntItem.cpp │ │ │ ├── IntItem.h │ │ │ ├── ModuleItem.cpp │ │ │ ├── ModuleItem.h │ │ │ ├── StackItem.cpp │ │ │ ├── StackItem.h │ │ │ ├── StartArrayItem.cpp │ │ │ ├── StartArrayItem.h │ │ │ ├── StringItem.cpp │ │ │ ├── StringItem.h │ │ │ ├── VariableItem.cpp │ │ │ └── VariableItem.h │ │ ├── Token.cpp │ │ ├── Token.h │ │ ├── Tokenizer.cpp │ │ ├── Tokenizer.h │ │ ├── Words │ │ │ ├── DefinitionWord.cpp │ │ │ ├── DefinitionWord.h │ │ │ ├── EndArrayWord.cpp │ │ │ ├── EndArrayWord.h │ │ │ ├── PushItemWord.cpp │ │ │ ├── PushItemWord.h │ │ │ ├── Word.cpp │ │ │ └── Word.h │ │ ├── dllmain.cpp │ │ ├── pch.cpp │ │ ├── pch.h │ │ └── targetver.h │ └── ForthicLibTests │ │ ├── Assets │ │ ├── LockScreenLogo.scale-200.png │ │ ├── SplashScreen.scale-200.png │ │ ├── Square150x150Logo.scale-200.png │ │ ├── Square44x44Logo.scale-200.png │ │ ├── Square44x44Logo.targetsize-24_altform-unplated.png │ │ ├── StoreLogo.png │ │ └── Wide310x150Logo.scale-200.png │ │ ├── ForthicLibTests.vcxproj │ │ ├── ForthicLibTests.vcxproj.filters │ │ ├── ForthicLibTests.vcxproj.user │ │ ├── ForthicLibTests_TemporaryKey.pfx │ │ ├── GlobalModuleTest.cpp │ │ ├── InterpreterTest.cpp │ │ ├── Moduletest.cpp │ │ ├── Package.appxmanifest │ │ ├── TokenizerTest.cpp │ │ ├── UnitTestApp.rd.xml │ │ ├── UnitTestApp.xaml │ │ ├── UnitTestApp.xaml.cpp │ │ ├── UnitTestApp.xaml.h │ │ ├── pch.cpp │ │ └── pch.h ├── forthic-hs │ ├── .gitignore │ ├── Forthic │ │ ├── GlobalModule.hs │ │ ├── Interpreter.hs │ │ ├── Module.hs │ │ ├── StackItem.hs │ │ ├── Tokenizer.hs │ │ └── Types.hs │ ├── Modules │ │ └── ModuleA.hs │ ├── README.md │ ├── Sample1.hs │ └── test_tokenizer.hs ├── forthic-jl │ ├── Forthic │ │ ├── Project.toml │ │ ├── src │ │ │ ├── Forthic.jl │ │ │ ├── global_module.jl │ │ │ ├── interpreter.jl │ │ │ ├── module.jl │ │ │ ├── test.jl │ │ │ └── tokenizer.jl │ │ ├── test.forthic │ │ └── test_interp.forthic │ └── README.md ├── forthic-nvcc │ ├── .gitignore │ ├── Interpreter.cpp │ ├── Interpreter.h │ ├── Makefile │ ├── Module.cpp │ ├── Module.h │ ├── S_StartArray.cpp │ ├── S_StartArray.h │ ├── S_String.cpp │ ├── S_String.h │ ├── S_Variable.cpp │ ├── S_Variable.h │ ├── StackItem.cpp │ ├── StackItem.h │ ├── Token.cpp │ ├── Token.h │ ├── Tokenizer.cpp │ ├── Tokenizer.h │ ├── W_Definition.cpp │ ├── W_Definition.h │ ├── W_EndArray.cpp │ ├── W_EndArray.h │ ├── W_PushItem.cpp │ ├── W_PushItem.h │ ├── Word.cpp │ ├── Word.h │ ├── deps.mk │ ├── deps.py │ ├── examples │ │ ├── BHM-p.62-LP.forthic │ │ ├── BHM-p.62.forthic │ │ ├── Ch2Module.cu │ │ ├── Ch2Module.h │ │ ├── Example-2.1.forthic │ │ ├── Example-2.2.forthic │ │ ├── TestContext.forthic │ │ ├── checkDimension.forthic │ │ ├── checkThreadIndex.forthic │ │ ├── main.cpp │ │ ├── sumArraysOnGPU-managed.forthic │ │ ├── sumArraysOnGPU-small-case.forthic │ │ ├── sumArraysOnGPU.forthic │ │ ├── sumMatrix2DGrid1DBlock.forthic │ │ └── sumMatrix2DGrid2DBlock.forthic │ ├── m_cuda │ │ ├── I_AsDim3.cu │ │ ├── I_AsDim3.h │ │ ├── M_Cuda.cu │ │ ├── M_Cuda.h │ │ ├── S_CudaDeviceProp.cu │ │ ├── S_CudaDeviceProp.h │ │ ├── S_Dim3.cu │ │ └── S_Dim3.h │ ├── m_gauss │ │ ├── M_Gauss.cu │ │ └── M_Gauss.h │ ├── m_global │ │ ├── I_AsArray.cpp │ │ ├── I_AsArray.h │ │ ├── I_AsFloat.cpp │ │ ├── I_AsFloat.h │ │ ├── I_AsFloatStar.cpp │ │ ├── I_AsFloatStar.h │ │ ├── I_AsInt.cpp │ │ ├── I_AsInt.h │ │ ├── I_AsIntStar.cpp │ │ ├── I_AsIntStar.h │ │ ├── I_AsModule.cpp │ │ ├── I_AsModule.h │ │ ├── I_AsString.cpp │ │ ├── I_AsString.h │ │ ├── I_AsTimePoint.cpp │ │ ├── I_AsTimePoint.h │ │ ├── I_AsVoidStar.cpp │ │ ├── I_AsVoidStar.h │ │ ├── M_Global.cpp │ │ ├── M_Global.h │ │ ├── S_Address.cpp │ │ ├── S_Address.h │ │ ├── S_Array.cpp │ │ ├── S_Array.h │ │ ├── S_Float.cpp │ │ ├── S_Float.h │ │ ├── S_Int.cpp │ │ ├── S_Int.h │ │ ├── S_Module.cpp │ │ ├── S_Module.h │ │ ├── S_TimePoint.cpp │ │ └── S_TimePoint.h │ ├── m_lp │ │ ├── M_LP.cu │ │ ├── M_LP.h │ │ ├── S_LP.cu │ │ ├── S_LP.h │ │ ├── S_LPEquation.cu │ │ └── S_LPEquation.h │ └── test │ │ ├── GlobalModuleTest.cpp │ │ ├── GlobalModuleTest.h │ │ ├── InterpreterTest.cpp │ │ ├── InterpreterTest.h │ │ ├── ModuleTest.cpp │ │ ├── ModuleTest.h │ │ ├── Test.cpp │ │ ├── Test.h │ │ ├── TokenizerTest.cpp │ │ ├── TokenizerTest.h │ │ ├── dummy.cu │ │ └── main_test.cpp ├── forthic-rs │ ├── .gitignore │ ├── Cargo.lock │ ├── Cargo.toml │ ├── Makefile │ ├── src │ │ ├── errors.rs │ │ ├── lib.rs │ │ ├── main.rs │ │ ├── token.rs │ │ └── tokenizer.rs │ └── tests │ │ ├── .gitignore │ │ ├── Cargo.lock │ │ ├── Cargo.toml │ │ └── src │ │ ├── lib.rs │ │ └── test_tokenizer.rs ├── forthic-swift │ ├── .gitignore │ └── Forthic │ │ ├── .gitignore │ │ ├── Package.resolved │ │ ├── Package.swift │ │ ├── README.md │ │ ├── Sources │ │ └── Forthic │ │ │ ├── Interpreter.swift │ │ │ ├── Module.swift │ │ │ ├── Tokenizer.swift │ │ │ ├── Tokens.swift │ │ │ └── global_module.swift │ │ └── Tests │ │ └── ForthicTests │ │ ├── GlobalModuleTests.swift │ │ ├── InterpreterTests.swift │ │ └── TokenizerTests.swift ├── forthic-zig │ ├── .gitignore │ ├── Makefile │ ├── build.zig │ ├── build.zig.zon │ └── src │ │ ├── forthic │ │ ├── token.zig │ │ └── tokenizer.zig │ │ ├── main.zig │ │ └── root.zig └── pre-forthic │ ├── forrth-asm │ ├── .gitattributes │ ├── .gitignore │ ├── forrth.sln │ └── forrth │ │ ├── BLOCK-1.forrth │ │ ├── Constants.inc │ │ ├── CoreWords.asm │ │ ├── DEFINITION_DESIGN.txt │ │ ├── Definitions.asm │ │ ├── Dictionary.asm │ │ ├── DictionaryMacros.inc │ │ ├── ERROR_DESIGN.txt │ │ ├── Engine.asm │ │ ├── Entry.inc │ │ ├── Error.asm │ │ ├── Exercise.asm │ │ ├── ForrthData.asm │ │ ├── LITERALS_DESIGN.txt │ │ ├── Literals.asm │ │ ├── NESTED_INPUT.txt │ │ ├── REWRITE_1.txt │ │ ├── STACK_DESIGN.txt │ │ ├── STRINGS.txt │ │ ├── UninitializedData.asm │ │ ├── forrth.cpp │ │ ├── forrth.vcxproj │ │ ├── forrth.vcxproj.filters │ │ ├── stdafx.cpp │ │ ├── stdafx.h │ │ └── targetver.h │ ├── forrth-cs │ ├── .gitattributes │ ├── .gitignore │ ├── HoloForrth.sln │ └── HoloForrth │ │ ├── AppView.cs │ │ ├── AppViewSource.cs │ │ ├── Assets │ │ ├── LockScreenLogo.scale-200.png │ │ ├── SplashScreen.scale-200.png │ │ ├── Square150x150Logo.scale-200.png │ │ ├── Square44x44Logo.scale-200.png │ │ ├── Square44x44Logo.targetsize-24_altform-unplated.png │ │ ├── StoreLogo.png │ │ └── Wide310x150Logo.scale-200.png │ │ ├── Blocks.cs │ │ ├── Common │ │ ├── CameraResources.cs │ │ ├── DeviceResources.cs │ │ ├── DirectXHelper.cs │ │ ├── Disposer.cs │ │ ├── InteropStatics.cs │ │ └── StepTimer.cs │ │ ├── Content │ │ ├── ShaderStructures.cs │ │ ├── Shaders │ │ │ ├── GeometryShader.hlsl │ │ │ ├── PixelShader.hlsl │ │ │ ├── VPRTVertexShader.hlsl │ │ │ ├── VertexShader.hlsl │ │ │ └── VertexShaderShared.hlsl │ │ ├── SpatialInputHandler.cs │ │ └── SpinningCubeRenderer.cs │ │ ├── CoreWords.cs │ │ ├── Entry.cs │ │ ├── Forrth.cs │ │ ├── FxCompile.cs │ │ ├── HoloForrth.csproj │ │ ├── HoloForrthMain.cs │ │ ├── Literals.cs │ │ ├── MessageBuffer.cs │ │ ├── Package.appxmanifest │ │ ├── Program.cs │ │ ├── Properties │ │ ├── AssemblyInfo.cs │ │ └── Default.rd.xml │ │ ├── Specs │ │ ├── COMMANDLINE_UI.txt │ │ ├── FORRTH.txt │ │ ├── LITERALS.txt │ │ └── PROCESSING_INPUT.txt │ │ └── ms.fxcompile.targets │ ├── forrth-erl │ ├── .gitignore │ ├── BLOCK-1.forrth │ ├── ferrth.erl │ └── specs │ │ ├── DEFINITIONS.txt │ │ ├── DICTIONARY.txt │ │ ├── FERRTH.txt │ │ ├── PARSE_INPUT.txt │ │ ├── PROCESS_LOOP.txt │ │ └── TASKS │ └── forrth-f90 │ ├── .gitignore │ ├── BLOCK-1.forrth │ ├── Makefile │ ├── constants.f90 │ ├── core_words.f90 │ ├── forrth_entry_sr.f90 │ ├── forrth_sr.f90 │ ├── forrth_types.f90 │ ├── forrthtran.f90 │ ├── items.f90 │ ├── parse_input.f90 │ ├── process_input.f90 │ └── specs │ ├── DEFINITIONS.txt │ ├── FORRTHTRAN.txt │ ├── PARAM_STACK.txt │ ├── PARSE_INPUT.txt │ ├── PROCESS_INPUT.txt │ └── TASKS ├── forthic-in ├── README.md ├── docs │ ├── v1 │ │ └── README.md │ ├── v2 │ │ ├── cache_module.md │ │ ├── confluence_module.md │ │ ├── datasets_module.md │ │ ├── excel_module.md │ │ ├── gdoc_module.md │ │ ├── global_module.md │ │ ├── gsheet_module.md │ │ ├── html_module.md │ │ ├── isoweek_module.md │ │ ├── jinja_module.md │ │ ├── jira_module.md │ │ └── org_module.md │ └── v3 │ │ ├── cache_module.md │ │ ├── datasets_module.md │ │ ├── global_module.md │ │ ├── gsheet_module.md │ │ ├── intake_module.md │ │ ├── jinja_module.md │ │ ├── jira_module.md │ │ └── org_module.md ├── forthic │ ├── __init__.py │ ├── py.typed │ ├── tests │ │ ├── v1 │ │ │ └── README.md │ │ ├── v2 │ │ │ ├── __init__.py │ │ │ ├── modules │ │ │ │ ├── confluence_context.py │ │ │ │ ├── jira_context.py │ │ │ │ ├── test_confluence_module.py │ │ │ │ ├── test_gdoc_module.py │ │ │ │ ├── test_html_module.py │ │ │ │ ├── test_isoweek_module.py │ │ │ │ ├── test_jira_module.py │ │ │ │ └── test_org_module.py │ │ │ ├── sample_date_module.py │ │ │ ├── test_global_module.py │ │ │ ├── test_interpreter.py │ │ │ ├── test_tokenizer.py │ │ │ └── test_tokenizer_errors.py │ │ └── v3 │ │ │ ├── __init__.py │ │ │ ├── modules │ │ │ ├── datasets_data │ │ │ │ ├── .gitignore │ │ │ │ └── README.md │ │ │ ├── jira_context.py │ │ │ ├── test_v3_datasets_module.py │ │ │ ├── test_v3_isoweek_module.py │ │ │ ├── test_v3_jira_module.py │ │ │ ├── test_v3_org_module.py │ │ │ ├── test_v3_trino_module.py │ │ │ └── trino_context.py │ │ │ ├── sample_date_module.py │ │ │ ├── test_v3_global_module.py │ │ │ ├── test_v3_interpreter.py │ │ │ └── test_v3_tokenizer.py │ ├── utils │ │ ├── __init__.py │ │ ├── creds.py │ │ └── errors.py │ ├── v1 │ │ └── README.md │ ├── v2 │ │ ├── flambda.py │ │ ├── global_module.py │ │ ├── interfaces.py │ │ ├── interpreter.py │ │ ├── module.py │ │ ├── modules │ │ │ ├── __init__.py │ │ │ ├── airtable_module.py │ │ │ ├── alation_module.py │ │ │ ├── cache_module.py │ │ │ ├── confluence_module.py │ │ │ ├── datasets_module.py │ │ │ ├── excel_module.py │ │ │ ├── gdoc_module.py │ │ │ ├── gsheet_module.py │ │ │ ├── html_module.py │ │ │ ├── isoweek_module.py │ │ │ ├── jinja_module.py │ │ │ ├── jira_module.py │ │ │ ├── org_module.py │ │ │ └── wiki_status_module.py │ │ ├── profile.py │ │ ├── tokenizer.py │ │ └── tokens.py │ └── v3 │ │ ├── README.md │ │ ├── __init__.py │ │ ├── global_module.py │ │ ├── interfaces.py │ │ ├── interpreter.py │ │ ├── module.py │ │ ├── modules │ │ ├── __init__.py │ │ ├── airtable_module.py │ │ ├── alation_module.py │ │ ├── cache_module.py │ │ ├── confluence_module.py │ │ ├── datasets_module.py │ │ ├── excel_module.py │ │ ├── gdoc_module.py │ │ ├── gsheet_module.py │ │ ├── html_module.py │ │ ├── intake_module.py │ │ ├── isoweek_module.py │ │ ├── jinja_module.py │ │ ├── jira_module.py │ │ ├── org_module.py │ │ ├── stats_module.py │ │ ├── svg_module.py │ │ ├── trino_module.py │ │ ├── ui_module.py │ │ └── wiki_status_module.py │ │ ├── profile.py │ │ ├── tokenizer.py │ │ └── tokens.py ├── setup.py └── setup_helpers.py ├── forthic-js ├── Makefile ├── css │ └── forthic.css ├── global_module.mjs ├── interpreter.mjs ├── module.mjs ├── modules │ ├── html_module.mjs │ └── org_module.mjs ├── run-server.sh ├── test_browser_all.mjs ├── tests.html ├── tests │ ├── modules │ │ └── test_html_module.mjs │ ├── sample_date_module.mjs │ ├── test_all.mjs │ ├── test_global_module.mjs │ ├── test_interpreter.mjs │ ├── test_tokenizer.mjs │ ├── test_tokenizer_errors.mjs │ └── utils.mjs └── tokenizer.mjs ├── forthic-py ├── .gitignore ├── LICENSE ├── Makefile ├── README.md ├── __init__.py ├── docs │ ├── cache_module.md │ ├── datasets_module.md │ ├── global_module.md │ ├── gsheet_module.md │ ├── intake_module.md │ ├── isoweek_module.md │ ├── jinja_module.md │ ├── jira_module.md │ └── org_module.md ├── pyproject.toml ├── src │ ├── README.md │ ├── __init__.py │ └── forthic │ │ ├── __init__.py │ │ ├── global_module.py │ │ ├── interfaces.py │ │ ├── interpreter.py │ │ ├── module.py │ │ ├── modules │ │ ├── __init__.py │ │ ├── airtable_module.py │ │ ├── alation_module.py │ │ ├── cache_module.py │ │ ├── confluence_module.py │ │ ├── datasets_module.py │ │ ├── excel_module.py │ │ ├── gdoc_module.py │ │ ├── gsheet_module.py │ │ ├── html_module.py │ │ ├── intake_module.py │ │ ├── isoweek_module.py │ │ ├── jinja_module.py │ │ ├── jira_module.py │ │ ├── org_module.py │ │ ├── stats_module.py │ │ ├── svg_module.py │ │ ├── ui_module.py │ │ └── wiki_status_module.py │ │ ├── profile.py │ │ ├── tokenizer.py │ │ ├── tokens.py │ │ └── utils │ │ ├── __init__.py │ │ ├── creds.py │ │ └── errors.py ├── tests │ ├── __init__.py │ ├── modules │ │ ├── __init__.py │ │ ├── datasets_data │ │ │ ├── .gitignore │ │ │ └── README.md │ │ ├── jira_context.py │ │ ├── test_datasets_module.py │ │ ├── test_isoweek_module.py │ │ ├── test_jira_module.py │ │ └── test_org_module.py │ ├── sample_date_module.py │ ├── test_global_module.py │ ├── test_interpreter.py │ ├── test_tokenizer.py │ └── tests_py │ │ └── v3 │ │ └── modules │ │ └── datasets_data │ │ └── datasets │ │ └── greek.dataset └── tox.ini ├── forthic-rb ├── .gitignore ├── .standard.yml ├── CHANGELOG.md ├── Gemfile ├── Gemfile.lock ├── Guardfile ├── README.md ├── Rakefile ├── bin │ ├── console │ └── setup ├── forthic.gemspec ├── lib │ ├── forthic.rb │ └── forthic │ │ ├── code_location.rb │ │ ├── forthic_error.rb │ │ ├── forthic_module.rb │ │ ├── global_module.rb │ │ ├── interpreter.rb │ │ ├── positioned_string.rb │ │ ├── token.rb │ │ ├── tokenizer.rb │ │ ├── variable.rb │ │ ├── version.rb │ │ └── words │ │ ├── definition_word.rb │ │ ├── end_array_word.rb │ │ ├── end_module_word.rb │ │ ├── imported_word.rb │ │ ├── map_word.rb │ │ ├── module_memo_bang_at_word.rb │ │ ├── module_memo_bang_word.rb │ │ ├── module_memo_word.rb │ │ ├── module_word.rb │ │ ├── push_value_word.rb │ │ ├── start_module_word.rb │ │ └── word.rb ├── sig │ └── forthic.rbs └── test │ ├── test_forthic.rb │ ├── test_global_module.rb │ ├── test_helper.rb │ ├── test_interpreter.rb │ └── test_tokenizer.rb ├── forthic-react └── v1 │ ├── .gitignore │ ├── Makefile │ ├── README.md │ ├── docs │ ├── elements │ │ ├── ForthicPage.md │ │ ├── RecordsTable.md │ │ ├── TicketsModal.md │ │ └── UserNav.md │ └── modules │ │ ├── global_module.md │ │ └── recharts_module.md │ ├── package-lock.json │ ├── package.json │ ├── public │ ├── favicon.ico │ ├── index.html │ ├── logo192.png │ ├── logo512.png │ ├── manifest.json │ └── robots.txt │ ├── src │ ├── forthic │ │ ├── elements │ │ │ ├── ForthicButton.jsx │ │ │ ├── ForthicPage.js │ │ │ ├── RawHTML.js │ │ │ ├── RecordsTable.js │ │ │ ├── TicketsModal.js │ │ │ ├── UserNav.js │ │ │ └── form │ │ │ │ ├── Attachment.jsx │ │ │ │ ├── ConfigurableForm.jsx │ │ │ │ ├── DateInput.jsx │ │ │ │ ├── Dropdown.jsx │ │ │ │ ├── Html.jsx │ │ │ │ ├── Markdown.jsx │ │ │ │ ├── MultiCheckbox.jsx │ │ │ │ ├── RadioCheckbox.jsx │ │ │ │ ├── TextInput.jsx │ │ │ │ └── Textarea.jsx │ │ ├── global_module.js │ │ ├── global_module.test.js │ │ ├── interpreter.js │ │ ├── interpreter.test.js │ │ ├── module.js │ │ ├── modules │ │ │ ├── intake_module.js │ │ │ └── recharts_module.js │ │ ├── tokenizer.js │ │ ├── tokenizer.test.js │ │ └── utils.js │ ├── index.css │ ├── index.js │ └── setupTests.js │ └── update_template.py ├── forthic-ts ├── .gitignore ├── .prettierignore ├── .prettierrc ├── LICENSE ├── README.md ├── eslint.config.mjs ├── jest.config.js ├── package-lock.json ├── package.json ├── src │ ├── forthic │ │ ├── errors.ts │ │ ├── global_module.ts │ │ ├── global_module │ │ │ └── map_word.ts │ │ ├── interpreter.ts │ │ ├── module.ts │ │ ├── tests │ │ │ ├── error.test.ts │ │ │ ├── global_module.test.ts │ │ │ ├── interp_recovery.test.ts │ │ │ ├── interpreter.test.ts │ │ │ ├── interpreter_validation.test.ts │ │ │ ├── streamingRun.test.ts │ │ │ └── tokenizer.test.ts │ │ ├── tokenizer.ts │ │ └── utils.ts │ └── index.ts ├── tsconfig.cjs.json ├── tsconfig.esm.json └── tsconfig.json ├── make-delete-secrets.ps1 ├── make-install.ps1 ├── make-server.ps1 └── server ├── __init__.py ├── apps ├── README.md ├── archetypes │ └── jira-time-in-state │ │ ├── README.md │ │ ├── config.json │ │ └── main.forthic ├── coding-forthic │ ├── cache-example │ │ ├── config.json │ │ └── main.forthic │ ├── gsheet-example │ │ ├── config.json │ │ └── main.forthic │ ├── intake-branched │ │ ├── .cache │ │ ├── README.md │ │ ├── config.json │ │ ├── intake-branched - Branched.tsv │ │ ├── intake-branched - Continue.tsv │ │ ├── intake-branched - Self-service.tsv │ │ └── main.forthic │ ├── intake-multistep │ │ ├── .cache │ │ ├── README.md │ │ ├── config.json │ │ ├── intake-multistep - Multistep 2.tsv │ │ ├── intake-multistep - Multistep.tsv │ │ └── main.forthic │ ├── intake-simple │ │ ├── .cache │ │ ├── README.md │ │ ├── config.json │ │ ├── intake-simple - Simple.tsv │ │ └── main.forthic │ ├── jira-example │ │ ├── config.json │ │ └── main.forthic │ ├── simple │ │ ├── config.json │ │ └── main.forthic │ └── time-in-state │ │ ├── README.md │ │ ├── config.json │ │ ├── main.forthic │ │ ├── main.forthic.part1-final │ │ ├── main.forthic.part1-start │ │ ├── main.forthic.part2-final │ │ ├── main.forthic.part2-start │ │ └── main.forthic.start ├── talks │ ├── jira │ │ ├── config.json │ │ └── main.forthic │ ├── map │ │ ├── config.json │ │ └── main.forthic │ └── simple │ │ ├── config.json │ │ └── main.forthic └── tests │ ├── forthic-react-smoke-test │ ├── config.json │ └── main.forthic │ ├── gsheet-smoke-test │ ├── config.json │ └── main.forthic │ ├── screen-smoke-test │ ├── config.json │ ├── main.forthic │ └── screens │ │ └── screen1.forthic │ ├── server-interpret-test │ ├── config.json │ └── main.forthic │ └── smoke-test │ ├── config.json │ └── main.forthic ├── contexts_module.py ├── interp.py ├── oauth_cfg.json ├── run.py ├── simple_module.py ├── static ├── js │ ├── babel.min.js │ ├── prop-types.min.js │ ├── react-dom.production.min.js │ └── react.production.min.js └── react │ └── react-app │ └── v1 │ ├── main.29ad0b1c.js │ ├── main.29ad0b1c.js.LICENSE.txt │ ├── main.29ad0b1c.js.map │ ├── main.add8d827.css │ └── manifest.json └── templates ├── basic.html ├── example.html ├── home.html ├── main.html ├── react └── react-app │ └── v1 │ └── main.html ├── talks.html ├── update_app_creds_form.html └── update_password_form.html /.gitignore: -------------------------------------------------------------------------------- 1 | forthic-env 2 | myenv 3 | *.swp 4 | TODO 5 | *.pyc 6 | .secrets* 7 | .key* 8 | one-ofs 9 | *.cache 10 | apps/examples/static/forthic/* 11 | *.DS_Store 12 | *.ignore 13 | .vscode 14 | .coverage 15 | forthic.egg-info 16 | build 17 | .tox 18 | tmp -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | SHELL := /bin/bash 2 | TOX_INI = -c ./forthic-py/tox.ini 3 | 4 | .PHONY: install-forthic test credentials-server 5 | 6 | # ----- Example server -------------------------------------------------------- 7 | example-server: install-forthic 8 | source myenv/bin/activate && cd server && FLASK_APP=run.py FLASK_DEBUG=true flask run --port=8000 9 | 10 | myenv: 11 | python3 -m venv myenv 12 | 13 | install-forthic: myenv 14 | source myenv/bin/activate && python -m pip install -U pip && cd ./forthic-py && pip install . && pip install Flask 15 | 16 | delete-secrets: 17 | rm server/.key 18 | rm server/.secrets 19 | 20 | credentials-server: 21 | FLASK_APP=apps/setup/run.py flask run --port=8000 22 | 23 | build-forthic-react: 24 | cd forthic-react/v1 && make build 25 | 26 | 27 | # ----- Tests ------------------------------------------------------------------ 28 | 29 | test-py: 30 | cd forthic-py && make test 31 | 32 | test-js: 33 | cd forthic-js && make test 34 | 35 | test-react: 36 | cd forthic-react/v1 && make test 37 | 38 | test: test-py test-react 39 | 40 | 41 | test-rs: 42 | cd experimental/forthic-rs && make test 43 | 44 | test-zig: 45 | cd experimental/forthic-zig && make test 46 | 47 | test-experimental: test-rs test-zig 48 | -------------------------------------------------------------------------------- /NOTES: -------------------------------------------------------------------------------- 1 | # NOTES 2 | 3 | This shows how to build and install a python module without publishing: https://towardsdatascience.com/building-a-python-package-without-publishing-e2d36c4686cd 4 | 5 | To create and use a virtual python environment: 6 | * python3 -m venv myenv 7 | * .\myenv\Scripts\activate 8 | 9 | To install locally, use `pip install .` -------------------------------------------------------------------------------- /NOTICE: -------------------------------------------------------------------------------- 1 | Copyright 2020 LinkedIn Corporation 2 | All Rights Reserved. 3 | 4 | Licensed under the BSD 2-Clause License (the "License"). 5 | See LICENSE in the project root for license information. 6 | 7 | 8 | This product includes: 9 | 10 | * N/A 11 | -------------------------------------------------------------------------------- /docs/app-architecture.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linkedin/forthic/dd84e4145e2a89df83026313d22e8885835502ab/docs/app-architecture.png -------------------------------------------------------------------------------- /docs/code-architecture.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linkedin/forthic/dd84e4145e2a89df83026313d22e8885835502ab/docs/code-architecture.png -------------------------------------------------------------------------------- /docs/index.md: -------------------------------------------------------------------------------- 1 | # Forthic 2 | 3 | Forthic is a language for concisely creating user-tweakable apps. 4 | 5 | ## Contents 6 | ```{toctree} 7 | --- 8 | maxdepth: 3 9 | --- 10 | 11 | OVERVIEW 12 | EXAMPLES 13 | ARCHITECTURE 14 | IDIOMS 15 | PHILOSOPHY 16 | THREAT_MODEL 17 | ``` 18 | 19 | ## Module Reference 20 | ```{toctree} 21 | --- 22 | maxdepth: 3 23 | --- 24 | 25 | modules/global_module 26 | modules/cache_module 27 | modules/confluence_module 28 | modules/datasets_module 29 | modules/excel_module 30 | modules/gsheet_module 31 | modules/html_module 32 | modules/jinja_module 33 | modules/jira_module 34 | modules/org_module 35 | ``` 36 | 37 | -------------------------------------------------------------------------------- /docs/modules/cache_module.md: -------------------------------------------------------------------------------- 1 | # cache_module 2 | 3 | The cache module allows you to store the top of the stack on disk as JSON (the 4 | stored object must be JSON serializable) and retrieve it later. This is useful 5 | for storing expensive computations or API responses. 6 | 7 | The data is stored in a `.cache` file in the working directory. The directory 8 | can be set using the `CWD!` word. 9 | 10 | Every object is stored and retrieved using a label. 11 | 12 | ## Example 13 | ``` 14 | ["cache"] USE-MODULES 15 | 16 | "~/my_stuff" cache.CWD! # Sets the current working directory 17 | [1 2 3 "Howdy"] "my_array" cache.CACHE! # Stores the array in the cache 18 | 19 | "my_array" cache.CACHE@ # Retrieves the array from cache 20 | 3 NTH # ([1 2 3 "Howdy"] -- "Howdy") 21 | ``` 22 | 23 | ## Reference 24 | 25 | ### CACHE! 26 | `(object key --)` 27 | 28 | Stores `object` in the cache at the specified `key`. The object will be 29 | serialized to JSON. 30 | 31 | 32 | ### CACHE@ 33 | `(key -- object)` 34 | 35 | Retrieves an object from the cache at the specified `key`. The object will be 36 | deserialized from JSON. -------------------------------------------------------------------------------- /docs/modules/jinja_module.md: -------------------------------------------------------------------------------- 1 | # jinja_module 2 | 3 | The jinja module uses the Python [jinja templating 4 | package](https://jinja.palletsprojects.com/en/2.11.x/) to render arbitrary 5 | strings using record data. 6 | 7 | Typically, this is the best choice for rendering html, emails, or anything that 8 | involves looping along with interpolation. 9 | 10 | ## Example 11 | ``` 12 | ["jinja"] USE-MODULES 13 | 14 | : MY-DATA [ 15 | ["letters" ["alpha" "beta" "gamma"]] 16 | ] REC; 17 | 18 | : MY-TEMPLATE " 19 | 24 | "; 25 | 26 | MY-TEMPLATE MY-DATA jira.RENDER 27 | ``` 28 | 29 | ## Reference 30 | 31 | ### RENDER 32 | `(template record -- string)` 33 | Given a jinja template and a Forthic record, renders a string using the jinja engine. 34 | 35 | NOTE: The record must have fields that are valid Python variable names since 36 | these are used within the jinja template. -------------------------------------------------------------------------------- /experimental/forthic-cpp/.gitignore: -------------------------------------------------------------------------------- 1 | .vs/ 2 | *.swp 3 | */bin/ 4 | */obj/ 5 | obj 6 | bin 7 | packages/ 8 | Debug/ 9 | App2/ 10 | Direct3D/ 11 | Generated\ Files 12 | -------------------------------------------------------------------------------- /experimental/forthic-cpp/ForthicLib/Defines.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define FORTHICLIB_API __declspec(dllexport) 4 | -------------------------------------------------------------------------------- /experimental/forthic-cpp/ForthicLib/ForthicLib.cpp: -------------------------------------------------------------------------------- 1 | #include "pch.h" 2 | #include "ForthicLib.h" 3 | -------------------------------------------------------------------------------- /experimental/forthic-cpp/ForthicLib/ForthicLib.h: -------------------------------------------------------------------------------- 1 | #pragma once -------------------------------------------------------------------------------- /experimental/forthic-cpp/ForthicLib/Modules/GlobalItemGetters.cpp: -------------------------------------------------------------------------------- 1 | #include "pch.h" 2 | #include "GlobalItemGetters.h" 3 | 4 | string FORTHICLIB_API ForthicGetString(StackItem *item) 5 | { 6 | if (auto i = dynamic_cast(item)) 7 | { 8 | return i->GetString(); 9 | } 10 | else 11 | { 12 | throw "Item does not implement IGetString"; 13 | } 14 | } 15 | 16 | vector> FORTHICLIB_API ForthicGetArray(StackItem *item) 17 | { 18 | if (auto i = dynamic_cast(item)) 19 | { 20 | return i->GetArray(); 21 | } 22 | else 23 | { 24 | throw "Item does not implement IGetArray"; 25 | } 26 | } 27 | 28 | shared_ptr FORTHICLIB_API ForthicGetValue(StackItem *item) 29 | { 30 | if (auto i = dynamic_cast(item)) 31 | { 32 | return i->GetValue(); 33 | } 34 | else 35 | { 36 | throw "Item does not implement IGetVariable"; 37 | } 38 | } 39 | 40 | shared_ptr FORTHICLIB_API ForthicGetModule(StackItem *item) 41 | { 42 | if (auto i = dynamic_cast(item)) 43 | { 44 | return i->GetModule(); 45 | } 46 | else 47 | { 48 | throw "Item does not implement IGetModule"; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /experimental/forthic-cpp/ForthicLib/Modules/GlobalItemGetters.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | 5 | #include "../Defines.h" 6 | #include "../StackItems/StackItem.h" 7 | 8 | class Module; 9 | 10 | using namespace std; 11 | 12 | class FORTHICLIB_API IGetString { 13 | public: 14 | virtual string GetString() = 0; 15 | }; 16 | 17 | class FORTHICLIB_API IGetArray { 18 | public: 19 | virtual vector> GetArray() = 0; 20 | }; 21 | 22 | class FORTHICLIB_API IGetValue { 23 | public: 24 | virtual shared_ptr GetValue() = 0; 25 | }; 26 | 27 | class FORTHICLIB_API IGetModule { 28 | public: 29 | virtual shared_ptr GetModule() = 0; 30 | }; 31 | 32 | string FORTHICLIB_API ForthicGetString(StackItem *item); 33 | vector> FORTHICLIB_API ForthicGetArray(StackItem *item); 34 | shared_ptr FORTHICLIB_API ForthicGetValue(StackItem *item); 35 | shared_ptr FORTHICLIB_API ForthicGetModule(StackItem *item); 36 | -------------------------------------------------------------------------------- /experimental/forthic-cpp/ForthicLib/Modules/GlobalModule.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #include "../Defines.h" 9 | #include "../Modules/Module.h" 10 | 11 | using namespace std; 12 | 13 | 14 | class FORTHICLIB_API GlobalModule : public Module 15 | { 16 | public: 17 | GlobalModule(); 18 | virtual ~GlobalModule(); 19 | 20 | protected: 21 | virtual shared_ptr treat_as_literal(string name); 22 | 23 | shared_ptr treat_as_float(string name); 24 | shared_ptr treat_as_int(string name); 25 | }; 26 | 27 | class FORTHICLIB_API IGetInt { 28 | public: 29 | virtual int GetInt() = 0; 30 | }; 31 | 32 | class FORTHICLIB_API IGetFloat { 33 | public: 34 | virtual float GetFloat() = 0; 35 | }; 36 | 37 | int FORTHICLIB_API ForthicGetInt(StackItem *item); 38 | float FORTHICLIB_API ForthicGetFloat(StackItem *item); 39 | -------------------------------------------------------------------------------- /experimental/forthic-cpp/ForthicLib/Modules/GlobalModuleWords.cpp: -------------------------------------------------------------------------------- 1 | #include "pch.h" 2 | #include "GlobalModuleWords.h" 3 | #include "GlobalItemGetters.h" 4 | #include "Interpreter.h" 5 | 6 | PopWord::PopWord(string name) : Word(name) 7 | { 8 | } 9 | 10 | 11 | void PopWord::Execute(Interpreter *interp) 12 | { 13 | interp->StackPop(); 14 | } 15 | 16 | 17 | UseModulesWord::UseModulesWord(string name) : Word(name) 18 | { 19 | } 20 | 21 | // ( modules -- ) 22 | void UseModulesWord::Execute(Interpreter *interp) 23 | { 24 | auto item = interp->StackPop(); 25 | vector> modules = ForthicGetArray(item.get()); 26 | for (int i = 0; i < modules.size(); i++) { 27 | shared_ptr m = ForthicGetModule(modules[i].get()); 28 | interp->CurModule()->UseModule(m); 29 | } 30 | } 31 | 32 | -------------------------------------------------------------------------------- /experimental/forthic-cpp/ForthicLib/Modules/GlobalModuleWords.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #include "../Defines.h" 9 | #include "Words/Word.h" 10 | 11 | class Interpreter; 12 | 13 | using namespace std; 14 | 15 | // ( a -- ) 16 | // Pops word from stack 17 | class PopWord : public Word 18 | { 19 | public: 20 | PopWord(string name); 21 | virtual void Execute(Interpreter *interp); 22 | }; 23 | 24 | 25 | // ( modules -- ) 26 | // Adds modules to current module's using module list 27 | class UseModulesWord : public Word 28 | { 29 | public: 30 | UseModulesWord(string name); 31 | virtual void Execute(Interpreter *interp); 32 | }; 33 | -------------------------------------------------------------------------------- /experimental/forthic-cpp/ForthicLib/Modules/Module.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #include "../Defines.h" 9 | #include "../Modules/GlobalItemGetters.h" 10 | #include "../ForthicLib/Words/Word.h" 11 | #include "../ForthicLib/StackItems/VariableItem.h" 12 | 13 | using namespace std; 14 | 15 | class FORTHICLIB_API Module 16 | { 17 | public: 18 | Module(string name); 19 | virtual ~Module(); 20 | 21 | virtual string ForthicCode(); 22 | 23 | string GetName(); 24 | void AddWord(shared_ptr word); 25 | void AddWord(Word* word); 26 | void EnsureVariable(string name); 27 | void UseModule(shared_ptr mod); 28 | 29 | shared_ptr FindWord(string name); 30 | 31 | protected: 32 | string name; 33 | vector> words; 34 | map> variables; 35 | vector> using_modules; 36 | 37 | shared_ptr find_in_words(string name); 38 | shared_ptr find_variable(string name); 39 | shared_ptr find_in_using_modules(string name); 40 | virtual shared_ptr treat_as_literal(string name); 41 | }; 42 | 43 | -------------------------------------------------------------------------------- /experimental/forthic-cpp/ForthicLib/StackItems/ArrayItem.cpp: -------------------------------------------------------------------------------- 1 | #include "pch.h" 2 | #include "ArrayItem.h" 3 | 4 | 5 | ArrayItem::ArrayItem(vector>_items) : items(_items) 6 | { 7 | } 8 | 9 | 10 | ArrayItem::~ArrayItem() 11 | { 12 | } 13 | 14 | vector> ArrayItem::GetArray() 15 | { 16 | return items; 17 | } -------------------------------------------------------------------------------- /experimental/forthic-cpp/ForthicLib/StackItems/ArrayItem.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | 5 | #include "../Defines.h" 6 | #include "../Modules/GlobalItemGetters.h" 7 | #include "StackItem.h" 8 | 9 | using namespace std; 10 | 11 | 12 | class FORTHICLIB_API ArrayItem : public StackItem, public IGetArray 13 | { 14 | public: 15 | ArrayItem(vector> items); 16 | virtual ~ArrayItem(); 17 | vector> GetArray(); 18 | 19 | protected: 20 | vector> items; 21 | }; -------------------------------------------------------------------------------- /experimental/forthic-cpp/ForthicLib/StackItems/FloatItem.cpp: -------------------------------------------------------------------------------- 1 | #include "pch.h" 2 | #include "FloatItem.h" 3 | 4 | 5 | FloatItem::FloatItem(float _value) : value(_value) 6 | { 7 | } 8 | 9 | 10 | FloatItem::~FloatItem() 11 | { 12 | } 13 | 14 | float FloatItem::GetFloat() 15 | { 16 | return value; 17 | } 18 | -------------------------------------------------------------------------------- /experimental/forthic-cpp/ForthicLib/StackItems/FloatItem.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | #include "../Defines.h" 5 | #include "../Modules/GlobalModule.h" 6 | #include "StackItem.h" 7 | 8 | using namespace std; 9 | 10 | 11 | class FORTHICLIB_API FloatItem : public StackItem, public IGetFloat 12 | { 13 | public: 14 | FloatItem(float value); 15 | virtual ~FloatItem(); 16 | float GetFloat(); 17 | 18 | protected: 19 | float value; 20 | }; 21 | -------------------------------------------------------------------------------- /experimental/forthic-cpp/ForthicLib/StackItems/IntItem.cpp: -------------------------------------------------------------------------------- 1 | #include "pch.h" 2 | #include "IntItem.h" 3 | 4 | 5 | IntItem::IntItem(int _value) : value(_value) 6 | { 7 | } 8 | 9 | 10 | IntItem::~IntItem() 11 | { 12 | } 13 | 14 | int IntItem::GetInt() 15 | { 16 | return value; 17 | } 18 | -------------------------------------------------------------------------------- /experimental/forthic-cpp/ForthicLib/StackItems/IntItem.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | #include "../Defines.h" 5 | #include "../Modules/GlobalModule.h" 6 | #include "StackItem.h" 7 | 8 | using namespace std; 9 | 10 | 11 | class FORTHICLIB_API IntItem : public StackItem, public IGetInt 12 | { 13 | public: 14 | IntItem(int value); 15 | virtual ~IntItem(); 16 | int GetInt(); 17 | 18 | protected: 19 | int value; 20 | }; 21 | -------------------------------------------------------------------------------- /experimental/forthic-cpp/ForthicLib/StackItems/ModuleItem.cpp: -------------------------------------------------------------------------------- 1 | #include "pch.h" 2 | #include "ModuleItem.h" 3 | 4 | 5 | 6 | ModuleItem::ModuleItem(Module* _mod) : mod(shared_ptr(_mod)) 7 | { 8 | } 9 | 10 | 11 | ModuleItem::ModuleItem(shared_ptr _mod) : mod(_mod) 12 | { 13 | } 14 | 15 | 16 | ModuleItem::~ModuleItem() 17 | { 18 | } 19 | 20 | shared_ptr ModuleItem::GetModule() 21 | { 22 | return mod; 23 | } 24 | -------------------------------------------------------------------------------- /experimental/forthic-cpp/ForthicLib/StackItems/ModuleItem.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | #include "../Defines.h" 5 | #include "../Modules/GlobalItemGetters.h" 6 | #include "StackItem.h" 7 | #include "../Modules/Module.h" 8 | 9 | using namespace std; 10 | 11 | 12 | class FORTHICLIB_API ModuleItem : public StackItem, public IGetModule 13 | { 14 | public: 15 | ModuleItem(Module* mod); 16 | ModuleItem(shared_ptr mod); 17 | virtual ~ModuleItem(); 18 | shared_ptr GetModule(); 19 | 20 | protected: 21 | shared_ptr mod; 22 | }; 23 | -------------------------------------------------------------------------------- /experimental/forthic-cpp/ForthicLib/StackItems/StackItem.cpp: -------------------------------------------------------------------------------- 1 | #include "pch.h" 2 | #include "StackItem.h" 3 | 4 | 5 | StackItem::StackItem() 6 | { 7 | } 8 | 9 | 10 | StackItem::~StackItem() 11 | { 12 | } 13 | -------------------------------------------------------------------------------- /experimental/forthic-cpp/ForthicLib/StackItems/StackItem.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "../Defines.h" 3 | 4 | class FORTHICLIB_API StackItem 5 | { 6 | public: 7 | StackItem(); 8 | virtual ~StackItem(); 9 | }; 10 | 11 | -------------------------------------------------------------------------------- /experimental/forthic-cpp/ForthicLib/StackItems/StartArrayItem.cpp: -------------------------------------------------------------------------------- 1 | #include "pch.h" 2 | #include "StartArrayItem.h" 3 | 4 | StartArrayItem::StartArrayItem() 5 | { 6 | } 7 | 8 | 9 | StartArrayItem::~StartArrayItem() 10 | { 11 | } 12 | -------------------------------------------------------------------------------- /experimental/forthic-cpp/ForthicLib/StackItems/StartArrayItem.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "../Defines.h" 3 | #include "StackItem.h" 4 | 5 | using namespace std; 6 | 7 | class FORTHICLIB_API StartArrayItem : public StackItem 8 | { 9 | public: 10 | StartArrayItem(); 11 | virtual ~StartArrayItem(); 12 | }; 13 | -------------------------------------------------------------------------------- /experimental/forthic-cpp/ForthicLib/StackItems/StringItem.cpp: -------------------------------------------------------------------------------- 1 | #include "pch.h" 2 | #include "StringItem.h" 3 | 4 | 5 | StringItem::StringItem(string s) : item_string(s) 6 | { 7 | } 8 | 9 | 10 | StringItem::~StringItem() 11 | { 12 | } 13 | 14 | string StringItem::GetString() 15 | { 16 | return item_string; 17 | } -------------------------------------------------------------------------------- /experimental/forthic-cpp/ForthicLib/StackItems/StringItem.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | #include "../Defines.h" 5 | #include "../Modules/GlobalItemGetters.h" 6 | #include "StackItem.h" 7 | 8 | using namespace std; 9 | 10 | 11 | class FORTHICLIB_API StringItem : public StackItem, public IGetString 12 | { 13 | public: 14 | StringItem(string s); 15 | virtual ~StringItem(); 16 | string GetString(); 17 | 18 | protected: 19 | string item_string; 20 | }; -------------------------------------------------------------------------------- /experimental/forthic-cpp/ForthicLib/StackItems/VariableItem.cpp: -------------------------------------------------------------------------------- 1 | #include "pch.h" 2 | #include "VariableItem.h" 3 | 4 | VariableItem::VariableItem() : value(nullptr) 5 | { 6 | } 7 | 8 | VariableItem::~VariableItem() 9 | { 10 | } 11 | 12 | shared_ptr VariableItem::GetValue() 13 | { 14 | return value; 15 | } 16 | 17 | void VariableItem::SetValue(shared_ptr new_value) 18 | { 19 | value = new_value; 20 | } 21 | -------------------------------------------------------------------------------- /experimental/forthic-cpp/ForthicLib/StackItems/VariableItem.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "../Defines.h" 3 | #include "../Modules/GlobalItemGetters.h" 4 | #include "StackItem.h" 5 | 6 | using namespace std; 7 | 8 | class FORTHICLIB_API VariableItem : public StackItem, public IGetValue 9 | { 10 | public: 11 | VariableItem(); 12 | virtual ~VariableItem(); 13 | 14 | virtual shared_ptr GetValue(); 15 | void SetValue(shared_ptr new_value); 16 | 17 | protected: 18 | shared_ptr value; 19 | }; 20 | -------------------------------------------------------------------------------- /experimental/forthic-cpp/ForthicLib/Token.cpp: -------------------------------------------------------------------------------- 1 | #include "pch.h" 2 | #include "Token.h" 3 | 4 | 5 | Token::Token(enum class TokenType t, string& s) 6 | { 7 | type = t; 8 | text = s; 9 | } 10 | 11 | Token::Token(enum class TokenType t) 12 | { 13 | type = t; 14 | text = ""; 15 | } 16 | 17 | Token::~Token() 18 | { 19 | } 20 | 21 | 22 | enum class TokenType Token::GetType() 23 | { 24 | return type; 25 | } 26 | 27 | string Token::GetText() 28 | { 29 | return text; 30 | } 31 | -------------------------------------------------------------------------------- /experimental/forthic-cpp/ForthicLib/Token.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | using namespace std; 5 | 6 | #define FORTHICLIB_API __declspec(dllexport) 7 | 8 | enum class TokenType { 9 | COMMENT, 10 | START_DEFINITION, 11 | END_DEFINITION, 12 | START_ARRAY, 13 | END_ARRAY, 14 | START_MODULE, 15 | END_MODULE, 16 | STRING, 17 | WORD, 18 | EOS }; 19 | 20 | class FORTHICLIB_API Token 21 | { 22 | public: 23 | Token(enum class TokenType t, string& s); 24 | Token(enum class TokenType t); 25 | ~Token(); 26 | 27 | enum class TokenType GetType(); 28 | string GetText(); 29 | 30 | protected: 31 | enum class TokenType type; 32 | string text; 33 | }; 34 | 35 | -------------------------------------------------------------------------------- /experimental/forthic-cpp/ForthicLib/Tokenizer.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include "Token.h" 5 | #include "Defines.h" 6 | 7 | using namespace std; 8 | 9 | class FORTHICLIB_API Tokenizer 10 | { 11 | public: 12 | Tokenizer(string& s); 13 | ~Tokenizer(); 14 | Token NextToken(); 15 | bool IsTripleQuote(int index, char c); 16 | 17 | protected: 18 | bool is_whitespace(char c); 19 | bool is_quote(char c); 20 | 21 | // Transition functions 22 | Token transition_from_START(); 23 | Token transition_from_COMMENT(); 24 | Token transition_from_START_DEFINITION(); 25 | Token transition_from_GATHER_DEFINITION_NAME(); 26 | Token transition_from_GATHER_MODULE(); 27 | Token transition_from_GATHER_TRIPLE_QUOTE_STRING(char delim); 28 | Token transition_from_GATHER_STRING(char delim); 29 | Token transition_from_GATHER_WORD(char first_char); 30 | 31 | 32 | unsigned int position; 33 | string input; 34 | string whitespace; 35 | string token_string; 36 | }; 37 | 38 | -------------------------------------------------------------------------------- /experimental/forthic-cpp/ForthicLib/Words/DefinitionWord.cpp: -------------------------------------------------------------------------------- 1 | #include "pch.h" 2 | #include "DefinitionWord.h" 3 | #include "../Interpreter.h" 4 | 5 | 6 | DefinitionWord::DefinitionWord(string word_name) : Word(word_name) 7 | { 8 | } 9 | 10 | DefinitionWord::~DefinitionWord() 11 | { 12 | } 13 | 14 | void DefinitionWord::CompileWord(shared_ptr word) 15 | { 16 | words.push_back(word); 17 | } 18 | 19 | void DefinitionWord::Execute(Interpreter *interp) 20 | { 21 | for (auto iter = words.begin(); iter != words.end(); iter++) 22 | { 23 | (*iter)->Execute(interp); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /experimental/forthic-cpp/ForthicLib/Words/DefinitionWord.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include "../Defines.h" 5 | #include "../StackItems/StackItem.h" 6 | #include "Word.h" 7 | 8 | using namespace std; 9 | 10 | class Interpreter; 11 | 12 | class FORTHICLIB_API DefinitionWord : public Word 13 | { 14 | public: 15 | DefinitionWord(string name); 16 | virtual ~DefinitionWord(); 17 | virtual void Execute(Interpreter *interp); 18 | 19 | void CompileWord(shared_ptr word); 20 | 21 | protected: 22 | vector> words; 23 | }; 24 | 25 | -------------------------------------------------------------------------------- /experimental/forthic-cpp/ForthicLib/Words/EndArrayWord.cpp: -------------------------------------------------------------------------------- 1 | #include "pch.h" 2 | #include 3 | #include "EndArrayWord.h" 4 | #include "../Interpreter.h" 5 | #include "../StackItems/ArrayItem.h" 6 | #include "../StackItems/StartArrayItem.h" 7 | 8 | 9 | EndArrayWord::EndArrayWord(string word_name) : Word(word_name) 10 | { 11 | } 12 | 13 | 14 | EndArrayWord::~EndArrayWord() 15 | { 16 | } 17 | 18 | void EndArrayWord::Execute(Interpreter *interp) 19 | { 20 | vector> result; 21 | 22 | while (true) 23 | { 24 | auto item = interp->StackPop(); 25 | if (dynamic_cast(item.get())) break; 26 | else result.push_back(item); 27 | } 28 | 29 | std::reverse(result.begin(), result.end()); 30 | interp->StackPush(shared_ptr(new ArrayItem(result))); 31 | } 32 | -------------------------------------------------------------------------------- /experimental/forthic-cpp/ForthicLib/Words/EndArrayWord.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include "../Defines.h" 4 | #include "../StackItems/StackItem.h" 5 | #include "Word.h" 6 | 7 | using namespace std; 8 | 9 | class Interpreter; 10 | 11 | class FORTHICLIB_API EndArrayWord : public Word 12 | { 13 | public: 14 | EndArrayWord(string name); 15 | virtual ~EndArrayWord(); 16 | virtual void Execute(Interpreter *interp); 17 | }; 18 | 19 | -------------------------------------------------------------------------------- /experimental/forthic-cpp/ForthicLib/Words/PushItemWord.cpp: -------------------------------------------------------------------------------- 1 | #include "pch.h" 2 | #include "PushItemWord.h" 3 | #include "../Interpreter.h" 4 | 5 | 6 | PushItemWord::PushItemWord(string word_name, shared_ptr i) : Word(word_name), item(i) 7 | { 8 | } 9 | 10 | PushItemWord::PushItemWord(string name, StackItem* item) : PushItemWord(name, shared_ptr(item)) 11 | { 12 | } 13 | 14 | PushItemWord::~PushItemWord() 15 | { 16 | // The item shouldn't be deleted here. Whover pops it from the stack should delete it. 17 | } 18 | 19 | void PushItemWord::Execute(Interpreter *interp) 20 | { 21 | interp->StackPush(item); 22 | } 23 | -------------------------------------------------------------------------------- /experimental/forthic-cpp/ForthicLib/Words/PushItemWord.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include "../Defines.h" 4 | #include "../StackItems/StackItem.h" 5 | #include "Word.h" 6 | 7 | using namespace std; 8 | 9 | class Interpreter; 10 | 11 | class FORTHICLIB_API PushItemWord : public Word 12 | { 13 | public: 14 | PushItemWord(string name, shared_ptr item); 15 | PushItemWord(string name, StackItem* item); 16 | virtual ~PushItemWord(); 17 | virtual void Execute(Interpreter *interp); 18 | 19 | protected: 20 | shared_ptr item; 21 | }; 22 | 23 | -------------------------------------------------------------------------------- /experimental/forthic-cpp/ForthicLib/Words/Word.cpp: -------------------------------------------------------------------------------- 1 | #include "pch.h" 2 | 3 | #include "Word.h" 4 | 5 | 6 | Word::Word(string word_name) : name(word_name) 7 | { 8 | } 9 | 10 | 11 | Word::~Word() 12 | { 13 | } 14 | 15 | string Word::GetName() 16 | { 17 | return name; 18 | } -------------------------------------------------------------------------------- /experimental/forthic-cpp/ForthicLib/Words/Word.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include "../Defines.h" 4 | 5 | using namespace std; 6 | 7 | class Interpreter; 8 | 9 | class FORTHICLIB_API Word 10 | { 11 | public: 12 | Word(string name); 13 | virtual ~Word(); 14 | virtual void Execute(Interpreter *interp) = 0; 15 | 16 | string GetName(); 17 | protected: 18 | string name; 19 | }; 20 | 21 | -------------------------------------------------------------------------------- /experimental/forthic-cpp/ForthicLib/dllmain.cpp: -------------------------------------------------------------------------------- 1 | #include "pch.h" 2 | 3 | BOOL APIENTRY DllMain(HMODULE /* hModule */, DWORD ul_reason_for_call, LPVOID /* lpReserved */) 4 | { 5 | switch (ul_reason_for_call) 6 | { 7 | case DLL_PROCESS_ATTACH: 8 | case DLL_THREAD_ATTACH: 9 | case DLL_THREAD_DETACH: 10 | case DLL_PROCESS_DETACH: 11 | break; 12 | } 13 | return TRUE; 14 | } 15 | -------------------------------------------------------------------------------- /experimental/forthic-cpp/ForthicLib/pch.cpp: -------------------------------------------------------------------------------- 1 | #include "pch.h" 2 | -------------------------------------------------------------------------------- /experimental/forthic-cpp/ForthicLib/pch.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "targetver.h" 4 | 5 | #ifndef WIN32_LEAN_AND_MEAN 6 | #define WIN32_LEAN_AND_MEAN 7 | #endif 8 | 9 | #include 10 | -------------------------------------------------------------------------------- /experimental/forthic-cpp/ForthicLib/targetver.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // Including SDKDDKVer.h defines the highest available Windows platform. 4 | 5 | // If you wish to build your application for a previous Windows platform, include WinSDKVer.h and 6 | // set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h. 7 | 8 | #include 9 | -------------------------------------------------------------------------------- /experimental/forthic-cpp/ForthicLibTests/Assets/LockScreenLogo.scale-200.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linkedin/forthic/dd84e4145e2a89df83026313d22e8885835502ab/experimental/forthic-cpp/ForthicLibTests/Assets/LockScreenLogo.scale-200.png -------------------------------------------------------------------------------- /experimental/forthic-cpp/ForthicLibTests/Assets/SplashScreen.scale-200.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linkedin/forthic/dd84e4145e2a89df83026313d22e8885835502ab/experimental/forthic-cpp/ForthicLibTests/Assets/SplashScreen.scale-200.png -------------------------------------------------------------------------------- /experimental/forthic-cpp/ForthicLibTests/Assets/Square150x150Logo.scale-200.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linkedin/forthic/dd84e4145e2a89df83026313d22e8885835502ab/experimental/forthic-cpp/ForthicLibTests/Assets/Square150x150Logo.scale-200.png -------------------------------------------------------------------------------- /experimental/forthic-cpp/ForthicLibTests/Assets/Square44x44Logo.scale-200.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linkedin/forthic/dd84e4145e2a89df83026313d22e8885835502ab/experimental/forthic-cpp/ForthicLibTests/Assets/Square44x44Logo.scale-200.png -------------------------------------------------------------------------------- /experimental/forthic-cpp/ForthicLibTests/Assets/Square44x44Logo.targetsize-24_altform-unplated.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linkedin/forthic/dd84e4145e2a89df83026313d22e8885835502ab/experimental/forthic-cpp/ForthicLibTests/Assets/Square44x44Logo.targetsize-24_altform-unplated.png -------------------------------------------------------------------------------- /experimental/forthic-cpp/ForthicLibTests/Assets/StoreLogo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linkedin/forthic/dd84e4145e2a89df83026313d22e8885835502ab/experimental/forthic-cpp/ForthicLibTests/Assets/StoreLogo.png -------------------------------------------------------------------------------- /experimental/forthic-cpp/ForthicLibTests/Assets/Wide310x150Logo.scale-200.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linkedin/forthic/dd84e4145e2a89df83026313d22e8885835502ab/experimental/forthic-cpp/ForthicLibTests/Assets/Wide310x150Logo.scale-200.png -------------------------------------------------------------------------------- /experimental/forthic-cpp/ForthicLibTests/ForthicLibTests.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /experimental/forthic-cpp/ForthicLibTests/ForthicLibTests_TemporaryKey.pfx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linkedin/forthic/dd84e4145e2a89df83026313d22e8885835502ab/experimental/forthic-cpp/ForthicLibTests/ForthicLibTests_TemporaryKey.pfx -------------------------------------------------------------------------------- /experimental/forthic-cpp/ForthicLibTests/UnitTestApp.xaml: -------------------------------------------------------------------------------- 1 |  6 | 7 | 8 | -------------------------------------------------------------------------------- /experimental/forthic-cpp/ForthicLibTests/UnitTestApp.xaml.h: -------------------------------------------------------------------------------- 1 | // 2 | // App.xaml.h 3 | // Declaration of the App class. 4 | // 5 | 6 | #pragma once 7 | 8 | #include "UnitTestApp.g.h" 9 | 10 | namespace ForthicLibTests 11 | { 12 | /// 13 | /// Provides application-specific behavior to supplement the default Application class. 14 | /// 15 | ref class App sealed 16 | { 17 | protected: 18 | virtual void OnLaunched(Windows::ApplicationModel::Activation::LaunchActivatedEventArgs^ e) override; 19 | 20 | internal: 21 | App(); 22 | 23 | private: 24 | void OnSuspending(Platform::Object^ sender, Windows::ApplicationModel::SuspendingEventArgs^ e); 25 | void OnNavigationFailed(Platform::Object ^sender, Windows::UI::Xaml::Navigation::NavigationFailedEventArgs ^e); 26 | }; 27 | } 28 | -------------------------------------------------------------------------------- /experimental/forthic-cpp/ForthicLibTests/pch.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // pch.cpp 3 | // 4 | 5 | #include "pch.h" 6 | -------------------------------------------------------------------------------- /experimental/forthic-cpp/ForthicLibTests/pch.h: -------------------------------------------------------------------------------- 1 | // 2 | // pch.h 3 | // 4 | 5 | #pragma once 6 | 7 | #include 8 | #include 9 | 10 | #include "UnitTestApp.xaml.h" 11 | -------------------------------------------------------------------------------- /experimental/forthic-hs/.gitignore: -------------------------------------------------------------------------------- 1 | *.swp 2 | scratch.hs 3 | temp 4 | -------------------------------------------------------------------------------- /experimental/forthic-hs/Forthic/StackItem.hs: -------------------------------------------------------------------------------- 1 | -- Forthic.StackItem: Defines stack items Interpreter can use 2 | -- 3 | -- To extend the Interpreter to handle custom stack items, add value 4 | -- constructors to the StackItem type 5 | 6 | module Forthic.StackItem( 7 | StackItem(..), -- Objects that can be pushed onto the Interpreter stack 8 | Variable(..), -- Maintains a name and value and is stored in a Module 9 | is_SString, 10 | is_SArray 11 | ) where 12 | 13 | import Data.Map 14 | import Data.Time 15 | 16 | -- Stores name and value of a variable 17 | data Variable = Variable String StackItem deriving(Eq, Ord, Show) 18 | 19 | 20 | -- Items that can be pushed onto Interpreter stack 21 | data StackItem = 22 | SNone | 23 | SBool Bool | 24 | SStartArray | 25 | SInt Int | 26 | SFloat Float | 27 | SString String | 28 | SDate Day | 29 | STime TimeOfDay | 30 | SArray [StackItem] | 31 | SRecord (Map String StackItem) | 32 | SVariable Variable 33 | deriving(Eq, Ord, Show) 34 | 35 | is_SString :: StackItem -> Bool 36 | is_SString (SString _) = True 37 | is_SString _ = False 38 | 39 | 40 | is_SArray :: StackItem -> Bool 41 | is_SArray (SArray _) = True 42 | is_SArray _ = False 43 | -------------------------------------------------------------------------------- /experimental/forthic-hs/README.md: -------------------------------------------------------------------------------- 1 | # forthic-hs 2 | Forthic interpreter using Haskell as the host language 3 | -------------------------------------------------------------------------------- /experimental/forthic-hs/test_tokenizer.hs: -------------------------------------------------------------------------------- 1 | import Forthic.Tokenizer 2 | 3 | sample1 = "# This is a comment\n\ 4 | \ [ 1 2 3 ]" 5 | 6 | sample2 = "# This is a comment" 7 | sample3 = "[ 1 2" 8 | sample4 = ": DOUBLE DUP + ;" 9 | sample5 = ": ITEMS [ 1 2 3 ] ;" 10 | sample6 = "{module" 11 | sample7 = "{" 12 | sample8 = "{\n: HOWDY ;" 13 | sample9 = "'''Now is the time\nfor all good men\nto come to the aid''' [" 14 | sample10 = "'Now is the time\nfor all good men\nto come to the aid' [" 15 | sample11 = "'''Now" 16 | sample12 = "'Now" 17 | 18 | main = putStrLn $ show $ tokens sample5 19 | -------------------------------------------------------------------------------- /experimental/forthic-jl/Forthic/Project.toml: -------------------------------------------------------------------------------- 1 | name = "Forthic" 2 | uuid = "6e52ba6b-ee15-4eb2-8f21-6007d3c3a569" 3 | authors = ["Rino Jose "] 4 | version = "0.1.0" 5 | -------------------------------------------------------------------------------- /experimental/forthic-jl/Forthic/src/Forthic.jl: -------------------------------------------------------------------------------- 1 | module Forthic 2 | 3 | include("./tokenizer.jl") 4 | include("./module.jl") 5 | include("./global_module.jl") 6 | include("./interpreter.jl") 7 | 8 | function test() 9 | println("Starting test!") 10 | forthic = read(open("./test.forthic", "r"), String) 11 | 12 | # tokenizer = Tokenizer.new_tokenizer(raw"{module : GREETING HOWDY;} GREETING ") 13 | tokenizer = new_tokenizer(forthic) 14 | while true 15 | token = next_token(tokenizer) 16 | println(token) 17 | if token.type == TOK_EOS break end 18 | end 19 | 20 | 21 | # my_module = new_Module("my-module", "") 22 | # println(my_module) 23 | end 24 | 25 | function test_interp() 26 | forthic = read(open("./test_interp.forthic", "r"), String) 27 | interp = new_Interpreter() 28 | run(interp, forthic) 29 | for item in interp.stack 30 | println(item) 31 | end 32 | end 33 | 34 | end -------------------------------------------------------------------------------- /experimental/forthic-jl/Forthic/src/test.jl: -------------------------------------------------------------------------------- 1 | include("./module.jl") 2 | include("./tokenizer.jl") 3 | include("./interpreter.jl") 4 | 5 | import .Forthic 6 | 7 | tokenizer = Forthic.new_tokenizer("# Howdy") 8 | # forthic = read(open("./test.forthic", "r"), String) 9 | 10 | # # tokenizer = Tokenizer.new_tokenizer(raw"{module : GREETING HOWDY;} GREETING ") 11 | # tokenizer = Forthic.new_tokenizer(forthic) 12 | # while true 13 | # token = Forthic.next_token(tokenizer) 14 | # println(token) 15 | # if token.type == Forthic.TOK_EOS break end 16 | # end 17 | 18 | 19 | # my_module = new_Module("my-module", "") 20 | # println(my_module) -------------------------------------------------------------------------------- /experimental/forthic-jl/Forthic/test.forthic: -------------------------------------------------------------------------------- 1 | # This is a test 2 | `1 + 1` 3 | ["jira"] USE-MODULES 4 | 5 | : JQL """assignee = "rjose" and resolved = null"""; 6 | JQL [] jira.SEARCH 7 | 8 | : MAIN-PAGE "Howdy!"; -------------------------------------------------------------------------------- /experimental/forthic-jl/Forthic/test_interp.forthic: -------------------------------------------------------------------------------- 1 | : DATA ["1" "2" "3"]; 2 | : 2DATA DATA DATA; 3 | : MY-MATRIX `[1 2 3; 4 5 6]`; 4 | MY-MATRIX 5 | 6 | "4DATA" "2DATA 2DATA" MEMO 7 | # 4DATA 8 | 9 | # 42 42.24 2021-09-04 10 | 11 | ["record"] VARIABLES 12 | [ 13 | ["alpha" 42] 14 | ["beta" [["date" 2021-09-04]] REC] 15 | ] REC record ! 16 | 17 | record @ ["beta" "date"] REC@ 18 | 19 | record @ "OUCH" "gamma" activate .` 5 | 3. `julia> using Revise` 6 | 4. `julia> using Forthic` 7 | 5. `julia> Forthic.test_interp()` -------------------------------------------------------------------------------- /experimental/forthic-nvcc/.gitignore: -------------------------------------------------------------------------------- 1 | app 2 | *.o 3 | *.swp 4 | .vscode 5 | test/test 6 | tmp 7 | old 8 | -------------------------------------------------------------------------------- /experimental/forthic-nvcc/Module.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #include "Word.h" 9 | #include "S_Variable.h" 10 | 11 | using namespace std; 12 | 13 | class Module { 14 | public: 15 | Module(string name); 16 | 17 | shared_ptr FindWord(string name); 18 | 19 | void AddWord(shared_ptr word); 20 | void AddWord(Word* word); 21 | 22 | void EnsureVariable(string name); 23 | void UseModule(shared_ptr mod); 24 | virtual string ForthicCode(); 25 | 26 | string GetName(); 27 | 28 | protected: 29 | string name; 30 | vector> words; 31 | map> variables; 32 | 33 | protected: 34 | shared_ptr find_in_words(string name); 35 | shared_ptr find_variable(string name); 36 | vector> using_modules; 37 | shared_ptr find_in_using_modules(string name); 38 | virtual shared_ptr treat_as_literal(string name); 39 | }; 40 | 41 | -------------------------------------------------------------------------------- /experimental/forthic-nvcc/S_StartArray.cpp: -------------------------------------------------------------------------------- 1 | #include "S_StartArray.h" 2 | 3 | S_StartArray::S_StartArray() 4 | { 5 | } 6 | 7 | 8 | S_StartArray::~S_StartArray() 9 | { 10 | } 11 | 12 | string S_StartArray::AsString() { 13 | return "S_StartArray"; 14 | } 15 | -------------------------------------------------------------------------------- /experimental/forthic-nvcc/S_StartArray.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "StackItem.h" 3 | 4 | using namespace std; 5 | 6 | class S_StartArray : public StackItem 7 | { 8 | public: 9 | S_StartArray(); 10 | virtual ~S_StartArray(); 11 | virtual string AsString(); 12 | }; 13 | -------------------------------------------------------------------------------- /experimental/forthic-nvcc/S_String.cpp: -------------------------------------------------------------------------------- 1 | #include "S_String.h" 2 | 3 | shared_ptr S_String::New(string s) { 4 | return shared_ptr(new S_String(s)); 5 | } 6 | 7 | string S_String::AsString() { 8 | return item_string; 9 | } 10 | 11 | string S_String::StringRep() { 12 | return item_string; 13 | } 14 | -------------------------------------------------------------------------------- /experimental/forthic-nvcc/S_String.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | #include "StackItem.h" 5 | #include "./m_global/I_AsString.h" 6 | 7 | using namespace std; 8 | 9 | 10 | class S_String : public StackItem, public I_AsString 11 | { 12 | public: 13 | S_String(string s) : item_string(s) {}; 14 | static shared_ptr New(string s); 15 | virtual ~S_String() {}; 16 | string AsString(); 17 | 18 | virtual string StringRep(); 19 | 20 | protected: 21 | string item_string; 22 | }; 23 | -------------------------------------------------------------------------------- /experimental/forthic-nvcc/S_Variable.cpp: -------------------------------------------------------------------------------- 1 | #include "S_Variable.h" 2 | 3 | using namespace std; 4 | 5 | shared_ptr S_Variable::GetValue() { 6 | return value; 7 | } 8 | 9 | void S_Variable::SetValue(shared_ptr new_value) { 10 | value = new_value; 11 | } 12 | 13 | string S_Variable::StringRep() { 14 | string value_str = "nullptr"; 15 | if (value != nullptr) value_str = value->StringRep(); 16 | string result = "S_Variable: "; 17 | result += value_str; 18 | return result; 19 | } 20 | 21 | string S_Variable::AsString() { 22 | return StringRep(); 23 | } 24 | -------------------------------------------------------------------------------- /experimental/forthic-nvcc/S_Variable.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | #include "StackItem.h" 5 | 6 | using namespace std; 7 | 8 | class S_Variable : public StackItem 9 | { 10 | public: 11 | S_Variable() : value(nullptr) {}; 12 | virtual ~S_Variable() {}; 13 | 14 | shared_ptr GetValue(); 15 | void SetValue(shared_ptr new_value); 16 | 17 | virtual string StringRep(); 18 | virtual string AsString(); 19 | 20 | protected: 21 | shared_ptr value; 22 | }; 23 | 24 | -------------------------------------------------------------------------------- /experimental/forthic-nvcc/StackItem.cpp: -------------------------------------------------------------------------------- 1 | #include "StackItem.h" 2 | 3 | 4 | StackItem::StackItem() 5 | { 6 | } 7 | 8 | 9 | StackItem::~StackItem() 10 | { 11 | } 12 | 13 | 14 | string StackItem::StringRep() { 15 | return "StackItem"; 16 | } 17 | -------------------------------------------------------------------------------- /experimental/forthic-nvcc/StackItem.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | using namespace std; 6 | 7 | class StackItem 8 | { 9 | public: 10 | StackItem(); 11 | virtual ~StackItem(); 12 | virtual string StringRep(); 13 | virtual string AsString() = 0; 14 | }; 15 | 16 | -------------------------------------------------------------------------------- /experimental/forthic-nvcc/Token.cpp: -------------------------------------------------------------------------------- 1 | #include "Token.h" 2 | 3 | 4 | Token::Token(TokenType t, string& s) 5 | { 6 | type = t; 7 | text = s; 8 | } 9 | 10 | Token::Token(TokenType t) 11 | { 12 | type = t; 13 | text = ""; 14 | } 15 | 16 | Token::~Token() 17 | { 18 | } 19 | 20 | 21 | TokenType Token::GetType() 22 | { 23 | return type; 24 | } 25 | 26 | string Token::GetText() 27 | { 28 | return text; 29 | } 30 | -------------------------------------------------------------------------------- /experimental/forthic-nvcc/Token.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | using namespace std; 5 | 6 | 7 | enum class TokenType { 8 | COMMENT, 9 | START_DEFINITION, 10 | END_DEFINITION, 11 | START_ARRAY, 12 | END_ARRAY, 13 | START_MODULE, 14 | END_MODULE, 15 | STRING, 16 | WORD, 17 | EOS }; 18 | 19 | class Token 20 | { 21 | public: 22 | Token(TokenType t, string& s); 23 | Token(TokenType t); 24 | ~Token(); 25 | 26 | TokenType GetType(); 27 | string GetText(); 28 | 29 | protected: 30 | TokenType type; 31 | string text; 32 | }; 33 | 34 | -------------------------------------------------------------------------------- /experimental/forthic-nvcc/Tokenizer.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include "Token.h" 5 | 6 | using namespace std; 7 | 8 | class Tokenizer 9 | { 10 | public: 11 | Tokenizer(string& s); 12 | ~Tokenizer(); 13 | Token NextToken(); 14 | bool IsTripleQuote(int index, char c); 15 | 16 | protected: 17 | bool is_whitespace(char c); 18 | bool is_quote(char c); 19 | 20 | // Transition functions 21 | Token transition_from_START(); 22 | Token transition_from_COMMENT(); 23 | Token transition_from_START_DEFINITION(); 24 | Token transition_from_GATHER_DEFINITION_NAME(); 25 | Token transition_from_GATHER_MODULE(); 26 | Token transition_from_GATHER_TRIPLE_QUOTE_STRING(char delim); 27 | Token transition_from_GATHER_STRING(char delim); 28 | Token transition_from_GATHER_WORD(char first_char); 29 | 30 | unsigned int position; 31 | string input; 32 | string whitespace; 33 | string token_string; 34 | }; 35 | -------------------------------------------------------------------------------- /experimental/forthic-nvcc/W_Definition.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "W_Definition.h" 3 | #include "Interpreter.h" 4 | #include "Module.h" 5 | 6 | 7 | W_Definition::W_Definition(string word_name, shared_ptr module) : Word(word_name), module(module) 8 | { 9 | } 10 | 11 | W_Definition::~W_Definition() 12 | { 13 | } 14 | 15 | void W_Definition::CompileWord(shared_ptr word) 16 | { 17 | words.push_back(word); 18 | } 19 | 20 | void W_Definition::Execute(Interpreter *interp) 21 | { 22 | for (auto iter = words.begin(); iter != words.end(); iter++) 23 | { 24 | interp->ContextPush(module); 25 | (*iter)->Execute(interp); 26 | interp->ContextPop(); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /experimental/forthic-nvcc/W_Definition.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | #include "StackItem.h" 6 | #include "Word.h" 7 | 8 | using namespace std; 9 | 10 | class Interpreter; 11 | class Module; 12 | 13 | class W_Definition : public Word 14 | { 15 | public: 16 | W_Definition(string name, shared_ptr module); 17 | virtual ~W_Definition(); 18 | virtual void Execute(Interpreter *interp); 19 | 20 | void CompileWord(shared_ptr word); 21 | 22 | protected: 23 | vector> words; 24 | shared_ptr module; 25 | }; 26 | 27 | -------------------------------------------------------------------------------- /experimental/forthic-nvcc/W_EndArray.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "W_EndArray.h" 3 | #include "Interpreter.h" 4 | #include "./m_global/S_Array.h" 5 | #include "S_StartArray.h" 6 | 7 | 8 | W_EndArray::W_EndArray(string word_name) : Word(word_name) 9 | { 10 | } 11 | 12 | 13 | W_EndArray::~W_EndArray() 14 | { 15 | } 16 | 17 | void W_EndArray::Execute(Interpreter *interp) 18 | { 19 | vector> result; 20 | 21 | while (true) 22 | { 23 | auto item = interp->StackPop(); 24 | if (dynamic_cast(item.get())) break; 25 | else result.push_back(item); 26 | } 27 | 28 | std::reverse(result.begin(), result.end()); 29 | interp->StackPush(shared_ptr(new S_Array(result))); 30 | } 31 | -------------------------------------------------------------------------------- /experimental/forthic-nvcc/W_EndArray.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include "StackItem.h" 4 | #include "Word.h" 5 | 6 | using namespace std; 7 | 8 | class Interpreter; 9 | 10 | class W_EndArray : public Word 11 | { 12 | public: 13 | W_EndArray(string name); 14 | virtual ~W_EndArray(); 15 | virtual void Execute(Interpreter *interp); 16 | }; 17 | 18 | -------------------------------------------------------------------------------- /experimental/forthic-nvcc/W_PushItem.cpp: -------------------------------------------------------------------------------- 1 | #include "W_PushItem.h" 2 | #include "Interpreter.h" 3 | 4 | 5 | W_PushItem::W_PushItem(string word_name, shared_ptr i) : Word(word_name), item(i) 6 | { 7 | } 8 | 9 | 10 | void W_PushItem::Execute(Interpreter *interp) 11 | { 12 | interp->StackPush(item); 13 | } 14 | -------------------------------------------------------------------------------- /experimental/forthic-nvcc/W_PushItem.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include "StackItem.h" 6 | #include "Word.h" 7 | 8 | using namespace std; 9 | 10 | class Interpreter; 11 | 12 | class W_PushItem : public Word 13 | { 14 | public: 15 | W_PushItem(string name, shared_ptr item); 16 | virtual void Execute(Interpreter *interp); 17 | 18 | protected: 19 | shared_ptr item; 20 | }; 21 | -------------------------------------------------------------------------------- /experimental/forthic-nvcc/Word.cpp: -------------------------------------------------------------------------------- 1 | #include "Word.h" 2 | 3 | Word::Word(string name) : name(name) { 4 | } 5 | 6 | Word::~Word() { 7 | } 8 | 9 | void Word::Execute(Interpreter *interp) { 10 | // By default, do nothing 11 | } 12 | 13 | 14 | string Word::GetName() { 15 | return name; 16 | } 17 | -------------------------------------------------------------------------------- /experimental/forthic-nvcc/Word.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | using namespace std; 5 | 6 | class Interpreter; 7 | 8 | class Word 9 | { 10 | public: 11 | Word(string name); 12 | virtual ~Word(); 13 | virtual void Execute(Interpreter *interp); 14 | 15 | string GetName(); 16 | protected: 17 | string name; 18 | }; 19 | 20 | -------------------------------------------------------------------------------- /experimental/forthic-nvcc/deps.py: -------------------------------------------------------------------------------- 1 | import subprocess 2 | 3 | def cmd(string): 4 | try: 5 | result = subprocess.check_output([string], shell=True).decode('utf-8')[:-1] 6 | except: 7 | result = "" 8 | return result 9 | 10 | 11 | def dot_h_files(): 12 | return cmd("ls *.h m_*/*.h test/*.h").split("\n") 13 | 14 | 15 | def header_dependencies(header): 16 | 17 | def grep_header(extension): 18 | def filename(f): 19 | return f.split("/")[-1] 20 | return cmd("grep {0} *{1} m_*/*{1} examples/*{1} test/*{1}".format(filename(header), extension)).split("\n") 21 | 22 | def dot_o(line, extension): 23 | base = line.split(extension)[0] 24 | if not base: 25 | return "" 26 | return base + ".o" 27 | 28 | def deps(extension): 29 | lines = grep_header(extension) 30 | return [dot_o(l, extension) for l in lines] 31 | 32 | dot_os = deps(".cu") + deps(".cpp") + deps(".h") 33 | 34 | result = "" 35 | if dot_os: 36 | result = "{0} : {1}".format(" ".join(dot_os), header) 37 | return result 38 | 39 | 40 | def dependencies(): 41 | return "\n".join([ header_dependencies(h) for h in dot_h_files()]) 42 | 43 | print(dependencies()) 44 | -------------------------------------------------------------------------------- /experimental/forthic-nvcc/examples/BHM-p.62-LP.forthic: -------------------------------------------------------------------------------- 1 | # Section 2.3: Simplex full example using LP 2 | 3 | [ cuda linear-program ] USE-MODULES 4 | 5 | [ "prob" ] VARIABLES 6 | 7 | : X [ "num_flatbed" "num_economy" "num_luxury" ] ; 8 | : OBJECTIVE [ 0 6 14 13 ] "Objective" LP-EQN ; 9 | : C-METAL [ 24 0.5 2 1 ] "Metal Hours" LP-EQN ; 10 | : C-WOOD [ 60 1 2 4 ] "Woodworking Hours" LP-EQN ; 11 | 12 | : PROB! X OBJECTIVE [ C-METAL C-WOOD ] LP-NEW prob ! ; 13 | : PROB prob @ ; 14 | : CLEANUP PROB LP-FREE CUDA-DEVICE-RESET ; 15 | 16 | PROB! 17 | PROB LP-PRINT-MATRIX 18 | 19 | # Manually run pivot steps 20 | # PROB 1 2 LP-PIVOT PROB LP-PRINT 21 | # PROB 2 3 LP-PIVOT PROB LP-PRINT 22 | # PROB 1 1 LP-PIVOT PROB LP-PRINT 23 | 24 | CLEANUP 25 | -------------------------------------------------------------------------------- /experimental/forthic-nvcc/examples/BHM-p.62.forthic: -------------------------------------------------------------------------------- 1 | # Section 2.3: Simplex full example 2 | 3 | [ cuda gauss ] USE-MODULES 4 | 5 | : METAL-WORKING-DAYS 24 ; 6 | : WOOD-WORKING-DAYS 60 ; 7 | 8 | : NUM-ROWS 3 ; 9 | : NUM-COLS 6 ; 10 | : NUM-ELEMS NUM-ROWS NUM-COLS * ; 11 | [ "_A" "_x" ] VARIABLES 12 | : A! [ 0 6 14 13 0 0 # Objective 13 | METAL-WORKING-DAYS 0.5 2 1 1 0 14 | WOOD-WORKING-DAYS 1 2 4 0 1 ] 15 | NUM-ROWS NUM-COLS GPU-MATRIX _A ! ; 16 | 17 | : A NUM-ROWS NUM-COLS _A @ ; 18 | : FREE-A _A @ CUDA-FREE ; 19 | 20 | # Define kernel launch config 21 | : THREADS/BLOCK 1024 ; 22 | : BLOCKS/GRID NUM-ELEMS THREADS/BLOCK + 1 - THREADS/BLOCK / ; 23 | : BLOCK THREADS/BLOCK 1 1 DIM3 ; 24 | : GRID BLOCKS/GRID 1 1 DIM3 ; 25 | 26 | [ "pivot_row" "pivot_col" ] VARIABLES 27 | : DO-PIVOT GRID BLOCK A pivot_row @ pivot_col @ PIVOT ; 28 | : PRINT-PIVOT [ "Pivot " pivot_row @ " " pivot_col @ ] CONCAT PRINT A PRINT-MATRIX ; 29 | : PIVOT-A (pivot_col ! pivot_row !) DO-PIVOT PRINT-PIVOT ; 30 | 31 | # Solve equations 32 | A! A PRINT-MATRIX 33 | 1 2 PIVOT-A 34 | 2 3 PIVOT-A 35 | 1 1 PIVOT-A 36 | 37 | # Cleanup 38 | FREE-A 39 | CUDA-DEVICE-RESET 40 | -------------------------------------------------------------------------------- /experimental/forthic-nvcc/examples/Ch2Module.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | #include "../Module.h" 11 | 12 | using namespace std; 13 | 14 | 15 | class Ch2Module : public Module 16 | { 17 | public: 18 | Ch2Module(); 19 | 20 | protected: 21 | // virtual shared_ptr treat_as_literal(string name); 22 | }; 23 | -------------------------------------------------------------------------------- /experimental/forthic-nvcc/examples/Example-2.1.forthic: -------------------------------------------------------------------------------- 1 | # Ex 2.1: Solve simultaneous equations 2 | 3 | [ cuda gauss ] USE-MODULES 4 | 5 | # Set up problem 6 | : b1 2 ; 7 | : b2 3 ; 8 | : b3 3 ; 9 | 10 | [ "_A" "_x" ] VARIABLES 11 | : NUM-ROWS 3 ; 12 | : NUM-COLS 4 ; 13 | : NUM-ELEMS NUM-ROWS NUM-COLS * ; 14 | : A! [ -1 1 -1 b1 15 | 1 1 2 b2 16 | 0 1 1 b3 ] NUM-ROWS NUM-COLS GPU-MATRIX _A ! ; 17 | : A NUM-ROWS NUM-COLS _A @ ; 18 | : FREE-A _A @ CUDA-FREE ; 19 | 20 | # Define kernel launch config 21 | : THREADS/BLOCK 1024 ; 22 | : BLOCKS/GRID NUM-ELEMS THREADS/BLOCK + 1 - THREADS/BLOCK / ; 23 | : BLOCK THREADS/BLOCK 1 1 DIM3 ; 24 | : GRID BLOCKS/GRID 1 1 DIM3 ; 25 | 26 | [ "pivot_row" "pivot_col" ] VARIABLES 27 | : DO-PIVOT GRID BLOCK A pivot_row @ pivot_col @ PIVOT ; 28 | : PRINT-PIVOT [ "Pivot " pivot_row @ " " pivot_col @ ] CONCAT PRINT A PRINT-MATRIX ; 29 | : PIVOT-A (pivot_col ! pivot_row !) DO-PIVOT PRINT-PIVOT ; 30 | 31 | # Solve equations 32 | A! A PRINT-MATRIX 33 | 0 0 PIVOT-A 34 | 1 1 PIVOT-A 35 | 2 2 PIVOT-A 36 | 37 | # Cleanup 38 | FREE-A 39 | CUDA-DEVICE-RESET 40 | -------------------------------------------------------------------------------- /experimental/forthic-nvcc/examples/TestContext.forthic: -------------------------------------------------------------------------------- 1 | # This tests executing Forthic in different contexts 2 | 3 | : MESSAGE "Outer message" ; 4 | 5 | {my-module 6 | : MESSAGE "Inner message" ; 7 | : RUN1 "MESSAGE" INTERPRET ; 8 | : RUN2 "MESSAGE" /INTERPRET ; 9 | : RUN3 "RUN1 RUN2" INTERPRET ; 10 | [ "RUN1" "RUN2" "RUN3" ] PUBLISH 11 | } 12 | 13 | [ my-module ] USE-MODULES 14 | 15 | # RUN1 .s # ( "Inner message" ) 16 | # POP 17 | # RUN2 .s # ( "Outer message" ) 18 | RUN3 .s 19 | 20 | # INTERPRET runs by searching the module stack at the point of definition 21 | # *INTERPRET runs by searching the module stack at the point of execution 22 | 23 | -------------------------------------------------------------------------------- /experimental/forthic-nvcc/examples/checkDimension.forthic: -------------------------------------------------------------------------------- 1 | [ cuda ] USE-MODULES 2 | 3 | : NUM-ELEM 6 ; 4 | : BLOCK 3 1 1 DIM3 ; 5 | : GRID NUM-ELEM BLOCK >x + 1 - BLOCK >x / 1 1 DIM3 ; 6 | : PRINT-DIMS GRID PRINT BLOCK PRINT ; 7 | : GPU-PRINT-DIMS GRID BLOCK GPU-CHECK-INDEX ; 8 | : RUN PRINT-DIMS GPU-PRINT-DIMS ; 9 | 10 | RUN 11 | -------------------------------------------------------------------------------- /experimental/forthic-nvcc/m_cuda/I_AsDim3.cu: -------------------------------------------------------------------------------- 1 | #include "I_AsDim3.h" 2 | 3 | 4 | dim3 AsDim3(shared_ptr item) { 5 | if (auto i = dynamic_cast(item.get())) { 6 | return i->AsDim3(); 7 | } 8 | else { 9 | throw "Item does not implement I_AsDim3"; 10 | } 11 | } 12 | 13 | -------------------------------------------------------------------------------- /experimental/forthic-nvcc/m_cuda/I_AsDim3.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | #include 5 | 6 | #include "../StackItem.h" 7 | 8 | class I_AsDim3 { 9 | public: 10 | virtual dim3 AsDim3() = 0; 11 | }; 12 | 13 | 14 | dim3 AsDim3(shared_ptr item); 15 | -------------------------------------------------------------------------------- /experimental/forthic-nvcc/m_cuda/M_Cuda.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | #include "../Module.h" 11 | 12 | using namespace std; 13 | 14 | 15 | class M_Cuda : public Module 16 | { 17 | public: 18 | M_Cuda(); 19 | virtual string ForthicCode(); 20 | 21 | protected: 22 | // virtual shared_ptr treat_as_literal(string name); 23 | }; 24 | 25 | void checkCudaCall(const cudaError_t res, const char* file, int line); -------------------------------------------------------------------------------- /experimental/forthic-nvcc/m_cuda/S_CudaDeviceProp.cu: -------------------------------------------------------------------------------- 1 | #include "S_CudaDeviceProp.h" 2 | 3 | shared_ptr S_CudaDeviceProp::New(cudaDeviceProp value) { 4 | return shared_ptr(new S_CudaDeviceProp(value)); 5 | } 6 | 7 | const cudaDeviceProp& S_CudaDeviceProp::deviceProp() { 8 | return value; 9 | } 10 | 11 | string S_CudaDeviceProp::StringRep() { 12 | return "S_CudaDeviceProp"; 13 | } 14 | 15 | string S_CudaDeviceProp::AsString() { 16 | return "S_CudaDeviceProp"; 17 | } 18 | -------------------------------------------------------------------------------- /experimental/forthic-nvcc/m_cuda/S_CudaDeviceProp.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | 6 | #include "../StackItem.h" 7 | 8 | using namespace std; 9 | 10 | class S_CudaDeviceProp : public StackItem 11 | { 12 | public: 13 | S_CudaDeviceProp(cudaDeviceProp value) : value(value) {}; 14 | static shared_ptr New(cudaDeviceProp value); 15 | 16 | const cudaDeviceProp& deviceProp(); 17 | 18 | virtual string StringRep(); 19 | virtual string AsString(); 20 | 21 | protected: 22 | cudaDeviceProp value; 23 | }; 24 | -------------------------------------------------------------------------------- /experimental/forthic-nvcc/m_cuda/S_Dim3.cu: -------------------------------------------------------------------------------- 1 | #include 2 | #include "S_Dim3.h" 3 | 4 | 5 | dim3 S_Dim3::AsDim3() { 6 | return value; 7 | } 8 | 9 | string S_Dim3::StringRep() { 10 | stringstream builder; 11 | builder << "S_Dim3: " << "(" << value.x << ", " << value.y << ", " << value.z << ")"; 12 | return builder.str(); 13 | } 14 | 15 | string S_Dim3::AsString() { 16 | stringstream builder; 17 | builder << "(" << value.x << ", " << value.y << ", " << value.z << ")"; 18 | return builder.str(); 19 | } 20 | -------------------------------------------------------------------------------- /experimental/forthic-nvcc/m_cuda/S_Dim3.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | #include "../StackItem.h" 5 | #include "I_AsDim3.h" 6 | 7 | using namespace std; 8 | 9 | 10 | class S_Dim3 : public StackItem, public I_AsDim3 11 | { 12 | public: 13 | S_Dim3(dim3 value) : value(value) {}; 14 | dim3 AsDim3(); 15 | 16 | virtual string StringRep(); 17 | virtual string AsString(); 18 | 19 | protected: 20 | dim3 value; 21 | }; 22 | -------------------------------------------------------------------------------- /experimental/forthic-nvcc/m_gauss/M_Gauss.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | #include "../Module.h" 11 | 12 | using namespace std; 13 | 14 | 15 | class M_Gauss : public Module 16 | { 17 | public: 18 | M_Gauss(); 19 | }; 20 | -------------------------------------------------------------------------------- /experimental/forthic-nvcc/m_global/I_AsArray.cpp: -------------------------------------------------------------------------------- 1 | #include "I_AsArray.h" 2 | 3 | vector> AsArray(shared_ptr item) 4 | { 5 | if (auto i = dynamic_cast(item.get())) 6 | { 7 | return i->AsArray(); 8 | } 9 | else 10 | { 11 | throw "Item does not implement I_AsArray"; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /experimental/forthic-nvcc/m_global/I_AsArray.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | #include "../StackItem.h" 8 | 9 | class I_AsArray { 10 | public: 11 | virtual vector> AsArray() = 0; 12 | }; 13 | 14 | vector> AsArray(shared_ptr item); -------------------------------------------------------------------------------- /experimental/forthic-nvcc/m_global/I_AsFloat.cpp: -------------------------------------------------------------------------------- 1 | #include "I_AsFloat.h" 2 | 3 | float AsFloat(shared_ptr item) { 4 | if (auto i = dynamic_cast(item.get())) { 5 | return i->AsFloat(); 6 | } 7 | else { 8 | throw item->StringRep() + " does not implement IGetFloat"; 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /experimental/forthic-nvcc/m_global/I_AsFloat.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include "../StackItem.h" 5 | 6 | class I_AsFloat { 7 | public: 8 | virtual float AsFloat() = 0; 9 | }; 10 | 11 | float AsFloat(shared_ptr item); -------------------------------------------------------------------------------- /experimental/forthic-nvcc/m_global/I_AsFloatStar.cpp: -------------------------------------------------------------------------------- 1 | #include "I_AsFloatStar.h" 2 | 3 | float* AsFloatStar(shared_ptr item) { 4 | if (auto i = dynamic_cast(item.get())) { 5 | return i->AsFloatStar(); 6 | } 7 | else { 8 | throw item->StringRep() + ": does not implement I_AsFloatStar"; 9 | } 10 | } -------------------------------------------------------------------------------- /experimental/forthic-nvcc/m_global/I_AsFloatStar.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | #include "../StackItem.h" 5 | 6 | class I_AsFloatStar { 7 | public: 8 | virtual float* AsFloatStar() = 0; 9 | }; 10 | 11 | float* AsFloatStar(shared_ptr item); -------------------------------------------------------------------------------- /experimental/forthic-nvcc/m_global/I_AsInt.cpp: -------------------------------------------------------------------------------- 1 | #include "I_AsInt.h" 2 | 3 | int AsInt(shared_ptr item) { 4 | if (auto i = dynamic_cast(item.get())) { 5 | return i->AsInt(); 6 | } 7 | else { 8 | throw item->StringRep() + " does not implement IGetInt"; 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /experimental/forthic-nvcc/m_global/I_AsInt.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include "../StackItem.h" 5 | 6 | class I_AsInt { 7 | public: 8 | virtual int AsInt() = 0; 9 | }; 10 | 11 | int AsInt(shared_ptr item); -------------------------------------------------------------------------------- /experimental/forthic-nvcc/m_global/I_AsIntStar.cpp: -------------------------------------------------------------------------------- 1 | #include "I_AsIntStar.h" 2 | 3 | 4 | int* AsIntStar(shared_ptr item) { 5 | if (auto i = dynamic_cast(item.get())) { 6 | return i->AsIntStar(); 7 | } 8 | else { 9 | throw item->StringRep() + ": does not implement I_AsIntStar"; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /experimental/forthic-nvcc/m_global/I_AsIntStar.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | #include "../StackItem.h" 5 | 6 | class I_AsIntStar { 7 | public: 8 | virtual int* AsIntStar() = 0; 9 | }; 10 | 11 | int* AsIntStar(shared_ptr item); -------------------------------------------------------------------------------- /experimental/forthic-nvcc/m_global/I_AsModule.cpp: -------------------------------------------------------------------------------- 1 | #include "I_AsModule.h" 2 | 3 | shared_ptr AsModule(shared_ptr item) 4 | { 5 | if (auto i = dynamic_cast(item.get())) 6 | { 7 | return i->AsModule(); 8 | } 9 | else 10 | { 11 | throw "Item does not implement IAsModule"; 12 | } 13 | } -------------------------------------------------------------------------------- /experimental/forthic-nvcc/m_global/I_AsModule.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "../StackItem.h" 6 | 7 | class Module; 8 | 9 | class I_AsModule { 10 | public: 11 | virtual shared_ptr AsModule() = 0; 12 | }; 13 | 14 | shared_ptr AsModule(shared_ptr item); 15 | -------------------------------------------------------------------------------- /experimental/forthic-nvcc/m_global/I_AsString.cpp: -------------------------------------------------------------------------------- 1 | #include "I_AsString.h" 2 | 3 | string AsString(shared_ptr item) 4 | { 5 | if (auto i = dynamic_cast(item.get())) 6 | { 7 | return i->AsString(); 8 | } 9 | else 10 | { 11 | throw "Item does not implement I_AsString"; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /experimental/forthic-nvcc/m_global/I_AsString.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | 5 | #include "../StackItem.h" 6 | 7 | class I_AsString { 8 | public: 9 | virtual string AsString() = 0; 10 | }; 11 | 12 | string AsString(shared_ptr item); 13 | 14 | -------------------------------------------------------------------------------- /experimental/forthic-nvcc/m_global/I_AsTimePoint.cpp: -------------------------------------------------------------------------------- 1 | #include "I_AsTimePoint.h" 2 | 3 | 4 | high_resolution_clock::time_point AsTimePoint(shared_ptr item) { 5 | if (auto i = dynamic_cast(item.get())) { 6 | return i->AsTimePoint(); 7 | } 8 | else { 9 | throw item->StringRep() + " does not implement I_AsTimePoint"; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /experimental/forthic-nvcc/m_global/I_AsTimePoint.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | #include "../StackItem.h" 7 | 8 | using namespace std; 9 | using namespace std::chrono; 10 | 11 | 12 | class I_AsTimePoint { 13 | public: 14 | virtual high_resolution_clock::time_point AsTimePoint() = 0; 15 | }; 16 | 17 | high_resolution_clock::time_point AsTimePoint(shared_ptr item); 18 | -------------------------------------------------------------------------------- /experimental/forthic-nvcc/m_global/I_AsVoidStar.cpp: -------------------------------------------------------------------------------- 1 | #include "I_AsVoidStar.h" 2 | 3 | void* AsVoidStar(shared_ptr item) { 4 | if (auto i = dynamic_cast(item.get())) { 5 | return i->AsVoidStar(); 6 | } 7 | else { 8 | throw item->StringRep() + ": does not implement I_AsVoidStar"; 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /experimental/forthic-nvcc/m_global/I_AsVoidStar.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | #include "../StackItem.h" 5 | 6 | class I_AsVoidStar { 7 | public: 8 | virtual void* AsVoidStar() = 0; 9 | }; 10 | 11 | void* AsVoidStar(shared_ptr item); -------------------------------------------------------------------------------- /experimental/forthic-nvcc/m_global/M_Global.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | #include "../Module.h" 11 | 12 | using namespace std; 13 | using namespace std::chrono; 14 | 15 | 16 | class M_Global : public Module 17 | { 18 | public: 19 | M_Global(); 20 | 21 | protected: 22 | virtual shared_ptr treat_as_literal(string name); 23 | 24 | shared_ptr treat_as_float(string name); 25 | shared_ptr treat_as_int(string name); 26 | }; -------------------------------------------------------------------------------- /experimental/forthic-nvcc/m_global/S_Address.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "S_Address.h" 3 | 4 | 5 | shared_ptr S_Address::New(void* address) { 6 | return shared_ptr(new S_Address(address)); 7 | } 8 | 9 | float* S_Address::AsFloatStar() { 10 | return (float*)(address); 11 | } 12 | 13 | int* S_Address::AsIntStar() { 14 | return (int*)(address); 15 | } 16 | 17 | void* S_Address::AsVoidStar() { 18 | return (address); 19 | } 20 | 21 | string S_Address::StringRep() { 22 | stringstream builder; 23 | builder << "S_Address: " << (long int)(address); 24 | return builder.str(); 25 | } 26 | 27 | string S_Address::AsString() { 28 | stringstream builder; 29 | builder << (long int)(address); 30 | return builder.str(); 31 | } 32 | -------------------------------------------------------------------------------- /experimental/forthic-nvcc/m_global/S_Address.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | #include "../StackItem.h" 5 | #include "I_AsFloatStar.h" 6 | #include "I_AsIntStar.h" 7 | #include "I_AsVoidStar.h" 8 | 9 | using namespace std; 10 | 11 | 12 | class S_Address : public StackItem, public I_AsFloatStar, public I_AsIntStar, public I_AsVoidStar 13 | { 14 | public: 15 | S_Address(void* address) : address(address) {}; 16 | static shared_ptr New(void* address); 17 | 18 | float* AsFloatStar(); 19 | int* AsIntStar(); 20 | void* AsVoidStar(); 21 | 22 | virtual string StringRep(); 23 | virtual string AsString(); 24 | 25 | protected: 26 | void* address; 27 | }; 28 | -------------------------------------------------------------------------------- /experimental/forthic-nvcc/m_global/S_Array.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "S_Array.h" 3 | 4 | vector> S_Array::AsArray() { 5 | return items; 6 | } 7 | 8 | string S_Array::StringRep() { 9 | stringstream builder; 10 | builder << "S_Array(" << items.size() << ")"; 11 | return builder.str(); 12 | } 13 | 14 | 15 | string S_Array::AsString() { 16 | return StringRep(); 17 | } 18 | -------------------------------------------------------------------------------- /experimental/forthic-nvcc/m_global/S_Array.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | 6 | #include "../StackItem.h" 7 | #include "I_AsArray.h" 8 | 9 | using namespace std; 10 | 11 | 12 | class S_Array : public StackItem, public I_AsArray 13 | { 14 | public: 15 | S_Array(vector> items) : items(items) {}; 16 | vector> AsArray(); 17 | 18 | virtual string AsString(); 19 | virtual string StringRep(); 20 | 21 | protected: 22 | vector> items; 23 | }; 24 | -------------------------------------------------------------------------------- /experimental/forthic-nvcc/m_global/S_Float.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "S_Float.h" 3 | 4 | 5 | S_Float::S_Float(float _value) : value(_value) 6 | { 7 | } 8 | 9 | 10 | S_Float::~S_Float() 11 | { 12 | } 13 | 14 | float S_Float::AsFloat() { 15 | return value; 16 | } 17 | 18 | int S_Float::AsInt() { 19 | return int(value); 20 | } 21 | 22 | 23 | string S_Float::StringRep() { 24 | stringstream builder; 25 | builder << "S_Float: " << value; 26 | return builder.str(); 27 | } 28 | 29 | string S_Float::AsString() { 30 | stringstream builder; 31 | builder << value; 32 | return builder.str(); 33 | } 34 | -------------------------------------------------------------------------------- /experimental/forthic-nvcc/m_global/S_Float.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | #include "../StackItem.h" 5 | #include "I_AsInt.h" 6 | #include "I_AsFloat.h" 7 | 8 | using namespace std; 9 | 10 | 11 | class S_Float : public StackItem, public I_AsFloat, public I_AsInt 12 | { 13 | public: 14 | S_Float(float value); 15 | virtual ~S_Float(); 16 | 17 | float AsFloat(); 18 | int AsInt(); 19 | virtual string StringRep(); 20 | virtual string AsString(); 21 | 22 | protected: 23 | float value; 24 | }; 25 | -------------------------------------------------------------------------------- /experimental/forthic-nvcc/m_global/S_Int.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "S_Int.h" 3 | 4 | 5 | shared_ptr S_Int::New(int value) { 6 | return shared_ptr(new S_Int(value)); 7 | } 8 | 9 | int S_Int::AsInt() { 10 | return value; 11 | } 12 | 13 | float S_Int::AsFloat() { 14 | return float(value); 15 | } 16 | 17 | string S_Int::StringRep() { 18 | stringstream builder; 19 | builder << "S_Int: " << value; 20 | return builder.str(); 21 | } 22 | 23 | string S_Int::AsString() { 24 | stringstream builder; 25 | builder << value; 26 | return builder.str(); 27 | } 28 | -------------------------------------------------------------------------------- /experimental/forthic-nvcc/m_global/S_Int.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | #include "../StackItem.h" 5 | 6 | #include "I_AsInt.h" 7 | #include "I_AsFloat.h" 8 | 9 | using namespace std; 10 | 11 | 12 | class S_Int : public StackItem, public I_AsInt, public I_AsFloat 13 | { 14 | public: 15 | S_Int(int value) : value(value) {}; 16 | static shared_ptr New(int value); 17 | 18 | int AsInt(); 19 | float AsFloat(); 20 | 21 | virtual string StringRep(); 22 | virtual string AsString(); 23 | 24 | protected: 25 | int value; 26 | }; 27 | -------------------------------------------------------------------------------- /experimental/forthic-nvcc/m_global/S_Module.cpp: -------------------------------------------------------------------------------- 1 | #include "S_Module.h" 2 | 3 | 4 | shared_ptr S_Module::AsModule() { 5 | return mod; 6 | } 7 | 8 | 9 | string S_Module::AsString() { 10 | return "S_Module"; 11 | } 12 | -------------------------------------------------------------------------------- /experimental/forthic-nvcc/m_global/S_Module.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | 5 | #include "I_AsModule.h" 6 | #include "../StackItem.h" 7 | #include "../Module.h" 8 | 9 | using namespace std; 10 | 11 | 12 | class S_Module : public StackItem, public I_AsModule 13 | { 14 | public: 15 | S_Module(shared_ptr mod) : mod(mod) {}; 16 | virtual ~S_Module() {}; 17 | shared_ptr AsModule(); 18 | virtual string AsString(); 19 | 20 | protected: 21 | shared_ptr mod; 22 | }; 23 | -------------------------------------------------------------------------------- /experimental/forthic-nvcc/m_global/S_TimePoint.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "S_TimePoint.h" 3 | 4 | shared_ptr S_TimePoint::New(high_resolution_clock::time_point value) { 5 | return shared_ptr(new S_TimePoint(value)); 6 | } 7 | 8 | high_resolution_clock::time_point S_TimePoint::AsTimePoint() { 9 | return value; 10 | } 11 | 12 | 13 | string S_TimePoint::StringRep() { 14 | stringstream builder; 15 | builder << "S_TimePoint"; 16 | return builder.str(); 17 | } 18 | 19 | string S_TimePoint::AsString() { 20 | stringstream builder; 21 | builder << "S_TimePoint"; 22 | return builder.str(); 23 | } 24 | -------------------------------------------------------------------------------- /experimental/forthic-nvcc/m_global/S_TimePoint.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | 5 | #include "I_AsTimePoint.h" 6 | #include "../StackItem.h" 7 | 8 | using namespace std; 9 | using namespace std::chrono; 10 | 11 | 12 | class S_TimePoint : public StackItem, public I_AsTimePoint 13 | { 14 | public: 15 | S_TimePoint(high_resolution_clock::time_point value) : value(value) {}; 16 | static shared_ptr New(high_resolution_clock::time_point value); 17 | 18 | high_resolution_clock::time_point AsTimePoint(); 19 | 20 | virtual string StringRep(); 21 | virtual string AsString(); 22 | 23 | protected: 24 | high_resolution_clock::time_point value; 25 | }; 26 | -------------------------------------------------------------------------------- /experimental/forthic-nvcc/m_lp/M_LP.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | #include "../Module.h" 11 | 12 | using namespace std; 13 | 14 | 15 | class M_LP : public Module 16 | { 17 | public: 18 | M_LP(); 19 | 20 | virtual string ForthicCode(); 21 | }; 22 | -------------------------------------------------------------------------------- /experimental/forthic-nvcc/m_lp/S_LP.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | #include "../m_cuda/M_Cuda.h" 5 | #include "../StackItem.h" 6 | 7 | using namespace std; 8 | 9 | 10 | class S_LP : public StackItem 11 | { 12 | public: 13 | S_LP(Interpreter* interp); 14 | 15 | virtual ~S_LP() {}; 16 | void Free(); 17 | 18 | void PrintMatrix(); 19 | 20 | virtual string StringRep(); 21 | virtual string AsString(); 22 | 23 | protected: 24 | 25 | void allocateMatrixMemory(); 26 | void fillMatrixMemory(); 27 | void fillConstraint(int constraintIndex); 28 | 29 | protected: 30 | Interpreter* interp; 31 | 32 | vector> constraints; 33 | shared_ptr objective; 34 | vector> varnames; 35 | 36 | int num_cols; 37 | int num_rows; 38 | int num_elems; 39 | float *matrix; 40 | }; 41 | 42 | 43 | S_LP* AsLPItem(shared_ptr item); 44 | -------------------------------------------------------------------------------- /experimental/forthic-nvcc/m_lp/S_LPEquation.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | #include "../StackItem.h" 5 | 6 | #include "../m_global/S_Array.h" 7 | 8 | #include "../m_cuda/M_Cuda.h" 9 | 10 | using namespace std; 11 | 12 | 13 | class S_LPEquation : public StackItem 14 | { 15 | public: 16 | S_LPEquation(vector> coeffs, string name); 17 | virtual ~S_LPEquation(); 18 | 19 | static shared_ptr New(vector> coeffs, string name); 20 | 21 | string GetName() { return name; } 22 | 23 | virtual string StringRep(); 24 | virtual string AsString(); 25 | 26 | int NumCoeffs() { return num_coeffs; } 27 | const float* Coeffs() { return coeffs; } 28 | 29 | protected: 30 | string name; 31 | int num_coeffs; 32 | float* coeffs; 33 | }; 34 | 35 | 36 | S_LPEquation* AsLPEquationItem(shared_ptr item); 37 | -------------------------------------------------------------------------------- /experimental/forthic-nvcc/test/GlobalModuleTest.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include "Test.h" 4 | 5 | class GlobalModuleTest : Test { 6 | public: 7 | GlobalModuleTest(); 8 | void run(); 9 | 10 | private: 11 | void testIntLiteral(); 12 | void testFloatLiteral(); 13 | void testUsingModules(); 14 | void testVariables(); 15 | }; 16 | -------------------------------------------------------------------------------- /experimental/forthic-nvcc/test/InterpreterTest.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "Test.h" 3 | 4 | class InterpreterTest : Test { 5 | public: 6 | InterpreterTest(); 7 | void run(); 8 | 9 | private: 10 | void testPushString(); 11 | void testPushEmptyArray(); 12 | void testPushArray(); 13 | void testPushModule(); 14 | void testCreateDefinition(); 15 | }; -------------------------------------------------------------------------------- /experimental/forthic-nvcc/test/ModuleTest.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include "Test.h" 4 | 5 | class ModuleTest : Test { 6 | public: 7 | ModuleTest(); 8 | void run(); 9 | 10 | private: 11 | void testEmptyModule(); 12 | void testAddWord(); 13 | void testEnsureVariable(); 14 | void testSearchUsingModule(); 15 | }; 16 | -------------------------------------------------------------------------------- /experimental/forthic-nvcc/test/Test.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "Test.h" 4 | 5 | Test::Test() { 6 | } 7 | 8 | void Test::printFailure(bool failed, const char* file, int line) { 9 | if (failed) printf("=> FAIL %s:%d\n", file, line); 10 | } 11 | 12 | bool Test::isCloseEnough(float l, float r) { 13 | double tolerance = 1E-5; 14 | return fabs(l - r) <= tolerance; 15 | } 16 | -------------------------------------------------------------------------------- /experimental/forthic-nvcc/test/Test.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class Test { 4 | public: 5 | Test(); 6 | void printFailure(bool failure, const char* file, int line); 7 | bool isCloseEnough(float l, float r); 8 | }; 9 | -------------------------------------------------------------------------------- /experimental/forthic-nvcc/test/TokenizerTest.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | class TokenizerTest { 5 | public: 6 | TokenizerTest(); 7 | void run(); 8 | 9 | protected: 10 | void printFailure(bool pass, const char* testName); 11 | 12 | private: 13 | void testWhitespace(); 14 | void testComment(); 15 | void testStartEndDefinition(); 16 | void testStartEndArray(); 17 | void testStartEndNamedModule(); 18 | void testAnonymousModule(); 19 | void testTripleQuote(); 20 | void testTripleQuoteString(); 21 | void testString(); 22 | void testWord(); 23 | 24 | private: 25 | std::string name; 26 | }; 27 | -------------------------------------------------------------------------------- /experimental/forthic-nvcc/test/dummy.cu: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linkedin/forthic/dd84e4145e2a89df83026313d22e8885835502ab/experimental/forthic-nvcc/test/dummy.cu -------------------------------------------------------------------------------- /experimental/forthic-nvcc/test/main_test.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "TokenizerTest.h" 4 | #include "ModuleTest.h" 5 | #include "InterpreterTest.h" 6 | #include "GlobalModuleTest.h" 7 | 8 | using namespace std; 9 | 10 | int main() { 11 | TokenizerTest tokenizerTest; 12 | ModuleTest moduleTest; 13 | InterpreterTest interpTest; 14 | GlobalModuleTest globalModuleTest; 15 | 16 | try { 17 | tokenizerTest.run(); 18 | moduleTest.run(); 19 | interpTest.run(); 20 | globalModuleTest.run(); 21 | } 22 | catch (const char *message) { 23 | printf("EXCEPTION: %s\n", message); 24 | } 25 | catch (string message) { 26 | printf("EXCEPTION: %s\n", message.c_str()); 27 | } 28 | return 0; 29 | } 30 | -------------------------------------------------------------------------------- /experimental/forthic-rs/.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | .env -------------------------------------------------------------------------------- /experimental/forthic-rs/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "forthic-rs" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 7 | 8 | [dependencies] 9 | enum_dispatch = "0.3.12" 10 | itertools = "0.12.0" 11 | lazy_static = "1.4" 12 | -------------------------------------------------------------------------------- /experimental/forthic-rs/Makefile: -------------------------------------------------------------------------------- 1 | test: 2 | cargo test --manifest-path ./tests/Cargo.toml -------------------------------------------------------------------------------- /experimental/forthic-rs/src/errors.rs: -------------------------------------------------------------------------------- 1 | #[derive(Debug)] 2 | pub struct InterpreterError { 3 | pub message: String, 4 | pub filename: String, 5 | pub line: u32, 6 | } 7 | 8 | #[macro_export] 9 | macro_rules! interpreter_error { 10 | ($msg:expr) => { 11 | InterpreterError { 12 | message: $msg.to_string(), 13 | filename: file!().to_string(), 14 | line: line!(), 15 | } 16 | }; 17 | } 18 | -------------------------------------------------------------------------------- /experimental/forthic-rs/src/lib.rs: -------------------------------------------------------------------------------- 1 | pub mod errors; 2 | pub mod token; 3 | pub mod tokenizer; 4 | -------------------------------------------------------------------------------- /experimental/forthic-rs/src/main.rs: -------------------------------------------------------------------------------- 1 | mod errors; 2 | mod token; 3 | mod tokenizer; 4 | 5 | use tokenizer::Tokenizer; 6 | 7 | fn main() { 8 | let mut lexer = Tokenizer::new("Hello, world!"); 9 | let t = lexer.next_token().unwrap(); 10 | println!("{:?}", t); 11 | } 12 | -------------------------------------------------------------------------------- /experimental/forthic-rs/src/token.rs: -------------------------------------------------------------------------------- 1 | #[derive(Debug, PartialEq, Clone)] 2 | pub enum Token { 3 | String(String), 4 | Comment(String), 5 | StartArray, 6 | EndArray, 7 | StartModule(String), 8 | EndModule, 9 | StartDefinition(String), 10 | EndDefinition, 11 | StartMemo(String), 12 | Word(String), 13 | EOS, 14 | } 15 | -------------------------------------------------------------------------------- /experimental/forthic-rs/tests/.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | .env -------------------------------------------------------------------------------- /experimental/forthic-rs/tests/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "tests_rs" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 7 | 8 | [dependencies] 9 | forthic-rs = { path="../../forthic-rs" } 10 | -------------------------------------------------------------------------------- /experimental/forthic-rs/tests/src/lib.rs: -------------------------------------------------------------------------------- 1 | mod test_tokenizer; 2 | -------------------------------------------------------------------------------- /experimental/forthic-swift/.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | -------------------------------------------------------------------------------- /experimental/forthic-swift/Forthic/.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | /.build 3 | /Packages 4 | /*.xcodeproj 5 | xcuserdata/ 6 | DerivedData/ 7 | .swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata 8 | -------------------------------------------------------------------------------- /experimental/forthic-swift/Forthic/Package.resolved: -------------------------------------------------------------------------------- 1 | { 2 | "object": { 3 | "pins": [ 4 | { 5 | "package": "swift-collections", 6 | "repositoryURL": "https://github.com/apple/swift-collections.git", 7 | "state": { 8 | "branch": null, 9 | "revision": "48254824bb4248676bf7ce56014ff57b142b77eb", 10 | "version": "1.0.2" 11 | } 12 | } 13 | ] 14 | }, 15 | "version": 1 16 | } 17 | -------------------------------------------------------------------------------- /experimental/forthic-swift/Forthic/README.md: -------------------------------------------------------------------------------- 1 | # Forthic 2 | 3 | A description of this package. 4 | -------------------------------------------------------------------------------- /experimental/forthic-swift/Forthic/Sources/Forthic/Tokens.swift: -------------------------------------------------------------------------------- 1 | class Token { 2 | } 3 | 4 | 5 | class StringToken : Token { 6 | var str: String 7 | 8 | init(string: String) { 9 | self.str = string 10 | } 11 | } 12 | 13 | 14 | class CommentToken : Token { 15 | var str: String 16 | 17 | init(string: String) { 18 | self.str = string 19 | } 20 | } 21 | 22 | 23 | class StartArrayToken : Token { 24 | } 25 | 26 | 27 | class EndArrayToken : Token { 28 | } 29 | 30 | 31 | class StartModuleToken : Token { 32 | var name: String 33 | 34 | init(name: String) { 35 | self.name = name 36 | } 37 | } 38 | 39 | 40 | class EndModuleToken : Token { 41 | } 42 | 43 | 44 | class StartDefinitionToken : Token { 45 | var name: String 46 | 47 | init(name: String) { 48 | self.name = name 49 | } 50 | } 51 | 52 | 53 | class EndDefinitionToken : Token { 54 | } 55 | 56 | class WordToken : Token { 57 | var name: String 58 | 59 | init(name: String) { 60 | self.name = name 61 | } 62 | } 63 | 64 | 65 | class EOSToken: Token { 66 | } 67 | -------------------------------------------------------------------------------- /experimental/forthic-zig/.gitignore: -------------------------------------------------------------------------------- 1 | zig-cache/ 2 | zig-out/ 3 | /release/ 4 | /debug/ 5 | /build/ 6 | /build-*/ 7 | /docgen_tmp/ -------------------------------------------------------------------------------- /experimental/forthic-zig/Makefile: -------------------------------------------------------------------------------- 1 | run: 2 | zig build run 3 | 4 | test: 5 | zig test src/forthic/tokenizer.zig 6 | zig test src/forthic/token.zig -------------------------------------------------------------------------------- /experimental/forthic-zig/src/main.zig: -------------------------------------------------------------------------------- 1 | const std = @import("std"); 2 | const tok = @import("forthic/tokenizer.zig"); 3 | 4 | pub fn main() !void { 5 | // Prints to stderr (it's a shortcut based on `std.io.getStdErr()`) 6 | std.debug.print("All your {s} are belong to us.\n", .{"codebase"}); 7 | 8 | // stdout is for the actual output of your application, for example if you 9 | // are implementing gzip, then only the compressed bytes should be sent to 10 | // stdout, not any debugging messages. 11 | const stdout_file = std.io.getStdOut().writer(); 12 | var bw = std.io.bufferedWriter(stdout_file); 13 | const stdout = bw.writer(); 14 | 15 | try stdout.print("Run `zig build test` to run the tests.\n", .{}); 16 | 17 | try bw.flush(); // don't forget to flush! 18 | } 19 | 20 | test "simple test" { 21 | var list = std.ArrayList(i32).init(std.testing.allocator); 22 | defer list.deinit(); // try commenting this out and see if zig detects the memory leak! 23 | try list.append(42); 24 | try std.testing.expectEqual(@as(i32, 42), list.pop()); 25 | } 26 | -------------------------------------------------------------------------------- /experimental/forthic-zig/src/root.zig: -------------------------------------------------------------------------------- 1 | const std = @import("std"); 2 | const testing = std.testing; 3 | 4 | export fn add(a: i32, b: i32) i32 { 5 | return a + b; 6 | } 7 | 8 | test "basic add functionality" { 9 | try testing.expect(add(3, 7) == 10); 10 | } 11 | -------------------------------------------------------------------------------- /experimental/pre-forthic/forrth-asm/forrth/BLOCK-1.forrth: -------------------------------------------------------------------------------- 1 | : taco PRINT-HI PRINT-HI ; 2 | 3 | : M1 ." This is message1!" ; 4 | : M2 ." Second message?!" ; 5 | 6 | M1 M2 .S .S -------------------------------------------------------------------------------- /experimental/pre-forthic/forrth-asm/forrth/Constants.inc: -------------------------------------------------------------------------------- 1 | ;; File : Constants_.inc 2 | ;; Created date : 11/19/2017 3 | ;; Last update : 11/24/2017 4 | ;; Author : Rino Jose 5 | ;; Description : Defines constants for Forrth interpreter 6 | 7 | RETSTACKLEN EQU 32 8 | STACKLEN EQU 32 ; Length of parameter stack 9 | 10 | MAXWORDLEN EQU 63 ; Max word length 11 | 12 | BUFFERLEN EQU 1024*10 ; Length of MessageBuffer_ 13 | 14 | NUM_ENTRIES EQU 512 ; Number of entries in the Dictionary_ 15 | 16 | AVG_ENTRY_SIZE EQU 48 ; This is in double words. It assumes that EntryWord is 32 17 | ; double words and we have roughly 10 parameters 18 | 19 | DICTIONARY_SIZE EQU NUM_ENTRIES * AVG_ENTRY_SIZE ; double words 20 | 21 | DICTIONARY_STRING_SIZE EQU 1024*100 ; 100K 22 | 23 | EOF EQU -1 ; Checked EOF char in C++ -------------------------------------------------------------------------------- /experimental/pre-forthic/forrth-asm/forrth/ERROR_DESIGN.txt: -------------------------------------------------------------------------------- 1 | ;;============================================================================== 2 | ;; File: ERROR_DESIGN.txt 3 | ;; Created date: 11/25/2017 4 | ;; Last update: 11/25/2017 5 | ;; Author: Rino Jose 6 | ;; Description: Describes error handling 7 | ;; 8 | 9 | One type of error is the invalid word. 10 | If a word is not in the dictionary and cannot be parsed as a literal, it is an invalid word. 11 | To handle an invalid word, we print the word and then reset the Forrth state. 12 | During the next pass of the control loop, the next word will be read from input. 13 | 14 | 15 | Another type of error is when something goes wrong with the execution of an instruction. 16 | We must check the result of executing an instruction and indicate what went wrong if possible. 17 | After that, we reset the interpreter state. 18 | 19 | 20 | RESETTING FORRTH STATE 21 | 22 | To handle an invalid word, we print the word and then reset the parameter stack, return stack, instruction pointer, GetNextWord func ptr. 23 | -------------------------------------------------------------------------------- /experimental/pre-forthic/forrth-asm/forrth/Entry.inc: -------------------------------------------------------------------------------- 1 | ;;============================================================================== 2 | ;; File : Entry.inc 3 | ;; Created date : 11/20/2017 4 | ;; Last update : 11/25/2017 5 | ;; Author : Rino Jose 6 | ;; Description : Defines Entry structure 7 | 8 | ;------------------------------------------------------------------------------- 9 | ; Entry: Holds a variable length dictionary entry 10 | ; 11 | ; Last update: 11/20/2017 12 | ; Description: A dictionary entry has 4 fields: 13 | ; 1. The name of the word being executed 14 | ; 2. The code to be executed 15 | ; 3. A link to the previous entry 16 | ; 4. Parameters (variable length) 17 | ; 18 | Entry struct 19 | EntryWord db (MAXWORDLEN+1) DUP(?) 20 | Routine dd ? 21 | Previous dd ? 22 | Immediate db 0 23 | Parameter dd ? 24 | Entry ends -------------------------------------------------------------------------------- /experimental/pre-forthic/forrth-asm/forrth/UninitializedData.asm: -------------------------------------------------------------------------------- 1 | ;;============================================================================== 2 | ;; File : UninitializedData.asm 3 | ;; Created date : 12/02/2017 4 | ;; Last update : 12/02/2017 5 | ;; Author : Rino Jose 6 | ;; Description : Declares uninitialized data 7 | ;; 8 | 9 | .model flat,c 10 | 11 | ;;============================================================================== 12 | ;; INCLUDES 13 | include Constants.inc 14 | 15 | ;;============================================================================== 16 | ;; PUBLIC 17 | public DictionaryStrings_ 18 | 19 | 20 | ;;============================================================================== 21 | ;; DATA 22 | .data? 23 | DictionaryStrings_ db DICTIONARY_STRING_SIZE DUP(?) 24 | 25 | end -------------------------------------------------------------------------------- /experimental/pre-forthic/forrth-asm/forrth/forrth.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linkedin/forthic/dd84e4145e2a89df83026313d22e8885835502ab/experimental/pre-forthic/forrth-asm/forrth/forrth.cpp -------------------------------------------------------------------------------- /experimental/pre-forthic/forrth-asm/forrth/stdafx.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linkedin/forthic/dd84e4145e2a89df83026313d22e8885835502ab/experimental/pre-forthic/forrth-asm/forrth/stdafx.cpp -------------------------------------------------------------------------------- /experimental/pre-forthic/forrth-asm/forrth/stdafx.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linkedin/forthic/dd84e4145e2a89df83026313d22e8885835502ab/experimental/pre-forthic/forrth-asm/forrth/stdafx.h -------------------------------------------------------------------------------- /experimental/pre-forthic/forrth-asm/forrth/targetver.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linkedin/forthic/dd84e4145e2a89df83026313d22e8885835502ab/experimental/pre-forthic/forrth-asm/forrth/targetver.h -------------------------------------------------------------------------------- /experimental/pre-forthic/forrth-cs/HoloForrth/AppViewSource.cs: -------------------------------------------------------------------------------- 1 | using Windows.ApplicationModel.Core; 2 | 3 | namespace HoloForrth 4 | { 5 | // The entry point for the app. 6 | internal class AppViewSource : IFrameworkViewSource 7 | { 8 | public IFrameworkView CreateView() 9 | { 10 | return new AppView(); 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /experimental/pre-forthic/forrth-cs/HoloForrth/Assets/LockScreenLogo.scale-200.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linkedin/forthic/dd84e4145e2a89df83026313d22e8885835502ab/experimental/pre-forthic/forrth-cs/HoloForrth/Assets/LockScreenLogo.scale-200.png -------------------------------------------------------------------------------- /experimental/pre-forthic/forrth-cs/HoloForrth/Assets/SplashScreen.scale-200.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linkedin/forthic/dd84e4145e2a89df83026313d22e8885835502ab/experimental/pre-forthic/forrth-cs/HoloForrth/Assets/SplashScreen.scale-200.png -------------------------------------------------------------------------------- /experimental/pre-forthic/forrth-cs/HoloForrth/Assets/Square150x150Logo.scale-200.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linkedin/forthic/dd84e4145e2a89df83026313d22e8885835502ab/experimental/pre-forthic/forrth-cs/HoloForrth/Assets/Square150x150Logo.scale-200.png -------------------------------------------------------------------------------- /experimental/pre-forthic/forrth-cs/HoloForrth/Assets/Square44x44Logo.scale-200.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linkedin/forthic/dd84e4145e2a89df83026313d22e8885835502ab/experimental/pre-forthic/forrth-cs/HoloForrth/Assets/Square44x44Logo.scale-200.png -------------------------------------------------------------------------------- /experimental/pre-forthic/forrth-cs/HoloForrth/Assets/Square44x44Logo.targetsize-24_altform-unplated.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linkedin/forthic/dd84e4145e2a89df83026313d22e8885835502ab/experimental/pre-forthic/forrth-cs/HoloForrth/Assets/Square44x44Logo.targetsize-24_altform-unplated.png -------------------------------------------------------------------------------- /experimental/pre-forthic/forrth-cs/HoloForrth/Assets/StoreLogo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linkedin/forthic/dd84e4145e2a89df83026313d22e8885835502ab/experimental/pre-forthic/forrth-cs/HoloForrth/Assets/StoreLogo.png -------------------------------------------------------------------------------- /experimental/pre-forthic/forrth-cs/HoloForrth/Assets/Wide310x150Logo.scale-200.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linkedin/forthic/dd84e4145e2a89df83026313d22e8885835502ab/experimental/pre-forthic/forrth-cs/HoloForrth/Assets/Wide310x150Logo.scale-200.png -------------------------------------------------------------------------------- /experimental/pre-forthic/forrth-cs/HoloForrth/Content/ShaderStructures.cs: -------------------------------------------------------------------------------- 1 | using System.Numerics; 2 | 3 | namespace HoloForrth.Content 4 | { 5 | /// 6 | /// Constant buffer used to send hologram position transform to the shader pipeline. 7 | /// 8 | internal struct ModelConstantBuffer 9 | { 10 | public Matrix4x4 model; 11 | } 12 | 13 | /// 14 | /// Used to send per-vertex data to the vertex shader. 15 | /// 16 | internal struct VertexPositionColor 17 | { 18 | public VertexPositionColor(Vector3 pos, Vector3 color) 19 | { 20 | this.pos = pos; 21 | this.color = color; 22 | } 23 | 24 | public Vector3 pos; 25 | public Vector3 color; 26 | }; 27 | } 28 | -------------------------------------------------------------------------------- /experimental/pre-forthic/forrth-cs/HoloForrth/Content/Shaders/GeometryShader.hlsl: -------------------------------------------------------------------------------- 1 | // Per-vertex data from the vertex shader. 2 | struct GeometryShaderInput 3 | { 4 | min16float4 pos : SV_POSITION; 5 | min16float3 color : COLOR0; 6 | uint instId : TEXCOORD0; 7 | }; 8 | 9 | // Per-vertex data passed to the rasterizer. 10 | struct GeometryShaderOutput 11 | { 12 | min16float4 pos : SV_POSITION; 13 | min16float3 color : COLOR0; 14 | uint rtvId : SV_RenderTargetArrayIndex; 15 | }; 16 | 17 | // This geometry shader is a pass-through that leaves the geometry unmodified 18 | // and sets the render target array index. 19 | [maxvertexcount(3)] 20 | void main(triangle GeometryShaderInput input[3], inout TriangleStream outStream) 21 | { 22 | GeometryShaderOutput output; 23 | [unroll(3)] 24 | for (int i = 0; i < 3; ++i) 25 | { 26 | output.pos = input[i].pos; 27 | output.color = input[i].color; 28 | output.rtvId = input[i].instId; 29 | outStream.Append(output); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /experimental/pre-forthic/forrth-cs/HoloForrth/Content/Shaders/PixelShader.hlsl: -------------------------------------------------------------------------------- 1 | // Per-pixel color data passed through the pixel shader. 2 | struct PixelShaderInput 3 | { 4 | min16float4 pos : SV_POSITION; 5 | min16float3 color : COLOR0; 6 | }; 7 | 8 | // The pixel shader passes through the color data. The color data from 9 | // is interpolated and assigned to a pixel at the rasterization step. 10 | min16float4 main(PixelShaderInput input) : SV_TARGET 11 | { 12 | return min16float4(input.color, 1.0f); 13 | } 14 | -------------------------------------------------------------------------------- /experimental/pre-forthic/forrth-cs/HoloForrth/Content/Shaders/VPRTVertexShader.hlsl: -------------------------------------------------------------------------------- 1 | // Per-vertex data passed to the geometry shader. 2 | struct VertexShaderOutput 3 | { 4 | min16float4 pos : SV_POSITION; 5 | min16float3 color : COLOR0; 6 | 7 | // The render target array index is set here in the vertex shader. 8 | uint viewId : SV_RenderTargetArrayIndex; 9 | }; 10 | 11 | #include "VertexShaderShared.hlsl" 12 | -------------------------------------------------------------------------------- /experimental/pre-forthic/forrth-cs/HoloForrth/Content/Shaders/VertexShader.hlsl: -------------------------------------------------------------------------------- 1 | // Per-vertex data passed to the geometry shader. 2 | struct VertexShaderOutput 3 | { 4 | min16float4 pos : SV_POSITION; 5 | min16float3 color : COLOR0; 6 | 7 | // The render target array index will be set by the geometry shader. 8 | uint viewId : TEXCOORD0; 9 | }; 10 | 11 | #include "VertexShaderShared.hlsl" 12 | -------------------------------------------------------------------------------- /experimental/pre-forthic/forrth-cs/HoloForrth/Entry.cs: -------------------------------------------------------------------------------- 1 | //============================================================================== 2 | // File: Entry.cs 3 | // Created date: 12/04/2017 4 | // Last update: 12/09/2017 5 | // Author: Rino Jose 6 | // Description: Implements a dictionary entry 7 | // 8 | 9 | using System; 10 | using System.Collections.Generic; 11 | using System.Linq; 12 | using System.Text; 13 | using System.Threading.Tasks; 14 | 15 | namespace HoloForrth 16 | { 17 | class Entry 18 | { 19 | public delegate void EntryRoutine(Forrth f, Entry entry); 20 | 21 | public string word; 22 | public List parameters; 23 | public EntryRoutine Routine; 24 | public bool immediate; 25 | 26 | 27 | public Entry(string word, EntryRoutine routine) 28 | { 29 | this.word = word; 30 | this.Routine = routine; 31 | parameters = new List(); 32 | immediate = false; 33 | } 34 | 35 | public Entry(string word, EntryRoutine routine, bool immediate) : this(word, routine) 36 | { 37 | this.immediate = immediate; 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /experimental/pre-forthic/forrth-cs/HoloForrth/Literals.cs: -------------------------------------------------------------------------------- 1 | using System.Diagnostics; 2 | 3 | namespace HoloForrth 4 | { 5 | class PseudoEntryPushValue : Entry 6 | { 7 | public PseudoEntryPushValue(object value) : base("PseudoEntryPushValue", PushValue) 8 | { 9 | parameters.Add(value); // Param 0 is the value to push 10 | } 11 | 12 | static void PushValue(Forrth f, Entry entry) 13 | { 14 | object value = entry.parameters[0]; 15 | f.Stack.Push(value); 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /experimental/pre-forthic/forrth-cs/HoloForrth/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Windows.ApplicationModel.Core; 3 | 4 | namespace HoloForrth 5 | { 6 | /// 7 | /// Windows Holographic application using SharpDX. 8 | /// 9 | internal class Program 10 | { 11 | /// 12 | /// Defines the entry point of the application. 13 | /// 14 | [MTAThread] 15 | private static void Main() 16 | { 17 | var exclusiveViewApplicationSource = new AppViewSource(); 18 | CoreApplication.Run(exclusiveViewApplicationSource); 19 | } 20 | } 21 | } -------------------------------------------------------------------------------- /experimental/pre-forthic/forrth-cs/HoloForrth/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("HoloForrth")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | 13 | [assembly: AssemblyProduct("HoloForrth")] 14 | [assembly: AssemblyCopyright("Copyright © 2017")] 15 | 16 | [assembly: AssemblyTrademark("")] 17 | [assembly: AssemblyCulture("")] 18 | 19 | // Version information for an assembly consists of the following four values: 20 | // 21 | // Major Version 22 | // Minor Version 23 | // Build Number 24 | // Revision 25 | // 26 | // You can specify all the values or you can default the Build and Revision Numbers 27 | // by using the '*' as shown below: 28 | // [assembly: AssemblyVersion("1.0.*")] 29 | [assembly: AssemblyVersion("1.0.0.0")] 30 | [assembly: AssemblyFileVersion("1.0.0.0")] 31 | [assembly: ComVisible(false)] 32 | -------------------------------------------------------------------------------- /experimental/pre-forthic/forrth-cs/HoloForrth/Specs/LITERALS.txt: -------------------------------------------------------------------------------- 1 | ;;============================================================================== 2 | ;; File: LITERALS.txt 3 | ;; Created date: 12/07/2017 4 | ;; Last update: 12/07/2017 5 | ;; Author: Rino Jose 6 | ;; Description: Describes treatment of literals 7 | ;; 8 | 9 | If a word cannot be found in the dictionary, the next step is to try viewing it as a literal value. 10 | 11 | First, we should see if the string is an integer. 12 | 13 | Second, we should see if the string is a floating point. 14 | 15 | If a literal is found, we return a PseudoEntry that pushes the value onto the stack. 16 | -------------------------------------------------------------------------------- /experimental/pre-forthic/forrth-cs/HoloForrth/Specs/PROCESSING_INPUT.txt: -------------------------------------------------------------------------------- 1 | ;;============================================================================== 2 | ;; File: PROCESSING_INPUT.txt 3 | ;; Created date: 12/03/2017 4 | ;; Last update: 12/03/2017 5 | ;; Author: Rino Jose 6 | ;; Description: Describes how the input string is processed 7 | ;; 8 | 9 | The first step is to break the input string into a linked list of words. 10 | We'll use a regular expression to parse out the word and the rest of the string and loop until done. 11 | Each word will be added to the end of a linked list. 12 | When a word is executed, it may result in a nested execution. 13 | In this case, words are added after the word that was executed and execution continues from there. -------------------------------------------------------------------------------- /experimental/pre-forthic/forrth-erl/.gitignore: -------------------------------------------------------------------------------- 1 | *.beam 2 | -------------------------------------------------------------------------------- /experimental/pre-forthic/forrth-erl/BLOCK-1.forrth: -------------------------------------------------------------------------------- 1 | # This is a comment 2 | : taco ( -- ) PRINT-HI PRINT-HI ; # Another comment 3 | 4 | ." taco" INTERPRET 5 | -------------------------------------------------------------------------------- /experimental/pre-forthic/forrth-erl/specs/DICTIONARY.txt: -------------------------------------------------------------------------------- 1 | %%============================================================================== 2 | %% File: DICTIONARY.txt 3 | %% Created date: 12/16/2017 4 | %% Last update: 12/16/2017 5 | %% Author: Rino Jose 6 | %% Description: Describes dictionaries 7 | %% 8 | 9 | A dictionary is a list of entries. 10 | 11 | A dictionary is traversed from most recent addition to least. 12 | 13 | An entry has the following form: 14 | 15 | -record(entry, {word, routine, parameters, immediate}). 16 | 17 | A dictionary is a list of entries in a forrth record. 18 | 19 | A forrth record has the following form: 20 | 21 | -record(forrth, {dictionary, stack, return_stack, compiling}) 22 | 23 | A forrth record is created on initialization. This also creates a dictionary. 24 | 25 | The core words are added during initialization. 26 | 27 | There is a function called find_entry that searches a forrth dictionary for a word. 28 | 29 | We use undefined to indicate that an entry could not be found. -------------------------------------------------------------------------------- /experimental/pre-forthic/forrth-erl/specs/FERRTH.txt: -------------------------------------------------------------------------------- 1 | %%============================================================================== 2 | %% File: FERRTH.txt 3 | %% Created date: 12/15/2017 4 | %% Last update: 12/17/2017 5 | %% Author: Rino Jose 6 | %% Description: Describes design of Ferlang 7 | %% 8 | 9 | Ferlang is an implementation of Forrth in Erlang. 10 | 11 | Each Ferlang server runs an instance of a Forrth interpreter. 12 | 13 | Forrth messages can be sent to Ferlang servers. 14 | 15 | The Forrth interpreter state is passed with each request. 16 | 17 | A request may have an empty Forrth state but use a Ferlang server to get a copy 18 | 19 | We should send Forrth messages to processes. 20 | 21 | When a process starts, it should create Forrth data items and initialize the dictionary. 22 | 23 | We should start by building a single forrth interpreter and seeing what it takes to implement. 24 | 25 | Should a server implement only one function? 26 | 27 | Server type: WordGetter 28 | Server type: Dictionary 29 | Server type: ProcessInput 30 | 31 | This doesn't seem right. 32 | 33 | A Forrth-ts system should be able to call into a Ferlang cluster. 34 | 35 | QUESTIONS 36 | 37 | * How do we deal with Forrth interpreters with different dictionaries? -------------------------------------------------------------------------------- /experimental/pre-forthic/forrth-erl/specs/PROCESS_LOOP.txt: -------------------------------------------------------------------------------- 1 | %%============================================================================== 2 | %% File: PROCESS_LOOP.txt 3 | %% Created date: 12/16/2017 4 | %% Last update: 12/16/2017 5 | %% Author: Rino Jose 6 | %% Description: Describes how parsed input is executed 7 | %% 8 | 9 | To process a list of input words, we call execute_words. 10 | 11 | |execute_words| takes a Forrth record and a list of input words. 12 | 13 | Each input word is looked up in the Forrth dictionary. 14 | 15 | If an entry is found, its routine is executed. 16 | 17 | If an entry is not found, we call an error routine to print a message and reset Forrth. 18 | 19 | -------------------------------------------------------------------------------- /experimental/pre-forthic/forrth-erl/specs/TASKS: -------------------------------------------------------------------------------- 1 | %%============================================================================== 2 | %% File: TASKS.txt 3 | %% Created date: 12/15/2017 4 | %% Last update: 12/15/2017 5 | %% Author: Rino Jose 6 | %% Description: Maintains current task list 7 | %% 8 | 9 | TASKS 10 | 11 | * Handle comments 12 | -------------------------------------------------------------------------------- /experimental/pre-forthic/forrth-f90/.gitignore: -------------------------------------------------------------------------------- 1 | *.o 2 | *.mod 3 | forrthtran -------------------------------------------------------------------------------- /experimental/pre-forthic/forrth-f90/BLOCK-1.forrth: -------------------------------------------------------------------------------- 1 | # Defines a couple of new words 2 | : TACO PRINT-HI PRINT-HI ; 3 | : 2TACO TACO TACO ; -------------------------------------------------------------------------------- /experimental/pre-forthic/forrth-f90/Makefile: -------------------------------------------------------------------------------- 1 | FORTRAN_STD=f2003 2 | OBJ = constants.o core_words.o forrth_entry_sr.o forrth_sr.o forrth_types.o \ 3 | items.o parse_input.o process_input.o 4 | 5 | forrthtran: forrthtran.f90 $(OBJ) 6 | gfortran -g -std=$(FORTRAN_STD) -o forrthtran $< $(OBJ) 7 | 8 | %.o:%.f90 9 | gfortran -g -std=$(FORTRAN_STD) -c $< 10 | 11 | 12 | constants.mod: constants.o 13 | 14 | forrth_types.mod: constants.mod forrth_types.o 15 | 16 | parse_input_sr.mod: constants.mod forrth_types.mod parse_input.o 17 | 18 | items.mod: constants.mod forrth_types.mod items.o 19 | 20 | forrth_sr.mod: constants.mod forrth_types.mod items.mod forrth_sr.o 21 | 22 | core_words.mod: core_words.o 23 | 24 | forrth_entry_sr.mod: constants.mod forrth_types.mod items.mod forrth_entry_sr.o 25 | 26 | process_input_sr.mod: forrth_types.mod parse_input_sr.mod forrth_sr.mod \ 27 | items.mod process_input_sr.mod core_words.mod 28 | 29 | core_words.o: constants.mod forrth_types.mod parse_input_sr.mod \ 30 | items.mod forrth_sr.mod 31 | 32 | clean: 33 | rm *.o *.mod forrthtran -------------------------------------------------------------------------------- /experimental/pre-forthic/forrth-f90/forrth_entry_sr.f90: -------------------------------------------------------------------------------- 1 | !!============================================================================== 2 | !! File: forrth_entry_sr.f90 3 | !! Created date: 01/03/2018 4 | !! Last update: 01/03/2018 5 | !! Author: Rino Jose 6 | !! Description: Defines functions for manipulating ForrthEntries 7 | !! 8 | 9 | MODULE forrth_entry_sr 10 | USE constants 11 | USE forrth_types 12 | USE items 13 | 14 | CONTAINS 15 | 16 | !!-------------------------------------------------------------------------- 17 | !! compile_entry: Compiles entry into current definition 18 | !! Last update: 01/03/2018 19 | !! 20 | SUBROUTINE compile_entry(f, entry_index) 21 | type(ForrthState) :: f 22 | integer :: entry_index 23 | 24 | ! TODO: Test cur size of ItemPointerArray 25 | END SUBROUTINE compile_entry 26 | 27 | END MODULE forrth_entry_sr -------------------------------------------------------------------------------- /experimental/pre-forthic/forrth-f90/forrthtran.f90: -------------------------------------------------------------------------------- 1 | !!============================================================================== 2 | !! File: forrthtran.f90 3 | !! Created date: 12/28/2017 4 | !! Last update: 01/02/2018 5 | !! Author: Rino Jose 6 | !! Description: Runs Forrth in a fortran environment 7 | !! 8 | PROGRAM forrthtran 9 | USE constants 10 | USE forrth_types 11 | USE forrth_sr 12 | USE process_input_sr 13 | USE items 14 | USE core_words 15 | 16 | IMPLICIT none 17 | 18 | integer :: i_err, entry_index 19 | type (ForrthState) :: forrth 20 | character (len=MESSAGE_BUFFER_LEN) :: buffer 21 | integer :: load_result 22 | 23 | ! Initialize items and the Forrth state 24 | CALL init_items 25 | CALL init_forrth(forrth) 26 | CALL add_core_words(forrth) 27 | 28 | ! Run REPL 29 | do while( .true. ) 30 | ! Read input into buffer 31 | READ(unit=*, fmt='(a)', iostat=i_err) buffer 32 | if ( i_err .NE. 0 ) exit 33 | 34 | ! Load forrth message buffer and process 35 | CALL load_msg_buffer(forrth, buffer, load_result) 36 | CALL process_input(forrth) 37 | end do 38 | 39 | 40 | END PROGRAM forrthtran -------------------------------------------------------------------------------- /experimental/pre-forthic/forrth-f90/specs/FORRTHTRAN.txt: -------------------------------------------------------------------------------- 1 | !!============================================================================== 2 | !! File: FORRTHTRAN.txt 3 | !! Created date: 12/28/2017 4 | !! Last update: 12/28/2017 5 | !! Author: Rino Jose 6 | !! Description: Describes overall design of Forrthtran 7 | !! 8 | 9 | All constants should be defined in a constants.f90 file. 10 | 11 | The Forrth state should be held in a Forrth object. 12 | 13 | The Forrth state should be passed into every subroutine that works on Forrth. 14 | 15 | When parameters are built up, we should use a linked list. 16 | 17 | When a definition is done, we should allocate an array, copy the list, and free the list. 18 | 19 | We need to implement a linked list type. 20 | 21 | The linked list type will be used with the dictionary. 22 | 23 | When we parse words out of the message buffer, we will use two integers (start and end). 24 | 25 | This will be managed by a type called StringIndexes. -------------------------------------------------------------------------------- /experimental/pre-forthic/forrth-f90/specs/TASKS: -------------------------------------------------------------------------------- 1 | !!============================================================================== 2 | !! File: TASKS.txt 3 | !! Created date: 12/28/2017 4 | !! Last update: 01/04/2018 5 | !! Author: Rino Jose 6 | !! Description: List of things to do 7 | !! 8 | 9 | * Think about support for data 10 | * Add support for lexicons 11 | -------------------------------------------------------------------------------- /forthic-in/README.md: -------------------------------------------------------------------------------- 1 | # README.md 2 | 3 | This is a legacy version of Forthic that runs LinkedIn's internal Forthic apps. 4 | It's here to provide backwards compatibility only and should not be used outside of LinkedIn. 5 | -------------------------------------------------------------------------------- /forthic-in/docs/v1/README.md: -------------------------------------------------------------------------------- 1 | # modules/v1 2 | 3 | This is included for completeness only. Forthic v1 is internal to LinkedIn and was not open-sourced. -------------------------------------------------------------------------------- /forthic-in/docs/v2/cache_module.md: -------------------------------------------------------------------------------- 1 | # cache_module 2 | 3 | The cache module allows you to store the top of the stack on disk as JSON (the 4 | stored object must be JSON serializable) and retrieve it later. This is useful 5 | for storing expensive computations or API responses. 6 | 7 | The data is stored in a `.cache` file in the working directory. The directory 8 | can be set using the `CWD!` word. 9 | 10 | Every object is stored and retrieved using a label. 11 | 12 | ## Example 13 | ``` 14 | ["cache"] USE-MODULES 15 | 16 | "~/my_stuff" cache.CWD! # Sets the current working directory 17 | [1 2 3 "Howdy"] "my_array" cache.CACHE! # Stores the array in the cache 18 | 19 | "my_array" cache.CACHE@ # Retrieves the array from cache 20 | 3 NTH # ([1 2 3 "Howdy"] -- "Howdy") 21 | ``` 22 | 23 | ## Reference 24 | 25 | ### CACHE! 26 | `(object key --)` 27 | 28 | Stores `object` in the cache at the specified `key`. The object will be 29 | serialized to JSON. 30 | 31 | 32 | ### CACHE@ 33 | `(key -- object)` 34 | 35 | Retrieves an object from the cache at the specified `key`. The object will be 36 | deserialized from JSON. -------------------------------------------------------------------------------- /forthic-in/docs/v2/jinja_module.md: -------------------------------------------------------------------------------- 1 | # jinja_module 2 | 3 | The jinja module uses the Python [jinja templating 4 | package](https://jinja.palletsprojects.com/en/2.11.x/) to render arbitrary 5 | strings using record data. 6 | 7 | Typically, this is the best choice for rendering html, emails, or anything that 8 | involves looping along with interpolation. 9 | 10 | ## Example 11 | ``` 12 | ["jinja"] USE-MODULES 13 | 14 | : MY-DATA [ 15 | ["letters" ["alpha" "beta" "gamma"]] 16 | ] REC; 17 | 18 | : MY-TEMPLATE " 19 |
    20 | {% for letter in letters %} 21 |
  • {{ letter }}
  • 22 | {% endfor %} 23 |
24 | "; 25 | 26 | MY-TEMPLATE MY-DATA jira.RENDER 27 | ``` 28 | 29 | ## Reference 30 | 31 | ### RENDER 32 | `(template record -- string)` 33 | Given a jinja template and a Forthic record, renders a string using the jinja engine. 34 | 35 | NOTE: The record must have fields that are valid Python variable names since 36 | these are used within the jinja template. -------------------------------------------------------------------------------- /forthic-in/docs/v3/cache_module.md: -------------------------------------------------------------------------------- 1 | # cache_module 2 | 3 | The cache module allows you to store the top of the stack on disk as JSON (the 4 | stored object must be JSON serializable) and retrieve it later. This is useful 5 | for storing expensive computations or API responses. 6 | 7 | The data is stored in a `.cache` file in the working directory. The directory 8 | can be set using the `CWD!` word. 9 | 10 | Every object is stored and retrieved using a label. 11 | 12 | ## Example 13 | ``` 14 | ["cache"] USE-MODULES 15 | 16 | "~/my_stuff" cache.CWD! # Sets the current working directory 17 | [1 2 3 "Howdy"] "my_array" cache.CACHE! # Stores the array in the cache 18 | 19 | "my_array" cache.CACHE@ # Retrieves the array from cache 20 | 3 NTH # ([1 2 3 "Howdy"] -- "Howdy") 21 | ``` 22 | 23 | ## Reference 24 | 25 | ### CACHE! 26 | `(object key --)` 27 | 28 | Stores `object` in the cache at the specified `key`. The object will be 29 | serialized to JSON. 30 | 31 | 32 | ### CACHE@ 33 | `(key -- object)` 34 | 35 | Retrieves an object from the cache at the specified `key`. The object will be 36 | deserialized from JSON. -------------------------------------------------------------------------------- /forthic-in/docs/v3/jinja_module.md: -------------------------------------------------------------------------------- 1 | # jinja_module 2 | 3 | The jinja module uses the Python [jinja templating 4 | package](https://jinja.palletsprojects.com/en/2.11.x/) to render arbitrary 5 | strings using record data. 6 | 7 | Typically, this is the best choice for rendering html, emails, or anything that 8 | involves looping along with interpolation. 9 | 10 | ## Example 11 | ``` 12 | ["jinja"] USE-MODULES 13 | 14 | : MY-DATA [ 15 | ["letters" ["alpha" "beta" "gamma"]] 16 | ] REC; 17 | 18 | : MY-TEMPLATE " 19 |
    20 | {% for letter in letters %} 21 |
  • {{ letter }}
  • 22 | {% endfor %} 23 |
24 | "; 25 | 26 | MY-TEMPLATE MY-DATA jira.RENDER 27 | ``` 28 | 29 | ## Reference 30 | 31 | ### RENDER 32 | `(template record -- string)` 33 | Given a jinja template and a Forthic record, renders a string using the jinja engine. 34 | 35 | NOTE: The record must have fields that are valid Python variable names since 36 | these are used within the jinja template. -------------------------------------------------------------------------------- /forthic-in/forthic/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linkedin/forthic/dd84e4145e2a89df83026313d22e8885835502ab/forthic-in/forthic/__init__.py -------------------------------------------------------------------------------- /forthic-in/forthic/py.typed: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linkedin/forthic/dd84e4145e2a89df83026313d22e8885835502ab/forthic-in/forthic/py.typed -------------------------------------------------------------------------------- /forthic-in/forthic/tests/v1/README.md: -------------------------------------------------------------------------------- 1 | # tests_py/v1 2 | 3 | Forthic v1 has not been open-sourced. -------------------------------------------------------------------------------- /forthic-in/forthic/tests/v2/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linkedin/forthic/dd84e4145e2a89df83026313d22e8885835502ab/forthic-in/forthic/tests/v2/__init__.py -------------------------------------------------------------------------------- /forthic-in/forthic/tests/v2/sample_date_module.py: -------------------------------------------------------------------------------- 1 | from forthic.v2.module import Module 2 | import datetime 3 | 4 | 5 | class SampleDateModule(Module): 6 | def __init__(self, interp): 7 | super().__init__("date", interp) 8 | self.add_module_word("TODAY", self.word_TODAY) 9 | 10 | # ( -- today ) 11 | def word_TODAY(self, interp): 12 | """Pushes today's date 13 | """ 14 | result = datetime.date.today() 15 | interp.stack_push(result) 16 | -------------------------------------------------------------------------------- /forthic-in/forthic/tests/v2/test_tokenizer_errors.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | from forthic.v2.tokenizer import Tokenizer, UnterminatedStringError, InvalidDefinitionError 3 | 4 | 5 | class TestTokenizerErrors(unittest.TestCase): 6 | def test_unterminated_string(self): 7 | """Raise exception if strings are unterminated 8 | """ 9 | tokenizer = Tokenizer("'Unterminated") 10 | self.assertRaises(UnterminatedStringError, tokenizer.next_token) 11 | 12 | def test_start_definition_eos(self): 13 | """Can't have an empty definition 14 | """ 15 | tokenizer = Tokenizer(":") 16 | self.assertRaises(InvalidDefinitionError, tokenizer.next_token) 17 | 18 | def test_start_definition_special_chars(self): 19 | """Can't have definition with Forthic special chars 20 | """ 21 | def check_for_exception(input): 22 | tokenizer = Tokenizer(input) 23 | self.assertRaises(InvalidDefinitionError, tokenizer.next_token) 24 | 25 | invalid_start_defs = [": 'HOWDY", ": HOW'DY", ": HOW[DY", ": HOW]DY", ": HOW{DY", ": HOW}DY"] 26 | 27 | for forthic in invalid_start_defs: 28 | check_for_exception(forthic) 29 | 30 | 31 | if __name__ == '__main__': 32 | unittest.main() 33 | -------------------------------------------------------------------------------- /forthic-in/forthic/tests/v3/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linkedin/forthic/dd84e4145e2a89df83026313d22e8885835502ab/forthic-in/forthic/tests/v3/__init__.py -------------------------------------------------------------------------------- /forthic-in/forthic/tests/v3/modules/datasets_data/.gitignore: -------------------------------------------------------------------------------- 1 | datasets -------------------------------------------------------------------------------- /forthic-in/forthic/tests/v3/modules/datasets_data/README.md: -------------------------------------------------------------------------------- 1 | # README.md 2 | 3 | This is a place to store test data for the datasets module test. -------------------------------------------------------------------------------- /forthic-in/forthic/tests/v3/modules/test_v3_trino_module.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | from forthic.v3.interpreter import Interpreter 3 | from forthic.v3.modules.trino_module import TrinoModule 4 | from tests.tests_py.v3.modules.trino_context import TrinoTestContext 5 | 6 | 7 | def get_interp(): 8 | interp = Interpreter() 9 | interp.register_module(TrinoModule) 10 | 11 | # Set up Trino test context 12 | interp.run("['trino'] USE-MODULES") 13 | interp.stack_push(TrinoTestContext()) 14 | interp.run("trino.PUSH-CONTEXT!") 15 | return interp 16 | 17 | 18 | class TestTrinoModule(unittest.TestCase): 19 | def setUp(self): 20 | self.interp = get_interp() 21 | 22 | def test_QUERY(self): 23 | self.interp.run(""" 24 | 'select * from metric_ds.dim_country_tests' trino.QUERY 25 | """) 26 | data = self.interp.stack[0] 27 | self.assertEqual('alpha', data['test_key']['0']) 28 | self.assertEqual('Tanzania', data['country']['0']) 29 | 30 | 31 | if __name__ == '__main__': 32 | unittest.main() -------------------------------------------------------------------------------- /forthic-in/forthic/tests/v3/sample_date_module.py: -------------------------------------------------------------------------------- 1 | from forthic.v3.module import Module 2 | import datetime 3 | 4 | 5 | class SampleDateModule(Module): 6 | def __init__(self, interp): 7 | super().__init__("date", interp) 8 | self.add_module_word("TODAY", self.word_TODAY) 9 | 10 | # ( -- today ) 11 | def word_TODAY(self, interp): 12 | """Pushes today's date 13 | """ 14 | result = datetime.date.today() 15 | interp.stack_push(result) 16 | -------------------------------------------------------------------------------- /forthic-in/forthic/utils/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linkedin/forthic/dd84e4145e2a89df83026313d22e8885835502ab/forthic-in/forthic/utils/__init__.py -------------------------------------------------------------------------------- /forthic-in/forthic/v1/README.md: -------------------------------------------------------------------------------- 1 | # Where's Forthic v1? 2 | 3 | The first version of Forthic was created to make an internal LinkedIn web app easier to configure 4 | for project management tooling. Forthic v1 code could only be revised within that web app and so 5 | it was never open sourced. The first version of Forthic to be open sourced was technically `v2`. -------------------------------------------------------------------------------- /forthic-in/forthic/v2/modules/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linkedin/forthic/dd84e4145e2a89df83026313d22e8885835502ab/forthic-in/forthic/v2/modules/__init__.py -------------------------------------------------------------------------------- /forthic-in/forthic/v2/modules/jinja_module.py: -------------------------------------------------------------------------------- 1 | import jinja2 2 | from ..module import Module 3 | from ..interfaces import IInterpreter 4 | 5 | 6 | class JinjaModule(Module): 7 | """This provides access to Jinja via a thin wrapper 8 | 9 | See `docs/modules/jinja_module.md` for detailed descriptions of each word. 10 | """ 11 | def __init__(self, interp: IInterpreter): 12 | super().__init__('jinja', interp, JINJA_FORTHIC) 13 | self.add_module_word('RENDER', self.word_RENDER) 14 | 15 | # ( template_contents kw_args -- string ) 16 | def word_RENDER(self, interp: IInterpreter): 17 | kw_args = interp.stack_pop() 18 | template_contents = interp.stack_pop() 19 | 20 | template = jinja2.Template(template_contents) 21 | result = template.render(kw_args) 22 | interp.stack_push(result) 23 | 24 | 25 | JINJA_FORTHIC = '' 26 | -------------------------------------------------------------------------------- /forthic-in/forthic/v2/tokens.py: -------------------------------------------------------------------------------- 1 | class Token: 2 | pass 3 | 4 | 5 | class StringToken(Token): 6 | def __init__(self, string: str): 7 | self.string: str = string 8 | 9 | 10 | class CommentToken(Token): 11 | def __init__(self, string: str): 12 | self.string: str = string 13 | 14 | 15 | class StartArrayToken(Token): 16 | pass 17 | 18 | 19 | class EndArrayToken(Token): 20 | pass 21 | 22 | 23 | class StartModuleToken(Token): 24 | def __init__(self, name: str): 25 | self.name: str = name 26 | 27 | 28 | class EndModuleToken(Token): 29 | pass 30 | 31 | 32 | class StartDefinitionToken(Token): 33 | def __init__(self, name: str): 34 | self.name: str = name 35 | 36 | 37 | class EndDefinitionToken(Token): 38 | pass 39 | 40 | 41 | class StartMemoToken(Token): 42 | def __init__(self, name: str): 43 | self.name: str = name 44 | 45 | 46 | class WordToken(Token): 47 | def __init__(self, name: str): 48 | self.name: str = name 49 | 50 | 51 | class EOSToken(Token): 52 | pass 53 | -------------------------------------------------------------------------------- /forthic-in/forthic/v3/README.md: -------------------------------------------------------------------------------- 1 | # README.md 2 | 3 | The `v3` version of Forthic is meant to tighten up the language, the modules, and the conventions based on the learnings of a year of actively developing and managing roughly 300 Forthic apps at LinkedIn. 4 | 5 | Many of the improvements are motivated by the success of applying ideas from Category Theory to Forthic development. This applies to both the language conventions and the Forthic modules. 6 | 7 | Some of the improvements in the modules built on 3rd party APIs is to improve the fidelity of the module so that if the API allows something, so will the module. But at the same time, if an API does something inconsistent, we will try to correct it where possible in the Forthic module. 8 | 9 | The overall aim is to simplify the Forthic language by making it more consistent and "categorical". -------------------------------------------------------------------------------- /forthic-in/forthic/v3/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linkedin/forthic/dd84e4145e2a89df83026313d22e8885835502ab/forthic-in/forthic/v3/__init__.py -------------------------------------------------------------------------------- /forthic-in/forthic/v3/modules/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linkedin/forthic/dd84e4145e2a89df83026313d22e8885835502ab/forthic-in/forthic/v3/modules/__init__.py -------------------------------------------------------------------------------- /forthic-in/forthic/v3/modules/jinja_module.py: -------------------------------------------------------------------------------- 1 | import jinja2 2 | from ..module import Module 3 | from ..interfaces import IInterpreter 4 | 5 | 6 | class JinjaModule(Module): 7 | """This provides access to Jinja via a thin wrapper 8 | 9 | See `docs/modules/jinja_module.md` for detailed descriptions of each word. 10 | """ 11 | def __init__(self, interp: IInterpreter): 12 | super().__init__('jinja', interp, JINJA_FORTHIC) 13 | self.add_module_word('RENDER', self.word_RENDER) 14 | 15 | # ( template_contents kw_args -- string ) 16 | def word_RENDER(self, interp: IInterpreter): 17 | kw_args = interp.stack_pop() 18 | template_contents = interp.stack_pop() 19 | 20 | template = jinja2.Template(template_contents) 21 | result = template.render(kw_args) 22 | interp.stack_push(result) 23 | 24 | 25 | JINJA_FORTHIC = '' 26 | -------------------------------------------------------------------------------- /forthic-in/forthic/v3/modules/stats_module.py: -------------------------------------------------------------------------------- 1 | """Implements module to compute statistics 2 | """ 3 | import statistics 4 | from ..module import Module 5 | from ..interfaces import IInterpreter 6 | 7 | 8 | class StatsModule(Module): 9 | def __init__(self, interp: IInterpreter): 10 | super().__init__("stats", interp, FORTHIC) 11 | self.add_module_word("MEAN", self.word_MEAN) 12 | self.add_module_word("MEDIAN", self.word_MEDIAN) 13 | return 14 | 15 | # ( numbers -- mean ) 16 | def word_MEAN(self, interp: IInterpreter): 17 | numbers = interp.stack_pop() 18 | result = statistics.mean(numbers) 19 | interp.stack_push(result) 20 | 21 | # ( numbers -- median ) 22 | def word_MEDIAN(self, interp: IInterpreter): 23 | numbers = interp.stack_pop() 24 | result = statistics.median(numbers) 25 | interp.stack_push(result) 26 | 27 | 28 | FORTHIC = "" 29 | -------------------------------------------------------------------------------- /forthic-in/forthic/v3/tokens.py: -------------------------------------------------------------------------------- 1 | class Token: 2 | pass 3 | 4 | 5 | class StringToken(Token): 6 | def __init__(self, string: str): 7 | self.string: str = string 8 | 9 | 10 | class CommentToken(Token): 11 | def __init__(self, string: str): 12 | self.string: str = string 13 | 14 | 15 | class StartArrayToken(Token): 16 | pass 17 | 18 | 19 | class EndArrayToken(Token): 20 | pass 21 | 22 | 23 | class StartModuleToken(Token): 24 | def __init__(self, name: str): 25 | self.name: str = name 26 | 27 | 28 | class EndModuleToken(Token): 29 | pass 30 | 31 | 32 | class StartDefinitionToken(Token): 33 | def __init__(self, name: str): 34 | self.name: str = name 35 | 36 | 37 | class EndDefinitionToken(Token): 38 | pass 39 | 40 | 41 | class StartMemoToken(Token): 42 | def __init__(self, name: str): 43 | self.name: str = name 44 | 45 | 46 | class WordToken(Token): 47 | def __init__(self, name: str): 48 | self.name: str = name 49 | 50 | 51 | class EOSToken(Token): 52 | pass 53 | -------------------------------------------------------------------------------- /forthic-in/setup_helpers.py: -------------------------------------------------------------------------------- 1 | __version__ = '3.0.0' 2 | -------------------------------------------------------------------------------- /forthic-js/Makefile: -------------------------------------------------------------------------------- 1 | test: 2 | node --experimental-modules ./tests/test_all.mjs 3 | -------------------------------------------------------------------------------- /forthic-js/run-server.sh: -------------------------------------------------------------------------------- 1 | python3 -m http.server 2 | -------------------------------------------------------------------------------- /forthic-js/test_browser_all.mjs: -------------------------------------------------------------------------------- 1 | import * as HtmlModTests from './tests/modules/test_html_module.mjs'; 2 | import { run_tests } from './tests/utils.mjs'; 3 | 4 | run_tests([ 5 | HtmlModTests.tests, 6 | ]).then(done, error) 7 | 8 | function done() { 9 | console.log("DONE") 10 | } 11 | 12 | function error() { 13 | console.error("ERROR") 14 | } 15 | 16 | -------------------------------------------------------------------------------- /forthic-js/tests.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | title 6 | 7 | 8 | 9 |

10 |

11 |

12 |
13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /forthic-js/tests/sample_date_module.mjs: -------------------------------------------------------------------------------- 1 | import { Module, Word, ModuleWord } from '../../forthic-js/module.mjs'; 2 | 3 | 4 | class SampleDateModule extends Module { 5 | constructor(interp) { 6 | super("sample_date", interp); 7 | this.add_exportable_word(new ModuleWord("TODAY", this.word_TODAY)); 8 | this.add_exportable_word(new ModuleWord("NORMALIZED-TODAY", this.word_NORMALIZED_TODAY)); 9 | } 10 | 11 | // ( -- today ) 12 | word_TODAY(interp) { 13 | let result = new Date(); 14 | interp.stack_push(result); 15 | } 16 | 17 | // ( -- today ) 18 | word_NORMALIZED_TODAY(interp) { 19 | let result = normalize_date(new Date()); 20 | interp.stack_push(result); 21 | } 22 | } 23 | 24 | function normalize_date(date) { 25 | let year = date.getFullYear(); 26 | let month = date.getMonth() + 1; 27 | let day = date.getDate(); 28 | let result = new Date(year + "-" + month + "-" + day); 29 | return result; 30 | } 31 | 32 | function new_module(interp) { 33 | return new SampleDateModule(interp); 34 | } 35 | 36 | export { SampleDateModule, normalize_date, new_module }; 37 | -------------------------------------------------------------------------------- /forthic-js/tests/test_all.mjs: -------------------------------------------------------------------------------- 1 | import * as TokTests from './test_tokenizer.mjs'; 2 | import * as TokErrorTests from './test_tokenizer_errors.mjs'; 3 | import * as InterpTests from './test_interpreter.mjs'; 4 | import * as GlobalModTests from './test_global_module.mjs'; 5 | import { run_tests } from './utils.mjs'; 6 | 7 | run_tests([ 8 | TokTests.tests, 9 | TokErrorTests.tests, 10 | InterpTests.tests, 11 | GlobalModTests.tests, 12 | ]).then(done, error) 13 | 14 | function done() { 15 | console.log("DONE") 16 | } 17 | 18 | function error() { 19 | console.error("ERROR") 20 | } 21 | 22 | -------------------------------------------------------------------------------- /forthic-py/.gitignore: -------------------------------------------------------------------------------- 1 | *.poetry 2 | dist 3 | flit-env 4 | build -------------------------------------------------------------------------------- /forthic-py/Makefile: -------------------------------------------------------------------------------- 1 | test: 2 | tox 3 | 4 | flit-env: 5 | python3 -m venv flit-env 6 | 7 | 8 | build: flit-env 9 | source flit-env/bin/activate && python -m pip install -U pip && pip install flit && flit build 10 | rm -rf flit-env 11 | 12 | -------------------------------------------------------------------------------- /forthic-py/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linkedin/forthic/dd84e4145e2a89df83026313d22e8885835502ab/forthic-py/__init__.py -------------------------------------------------------------------------------- /forthic-py/docs/cache_module.md: -------------------------------------------------------------------------------- 1 | # cache_module 2 | 3 | The cache module allows you to store the top of the stack on disk as JSON (the 4 | stored object must be JSON serializable) and retrieve it later. This is useful 5 | for storing expensive computations or API responses. 6 | 7 | The data is stored in a `.cache` file in the working directory. The directory 8 | can be set using the `CWD!` word. 9 | 10 | Every object is stored and retrieved using a label. 11 | 12 | ## Example 13 | ``` 14 | ["cache"] USE-MODULES 15 | 16 | "~/my_stuff" cache.CWD! # Sets the current working directory 17 | [1 2 3 "Howdy"] "my_array" cache.CACHE! # Stores the array in the cache 18 | 19 | "my_array" cache.CACHE@ # Retrieves the array from cache 20 | 3 NTH # ([1 2 3 "Howdy"] -- "Howdy") 21 | ``` 22 | 23 | ## Reference 24 | 25 | ### CACHE! 26 | `(object key --)` 27 | 28 | Stores `object` in the cache at the specified `key`. The object will be 29 | serialized to JSON. 30 | 31 | 32 | ### CACHE@ 33 | `(key -- object)` 34 | 35 | Retrieves an object from the cache at the specified `key`. The object will be 36 | deserialized from JSON. -------------------------------------------------------------------------------- /forthic-py/docs/jinja_module.md: -------------------------------------------------------------------------------- 1 | # jinja_module 2 | 3 | The jinja module uses the Python [jinja templating 4 | package](https://jinja.palletsprojects.com/en/2.11.x/) to render arbitrary 5 | strings using record data. 6 | 7 | Typically, this is the best choice for rendering html, emails, or anything that 8 | involves looping along with interpolation. 9 | 10 | ## Example 11 | ``` 12 | ["jinja"] USE-MODULES 13 | 14 | : MY-DATA [ 15 | ["letters" ["alpha" "beta" "gamma"]] 16 | ] REC; 17 | 18 | : MY-TEMPLATE " 19 |
    20 | {% for letter in letters %} 21 |
  • {{ letter }}
  • 22 | {% endfor %} 23 |
24 | "; 25 | 26 | MY-TEMPLATE MY-DATA jira.RENDER 27 | ``` 28 | 29 | ## Reference 30 | 31 | ### RENDER 32 | `(template record -- string)` 33 | Given a jinja template and a Forthic record, renders a string using the jinja engine. 34 | 35 | NOTE: The record must have fields that are valid Python variable names since 36 | these are used within the jinja template. -------------------------------------------------------------------------------- /forthic-py/pyproject.toml: -------------------------------------------------------------------------------- 1 | [build-system] 2 | requires = ["flit_core >=3.2,<4"] 3 | build-backend = "flit_core.buildapi" 4 | 5 | [project] 6 | name = "forthic" 7 | authors = [{name = "Rino Jose", email = "rjose@forthix.com"}] 8 | license = {file = "LICENSE"} 9 | readme = "README.md" 10 | version = "4.0.0" 11 | description = "A stack-based language for concisely building tweakable apps" 12 | dependencies = [ 13 | "urllib3 == 1.26.15", 14 | "pytz", 15 | "cryptography", 16 | "python-dateutil", 17 | "requests-oauthlib", 18 | "Jinja2", 19 | "Markdown", 20 | ] 21 | 22 | [project.urls] 23 | Home = "https://github.com/linkedin/forthic" 24 | 25 | 26 | -------------------------------------------------------------------------------- /forthic-py/src/README.md: -------------------------------------------------------------------------------- 1 | # README.md 2 | 3 | The `v3` version of Forthic is meant to tighten up the language, the modules, and the conventions based on the learnings of a year of actively developing and managing roughly 300 Forthic apps at LinkedIn. 4 | 5 | Many of the improvements are motivated by the success of applying ideas from Category Theory to Forthic development. This applies to both the language conventions and the Forthic modules. 6 | 7 | Some of the improvements in the modules built on 3rd party APIs is to improve the fidelity of the module so that if the API allows something, so will the module. But at the same time, if an API does something inconsistent, we will try to correct it where possible in the Forthic module. 8 | 9 | The overall aim is to simplify the Forthic language by making it more consistent and "categorical". -------------------------------------------------------------------------------- /forthic-py/src/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linkedin/forthic/dd84e4145e2a89df83026313d22e8885835502ab/forthic-py/src/__init__.py -------------------------------------------------------------------------------- /forthic-py/src/forthic/__init__.py: -------------------------------------------------------------------------------- 1 | from .interpreter import Interpreter 2 | from .modules.cache_module import CacheModule 3 | from .modules.org_module import OrgModule, OrgContext 4 | from .modules.jira_module import JiraModule, JiraContext -------------------------------------------------------------------------------- /forthic-py/src/forthic/modules/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linkedin/forthic/dd84e4145e2a89df83026313d22e8885835502ab/forthic-py/src/forthic/modules/__init__.py -------------------------------------------------------------------------------- /forthic-py/src/forthic/modules/jinja_module.py: -------------------------------------------------------------------------------- 1 | import jinja2 2 | from ..module import Module 3 | from ..interfaces import IInterpreter 4 | 5 | 6 | class JinjaModule(Module): 7 | """This provides access to Jinja via a thin wrapper 8 | 9 | See `docs/modules/jinja_module.md` for detailed descriptions of each word. 10 | """ 11 | def __init__(self, interp: IInterpreter): 12 | super().__init__('jinja', interp, JINJA_FORTHIC) 13 | self.add_module_word('RENDER', self.word_RENDER) 14 | 15 | # ( template_contents kw_args -- string ) 16 | def word_RENDER(self, interp: IInterpreter): 17 | kw_args = interp.stack_pop() 18 | template_contents = interp.stack_pop() 19 | 20 | template = jinja2.Template(template_contents) 21 | result = template.render(kw_args) 22 | interp.stack_push(result) 23 | 24 | 25 | JINJA_FORTHIC = '' 26 | -------------------------------------------------------------------------------- /forthic-py/src/forthic/modules/stats_module.py: -------------------------------------------------------------------------------- 1 | """Implements module to compute statistics 2 | """ 3 | import statistics 4 | from ..module import Module 5 | from ..interfaces import IInterpreter 6 | 7 | 8 | class StatsModule(Module): 9 | def __init__(self, interp: IInterpreter): 10 | super().__init__("stats", interp, FORTHIC) 11 | self.add_module_word("MEAN", self.word_MEAN) 12 | self.add_module_word("MEDIAN", self.word_MEDIAN) 13 | return 14 | 15 | # ( numbers -- mean ) 16 | def word_MEAN(self, interp: IInterpreter): 17 | numbers = interp.stack_pop() 18 | result = statistics.mean(numbers) 19 | interp.stack_push(result) 20 | 21 | # ( numbers -- median ) 22 | def word_MEDIAN(self, interp: IInterpreter): 23 | numbers = interp.stack_pop() 24 | result = statistics.median(numbers) 25 | interp.stack_push(result) 26 | 27 | 28 | FORTHIC = "" 29 | -------------------------------------------------------------------------------- /forthic-py/src/forthic/tokens.py: -------------------------------------------------------------------------------- 1 | class Token: 2 | pass 3 | 4 | 5 | class StringToken(Token): 6 | def __init__(self, string: str): 7 | self.string: str = string 8 | 9 | 10 | class CommentToken(Token): 11 | def __init__(self, string: str): 12 | self.string: str = string 13 | 14 | 15 | class StartArrayToken(Token): 16 | pass 17 | 18 | 19 | class EndArrayToken(Token): 20 | pass 21 | 22 | 23 | class StartModuleToken(Token): 24 | def __init__(self, name: str): 25 | self.name: str = name 26 | 27 | 28 | class EndModuleToken(Token): 29 | pass 30 | 31 | 32 | class StartDefinitionToken(Token): 33 | def __init__(self, name: str): 34 | self.name: str = name 35 | 36 | 37 | class EndDefinitionToken(Token): 38 | pass 39 | 40 | 41 | class StartMemoToken(Token): 42 | def __init__(self, name: str): 43 | self.name: str = name 44 | 45 | 46 | class WordToken(Token): 47 | def __init__(self, name: str): 48 | self.name: str = name 49 | 50 | 51 | class EOSToken(Token): 52 | pass 53 | -------------------------------------------------------------------------------- /forthic-py/src/forthic/utils/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linkedin/forthic/dd84e4145e2a89df83026313d22e8885835502ab/forthic-py/src/forthic/utils/__init__.py -------------------------------------------------------------------------------- /forthic-py/tests/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linkedin/forthic/dd84e4145e2a89df83026313d22e8885835502ab/forthic-py/tests/__init__.py -------------------------------------------------------------------------------- /forthic-py/tests/modules/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linkedin/forthic/dd84e4145e2a89df83026313d22e8885835502ab/forthic-py/tests/modules/__init__.py -------------------------------------------------------------------------------- /forthic-py/tests/modules/datasets_data/.gitignore: -------------------------------------------------------------------------------- 1 | datasets -------------------------------------------------------------------------------- /forthic-py/tests/modules/datasets_data/README.md: -------------------------------------------------------------------------------- 1 | # README.md 2 | 3 | This is a place to store test data for the datasets module test. -------------------------------------------------------------------------------- /forthic-py/tests/sample_date_module.py: -------------------------------------------------------------------------------- 1 | from forthic.module import Module 2 | import datetime 3 | 4 | 5 | class SampleDateModule(Module): 6 | def __init__(self, interp): 7 | super().__init__("date", interp) 8 | self.add_module_word("TODAY", self.word_TODAY) 9 | 10 | # ( -- today ) 11 | def word_TODAY(self, interp): 12 | """Pushes today's date""" 13 | result = datetime.date.today() 14 | interp.stack_push(result) 15 | -------------------------------------------------------------------------------- /forthic-py/tests/tests_py/v3/modules/datasets_data/datasets/greek.dataset: -------------------------------------------------------------------------------- 1 | { 2 | "alpha": [ 3 | 1, 4 | 2, 5 | 3 6 | ], 7 | "beta": [ 8 | 4, 9 | 5, 10 | 6 11 | ] 12 | } -------------------------------------------------------------------------------- /forthic-py/tox.ini: -------------------------------------------------------------------------------- 1 | [tox] 2 | envlist = {py310},qa 3 | skip_missing_interpreters = True 4 | 5 | [testenv] 6 | usedevelop = True 7 | commands = 8 | pytest --cov tests {posargs} 9 | setenv = PYTHONPATH = '' 10 | deps = 11 | pytest 12 | pytest-cov 13 | 14 | [testenv:qa] 15 | basepython = python3 16 | commands = 17 | python -m flake8 18 | deps = 19 | flake8 20 | mypy 21 | types-requests 22 | types-Markdown 23 | types-pytz 24 | types-oauthlib 25 | types-python-dateutil 26 | types-Jinja2 27 | types-cryptography 28 | 29 | 30 | [flake8] 31 | max_line_length = 120 32 | ignore = E501,W605 33 | -------------------------------------------------------------------------------- /forthic-rb/.gitignore: -------------------------------------------------------------------------------- 1 | /.bundle/ 2 | /.yardoc 3 | /_yardoc/ 4 | /coverage/ 5 | /doc/ 6 | /pkg/ 7 | /spec/reports/ 8 | /tmp/ 9 | .DS_Store 10 | .ruby-lsp -------------------------------------------------------------------------------- /forthic-rb/.standard.yml: -------------------------------------------------------------------------------- 1 | # For available configuration options, see: 2 | # https://github.com/standardrb/standard 3 | ruby_version: 3.1 4 | -------------------------------------------------------------------------------- /forthic-rb/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## [Unreleased] 2 | 3 | ## [0.1.0] - 2024-12-27 4 | 5 | - Initial release 6 | -------------------------------------------------------------------------------- /forthic-rb/Gemfile: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | source "https://rubygems.org" 4 | 5 | # Specify your gem's dependencies in forthic.gemspec 6 | gemspec 7 | 8 | gem "rake", "~> 13.0" 9 | 10 | group :development do 11 | gem 'guard' 12 | gem 'guard-minitest' 13 | gem 'minitest-reporters' 14 | gem "minitest", "~> 5.16" 15 | gem "standard", "~> 1.3" 16 | end -------------------------------------------------------------------------------- /forthic-rb/README.md: -------------------------------------------------------------------------------- 1 | # Forthic 2 | 3 | A Forthic interpreter that runs within Ruby. 4 | 5 | ## Installation 6 | 7 | Install the gem and add to the application's Gemfile by executing: 8 | 9 | ```bash 10 | bundle add forthic 11 | ``` 12 | 13 | If bundler is not being used to manage dependencies, install the gem by executing: 14 | 15 | ```bash 16 | gem install forthic 17 | ``` 18 | 19 | ## Usage 20 | 21 | Here's a basic example of how to use the Forthic interpreter: 22 | 23 | ```ruby 24 | require 'forthic' 25 | 26 | interp = Forthic::Interpreter.new 27 | interp.run("[1 2 3] '8 *' MAP") 28 | puts interp.stack_pop 29 | 30 | # Output: 31 | # 32 | # [ 8, 16, 24 ] 33 | ``` 34 | 35 | ## Contributing 36 | 37 | Bug reports and pull requests are welcome on GitHub at https://github.com/linkedin/forthic. 38 | -------------------------------------------------------------------------------- /forthic-rb/Rakefile: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require "bundler/gem_tasks" 4 | require "minitest/test_task" 5 | 6 | Minitest::TestTask.create 7 | 8 | require "standard/rake" 9 | 10 | task default: %i[test standard] 11 | 12 | task :guard do 13 | sh "bundle exec guard" 14 | end -------------------------------------------------------------------------------- /forthic-rb/bin/console: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | # frozen_string_literal: true 3 | 4 | require "bundler/setup" 5 | require "forthic" 6 | 7 | # You can add fixtures and/or initialization code here to make experimenting 8 | # with your gem easier. You can also use a different console, if you like. 9 | 10 | require "irb" 11 | IRB.start(__FILE__) 12 | -------------------------------------------------------------------------------- /forthic-rb/bin/setup: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -euo pipefail 3 | IFS=$'\n\t' 4 | set -vx 5 | 6 | bundle install 7 | 8 | # Do any other automated setup that you need to do here 9 | -------------------------------------------------------------------------------- /forthic-rb/lib/forthic.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require_relative "forthic/version" 4 | 5 | module Forthic 6 | autoload :Tokenizer, 'forthic/tokenizer' 7 | autoload :CodeLocation, 'forthic/code_location' 8 | autoload :Token, 'forthic/token' 9 | autoload :PositionedString, 'forthic/positioned_string' 10 | autoload :ForthicError, 'forthic/forthic_error' 11 | autoload :Word, 'forthic/words/word' 12 | autoload :PushValueWord, 'forthic/words/push_value_word' 13 | autoload :DefinitionWord, 'forthic/words/definition_word' 14 | autoload :ModuleMemoWord, 'forthic/words/module_memo_word' 15 | autoload :ModuleMemoBangAtWord, 'forthic/words/module_memo_bang_at_word' 16 | autoload :ModuleMemoBangWord, 'forthic/words/module_memo_bang_word' 17 | autoload :ModuleMemoBangAtWord, 'forthic/words/module_memo_bang_at_word' 18 | autoload :EndArrayWord, 'forthic/words/end_array_word' 19 | autoload :StartModuleWord, 'forthic/words/start_module_word' 20 | autoload :EndModuleWord, 'forthic/words/end_module_word' 21 | autoload :MapWord, 'forthic/words/map_word' 22 | autoload :ForthicModule, 'forthic/forthic_module' 23 | autoload :GlobalModule, 'forthic/global_module' 24 | autoload :Interpreter, 'forthic/interpreter' 25 | end 26 | -------------------------------------------------------------------------------- /forthic-rb/lib/forthic/code_location.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module Forthic 4 | class CodeLocation 5 | attr_accessor :screen_name, :line, :column, :start_pos, :end_pos 6 | 7 | # @param [String] screen_name 8 | # @param [Integer] line 9 | # @param [Integer] column 10 | # @param [Integer] start_pos 11 | # @param [Integer] end_pos 12 | def initialize(screen_name: "", line: 1, column: 1, start_pos: 0, end_pos: 0) 13 | @screen_name = screen_name 14 | @line = line 15 | @column = column 16 | @start_pos = start_pos 17 | @end_pos = end_pos 18 | end 19 | end 20 | end 21 | -------------------------------------------------------------------------------- /forthic-rb/lib/forthic/positioned_string.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module Forthic 4 | class PositionedString 5 | attr_accessor :string, :location 6 | 7 | # @string [String] the string value 8 | # @location [CodeLocation] the location of the string in the code 9 | def initialize(string, location) 10 | @string = string 11 | @location = location 12 | end 13 | 14 | # @return [String] 15 | def value_of 16 | @string 17 | end 18 | end 19 | end 20 | -------------------------------------------------------------------------------- /forthic-rb/lib/forthic/token.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module Forthic 4 | module TokenType 5 | STRING = 1 6 | COMMENT = 2 7 | START_ARRAY = 3 8 | END_ARRAY = 4 9 | START_MODULE = 5 10 | END_MODULE = 6 11 | START_DEF = 7 12 | END_DEF = 8 13 | START_MEMO = 9 14 | WORD = 10 15 | EOS = 11 16 | end 17 | end 18 | 19 | 20 | module Forthic 21 | class Token 22 | attr_reader :type, :value, :location 23 | 24 | # @param [TokenType] type 25 | # @param [String] value 26 | # @param [CodeLocation] location 27 | def initialize(type, value, location) 28 | @type = type 29 | @value = value 30 | @location = location 31 | end 32 | 33 | # @return [String] 34 | def string 35 | @value 36 | end 37 | end 38 | end -------------------------------------------------------------------------------- /forthic-rb/lib/forthic/variable.rb: -------------------------------------------------------------------------------- 1 | # # frozen_string_literal: true 2 | 3 | module Forthic 4 | class Variable 5 | attr_accessor :name, :value 6 | 7 | # @param [String] name 8 | # @param [Object] value 9 | def initialize(name, value = nil) 10 | @name = name 11 | @value = value 12 | end 13 | 14 | # @return [String] 15 | def get_name 16 | @name 17 | end 18 | 19 | # @param [Object] val 20 | def set_value(val) 21 | @value = val 22 | end 23 | 24 | # @return [Object] 25 | def get_value 26 | @value 27 | end 28 | 29 | # @return [Variable] 30 | def dup 31 | Variable.new(@name, @value) 32 | end 33 | end 34 | end -------------------------------------------------------------------------------- /forthic-rb/lib/forthic/version.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module Forthic 4 | VERSION = "0.1.0" 5 | end 6 | -------------------------------------------------------------------------------- /forthic-rb/lib/forthic/words/definition_word.rb: -------------------------------------------------------------------------------- 1 | # # frozen_string_literal: true 2 | 3 | require_relative 'word' 4 | require_relative '../forthic_error' 5 | 6 | module Forthic 7 | class DefinitionWord < Word 8 | attr_accessor :words, :cur_index 9 | 10 | # @param [String] name 11 | def initialize(name) 12 | super(name) 13 | @words = [] 14 | @cur_index = 0 15 | end 16 | 17 | # @param [Word] word 18 | def add_word(word) 19 | @words.push(word) 20 | end 21 | 22 | # @param [Interpreter] interp 23 | def execute(interp) 24 | @words.each do |word| 25 | begin 26 | word.execute(interp) 27 | rescue => e 28 | error = ForthicError.new( 29 | "definition_word-29", 30 | "Error executing word #{word.name}", 31 | "Error in #{self.name} definition", 32 | interp.get_string_location 33 | ) 34 | error.set_caught_error(e) 35 | raise error 36 | end 37 | end 38 | end 39 | end 40 | end -------------------------------------------------------------------------------- /forthic-rb/lib/forthic/words/end_array_word.rb: -------------------------------------------------------------------------------- 1 | # # frozen_string_literal: true 2 | 3 | require_relative 'word' 4 | require_relative '../token' 5 | 6 | module Forthic 7 | class EndArrayWord < Word 8 | def initialize 9 | super("]") 10 | end 11 | 12 | # @param [Interpreter] interp 13 | def execute(interp) 14 | items = [] 15 | item = interp.stack_pop 16 | 17 | # NOTE: This won't infinite loop because interp.stack_pop() will eventually fail 18 | loop do 19 | break if item.is_a?(Token) && item.type == TokenType::START_ARRAY 20 | items.push(item) 21 | item = interp.stack_pop 22 | end 23 | 24 | items.reverse! 25 | interp.stack_push(items) 26 | end 27 | end 28 | end -------------------------------------------------------------------------------- /forthic-rb/lib/forthic/words/end_module_word.rb: -------------------------------------------------------------------------------- 1 | # # frozen_string_literal: true 2 | 3 | require_relative 'word' 4 | 5 | module Forthic 6 | class EndModuleWord < Word 7 | def initialize 8 | super("}") 9 | end 10 | 11 | # @param [Interpreter] interp 12 | def execute(interp) 13 | interp.module_stack_pop 14 | end 15 | end 16 | end -------------------------------------------------------------------------------- /forthic-rb/lib/forthic/words/imported_word.rb: -------------------------------------------------------------------------------- 1 | # # frozen_string_literal: true 2 | 3 | require_relative 'word' 4 | require_relative 'module_word' 5 | 6 | module Forthic 7 | class ImportedWord < Word 8 | attr_accessor :module_word, :imported_module 9 | 10 | # @param [Word] module_word 11 | # @param [String] prefix 12 | # @param [ModuleWord] imported_module 13 | def initialize(module_word, prefix, imported_module) 14 | prefix = prefix.empty? ? "" : "#{prefix}." 15 | super("#{prefix}#{module_word.name}") 16 | @module_word = module_word 17 | @imported_module = imported_module 18 | end 19 | 20 | # @param [Interpreter] interp 21 | def execute(interp) 22 | interp.module_stack_push(@imported_module) 23 | @module_word.execute(interp) 24 | interp.module_stack_pop 25 | end 26 | end 27 | end -------------------------------------------------------------------------------- /forthic-rb/lib/forthic/words/module_memo_bang_at_word.rb: -------------------------------------------------------------------------------- 1 | # # frozen_string_literal: true 2 | 3 | require_relative 'word' 4 | require_relative 'module_memo_word' 5 | 6 | module Forthic 7 | class ModuleMemoBangAtWord < Word 8 | attr_accessor :memo_word 9 | 10 | # @param [ModuleMemoWord] memo_word 11 | def initialize(memo_word) 12 | super("#{memo_word.name}!@") 13 | @memo_word = memo_word 14 | end 15 | 16 | # @param [Interpreter] interp 17 | def execute(interp) 18 | @memo_word.refresh(interp) 19 | interp.stack_push(@memo_word.value) 20 | end 21 | end 22 | end -------------------------------------------------------------------------------- /forthic-rb/lib/forthic/words/module_memo_bang_word.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require_relative 'word' 4 | require_relative 'module_memo_word' 5 | 6 | module Forthic 7 | class ModuleMemoBangWord < Word 8 | attr_accessor :memo_word 9 | 10 | # @param [ModuleMemoWord] memo_word 11 | def initialize(memo_word) 12 | super("#{memo_word.name}!") 13 | @memo_word = memo_word 14 | end 15 | 16 | # @param [Interpreter] interp 17 | def execute(interp) 18 | @memo_word.refresh(interp) 19 | end 20 | end 21 | end -------------------------------------------------------------------------------- /forthic-rb/lib/forthic/words/module_memo_word.rb: -------------------------------------------------------------------------------- 1 | # # frozen_string_literal: true 2 | 3 | require_relative 'word' 4 | 5 | module Forthic 6 | class ModuleMemoWord < Word 7 | attr_accessor :word, :has_value, :value 8 | 9 | # @param [Word] word 10 | def initialize(word) 11 | super(word.name) 12 | @word = word 13 | @has_value = false 14 | @value = nil 15 | end 16 | 17 | # @param [Interpreter] interp 18 | def refresh(interp) 19 | @word.execute(interp) 20 | @value = interp.stack_pop 21 | @has_value = true 22 | end 23 | 24 | # @param [Interpreter] interp 25 | def execute(interp) 26 | refresh(interp) unless @has_value 27 | interp.stack_push(@value) 28 | end 29 | 30 | def reset 31 | @has_value = false 32 | @value = nil 33 | end 34 | end 35 | end -------------------------------------------------------------------------------- /forthic-rb/lib/forthic/words/module_word.rb: -------------------------------------------------------------------------------- 1 | # # frozen_string_literal: true 2 | 3 | require_relative 'word' 4 | 5 | module Forthic 6 | class ModuleWord < Word 7 | attr_accessor :handler 8 | 9 | # @param [String] name 10 | # @param [Proc] handler 11 | def initialize(name, handler) 12 | super(name) 13 | @handler = handler 14 | end 15 | 16 | # @param [Interpreter] interp 17 | def execute(interp) 18 | @handler.call(interp) 19 | end 20 | end 21 | end -------------------------------------------------------------------------------- /forthic-rb/lib/forthic/words/push_value_word.rb: -------------------------------------------------------------------------------- 1 | # # frozen_string_literal: true 2 | 3 | require_relative 'word' 4 | 5 | module Forthic 6 | class PushValueWord < Word 7 | attr_accessor :value 8 | 9 | # @param [String] name 10 | # @param [Object] value 11 | def initialize(name, value) 12 | super(name) 13 | @value = value 14 | end 15 | 16 | # @param [Interpreter] interp 17 | def execute(interp, _options = {}) 18 | interp.stack_push(@value) 19 | end 20 | end 21 | end -------------------------------------------------------------------------------- /forthic-rb/lib/forthic/words/start_module_word.rb: -------------------------------------------------------------------------------- 1 | # # frozen_string_literal: true 2 | 3 | require_relative 'word' 4 | require_relative '../forthic_module' 5 | 6 | module Forthic 7 | class StartModuleWord < Word 8 | # @param [Interpreter] interp 9 | def execute(interp) 10 | # The app module is the only module with a blank name 11 | if self.name == "" 12 | interp.module_stack_push(interp.get_app_module) 13 | return 14 | end 15 | 16 | # If the module is used by the current module, push it onto the stack, otherwise 17 | # create a new module. 18 | mod = interp.cur_module.find_module(self.name) 19 | unless mod 20 | mod = ForthicModule.new(self.name) 21 | interp.cur_module.register_module(mod.name, mod.name, mod) 22 | 23 | # If we're at the app module, also register with interpreter 24 | if interp.cur_module.name == "" 25 | interp.register_module(mod) 26 | end 27 | end 28 | interp.module_stack_push(mod) 29 | end 30 | end 31 | end -------------------------------------------------------------------------------- /forthic-rb/lib/forthic/words/word.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module Forthic 4 | class Word 5 | attr_accessor :name, :string, :location 6 | 7 | # @param [String] name 8 | def initialize(name) 9 | @name = name 10 | @string = name 11 | @location = nil 12 | end 13 | 14 | # @param [CodeLocation] location 15 | def set_location(location) 16 | @location = location 17 | end 18 | 19 | # @return [CodeLocation, nil] 20 | def get_location 21 | @location 22 | end 23 | 24 | # @param [Interpreter] _interp 25 | # @param [Hash] _options 26 | def execute(_interp, _options = {}) 27 | raise "Must override Word.execute" 28 | end 29 | end 30 | end -------------------------------------------------------------------------------- /forthic-rb/sig/forthic.rbs: -------------------------------------------------------------------------------- 1 | module Forthic 2 | VERSION: String 3 | # See the writing guide of rbs: https://github.com/ruby/rbs#guides 4 | end 5 | -------------------------------------------------------------------------------- /forthic-rb/test/test_forthic.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require "test_helper" 4 | 5 | class TestForthic < Minitest::Test 6 | def test_that_it_has_a_version_number 7 | refute_nil ::Forthic::VERSION 8 | end 9 | 10 | def test_it_does_something_useful 11 | assert true 12 | end 13 | end 14 | -------------------------------------------------------------------------------- /forthic-rb/test/test_helper.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | $LOAD_PATH.unshift File.expand_path("../lib", __dir__) 4 | require "forthic" 5 | require "minitest/autorun" 6 | require "minitest/reporters" 7 | 8 | Minitest::Reporters.use!(Minitest::Reporters::SpecReporter.new) -------------------------------------------------------------------------------- /forthic-react/v1/.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | /.pnp 6 | .pnp.js 7 | 8 | # testing 9 | /coverage 10 | 11 | # production 12 | /build 13 | 14 | # misc 15 | .DS_Store 16 | .env.local 17 | .env.development.local 18 | .env.test.local 19 | .env.production.local 20 | 21 | npm-debug.log* 22 | yarn-debug.log* 23 | yarn-error.log* 24 | -------------------------------------------------------------------------------- /forthic-react/v1/Makefile: -------------------------------------------------------------------------------- 1 | # Makefile for react-app 2 | STATIC_DIR=../../server/static/react/react-app/v1 3 | 4 | .PHONY: build test run 5 | 6 | run: 7 | HTTPS=true BROWSER=none npm run start 8 | 9 | test: 10 | @echo 11 | @echo "Forthic React tests" 12 | @echo "============" 13 | CI=1 npm run test 14 | 15 | run-test: 16 | npm run test 17 | 18 | build: 19 | npm run build 20 | rm -rf $(STATIC_DIR); mkdir -p $(STATIC_DIR) 21 | cp build/static/js/main*.js* $(STATIC_DIR) 22 | cp build/static/css/main*.css $(STATIC_DIR) 23 | cp build/manifest.json $(STATIC_DIR) 24 | python3 update_template.py 25 | -------------------------------------------------------------------------------- /forthic-react/v1/docs/elements/UserNav.md: -------------------------------------------------------------------------------- 1 | # UserNav 2 | 3 | The `UserNav` implements a breadcrumb-oriented user selector. For the selected user, it shows breadcrumbs for each manager in their chain up to the root manager. It also has a user search typeahead control. 4 | 5 | ## Props 6 | 7 | * `breadcrumbLabelKey`: The user field to display in the breadcrumb 8 | * `typeaheadLabelKey`: The field of the search result records that's used to match typeahead input 9 | * `fsearch`: Forthic that takes a string and returns an array of records and is executed when typeahead is active 10 | * `fselected`: Forthic that is executed when a user is selected 11 | * `mgr_chain`: List of records representing the current management chain. Each record must have `username` and `fullname` fields 12 | * `interp`: Forthic interpreter. This is automatically set by the global module. 13 | 14 | ## Examples 15 | 16 | ### Simple Example 17 | ``` 18 | : USER-NAV "UserNav" Element [ 19 | ["fsearch" "PERSON-SEARCH"] 20 | ["typeaheadLabelKey" "label"] 21 | ["breadcrumbLabelKey" "fullname"] 22 | ["fselected" "'username' QPARAM!"] 23 | ["mgr_chain" PAGE-DATA "manager_chain" REC@] 24 | ] REC ; 7 | } 8 | 9 | export default RawHTML; 10 | -------------------------------------------------------------------------------- /forthic-react/v1/src/forthic/elements/form/DateInput.jsx: -------------------------------------------------------------------------------- 1 | import Form from 'react-bootstrap/Form'; 2 | 3 | export function DateInput({ 4 | field_record, // See [HEADER-INFO](../../../../../../forthic/v3/modules/intake_module.py) 5 | update_state, // A function taking a (field_id, value) and setting the data in the form 6 | valuesByFieldId, // Field values 7 | interp, // Forthic interpreter 8 | }) { 9 | 10 | const field_id = field_record['Field ID'] 11 | const defaultValue = valuesByFieldId[field_id] 12 | return ( 13 | {update_state(field_id, event.target.value)}} 18 | /> 19 | ) 20 | } 21 | -------------------------------------------------------------------------------- /forthic-react/v1/src/forthic/elements/form/Dropdown.jsx: -------------------------------------------------------------------------------- 1 | import Form from 'react-bootstrap/Form'; 2 | 3 | export function Dropdown({ 4 | field_record, // See [HEADER-INFO](../../../../../../forthic/v3/modules/intake_module.py) 5 | update_state, // A function taking a (field_id, value) and setting the data in the form 6 | valuesByFieldId, // Field values 7 | interp, // Forthic interpreter 8 | }) { 9 | 10 | const options_string = field_record["Field Content"] ? field_record["Field Content"] : "" 11 | const options = options_string.split("\n").map(o => ) 12 | const field_id = field_record['Field ID'] 13 | const defaultValue = valuesByFieldId[field_id] 14 | return ( 15 | {update_state(field_id, event.target.value)}} defaultValue={defaultValue}> 16 | 17 | {options} 18 | 19 | ) 20 | } 21 | -------------------------------------------------------------------------------- /forthic-react/v1/src/forthic/elements/form/Html.jsx: -------------------------------------------------------------------------------- 1 | import RawHTML from "../RawHTML" 2 | 3 | export function Html({ 4 | field_record, // See [HEADER-INFO](../../../../../../forthic/v3/modules/intake_module.py) 5 | }) { 6 | 7 | return ( 8 | 9 | ) 10 | } 11 | -------------------------------------------------------------------------------- /forthic-react/v1/src/forthic/elements/form/Markdown.jsx: -------------------------------------------------------------------------------- 1 | import ReactMarkdown from 'react-markdown' 2 | 3 | export function Markdown({ 4 | field_record, // See [HEADER-INFO](../../../../../../forthic/v3/modules/intake_module.py) 5 | }) { 6 | 7 | return ( 8 | 9 | {field_record["Field Content"]} 10 | 11 | ) 12 | } 13 | -------------------------------------------------------------------------------- /forthic-react/v1/src/setupTests.js: -------------------------------------------------------------------------------- 1 | // jest-dom adds custom jest matchers for asserting on DOM nodes. 2 | // allows you to do things like: 3 | // expect(element).toHaveTextContent(/react/i) 4 | // learn more: https://github.com/testing-library/jest-dom 5 | import '@testing-library/jest-dom'; 6 | -------------------------------------------------------------------------------- /forthic-react/v1/update_template.py: -------------------------------------------------------------------------------- 1 | import re 2 | import glob 3 | 4 | 5 | def main(): 6 | template_path = "../../server/templates/react/react-app/v1/main.html" 7 | 8 | # Get new js and css filenames 9 | [js_path] = glob.glob("./build/static/js/main*.js") 10 | [css_path] = glob.glob("./build/static/css/main*.css") 11 | js_file = re.match(".*(main\\..*\\.js)", js_path).group(1) 12 | css_file = re.match(".*(main\\..*\\.css)", css_path).group(1) 13 | 14 | # Load current template 15 | with open(template_path) as file: 16 | contents = file.read() 17 | 18 | # Replace current compiled files with new ones 19 | contents = re.sub("main\\..*\\.js", js_file, contents) 20 | contents = re.sub("main\\..*\\.css", css_file, contents) 21 | 22 | # Update file 23 | with open(template_path, "w") as file: 24 | file.write(contents) 25 | return 26 | 27 | 28 | if __name__ == "__main__": 29 | main() 30 | -------------------------------------------------------------------------------- /forthic-ts/.gitignore: -------------------------------------------------------------------------------- 1 | # These are some examples of commonly ignored file patterns. 2 | # You should customize this list as applicable to your project. 3 | # Learn more about .gitignore: 4 | # https://www.atlassian.com/git/tutorials/saving-changes/gitignore 5 | 6 | # Node artifact files 7 | node_modules/ 8 | dist/ 9 | 10 | # Compiled Java class files 11 | *.class 12 | 13 | # Compiled Python bytecode 14 | *.py[cod] 15 | 16 | # Log files 17 | *.log 18 | 19 | # Package files 20 | *.jar 21 | 22 | # Maven 23 | target/ 24 | dist/ 25 | 26 | # JetBrains IDE 27 | .idea/ 28 | 29 | # Unit test reports 30 | TEST*.xml 31 | 32 | # Generated by MacOS 33 | .DS_Store 34 | 35 | # Generated by Windows 36 | Thumbs.db 37 | 38 | # Applications 39 | *.app 40 | *.exe 41 | *.war 42 | 43 | # Large media files 44 | *.mp4 45 | *.tiff 46 | *.avi 47 | *.flv 48 | *.mov 49 | *.wmv 50 | 51 | *.pdf 52 | build -------------------------------------------------------------------------------- /forthic-ts/.prettierignore: -------------------------------------------------------------------------------- 1 | # Ignore artifacts: 2 | build 3 | coverage 4 | dist -------------------------------------------------------------------------------- /forthic-ts/.prettierrc: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /forthic-ts/README.md: -------------------------------------------------------------------------------- 1 | # @forthic/interp 2 | 3 | A Forthic interpreter that runs within TypeScript. 4 | 5 | ## Description 6 | 7 | This package provides a Forthic interpreter that allows you to execute Forthic code within your JavaScript/TypeScript projects. Forthic is a stack-based programming language inspired by Forth. 8 | 9 | ## Installation 10 | 11 | You can install the package using npm: 12 | 13 | ```sh 14 | npm install @forthic/interp 15 | ``` 16 | 17 | Or using yarn: 18 | 19 | ```sh 20 | yarn add @forthic/interp 21 | ``` 22 | 23 | ## Usage 24 | Here's a basic example of how to use the Forthic interpreter: 25 | 26 | ```js 27 | import { Interpreter } from "@forthic/interp" 28 | 29 | 30 | (async () => { 31 | const interp = new Interpreter(); 32 | await interp.run("[1 2 3] '3 *' MAP"); 33 | const result = interp.stack_pop(); 34 | console.log("Howdy!", {result}); 35 | })(); 36 | 37 | // Output: 38 | // 39 | // Howdy! { result: [ 3, 6, 9 ] } 40 | ``` 41 | 42 | ## License 43 | This project is licensed under the BSD-2-Clause License see the [LICENSE](./LICENSE) file for details. 44 | 45 | ## Author 46 | Rino Jose 47 | 48 | ## Links 49 | - [Repository](https://github.com/linkedin/forthic/forthic-ts) 50 | - [Issues](https://github.com/linkedin/forthic/issues) -------------------------------------------------------------------------------- /forthic-ts/eslint.config.mjs: -------------------------------------------------------------------------------- 1 | import globals from "globals"; 2 | import pluginJs from "@eslint/js"; 3 | import tseslint from "typescript-eslint"; 4 | 5 | export default [ 6 | { files: ["**/*.{js,mjs,cjs,ts,jsx,tsx}"] }, 7 | { languageOptions: { globals: { ...globals.browser, ...globals.node } } }, 8 | pluginJs.configs.recommended, 9 | ...tseslint.configs.recommended, 10 | { 11 | rules: { 12 | "@typescript-eslint/no-explicit-any": "off", 13 | "@typescript-eslint/no-this-alias": "off", 14 | "@typescript-eslint/no-unused-vars": [ 15 | "error", 16 | { argsIgnorePattern: "^_" }, 17 | ], 18 | }, 19 | }, 20 | ]; 21 | -------------------------------------------------------------------------------- /forthic-ts/jest.config.js: -------------------------------------------------------------------------------- 1 | /** @type {import('ts-jest').JestConfigWithTsJest} **/ 2 | module.exports = { 3 | testEnvironment: "node", 4 | transform: { 5 | "^.+.tsx?$": ["ts-jest", {}], 6 | }, 7 | testMatch: ["**/tests/**/*.test.[jt]s?(x)"], 8 | }; 9 | -------------------------------------------------------------------------------- /forthic-ts/src/forthic/tests/interpreter_validation.test.ts: -------------------------------------------------------------------------------- 1 | import { Interpreter } from "../interpreter"; 2 | import { UnknownWordError, MissingSemicolonError } from "../errors"; 3 | import { UnterminatedStringError } from "../tokenizer"; 4 | 5 | test("Initial state", () => { 6 | const interp = new Interpreter(); 7 | expect((interp as any).stack).toEqual([]); 8 | expect(interp.cur_module().name).toEqual(""); 9 | expect(interp.get_validation_mode()).toBe(false); 10 | }); 11 | 12 | test("Unknown word", async () => { 13 | const interp = new Interpreter(); 14 | interp.set_validation_mode(true); 15 | await expect(interp.run("UNKNOWN")).rejects.toThrow(UnknownWordError); 16 | }); 17 | 18 | test("Missing semicolon", async () => { 19 | const interp = new Interpreter(); 20 | interp.set_validation_mode(true); 21 | await expect(interp.run(": UNKNOWN : HOWDY ;")).rejects.toThrow(MissingSemicolonError); 22 | }); 23 | 24 | 25 | test("Unterminated string", async () => { 26 | const interp = new Interpreter(); 27 | interp.set_validation_mode(true); 28 | await expect(interp.run("'Hello")).rejects.toThrow(UnterminatedStringError); 29 | }); 30 | -------------------------------------------------------------------------------- /forthic-ts/src/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./forthic/interpreter.js"; 2 | export * from "./forthic/tokenizer"; 3 | export * from "./forthic/module.js"; 4 | export * from "./forthic/errors.js" 5 | export * from "./forthic/utils.js" 6 | -------------------------------------------------------------------------------- /forthic-ts/tsconfig.cjs.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "outDir": "./dist/cjs", 4 | "module": "NodeNext", 5 | "target": "ES2023", 6 | "lib": ["ES2023", "DOM"], 7 | "declaration": true, 8 | "sourceMap": true, 9 | "moduleResolution": "nodenext" 10 | }, 11 | "include": ["src"], 12 | "exclude": ["src/**/__tests__", "src/**/__mocks__", "src/**/tests"] 13 | } -------------------------------------------------------------------------------- /forthic-ts/tsconfig.esm.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "outDir": "./dist/esm", 4 | "module": "ESNext", 5 | "target": "ES2023", 6 | "lib": ["ES2023", "DOM"], 7 | "declaration": true, 8 | "sourceMap": true, 9 | "moduleResolution": "bundler", 10 | "emitDeclarationOnly": false, 11 | "esModuleInterop": true 12 | }, 13 | "include": ["src"], 14 | "exclude": ["src/**/__tests__", "src/**/__mocks__", "src/**/tests"] 15 | } -------------------------------------------------------------------------------- /forthic-ts/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "outDir": "./dist", 4 | "allowJs": true, 5 | "target": "ES2023", 6 | "lib": ["ES2023", "DOM"], 7 | "moduleResolution": "node", 8 | "esModuleInterop": true, 9 | "baseUrl": ".", 10 | "paths": { 11 | "@forthix/utils": ["node_modules/@forthix/utils"] 12 | } 13 | }, 14 | "include": ["./src/**/*"] 15 | } 16 | -------------------------------------------------------------------------------- /make-delete-secrets.ps1: -------------------------------------------------------------------------------- 1 | rm ./server/.key 2 | rm ./server/.secrets -------------------------------------------------------------------------------- /make-install.ps1: -------------------------------------------------------------------------------- 1 | python -m venv myenv 2 | ./myenv/Scripts/Activate.ps1 3 | python -m pip install -U pip 4 | pip install ./forthic-py -------------------------------------------------------------------------------- /make-server.ps1: -------------------------------------------------------------------------------- 1 | ./myenv/Scripts/Activate.ps1 2 | $env:FLASK_APP="run.py" 3 | $env:FLASK_DEBUG="true" 4 | cd server && flask run --port=5000 -------------------------------------------------------------------------------- /server/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linkedin/forthic/dd84e4145e2a89df83026313d22e8885835502ab/server/__init__.py -------------------------------------------------------------------------------- /server/apps/README.md: -------------------------------------------------------------------------------- 1 | ## TODO: Describe structure of apps and the config.json file -------------------------------------------------------------------------------- /server/apps/archetypes/jira-time-in-state/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "forthic_version": "v3", 3 | "tags": ["archetype", "jira"] 4 | } -------------------------------------------------------------------------------- /server/apps/coding-forthic/cache-example/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "forthic_version": "v3", 3 | "tags": ["coding-forthic", "cache"] 4 | } -------------------------------------------------------------------------------- /server/apps/coding-forthic/cache-example/main.forthic: -------------------------------------------------------------------------------- 1 | ["cache"] USE-MODULES 2 | 3 | # This stores the array of strings under the "greek" key in the cache. 4 | # You can examine the cache by looking at the `.cache` file in the 5 | # example app's directory 6 | ["Alpha" "Beta" "Gamma"] "greek" cache.CACHE! 7 | 8 | # This returns the value of the cached content 9 | : GREEK "greek" cache.CACHE@; 10 | 11 | : MAIN-PAGE ["" GREEK >STR ""] CONCAT; -------------------------------------------------------------------------------- /server/apps/coding-forthic/gsheet-example/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "forthic_version": "v3", 3 | "tags": ["coding-forthic", "gsheet"] 4 | } -------------------------------------------------------------------------------- /server/apps/coding-forthic/gsheet-example/main.forthic: -------------------------------------------------------------------------------- 1 | ["contexts" "gsheet"] USE-MODULES 2 | 3 | contexts.GOOGLE gsheet.PUSH-CONTEXT! 4 | 5 | # NOTE: Follow the direcitons in EXAMPLES.md to set up your Google client 6 | 7 | # Instructions: Replace this with your gsheet URL 8 | : GSHEET-URL "https://add-your-gsheet-url-here"; 9 | 10 | : TAB GSHEET-URL gsheet.TAB; 11 | : TAB-ROWS TAB gsheet.ROWS; 12 | : |TO-LINES ">STR" MAP "
" JOIN; 13 | : MAIN-PAGE ["" TAB-ROWS |TO-LINES ""] CONCAT; -------------------------------------------------------------------------------- /server/apps/coding-forthic/intake-branched/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "forthic_version": "v3", 3 | "tags": ["coding-forthic", "jira", "gsheet"] 4 | } -------------------------------------------------------------------------------- /server/apps/coding-forthic/intake-branched/intake-branched - Branched.tsv: -------------------------------------------------------------------------------- 1 | Field ID Jira Field Field Label Field Description Is Required? Field Type Field Content Max Input Length Condition 2 | subject Summary Subject Please enter a summary Yes TextInput 255 3 | request_type Description Request Type Select a request type Yes Dropdown New Feature Bug Report Unimportant ask -------------------------------------------------------------------------------- /server/apps/coding-forthic/intake-branched/intake-branched - Continue.tsv: -------------------------------------------------------------------------------- 1 | Field ID Jira Field Field Label Field Description Is Required? Field Type Field Content Max Input Length Condition 2 | problem description Description Please describe your problem Yes Textarea -------------------------------------------------------------------------------- /server/apps/coding-forthic/intake-branched/intake-branched - Self-service.tsv: -------------------------------------------------------------------------------- 1 | Field ID Jira Field Field Label Field Description Is Required? Field Type Field Content Max Input Length Condition 2 | self_service Markdown ## Self-service We believe your issue would best be handled by these self service resources 3 | resources Html
Resource
go/help
-------------------------------------------------------------------------------- /server/apps/coding-forthic/intake-multistep/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "forthic_version": "v3", 3 | "tags": ["coding-forthic", "jira", "gsheet"] 4 | } -------------------------------------------------------------------------------- /server/apps/coding-forthic/intake-multistep/intake-multistep - Multistep 2.tsv: -------------------------------------------------------------------------------- 1 | Field ID Jira Field Field Label Field Description Is Required? Field Type Field Content Max Input Length Condition 2 | impact Labels Impact What is the impact Yes Dropdown High Medium Low 3 | team Labels Team What team should handle this? Yes RadioCheckbox Engineering Product Sales -------------------------------------------------------------------------------- /server/apps/coding-forthic/intake-multistep/intake-multistep - Multistep.tsv: -------------------------------------------------------------------------------- 1 | Field ID Jira Field Field Label Field Description Is Required? Field Type Field Content Max Input Length Condition 2 | summary Summary Subject Add a summary of your request Yes TextInput 3 | description Description Problem Add more details about your problem Yes Textarea -------------------------------------------------------------------------------- /server/apps/coding-forthic/intake-simple/README.md: -------------------------------------------------------------------------------- 1 | # intake-simple 2 | This is an example of a single step intake form. You can run this out of the box because the 3 | `.cache` file contains config information stored by running `REFRESH-CONFIGS!`. The source spreadsheet 4 | is in the [intake-simple - Simple.tsv](./intake-simple%20-%20Simple.tsv) file. 5 | 6 | ## Configuring for your own case 7 | To run this on your own, make sure you've set up Forthic to [work with Jira](https://www.youtube.com/watch?v=sK4_8esQttw) 8 | and [with Google Sheets](https://www.youtube.com/watch?v=BPg8RlQfUFE). Then you can do the following: 9 | 10 | 1. Update `CONFIG-URL` to point to a new Google sheet 11 | 2. Change `FORM-ADMINS` to include your user info (for Jira Cloud, this will be the email you use for your instance) 12 | 3. Update `FORM-CONFIGS` to reflect your Jira Project and Issue Type 13 | 4. Load the example and click on the "Refresh Configs" button. This will ensure that a config tab exists in your Google sheet 14 | 5. Import the [intake-simple - Simple.tsv](./intake-simple%20-%20Simple.tsv) file into your config tab and click "Refresh Configs" again 15 | -------------------------------------------------------------------------------- /server/apps/coding-forthic/intake-simple/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "forthic_version": "v3", 3 | "tags": ["coding-forthic", "jira", "gsheet"] 4 | } -------------------------------------------------------------------------------- /server/apps/coding-forthic/intake-simple/intake-simple - Simple.tsv: -------------------------------------------------------------------------------- 1 | Field ID Jira Field Field Label Field Description Is Required? Field Type Field Content Max Input Length Condition 2 | summary Summary Subject A *one sentence* description of your ask Yes TextInput 255 3 | problem Description Problem Please enter more details about your problem Yes Textarea 4 | impact Description Impact What is the impact? Yes Textarea 5 | urgency Description Urgency How urgent is this? Yes Dropdown Extremely Urgent Urgent Fairly Urgent Not Urgent -------------------------------------------------------------------------------- /server/apps/coding-forthic/jira-example/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "forthic_version": "v3", 3 | "tags": ["coding-forthic", "gsheet"] 4 | } -------------------------------------------------------------------------------- /server/apps/coding-forthic/jira-example/main.forthic: -------------------------------------------------------------------------------- 1 | ["contexts" "jira" "jinja"] USE-MODULES 2 | 3 | contexts.JIRA-PROD jira.PUSH-CONTEXT! 4 | 5 | : JQL ["resolution = null and updated > -3d"] CONCAT; 6 | : FIELDS ['Summary' 'Assignee']; 7 | : |TO-LINES ">STR" MAP "
" JOIN; 8 | @: ACTIVE-TICKETS JQL FIELDS jira.SEARCH; 9 | 10 | : MAIN-TEMPLATE ''' 11 |

Jira Example

12 |

Num tickets: {{ num_tickets }}

13 | 14 | {{ ticket_json_lines }} 15 | 16 | '''; 17 | 18 | : MAIN-DATA [ 19 | ["num_tickets" ACTIVE-TICKETS LENGTH] 20 | ["ticket_json_lines" ACTIVE-TICKETS |TO-LINES] 21 | ] REC; 22 | 23 | : MAIN-PAGE MAIN-TEMPLATE MAIN-DATA jinja.RENDER; 24 | -------------------------------------------------------------------------------- /server/apps/coding-forthic/simple/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "forthic_version": "v3", 3 | "tags": ["coding-forthic", "cache"] 4 | } -------------------------------------------------------------------------------- /server/apps/coding-forthic/simple/main.forthic: -------------------------------------------------------------------------------- 1 | ["simple"] USE-MODULES 2 | 3 | : RUN 2 5 + 4 *; 4 | : MAIN-PAGE ["" RUN >JSON ""] CONCAT; 5 | -------------------------------------------------------------------------------- /server/apps/coding-forthic/time-in-state/README.md: -------------------------------------------------------------------------------- 1 | # Time in State 2 | This example shows how to compute the time that tickets were in each of their states. 3 | Part 1 starts with an existing app and revises it to make it more categorical. 4 | 5 | ## References 6 | - [CF03 Time in State, Part 1 (YouTube)](https://youtu.be/_cjNMRpo97M) 7 | - [CF04 Time in State, Part 2 (YouTube)](https://youtu.be/Ytu9YLu0EAg) -------------------------------------------------------------------------------- /server/apps/coding-forthic/time-in-state/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "forthic_version": "v3", 3 | "tags": ["coding-forthic", "jira"] 4 | } -------------------------------------------------------------------------------- /server/apps/coding-forthic/time-in-state/main.forthic.part1-final: -------------------------------------------------------------------------------- 1 | # NOTE: This is the ending point for [CF03 Jira Time in State, Part 1](https://youtu.be/_cjNMRpo97M) 2 | 3 | ["jira" "contexts"] USE-MODULES 4 | 5 | contexts.JIRA-PROD jira.PUSH-CONTEXT! 6 | 7 | # ----- Utils ------------------------------------------------------------------------------------- 8 | : |TO-LINES ">JSON" MAP "
" JOIN; 9 | 10 | # ----- Report ------------------------------------------------------------------------------------ 11 | ["ticket"] VARIABLES 12 | 13 | : TICKETS "" ["Resolution" "Status" "Assignee"] jira.SEARCH; 14 | : ticket-RESOLUTION ticket @ 'Resolution' REC@; 15 | : ticket-KEY ticket @ 'key' REC@; 16 | : ticket-STATUS-CHANGES ticket-KEY ['status'] jira.CHANGELOG; 17 | : ticket-STATE-DURATION ticket-RESOLUTION ticket-STATUS-CHANGES 'status' jira.TIME-IN-STATE; 18 | : AUGMENTED-TICKETS TICKETS "(ticket !@) ticket-STATE-DURATION 'duration' " AUGMENTED-TICKETS |TO-LINES ""] CONCAT; 20 | 21 | # ----- MAIN-PAGE ------------------------------------------------------------------------------------ 22 | : MAIN-PAGE REPORT; 23 | 24 | -------------------------------------------------------------------------------- /server/apps/coding-forthic/time-in-state/main.forthic.part2-start: -------------------------------------------------------------------------------- 1 | # NOTE: This is the starting point for [CF04 Jira Time in State, Part 2](https://youtu.be/Ytu9YLu0EAg) 2 | 3 | ["jira" "contexts"] USE-MODULES 4 | 5 | contexts.JIRA-PROD jira.PUSH-CONTEXT! 6 | 7 | # ----- Utils ------------------------------------------------------------------------------------- 8 | : |TO-LINES ">JSON" MAP "
" JOIN; 9 | 10 | # ----- Report ------------------------------------------------------------------------------------ 11 | ["ticket"] VARIABLES 12 | 13 | : TICKETS "" ["Resolution" "Status" "Assignee"] jira.SEARCH; 14 | : ticket-RESOLUTION ticket @ 'Resolution' REC@; 15 | : ticket-KEY ticket @ 'key' REC@; 16 | : ticket-STATUS-CHANGES ticket-KEY ['status'] jira.CHANGELOG; 17 | : ticket-STATE-DURATION ticket-RESOLUTION ticket-STATUS-CHANGES 'status' jira.TIME-IN-STATE; 18 | : AUGMENTED-TICKETS TICKETS "(ticket !@) ticket-STATE-DURATION 'duration' " AUGMENTED-TICKETS |TO-LINES ""] CONCAT; 20 | 21 | # ----- MAIN-PAGE ------------------------------------------------------------------------------------ 22 | : MAIN-PAGE REPORT; 23 | 24 | -------------------------------------------------------------------------------- /server/apps/coding-forthic/time-in-state/main.forthic.start: -------------------------------------------------------------------------------- 1 | # NOTE: This is the starting point for a video on how to tweak Forthic code 2 | ["jira" "contexts"] USE-MODULES 3 | 4 | contexts.JIRA-PROD jira.PUSH-CONTEXT! 5 | 6 | 7 | ["my_tickets"] VARIABLES 8 | 9 | : GET-TICKETS "Your JQL here" ["Resolution" "Status"] jira.SEARCH; 10 | : PUSH-JQL-RECORD my_tickets !; 11 | : PULL-JQL-RECORD my_tickets @; 12 | : TICKET-RESOLUTION PULL-JQL-RECORD 'Resolution' REC@; 13 | : TICKET-KEY PULL-JQL-RECORD 'key' REC@; 14 | : TICKET-STATUS-CHANGES TICKET-KEY ['status'] jira.CHANGELOG; 15 | : TICKET-STATE-DURATION TICKET-RESOLUTION TICKET-STATUS-CHANGES 'status' jira.TIME-IN-STATE; 16 | : STATE-DURATION-FOR-TICKET TICKET-STATE-DURATION; 17 | : STATE-DURATION-FOR-TICKETS GET-TICKETS "PUSH-JQL-RECORD STATE-DURATION-FOR-TICKET" MAP; # return the time in state for all the tickets returened by JQL 18 | : |TO-LINES ">JSON" MAP "
" JOIN; 19 | : PRINT-DURATION-FOR-TICKETS ["" STATE-DURATION-FOR-TICKETS |TO-LINES ""] CONCAT; 20 | : MAIN-PAGE PRINT-DURATION-FOR-TICKETS; # print the results where the JSON is converted to string to print. 21 | 22 | -------------------------------------------------------------------------------- /server/apps/talks/jira/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "forthic_version": "v3", 3 | "tags": ["coding-forthic", "cache"] 4 | } -------------------------------------------------------------------------------- /server/apps/talks/jira/main.forthic: -------------------------------------------------------------------------------- 1 | ["jira" "contexts" "cache"] USE-MODULES 2 | 3 | contexts.JIRA-PROD jira.PUSH-CONTEXT! 4 | 5 | : JQL "resolution = null and updated > -60d"; 6 | : FIELDS ["Summary" "Assignee" "Status"]; 7 | : TICKETS JQL FIELDS jira.SEARCH; 8 | 9 | TICKETS 10 | # TICKETS "Assignee" GROUP-BY-FIELD "LENGTH" MAP "tickets" cache.CACHE! 11 | 12 | -------------------------------------------------------------------------------- /server/apps/talks/map/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "forthic_version": "v3", 3 | "tags": ["coding-forthic", "cache"] 4 | } -------------------------------------------------------------------------------- /server/apps/talks/map/main.forthic: -------------------------------------------------------------------------------- 1 | [1 2 3] "3 *" MAP 2 | 3 | # [ 4 | # ["alpha" 1] 5 | # ["beta" 2] 6 | # ["gamma" 3] 7 | # ] REC "3 *" MAP -------------------------------------------------------------------------------- /server/apps/talks/simple/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "forthic_version": "v3", 3 | "tags": ["coding-forthic", "cache"] 4 | } -------------------------------------------------------------------------------- /server/apps/talks/simple/main.forthic: -------------------------------------------------------------------------------- 1 | : VAL 2 5 + 4 *; 2 | [VAL 1 2 3] "3 *" MAP 3 | -------------------------------------------------------------------------------- /server/apps/tests/forthic-react-smoke-test/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "forthic_version": "v3", 3 | "tags": ["test", "smoke-test", "react"] 4 | } -------------------------------------------------------------------------------- /server/apps/tests/forthic-react-smoke-test/main.forthic: -------------------------------------------------------------------------------- 1 | ["ui"] USE-MODULES 2 | 3 | : CSS ''' 4 | h1 { 5 | color: blue; 6 | } 7 | '''; 8 | 9 | : UI-FORTHIC ''' 10 | : H1 "'h1'" Element; 11 | : HOME-ELEMENT H1 "Forthic React Smoke Test" 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | {{main_page |safe}} 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /server/templates/example.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Forthic Example: {{example}} 7 | 8 | 9 |

Forthic Example: {{example}}

10 |

Overview

11 | {{overview |safe}} 12 |

Forthic Code

13 | 14 |
{{example_forthic}}
15 |
16 |

Example Output

17 |
18 | {{html_output |safe}} 19 |
20 | 21 | -------------------------------------------------------------------------------- /server/templates/main.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | Forthic Examples 13 | 14 | 15 |

Forthic Examples

16 | {% for info in ex_infos %} 17 |

{{info['name']}}

18 | {{info['description'] |safe}} 19 |

Link

20 | {% endfor %} 21 | 22 | -------------------------------------------------------------------------------- /server/templates/react/react-app/v1/main.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 26 | 29 | 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /server/templates/talks.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | {{main_page |safe}} 11 | 12 | 13 | 14 | --------------------------------------------------------------------------------