SQFvm / runtime

Custom implementation of the Arma script language SQF
GNU Lesser General Public License v3.0
96 stars 30 forks source link

--pretty-print command reimplementation #209

Closed Casperento closed 1 year ago

Casperento commented 1 year ago

I've started the reimplementation of the old --pretty-print command.

Result example (sqfvm --automated --parse-only --pretty-print filename.sqf): https://pastebin.com/RaT1Swww

Currently, build is passing all cmake tests (tested on Windows and Linux). I've been trying to modify less code as possible, so maybe I've missed something 😅

X39 commented 1 year ago

Could you move this out of the parser and put it into a separate class (thinking of possibly modifying this in the future to allow customization)

Casperento commented 1 year ago

I'm having trouble when trying to reference the parser inside the new class for the sqf formatter:

::sqf::parser::sqf::formatter::formatter(::sqf::runtime::runtime& r, ::sqf::parser::sqf::parser& p_ptr, std::string c, ::sqf::runtime::fileio::pathinfo f) : runtime{ r }, contents{ c }, file{ f } {
    tokenizer t(contents.begin(), contents.end(), file.physical);
    ::sqf::parser::sqf::bison::parser p(t, this->res, p_ptr, this->runtime);
    this->hasError = p.parse() != 0;
}
::sqf::parser::sqf::formatter fmt(m_runtime, m_runtime.parser_sqf(), str, {path.string(), {}});

'C++ no instance of constructor matches the argument list argument types are: (sqf::runtime::runtime, sqf::runtime::parser::sqf, std::string, {...})'

what am i doing wrong ?

Casperento commented 1 year ago

Sorry for the last comment.

I managed to fix the issue and created a new class called formatter successfully.

Build is still passing cmake tests.

X39 commented 1 year ago

There is no need to sorry.

Thanks, will check the full pr tomorrow :)

X39 commented 1 year ago

Minor changes are technically required (+= vs <<)