| @ -0,0 +1,213 @@ | |||
| Language: Cpp | |||
| AccessModifierOffset: -4 | |||
| AlignAfterOpenBracket: BlockIndent | |||
| AlignArrayOfStructures: None | |||
| AlignConsecutiveAssignments: | |||
| Enabled: false | |||
| AcrossEmptyLines: false | |||
| AcrossComments: false | |||
| AlignCompound: false | |||
| PadOperators: true | |||
| AlignConsecutiveBitFields: | |||
| Enabled: false | |||
| AcrossEmptyLines: false | |||
| AcrossComments: false | |||
| AlignCompound: false | |||
| PadOperators: false | |||
| AlignConsecutiveDeclarations: | |||
| Enabled: false | |||
| AcrossEmptyLines: false | |||
| AcrossComments: false | |||
| AlignCompound: false | |||
| PadOperators: false | |||
| AlignConsecutiveMacros: | |||
| Enabled: false | |||
| AcrossEmptyLines: false | |||
| AcrossComments: false | |||
| AlignCompound: false | |||
| PadOperators: false | |||
| AlignEscapedNewlines: Right | |||
| AlignOperands: DontAlign | |||
| AlignTrailingComments: true | |||
| AllowAllArgumentsOnNextLine: false | |||
| AllowAllParametersOfDeclarationOnNextLine: false | |||
| AllowShortEnumsOnASingleLine: true | |||
| AllowShortBlocksOnASingleLine: Empty | |||
| AllowShortCaseLabelsOnASingleLine: false | |||
| AllowShortFunctionsOnASingleLine: Inline | |||
| AllowShortLambdasOnASingleLine: All | |||
| AllowShortIfStatementsOnASingleLine: WithoutElse | |||
| AllowShortLoopsOnASingleLine: false | |||
| AlwaysBreakAfterDefinitionReturnType: None | |||
| AlwaysBreakAfterReturnType: None | |||
| AlwaysBreakBeforeMultilineStrings: false | |||
| AlwaysBreakTemplateDeclarations: Yes | |||
| AttributeMacros: | |||
| - __capability | |||
| BinPackArguments: true | |||
| BinPackParameters: true | |||
| BraceWrapping: | |||
| AfterCaseLabel: false | |||
| AfterClass: false | |||
| AfterControlStatement: Never | |||
| AfterEnum: false | |||
| AfterFunction: false | |||
| AfterNamespace: false | |||
| AfterObjCDeclaration: false | |||
| AfterStruct: false | |||
| AfterUnion: false | |||
| AfterExternBlock: false | |||
| BeforeCatch: false | |||
| BeforeElse: false | |||
| BeforeLambdaBody: false | |||
| BeforeWhile: false | |||
| IndentBraces: false | |||
| SplitEmptyFunction: true | |||
| SplitEmptyRecord: true | |||
| SplitEmptyNamespace: true | |||
| BreakBeforeBinaryOperators: None | |||
| BreakBeforeConceptDeclarations: Always | |||
| BreakBeforeBraces: Attach | |||
| BreakBeforeInheritanceComma: false | |||
| BreakInheritanceList: BeforeColon | |||
| BreakBeforeTernaryOperators: false | |||
| BreakConstructorInitializersBeforeComma: false | |||
| BreakConstructorInitializers: BeforeComma | |||
| BreakAfterJavaFieldAnnotations: false | |||
| BreakArrays: true | |||
| BreakStringLiterals: true | |||
| ColumnLimit: 120 | |||
| CommentPragmas: '^ IWYU pragma:' | |||
| QualifierAlignment: Leave | |||
| CompactNamespaces: false | |||
| ConstructorInitializerIndentWidth: 4 | |||
| ContinuationIndentWidth: 4 | |||
| Cpp11BracedListStyle: true | |||
| DeriveLineEnding: true | |||
| DerivePointerAlignment: false | |||
| DisableFormat: false | |||
| EmptyLineAfterAccessModifier: Never | |||
| EmptyLineBeforeAccessModifier: LogicalBlock | |||
| ExperimentalAutoDetectBinPacking: false | |||
| PackConstructorInitializers: BinPack | |||
| BasedOnStyle: '' | |||
| ConstructorInitializerAllOnOneLineOrOnePerLine: false | |||
| AllowAllConstructorInitializersOnNextLine: true | |||
| FixNamespaceComments: true | |||
| ForEachMacros: | |||
| - foreach | |||
| - Q_FOREACH | |||
| - BOOST_FOREACH | |||
| IfMacros: | |||
| - KJ_IF_MAYBE | |||
| IncludeBlocks: Preserve | |||
| IncludeCategories: | |||
| - Regex: '^"(llvm|llvm-c|clang|clang-c)/' | |||
| Priority: 2 | |||
| SortPriority: 0 | |||
| CaseSensitive: false | |||
| - Regex: '^(<|"(gtest|gmock|isl|json)/)' | |||
| Priority: 3 | |||
| SortPriority: 0 | |||
| CaseSensitive: false | |||
| - Regex: '.*' | |||
| Priority: 1 | |||
| SortPriority: 0 | |||
| CaseSensitive: false | |||
| IncludeIsMainRegex: '(Test)?$' | |||
| IncludeIsMainSourceRegex: '' | |||
| IndentAccessModifiers: false | |||
| IndentCaseLabels: true | |||
| IndentCaseBlocks: false | |||
| IndentGotoLabels: true | |||
| IndentPPDirectives: BeforeHash | |||
| IndentExternBlock: AfterExternBlock | |||
| IndentRequiresClause: true | |||
| IndentWidth: 4 | |||
| IndentWrappedFunctionNames: false | |||
| InsertBraces: false | |||
| InsertTrailingCommas: None | |||
| JavaScriptQuotes: Leave | |||
| JavaScriptWrapImports: true | |||
| KeepEmptyLinesAtTheStartOfBlocks: true | |||
| LambdaBodyIndentation: Signature | |||
| MacroBlockBegin: '' | |||
| MacroBlockEnd: '' | |||
| MaxEmptyLinesToKeep: 2 | |||
| NamespaceIndentation: All | |||
| ObjCBinPackProtocolList: Auto | |||
| ObjCBlockIndentWidth: 2 | |||
| ObjCBreakBeforeNestedBlockParam: true | |||
| ObjCSpaceAfterProperty: false | |||
| ObjCSpaceBeforeProtocolList: true | |||
| PenaltyBreakAssignment: 2 | |||
| PenaltyBreakBeforeFirstCallParameter: 19 | |||
| PenaltyBreakComment: 300 | |||
| PenaltyBreakFirstLessLess: 120 | |||
| PenaltyBreakOpenParenthesis: 0 | |||
| PenaltyBreakString: 1000 | |||
| PenaltyBreakTemplateDeclaration: 10 | |||
| PenaltyExcessCharacter: 1000000 | |||
| PenaltyReturnTypeOnItsOwnLine: 60 | |||
| PenaltyIndentedWhitespace: 0 | |||
| PointerAlignment: Left | |||
| PPIndentWidth: -1 | |||
| ReferenceAlignment: Pointer | |||
| ReflowComments: false | |||
| RemoveBracesLLVM: false | |||
| RequiresClausePosition: OwnLine | |||
| SeparateDefinitionBlocks: Leave | |||
| ShortNamespaceLines: 1 | |||
| SortIncludes: CaseSensitive | |||
| SortJavaStaticImport: Before | |||
| SortUsingDeclarations: true | |||
| SpaceAfterCStyleCast: false | |||
| SpaceAfterLogicalNot: false | |||
| SpaceAfterTemplateKeyword: false | |||
| SpaceBeforeAssignmentOperators: true | |||
| SpaceBeforeCaseColon: false | |||
| SpaceBeforeCpp11BracedList: false | |||
| SpaceBeforeCtorInitializerColon: true | |||
| SpaceBeforeInheritanceColon: true | |||
| SpaceBeforeParens: Never | |||
| SpaceBeforeParensOptions: | |||
| AfterControlStatements: false | |||
| AfterForeachMacros: false | |||
| AfterFunctionDefinitionName: false | |||
| AfterFunctionDeclarationName: false | |||
| AfterIfMacros: false | |||
| AfterOverloadedOperator: false | |||
| AfterRequiresInClause: false | |||
| AfterRequiresInExpression: false | |||
| BeforeNonEmptyParentheses: false | |||
| SpaceAroundPointerQualifiers: Default | |||
| SpaceBeforeRangeBasedForLoopColon: true | |||
| SpaceInEmptyBlock: false | |||
| SpaceInEmptyParentheses: false | |||
| SpacesBeforeTrailingComments: 0 | |||
| SpacesInAngles: Never | |||
| SpacesInConditionalStatement: false | |||
| SpacesInContainerLiterals: false | |||
| SpacesInCStyleCastParentheses: false | |||
| SpacesInLineCommentPrefix: | |||
| Minimum: 1 | |||
| Maximum: -1 | |||
| SpacesInParentheses: false | |||
| SpacesInSquareBrackets: false | |||
| SpaceBeforeSquareBrackets: false | |||
| BitFieldColonSpacing: Both | |||
| Standard: c++20 | |||
| StatementAttributeLikeMacros: | |||
| - Q_EMIT | |||
| StatementMacros: | |||
| - Q_UNUSED | |||
| - QT_REQUIRE_VERSION | |||
| TabWidth: 4 | |||
| UseCRLF: false | |||
| UseTab: Never | |||
| WhitespaceSensitiveMacros: | |||
| - STRINGIZE | |||
| - PP_STRINGIZE | |||
| - BOOST_PP_STRINGIZE | |||
| - NS_SWIFT_NAME | |||
| - CF_SWIFT_NAME | |||
| @ -0,0 +1,172 @@ | |||
| --- | |||
| InheritParentConfig: false | |||
| Checks: '-*, | |||
| bugprone-argument-comment, | |||
| bugprone-assert-side-effect, | |||
| bugprone-bad-signal-to-kill-thread, | |||
| bugprone-branch-clone, | |||
| bugprone-copy-constructor-init, | |||
| bugprone-dangling-handle, | |||
| bugprone-dynamic-static-initializers, | |||
| bugprone-fold-init-type, | |||
| bugprone-forward-declaration-namespace, | |||
| bugprone-forwarding-reference-overload, | |||
| bugprone-inaccurate-erase, | |||
| bugprone-incorrect-roundings, | |||
| bugprone-integer-division, | |||
| bugprone-lambda-function-name, | |||
| bugprone-macro-parentheses, | |||
| bugprone-macro-repeated-side-effects, | |||
| bugprone-misplaced-operator-in-strlen-in-alloc, | |||
| bugprone-misplaced-pointer-arithmetic-in-alloc, | |||
| bugprone-misplaced-widening-cast, | |||
| bugprone-move-forwarding-reference, | |||
| bugprone-multiple-statement-macro, | |||
| bugprone-no-escape, | |||
| bugprone-not-null-terminated-result, | |||
| bugprone-parent-virtual-call, | |||
| bugprone-posix-return, | |||
| bugprone-reserved-identifier, | |||
| bugprone-sizeof-container, | |||
| bugprone-sizeof-expression, | |||
| bugprone-spuriously-wake-up-functions, | |||
| bugprone-string-constructor, | |||
| bugprone-string-integer-assignment, | |||
| bugprone-string-literal-with-embedded-nul, | |||
| bugprone-suspicious-enum-usage, | |||
| bugprone-suspicious-include, | |||
| bugprone-suspicious-memory-comparison, | |||
| bugprone-suspicious-memset-usage, | |||
| bugprone-suspicious-missing-comma, | |||
| bugprone-suspicious-semicolon, | |||
| bugprone-suspicious-string-compare, | |||
| bugprone-swapped-arguments, | |||
| bugprone-terminating-continue, | |||
| bugprone-throw-keyword-missing, | |||
| bugprone-too-small-loop-variable, | |||
| bugprone-undefined-memory-manipulation, | |||
| bugprone-undelegated-constructor, | |||
| bugprone-unhandled-self-assignment, | |||
| bugprone-unused-raii, | |||
| bugprone-unused-return-value, | |||
| bugprone-use-after-move, | |||
| bugprone-virtual-near-miss, | |||
| cert-dcl21-cpp, | |||
| cert-dcl58-cpp, | |||
| cert-err34-c, | |||
| cert-err52-cpp, | |||
| cert-err60-cpp, | |||
| cert-flp30-c, | |||
| cert-msc50-cpp, | |||
| cert-msc51-cpp, | |||
| cert-str34-c, | |||
| cppcoreguidelines-interfaces-global-init, | |||
| cppcoreguidelines-narrowing-conversions, | |||
| cppcoreguidelines-pro-type-member-init, | |||
| cppcoreguidelines-pro-type-static-cast-downcast, | |||
| cppcoreguidelines-slicing, | |||
| google-default-arguments, | |||
| google-explicit-constructor, | |||
| google-runtime-operator, | |||
| hicpp-exception-baseclass, | |||
| hicpp-multiway-paths-covered, | |||
| misc-misplaced-const, | |||
| misc-new-delete-overloads, | |||
| misc-no-recursion, | |||
| misc-non-copyable-objects, | |||
| misc-throw-by-value-catch-by-reference, | |||
| misc-unconventional-assign-operator, | |||
| misc-uniqueptr-reset-release, | |||
| modernize-avoid-bind, | |||
| modernize-concat-nested-namespaces, | |||
| modernize-deprecated-headers, | |||
| modernize-deprecated-ios-base-aliases, | |||
| modernize-loop-convert, | |||
| modernize-make-shared, | |||
| modernize-make-unique, | |||
| modernize-pass-by-value, | |||
| modernize-raw-string-literal, | |||
| modernize-redundant-void-arg, | |||
| modernize-replace-auto-ptr, | |||
| modernize-replace-disallow-copy-and-assign-macro, | |||
| modernize-replace-random-shuffle, | |||
| modernize-return-braced-init-list, | |||
| modernize-shrink-to-fit, | |||
| modernize-unary-static-assert, | |||
| modernize-use-auto, | |||
| modernize-use-bool-literals, | |||
| modernize-use-emplace, | |||
| modernize-use-equals-default, | |||
| modernize-use-equals-delete, | |||
| modernize-use-nodiscard, | |||
| modernize-use-noexcept, | |||
| modernize-use-nullptr, | |||
| modernize-use-override, | |||
| modernize-use-transparent-functors, | |||
| modernize-use-uncaught-exceptions, | |||
| mpi-buffer-deref, | |||
| mpi-type-mismatch, | |||
| openmp-use-default-none, | |||
| performance-faster-string-find, | |||
| performance-for-range-copy, | |||
| performance-implicit-conversion-in-loop, | |||
| performance-inefficient-algorithm, | |||
| performance-inefficient-string-concatenation, | |||
| performance-inefficient-vector-operation, | |||
| performance-move-const-arg, | |||
| performance-move-constructor-init, | |||
| performance-no-automatic-move, | |||
| performance-noexcept-move-constructor, | |||
| performance-trivially-destructible, | |||
| performance-type-promotion-in-math-fn, | |||
| performance-unnecessary-copy-initialization, | |||
| performance-unnecessary-value-param, | |||
| portability-simd-intrinsics, | |||
| readability-avoid-const-params-in-decls, | |||
| readability-const-return-type, | |||
| readability-container-size-empty, | |||
| readability-convert-member-functions-to-static, | |||
| readability-delete-null-pointer, | |||
| readability-deleted-default, | |||
| readability-inconsistent-declaration-parameter-name, | |||
| readability-make-member-function-const, | |||
| readability-misleading-indentation, | |||
| readability-misplaced-array-index, | |||
| readability-non-const-parameter, | |||
| readability-redundant-control-flow, | |||
| readability-redundant-declaration, | |||
| readability-identifier-naming, | |||
| readability-redundant-function-ptr-dereference, | |||
| readability-redundant-smartptr-get, | |||
| readability-redundant-string-cstr, | |||
| readability-redundant-string-init, | |||
| readability-simplify-subscript-expr, | |||
| readability-static-accessed-through-instance, | |||
| readability-static-definition-in-anonymous-namespace, | |||
| readability-string-compare, | |||
| readability-uniqueptr-delete-release, | |||
| readability-use-anyofallof' | |||
| CheckOptions: | |||
| - {key: readability-identifier-naming.NamespaceCase, value: lower_case } | |||
| - {key: readability-identifier-naming.AbstractClassCase, value: lower_case } | |||
| - {key: readability-identifier-naming.ClassCase, value: lower_case } | |||
| - {key: readability-identifier-naming.ClassMemberCase, value: lower_case } | |||
| - {key: readability-identifier-naming.ClassMethodCase, value: lower_case } | |||
| - {key: readability-identifier-naming.ClassConstantCase, value: lower_case } | |||
| - {key: readability-identifier-naming.ConstantParameterCase, value: lower_case } | |||
| - {key: readability-identifier-naming.ConstantMemberCase, value: lower_case } | |||
| - {key: readability-identifier-naming.ConstexprFunctionCase, value: lower_case } | |||
| - {key: readability-identifier-naming.ConstantPointerParameterCase, value: lower_case } | |||
| - {key: readability-identifier-naming.TemplateParameterCase, value: CamelCase } | |||
| - {key: readability-identifier-naming.VirtualMethodCase, value: lower_case } | |||
| - {key: readability-identifier-naming.TypedefCase, value: lower_case } | |||
| - {key: readability-identifier-naming.StructCase, value: lower_case } | |||
| - {key: readability-identifier-naming.FunctionCase, value: lower_case } | |||
| - {key: readability-identifier-naming.MethodCase, value: lower_case } | |||
| - {key: readability-identifier-naming.MemberCase, value: lower_case } | |||
| - {key: readability-identifier-naming.ParameterCase, value: lower_case } | |||
| - {key: readability-identifier-naming.VariableCase, value: lower_case } | |||
| - {key: readability-identifier-naming.LocalVariableCase, value: lower_case } | |||
| - {key: readability-identifier-naming.GlobalConstantCase, value: lower_case } | |||
| - {key: readability-identifier-naming.ConstexprVariableCase, value: lower_case } | |||
| - {key: readability-identifier-naming.EnumConstantCase, value: lower_case } | |||
| @ -0,0 +1,48 @@ | |||
| <component name="ProjectCodeStyleConfiguration"> | |||
| <code_scheme name="Project" version="173"> | |||
| <option name="LINE_SEPARATOR" value="
" /> | |||
| <Objective-C-extensions> | |||
| <rules> | |||
| <rule entity="NAMESPACE" visibility="ANY" specifier="ANY" prefix="" style="SNAKE_CASE" suffix="" /> | |||
| <rule entity="MACRO" visibility="ANY" specifier="ANY" prefix="" style="SNAKE_CASE" suffix="" /> | |||
| <rule entity="CLASS" visibility="ANY" specifier="ANY" prefix="" style="SNAKE_CASE" suffix="" /> | |||
| <rule entity="STRUCT" visibility="ANY" specifier="ANY" prefix="" style="SNAKE_CASE" suffix="" /> | |||
| <rule entity="ENUM" visibility="ANY" specifier="ANY" prefix="" style="SNAKE_CASE" suffix="" /> | |||
| <rule entity="ENUMERATOR" visibility="ANY" specifier="ANY" prefix="" style="SNAKE_CASE" suffix="" /> | |||
| <rule entity="TYPEDEF" visibility="ANY" specifier="ANY" prefix="" style="SNAKE_CASE" suffix="" /> | |||
| <rule entity="UNION" visibility="ANY" specifier="ANY" prefix="" style="SNAKE_CASE" suffix="" /> | |||
| <rule entity="CLASS_MEMBER_FUNCTION" visibility="ANY" specifier="ANY" prefix="" style="SNAKE_CASE" suffix="" /> | |||
| <rule entity="STRUCT_MEMBER_FUNCTION" visibility="ANY" specifier="ANY" prefix="" style="SNAKE_CASE" suffix="" /> | |||
| <rule entity="CLASS_MEMBER_FIELD" visibility="ANY" specifier="ANY" prefix="" style="SNAKE_CASE" suffix="" /> | |||
| <rule entity="STRUCT_MEMBER_FIELD" visibility="ANY" specifier="ANY" prefix="" style="SNAKE_CASE" suffix="" /> | |||
| <rule entity="GLOBAL_FUNCTION" visibility="ANY" specifier="ANY" prefix="" style="SNAKE_CASE" suffix="" /> | |||
| <rule entity="GLOBAL_VARIABLE" visibility="ANY" specifier="ANY" prefix="" style="SNAKE_CASE" suffix="" /> | |||
| <rule entity="PARAMETER" visibility="ANY" specifier="ANY" prefix="" style="SNAKE_CASE" suffix="" /> | |||
| <rule entity="LOCAL_VARIABLE" visibility="ANY" specifier="ANY" prefix="" style="SNAKE_CASE" suffix="" /> | |||
| </rules> | |||
| </Objective-C-extensions> | |||
| <Objective-C-extensions> | |||
| <rules> | |||
| <rule entity="NAMESPACE" visibility="ANY" specifier="ANY" prefix="" style="SNAKE_CASE" suffix="" /> | |||
| <rule entity="MACRO" visibility="ANY" specifier="ANY" prefix="" style="SNAKE_CASE" suffix="" /> | |||
| <rule entity="CLASS" visibility="ANY" specifier="ANY" prefix="" style="SNAKE_CASE" suffix="" /> | |||
| <rule entity="STRUCT" visibility="ANY" specifier="ANY" prefix="" style="SNAKE_CASE" suffix="" /> | |||
| <rule entity="ENUM" visibility="ANY" specifier="ANY" prefix="" style="SNAKE_CASE" suffix="" /> | |||
| <rule entity="ENUMERATOR" visibility="ANY" specifier="ANY" prefix="" style="SNAKE_CASE" suffix="" /> | |||
| <rule entity="TYPEDEF" visibility="ANY" specifier="ANY" prefix="" style="SNAKE_CASE" suffix="" /> | |||
| <rule entity="UNION" visibility="ANY" specifier="ANY" prefix="" style="SNAKE_CASE" suffix="" /> | |||
| <rule entity="CLASS_MEMBER_FUNCTION" visibility="ANY" specifier="ANY" prefix="" style="SNAKE_CASE" suffix="" /> | |||
| <rule entity="STRUCT_MEMBER_FUNCTION" visibility="ANY" specifier="ANY" prefix="" style="SNAKE_CASE" suffix="" /> | |||
| <rule entity="CLASS_MEMBER_FIELD" visibility="ANY" specifier="ANY" prefix="" style="SNAKE_CASE" suffix="" /> | |||
| <rule entity="STRUCT_MEMBER_FIELD" visibility="ANY" specifier="ANY" prefix="" style="SNAKE_CASE" suffix="" /> | |||
| <rule entity="GLOBAL_FUNCTION" visibility="ANY" specifier="ANY" prefix="" style="SNAKE_CASE" suffix="" /> | |||
| <rule entity="GLOBAL_VARIABLE" visibility="ANY" specifier="ANY" prefix="" style="SNAKE_CASE" suffix="" /> | |||
| <rule entity="PARAMETER" visibility="ANY" specifier="ANY" prefix="" style="SNAKE_CASE" suffix="" /> | |||
| <rule entity="LOCAL_VARIABLE" visibility="ANY" specifier="ANY" prefix="" style="SNAKE_CASE" suffix="" /> | |||
| </rules> | |||
| </Objective-C-extensions> | |||
| <clangFormatSettings> | |||
| <option name="ENABLED" value="true" /> | |||
| </clangFormatSettings> | |||
| </code_scheme> | |||
| </component> | |||
| @ -0,0 +1,5 @@ | |||
| <component name="ProjectCodeStyleConfiguration"> | |||
| <state> | |||
| <option name="USE_PER_PROJECT_SETTINGS" value="true" /> | |||
| </state> | |||
| </component> | |||
| @ -0,0 +1,7 @@ | |||
| <component name="InspectionProjectProfileManager"> | |||
| <profile version="1.0"> | |||
| <option name="myName" value="Project Default" /> | |||
| <inspection_tool class="OCInconsistentNaming" enabled="true" level="WEAK WARNING" enabled_by_default="true" /> | |||
| <inspection_tool class="UnconstrainedVariableType" enabled="true" level="WARNING" enabled_by_default="true" /> | |||
| </profile> | |||
| </component> | |||
| @ -1,7 +1,4 @@ | |||
| __PROC__ procedure_name | |||
| i16 i8 | |||
| __PROC__ main | |||
| __--__ | |||
| i32 | |||
| __DO__ | |||
| i32 __CAST__ __SWAP__ i32 __CAST__ * | |||
| __END__ | |||
| @ -1,55 +1,85 @@ | |||
| #include "molasses/lexer.h" | |||
| #include "molasses/parser_primitives.h" | |||
| #include <cstring> | |||
| #include <filesystem> | |||
| #include <fstream> | |||
| #include <iostream> | |||
| #include <sstream> | |||
| #include <stack> | |||
| #include <string> | |||
| #include <variant> | |||
| int main() { | |||
| /* | |||
| molasses::lexed_output initial; | |||
| initial.dictionary[1] = "+"; | |||
| { | |||
| auto v = molasses::lex("hello hello potato 128 hello 128 +"); | |||
| auto v2 = molasses::lex("salad hello potato 129 hello 128"); | |||
| for (auto symbol: v.symbols) { | |||
| std::cout << "v: " << symbol << " - " << v.dictionary.at(symbol) << "\n"; | |||
| } | |||
| std::cout << "\n"; | |||
| for (auto symbol: v2.symbols) { | |||
| std::cout << "v2: " << symbol << " - " << v2.dictionary.at(symbol) << "\n"; | |||
| } | |||
| auto v_merged = molasses::concatenate(initial, molasses::concatenate(v, v2)); | |||
| std::cout << "\n"; | |||
| for (auto symbol: v_merged.symbols) { | |||
| std::cout << "v_merged: " << symbol << " - " << v_merged.dictionary.at(symbol) << "\n"; | |||
| } | |||
| } | |||
| auto v = molasses::lex("1 2 +"); | |||
| molasses::parser_context ctx; | |||
| ctx = molasses::register_integers(ctx); | |||
| ctx.operations.emplace_back(std::make_shared<molasses::primitive_operation>(std::string{"+"}, std::vector<std::string>({"i32", "i32"}), std::vector<std::string>({"i32"}))); | |||
| if(molasses::type_check(ctx, v, v.symbols, {}, {"i32"})) { | |||
| std::cout << "Checks out\n"; | |||
| }*/ | |||
| /* | |||
| auto lexed = molasses::lex("__PROC__ sum\n" | |||
| "i32 i32\n" | |||
| "__--__\n" | |||
| "i32\n" | |||
| "__DO__\n" | |||
| "+\n" | |||
| "__END__");*/ | |||
| auto lexed = molasses::lex("__PROC__ main\n" | |||
| "__--__\n" | |||
| "__DO__\n" | |||
| "__END__"); | |||
| molasses::parser_context ctx; | |||
| ctx = molasses::register_integers(ctx); | |||
| ctx = molasses::register_i32_operations(ctx); | |||
| molasses::parse(ctx, lexed); | |||
| using compile_element = std::variant<molasses::lexed_output, molasses::generate_context, std::string>; | |||
| int main(int argc, char** argv) { | |||
| std::vector<std::string> arguments; | |||
| while(argc > 1) { | |||
| argv++; | |||
| arguments.emplace_back(*argv, strlen(*argv)); | |||
| argc--; | |||
| } | |||
| std::stack<compile_element> compile_stack; | |||
| for(auto elem : arguments) { | |||
| if(elem == "generate") { | |||
| if(std::holds_alternative<std::string>(compile_stack.top())) { | |||
| auto filename = std::get<std::string>(compile_stack.top()); | |||
| compile_stack.pop(); | |||
| if(std::holds_alternative<molasses::generate_context>(compile_stack.top())) { | |||
| auto generator = std::get<molasses::generate_context>(compile_stack.top()); | |||
| compile_stack.pop(); | |||
| auto assembler = molasses::generate(generator); | |||
| std::ofstream output(filename+".s"); | |||
| for(const auto& line : assembler) { | |||
| output << line; | |||
| } | |||
| compile_stack.emplace(filename); | |||
| } else throw std::runtime_error("generate expects a parsed output"); | |||
| } else throw std::runtime_error("generate expects a filename"); | |||
| } else if(elem == "parse") { | |||
| molasses::parser_context ctx; | |||
| ctx = molasses::register_integers(ctx); | |||
| ctx = molasses::register_i32_operations(ctx); | |||
| if(std::holds_alternative<molasses::lexed_output>(compile_stack.top())) { | |||
| auto lexer = std::get<molasses::lexed_output>(compile_stack.top()); | |||
| compile_stack.pop(); | |||
| auto generator = molasses::parse(ctx, lexer); | |||
| compile_stack.emplace(generator); | |||
| } else throw std::runtime_error("parse expects a lexed output"); | |||
| } else if(elem == "lex") { | |||
| if(std::holds_alternative<std::string>(compile_stack.top())) { | |||
| auto filename = std::get<std::string>(compile_stack.top()); | |||
| compile_stack.pop(); | |||
| if(not std::filesystem::exists(filename)) throw std::runtime_error("file "+filename+" does not exist"); | |||
| std::ifstream t(filename); | |||
| std::stringstream buffer; | |||
| buffer << t.rdbuf(); | |||
| auto lexed = molasses::lex(buffer.str()); | |||
| compile_stack.emplace(lexed); | |||
| } else throw std::runtime_error("lex expects a filename"); | |||
| } else if(elem == "merge") { | |||
| if(std::holds_alternative<molasses::lexed_output>(compile_stack.top())) { | |||
| auto lexer_1 = std::get<molasses::lexed_output>(compile_stack.top()); | |||
| compile_stack.pop(); | |||
| if(std::holds_alternative<molasses::lexed_output>(compile_stack.top())) { | |||
| auto lexer_2 = std::get<molasses::lexed_output>(compile_stack.top()); | |||
| compile_stack.pop(); | |||
| compile_stack.emplace(molasses::concatenate(lexer_1, lexer_2)); | |||
| } else throw std::runtime_error("merge expects 2 lexed outputs"); | |||
| } else throw std::runtime_error("merge expects 2 lexed outputs"); | |||
| } else if(elem == "assemble") { | |||
| if(std::holds_alternative<std::string>(compile_stack.top())) { | |||
| auto filename = std::get<std::string>(compile_stack.top()); | |||
| compile_stack.pop(); | |||
| std::stringstream compile; compile << "clang -c " << filename << ".s -o " << filename << ".o"; | |||
| std::stringstream link; link << "ld -e _start " << filename << ".o -o " << filename; | |||
| std::cout << compile.str() << std::endl; | |||
| system(compile.str().c_str()); | |||
| std::cout << link.str() << std::endl; | |||
| system(link.str().c_str()); | |||
| } else throw std::runtime_error("assemble expects an assembly file"); | |||
| } else compile_stack.emplace(elem); | |||
| } | |||
| } | |||