Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/code formatter #443

Merged
merged 12 commits into from
Mar 31, 2024
Merged

Feat/code formatter #443

merged 12 commits into from
Mar 31, 2024

Conversation

SuperFola
Copy link
Member

@SuperFola SuperFola commented Mar 24, 2024

Description

Adds a very simple and non-configurable ArkScript code formatter to the CLI.

It seems that with the parser modifications this PR required, the parsing times went up by a lot. I'll need to confirm and check why.

Closes #421

Checklist

  • I have read the Contributor guide
  • My code follows the style guidelines of this project
  • I have commented my code, particularly in hard-to-understand areas
  • I have updated the documentation if needed
  • I have added tests that prove my fix/feature is working
  • New and existing tests pass locally with my changes

@SuperFola
Copy link
Member Author

SuperFola commented Mar 24, 2024

It occurred to me that a lot of calls of getCursor were added, and this method recompute the position every time it's called, from scratch. An alternative will have to be created, so that we can dynamically compute the line and column number when calling next/backtrack, without requiring to recompute from scratch said cursor.

Edit: this has been fixed, see BaseParser and the usage of m_it_to_row.

@SuperFola SuperFola force-pushed the feat/code-formatter branch 2 times, most recently from 2e33e10 to ed5db0f Compare March 25, 2024 13:20
@SuperFola SuperFola force-pushed the feat/code-formatter branch from ed5db0f to 59ccf88 Compare March 25, 2024 21:35
@ArkScript-lang ArkScript-lang deleted a comment from github-actions bot Mar 26, 2024
@ArkScript-lang ArkScript-lang deleted a comment from github-actions bot Mar 26, 2024
@SuperFola SuperFola force-pushed the feat/code-formatter branch 2 times, most recently from ee2784e to e2198ea Compare March 28, 2024 07:14
@SuperFola SuperFola force-pushed the feat/code-formatter branch from c9d2a01 to a0ff755 Compare March 29, 2024 18:58
Copy link

github-actions bot commented Mar 29, 2024

Static analysis report

Lizard report


Listing only functions with cyclomatic complexity >= 15 or NLOC >= 100 or parameters >= 10.

Filename Start line:end line Function name Parameters NLOC CCN
./src/arkreactor/VM/VM.cpp 258:1153 Ark::VM::safeRun 2 644 165
./src/arkreactor/Compiler/BytecodeReader.cpp 70:438 Ark::BytecodeReader::display 4 327 131
./src/arkreactor/Compiler/Macros/Processor.cpp 219:463 Ark::internal::MacroProcessor::evaluate 2 206 72
./include/Ark/Compiler/AST/Parser.hpp 78:169 Ark::internal::ARK_APIParser::string 0 89 34
./src/arkscript/main.cpp 17:310 main 2 252 31
./src/arkreactor/Compiler/Compiler.cpp 530:635 Ark::Compiler::handleCalls 5 78 27
./src/arkreactor/Compiler/Compiler.cpp 261:352 Ark::Compiler::compileExpression 5 74 24
./src/arkscript/JsonCompiler.cpp 23:188 JsonCompiler::_compile 1 139 23
./src/arkreactor/Compiler/AST/Node.cpp 209:279 Ark::internal::operator < < 2 61 23
./src/arkreactor/VM/State.cpp 148:288 Ark::State::configure 0 116 22
./include/utf8.hpp 137:183 utf8::isValid 1 44 21
./src/arkreactor/Compiler/Macros/Processor.cpp 121:185 Ark::internal::MacroProcessor::processNode 2 48 20
./src/arkreactor/Compiler/AST/Parser.cpp 278:388 Ark::internal::Parser::import_ 0 89 19
./src/arkreactor/Compiler/Macros/Executors/Function.cpp 12:87 Ark::internal::FunctionExecutor::applyMacro 1 61 18
./src/arkreactor/VM/Value.cpp 146:225 Ark::Value::toString 2 67 17
./src/arkreactor/Compiler/AST/Node.cpp 143:207 Ark::internal::Node::repr 0 56 17
./include/Ark/Compiler/AST/Predicates.hpp 162:186 Ark::internal::IsSymbol::operator ( ) 1 24 16
./src/arkscript/REPL/Repl.cpp 14:106 Ark::Repl::run 0 74 16
./src/arkreactor/Compiler/Macros/Processor.cpp 53:101 Ark::internal::MacroProcessor::registerMacro 1 44 16
./src/arkscript/Formatter.cpp 117:170 Formatter::format 3 51 15
./src/arkreactor/TypeChecker.cpp 27:78 Ark::types::displayContract 2 45 15

CppCheck report


@SuperFola SuperFola force-pushed the feat/code-formatter branch from a0ff755 to 0ac0153 Compare March 29, 2024 21:57
@ArkScript-lang ArkScript-lang deleted a comment from github-actions bot Mar 29, 2024
@SuperFola SuperFola force-pushed the feat/code-formatter branch 10 times, most recently from 3d8bafa to 2337008 Compare March 30, 2024 18:18
@SuperFola SuperFola force-pushed the feat/code-formatter branch from 2337008 to 80ca896 Compare March 31, 2024 10:40
@SuperFola SuperFola force-pushed the feat/code-formatter branch 3 times, most recently from 2f188a7 to 5907063 Compare March 31, 2024 16:47
@SuperFola SuperFola force-pushed the feat/code-formatter branch from 5907063 to 6e81769 Compare March 31, 2024 17:04
@SuperFola SuperFola force-pushed the feat/code-formatter branch from 6e81769 to a773898 Compare March 31, 2024 17:06
@SuperFola SuperFola merged commit 66edee2 into dev Mar 31, 2024
16 checks passed
@SuperFola SuperFola deleted the feat/code-formatter branch March 31, 2024 18:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature: add a code formatter to the CLI
1 participant