AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Snippets and Tutorials (https://forums.alliedmods.net/forumdisplay.php?f=112)
-   -   TOGs SourcePawn Syntax Converter [MS Excel Based for now] (https://forums.alliedmods.net/showthread.php?t=290805)

ThatOneGuy 11-24-2016 01:37

TOGs SourcePawn Syntax Converter [MS Excel Based for now]
 
3 Attachment(s)
I wasnt sure which forum section to post this in, but since there are syntax highlighters and other indirectly related stuff to SP coding, I thought this the best fit.

I created some code in VBA in a Microsoft Excel environment to convert SourcePawn plugins from old syntax into new syntax. While the project is not yet finished, I thought I would release it for others to use, and for feedback (provided I have time to implement much feedback). It REALLY should be ported over to another language so that MS Excel isnt required. Despite all that, here it is. Perhaps in the future, myself or another will port my code to PHP and make a web version...

Also, it isnt perfect (and probably never will be). Here is the identified TO-DO's, should I find the time for them...the point is that the tool gets you most of the way there, taking a lot of the work out of it (if not all).

To Do and Stuff Not Yet Handled:


Things handled by this program:


Usage/Instructions:


Note:The changelog is available with the spreadsheet in the "changelog" sheet.

I hope this is helpful! To see the code in Excel, press Alt+F11, or right click the tab and click "View Code". This tool will NOT edit the source file, but will create a new file with the same name then " newsyntax" appended. If a file already exists with that name, it will get a number appended in addition to that.

Timocop 11-24-2016 04:09

Re: TOGs SourcePawn Syntax Converter [MS Excel Based for now]
 
You could also use Visual Basic Script *.vbs as a single file. Works for all Windows versions and should work for Linux with Wine aswell, i think (i saw MS Scripting Control in winetricks).

ThatOneGuy 11-24-2016 07:17

Re: TOGs SourcePawn Syntax Converter [MS Excel Based for now]
 
Quote:

Originally Posted by Timocop (Post 2472270)
You could also use Visual Basic Script *.vbs as a single file. Works for all Windows versions and should work for Linux with Wine aswell, i think (i saw MS Scripting Control in winetricks).

I actually started the conversion to vbs and havent finished it because of some of the differences. Ideally, I'd rather just port the logic to php and make a web page for people to use, but we'll see.

friagram 11-24-2016 10:11

Re: TOGs SourcePawn Syntax Converter [MS Excel Based for now]
 
convert back to old syntax would be useful

ThatOneGuy 11-24-2016 14:08

Re: TOGs SourcePawn Syntax Converter [MS Excel Based for now]
 
Quote:

Originally Posted by friagram (Post 2472328)
convert back to old syntax would be useful

lol...but why would someone want to do that?! I'm sure there are times it would be useful though...

Miu 11-24-2016 15:12

Re: TOGs SourcePawn Syntax Converter [MS Excel Based for now]
 
what the fuck vba :psyduck:

ThatOneGuy 11-24-2016 15:35

Re: TOGs SourcePawn Syntax Converter [MS Excel Based for now]
 
Quote:

Originally Posted by Miu (Post 2472393)
what the fuck vba :psyduck:

^This. lol. I already had a lot of code available from past projects I've done at work, so after a few drinks one night...

Anyways, when I finish the project, I'll probably make a PHP page to do the same. For now though, the development is easier in VBA, specifically for the includes processing, which I'm working on now. I dont know if you can easily follow a recursive include model from PHP without the user uploading all of those files as well...

ThatOneGuy 11-25-2016 04:02

Re: TOGs SourcePawn Syntax Converter [MS Excel Based for now]
 
Updated code and OP description.

shavit 11-25-2016 05:34

Re: TOGs SourcePawn Syntax Converter [MS Excel Based for now]
 
great job!

headline 11-25-2016 15:38

Re: TOGs SourcePawn Syntax Converter [MS Excel Based for now]
 
:bacon:

Good Job!

ThatOneGuy 11-26-2016 03:32

Re: TOGs SourcePawn Syntax Converter [MS Excel Based for now]
 
Updated to v1.1.1.

Here's the changelog (also viewable from the tool as another sheet).
Spoiler

TheWho 11-26-2016 22:42

Re: TOGs SourcePawn Syntax Converter [MS Excel Based for now]
 
Looks nice but please don't even convert it to php, convert it to javascript otherwise we'll see bunch of pirated plugin saved in databases..

ThatOneGuy 11-26-2016 23:36

Re: TOGs SourcePawn Syntax Converter [MS Excel Based for now]
 
Quote:

Originally Posted by TheWho (Post 2472919)
Looks nice but please don't even convert it to php, convert it to javascript otherwise we'll see bunch of pirated plugin saved in databases..

Good point - it can be modified to store the script, whereas js you can see the code. Be my guest when it comes to converting it though.

ThatOneGuy 11-27-2016 06:46

Re: TOGs SourcePawn Syntax Converter [MS Excel Based for now]
 
Updated to v1.1.2. Changelog is in file. Added a lot of fixes to special circumstances and finished quite a few things on the to-do list.



P.S.: I meant to leave the old version up for reference, but accidentally clicked the remove button when uploading this version....Why is there no cancel!?!?

headline 12-06-2016 15:46

Re: TOGs SourcePawn Syntax Converter [MS Excel Based for now]
 
Might as well make it a cross compiler, too. That way you can convert and compile in one step. That'd be cool. Any update on it being ported to PHP?

ThatOneGuy 12-07-2016 20:52

Re: TOGs SourcePawn Syntax Converter [MS Excel Based for now]
 
Quote:

Originally Posted by Headline (Post 2475698)
Might as well make it a cross compiler, too. That way you can convert and compile in one step. That'd be cool. Any update on it being ported to PHP?

Until the tool can handle everything, it wont be able to compile...as far as porting, nothing planned at this time....or the next 3 months for that matter (I have a 6 hr test I am studying for mid-March).

ThatOneGuy 01-02-2017 03:59

Re: TOGs SourcePawn Syntax Converter [MS Excel Based for now]
 
Updated to version 1.1.4. Change log is in file. The main changes regard comments being processed correctly (in a couple situations, they could be processed as code previously).

404UserNotFound 02-13-2017 17:06

Re: TOGs SourcePawn Syntax Converter [MS Excel Based for now]
 
Welp, can't use this because Excel Starter doesn't allow running macros >:l

Neuro Toxin 02-13-2017 19:42

Re: TOGs SourcePawn Syntax Converter [MS Excel Based for now]
 
Quote:

Originally Posted by abrandnewday (Post 2495245)
Welp, can't use this because Excel Starter doesn't allow running macros >:l

Lol.

Fuck excell.

OP should copy paste to vba

404UserNotFound 02-13-2017 20:30

Re: TOGs SourcePawn Syntax Converter [MS Excel Based for now]
 
You can make Notepad++ plugins too. Notepad++ can also run scripts though I'm not sure what language the scripts use.

Not sure why something couldn't be made in the format of one of those two options.

Neuro Toxin 02-14-2017 02:40

Re: TOGs SourcePawn Syntax Converter [MS Excel Based for now]
 
A php site would be nice

404UserNotFound 02-14-2017 15:21

Re: TOGs SourcePawn Syntax Converter [MS Excel Based for now]
 
Yes, a PHP site would indeed be wonderful. Upload source code, convert. Problem is, someone could set the site up to harvest any source code entered into it which would mean bad things for private plugins that are entered in.

headline 02-14-2017 15:27

Re: TOGs SourcePawn Syntax Converter [MS Excel Based for now]
 
Quote:

Originally Posted by abrandnewday (Post 2495279)
You can make Notepad++ plugins too. Notepad++ can also run scripts though I'm not sure what language the scripts use.

Not sure why something couldn't be made in the format of one of those two options.

I mean, online compilers probably do that anyway lol
Just keep the php site open source, and no problem

Neuro Toxin 02-14-2017 15:40

Re: TOGs SourcePawn Syntax Converter [MS Excel Based for now]
 
Or use Javascript instead.

404UserNotFound 02-14-2017 16:48

Re: TOGs SourcePawn Syntax Converter [MS Excel Based for now]
 
Quote:

Originally Posted by Headline (Post 2495448)
I mean, online compilers probably do that anyway lol
Just keep the php site open source, and no problem

S'why I don't use online compilers. I keep a "clean" (unmodified) SourceMod install in a folder with new syntax-updated versions of many includes from these forums (updated by me, added for compatibility so I can compile things with custom includes) that I use for compiling my own plugins. Drag and drop the .sp file on compile.exe for a "test" compile so I can check for errors (because compile.exe's console window stays up). If I know something is fine, I'll drop it onto spcomp.exe for a speedy compile with no console window just to generate the .smx file in the same folder (another nice benefit, doesn't put them in /scripting/compiled).

ThatOneGuy 02-15-2017 09:09

Re: TOGs SourcePawn Syntax Converter [MS Excel Based for now]
 
Quote:

Originally Posted by abrandnewday (Post 2495462)
S'why I don't use online compilers. I keep a "clean" (unmodified) SourceMod install in a folder with new syntax-updated versions of many includes from these forums (updated by me, added for compatibility so I can compile things with custom includes) that I use for compiling my own plugins. Drag and drop the .sp file on compile.exe for a "test" compile so I can check for errors (because compile.exe's console window stays up). If I know something is fine, I'll drop it onto spcomp.exe for a speedy compile with no console window just to generate the .smx file in the same folder (another nice benefit, doesn't put them in /scripting/compiled).

You could instead use Notepad++ to compile for you (since you already mentioned you use it). Install the NPPExec addon from the plugin manager. Follow instructions here: https://forums.alliedmods.net/showpo...&postcount=164

With NPP doing the compiling, it will stay in the NPP console and you can double click the error/warning to go straight to the line it came from. Then, map the macro to a shortcut key. So, when all is said and done, I press ctrl+shift+b to compile a script that is anywhere and the .smx will appear next to it in the same folder. Note: The includes will need to be in the include folder relative to your compiler path.

Currently, I run this script to compile:
Spoiler


I used to run a simpler script but found that on windows, pseudo mapped locations (through vsubst) seemed to add an extra slash, where it didnt for full paths. So, hence the checking for the slash at the end before adding it.

-----------------------------------------------

As far as converting the whole thing to PHP, I was planning on doing it some time, but am too busy until around April, so it likely wouldnt happen until then. As far as exporting the code for you:


When April comes around, I'll check back in on this, unless someone else beats me to it. Perhaps we can get a github repo going with a PHP or java version created.

404UserNotFound 02-15-2017 11:51

Re: TOGs SourcePawn Syntax Converter [MS Excel Based for now]
 
Quote:

Originally Posted by ThatOneGuy (Post 2495578)
You could instead use Notepad++ to compile for you (since you already mentioned you use it). Install the NPPExec addon from the plugin manager. Follow instructions here: https://forums.alliedmods.net/showpo...&postcount=164

With NPP doing the compiling, it will stay in the NPP console and you can double click the error/warning to go straight to the line it came from. Then, map the macro to a shortcut key. So, when all is said and done, I press ctrl+shift+b to compile a script that is anywhere and the .smx will appear next to it in the same folder. Note: The includes will need to be in the include folder relative to your compiler path.

Currently, I run this script to compile:
Spoiler

So do I except I modified mine ages ago and shrunk it down after removing useless shit. Should've noted that drag & drop was my OLD method until I started using that script about....fuck I forget when, it's been a while.
Spoiler

ThatOneGuy 02-15-2017 20:58

Re: TOGs SourcePawn Syntax Converter [MS Excel Based for now]
 
Quote:

Originally Posted by abrandnewday (Post 2495606)
So do I except I modified mine ages ago and shrunk it down after removing useless shit. Should've noted that drag & drop was my OLD method until I started using that script about....fuck I forget when, it's been a while.

Yup...that is what mine looked like until recently when my vsubst drives were causing the path to have a double / near the end if in root mapped folder of the vsubst "drive". For 98% of users out there, the shorter version is all that is needed.

nergal 05-13-2017 20:22

Re: TOGs SourcePawn Syntax Converter [MS Excel Based for now]
 
why not just a transcompiler written in Python?

ThatOneGuy 05-13-2017 20:51

Re: TOGs SourcePawn Syntax Converter [MS Excel Based for now]
 
Quote:

Originally Posted by nergal (Post 2520376)
why not just a transcompiler written in Python?

Firstly because I didnt know VBA -> Python translators exist (though I just looked and there is one). Secondly, because I have only learned basic python and have issues getting the proper tools set up to even utilize python. Also, then I assume you couldnt make a web based program for converting? Good idea though...would you be willing to take that on? I found this one here: http://vb2py.sourceforge.net/

nergal 05-14-2017 03:06

Re: TOGs SourcePawn Syntax Converter [MS Excel Based for now]
 
Quote:

Originally Posted by ThatOneGuy (Post 2520379)
Firstly because I didnt know VBA -> Python translators exist (though I just looked and there is one). Secondly, because I have only learned basic python and have issues getting the proper tools set up to even utilize python. Also, then I assume you couldnt make a web based program for converting? Good idea though...would you be willing to take that on? I found this one here: http://vb2py.sourceforge.net/

I meant a python transcompiler that converts old sp to new syntax.

ThatOneGuy 05-14-2017 06:09

Re: TOGs SourcePawn Syntax Converter [MS Excel Based for now]
 
Quote:

Originally Posted by nergal (Post 2520403)
I meant a python transcompiler that converts old sp to new syntax.

Well, if such a thing is out there, it would be nice to be made available to others. If you're proposing I develop it, again, I dont know python (yet), and would encourage you to develop it if that is your idea. I'm still leaning towards php with the code made open source, as then it can be utilized on the web by anyone, anywhere, with no need to install anything to run the tool.

Side Note: Perhaps someone can get me started with the right setup for coding/compiling scripts in Python. I've installed python 3.5 in the past and read several tutorials to learn the language....seems pretty straight forward....but I couldnt figure out what I was doing in the software and wasnt committed enough to spend forever looking for tutorials on how to compile, etc. Every tutorial I did find looked nothing like what I was looking at on my screen or had options that I was missing, etc. So, I dropped it for the time.

headline 05-15-2017 02:35

Re: TOGs SourcePawn Syntax Converter [MS Excel Based for now]
 
Quote:

Originally Posted by ThatOneGuy (Post 2520431)
Well, if such a thing is out there, it would be nice to be made available to others. If you're proposing I develop it, again, I dont know python (yet), and would encourage you to develop it if that is your idea. I'm still leaning towards php with the code made open source, as then it can be utilized on the web by anyone, anywhere, with no need to install anything to run the tool.

Side Note: Perhaps someone can get me started with the right setup for coding/compiling scripts in Python. I've installed python 3.5 in the past and read several tutorials to learn the language....seems pretty straight forward....but I couldnt figure out what I was doing in the software and wasnt committed enough to spend forever looking for tutorials on how to compile, etc. Every tutorial I did find looked nothing like what I was looking at on my screen or had options that I was missing, etc. So, I dropped it for the time.

Python isn't compiled, but rather interpreted. I use Pycharm as my IDE and it works out of the box well

ThatOneGuy 05-15-2017 19:34

Re: TOGs SourcePawn Syntax Converter [MS Excel Based for now]
 
Quote:

Originally Posted by Headline (Post 2520667)
Python isn't compiled, but rather interpreted. I use Pycharm as my IDE and it works out of the box well

Nice. I've tried visual studio and the default install from python.org, and ran into the roadblocks mentioned (and didnt care enough at the time to work too hard to resolve the issues). I'll look into pycharm though!

T1MOXA 07-10-2017 10:03

Re: TOGs SourcePawn Syntax Converter [MS Excel Based for now]
 
Error when converting https://forums.alliedmods.net/showthread.php?t=71867
http://i.imgur.com/fDByphP.png
http://i.imgur.com/vzxe4s1.png

ThatOneGuy 07-11-2017 00:17

Re: TOGs SourcePawn Syntax Converter [MS Excel Based for now]
 
2 Attachment(s)
Quote:

Originally Posted by T1MOXA (Post 2534433)

Thanks for the feedback! I just patched this for you. Try the new version (1.1.6) in the OP.

Note: The processor doesnt handle splitting lines into multiple when multiple variable types are declared and the default values are set in the same line. This plugin has an instance of that. After fixing that, some view_as<>() stuff, and the AskPluginToLoad2 function, this is what I got.

cigzag 07-12-2017 00:28

Re: TOGs SourcePawn Syntax Converter [MS Excel Based for now]
 
How in the world do you even get this too work?

T1MOXA 07-12-2017 10:03

Re: TOGs SourcePawn Syntax Converter [MS Excel Based for now]
 
@ThatOneGuy :3 Thanks!

ThatOneGuy 07-12-2017 23:59

Re: TOGs SourcePawn Syntax Converter [MS Excel Based for now]
 
Quote:

Originally Posted by T1MOXA (Post 2534847)
@ThatOneGuy :3 Thanks!

Your welcome!

Quote:

Originally Posted by SnowTigerVidz (Post 2534767)
How in the world do you even get this too work?

It is a Microsoft Excel based tool for now. All you need to do to use it is:
  1. Open the tool. If there is a yellow bar at the top asking if you want macros enabled, say yes (that allows the code to run). If there is a dialogue asking if ActiveX should run, say yes. This allows the button to work, though you could say no and run the code directly from the VBA window.
  2. Make sure your include path is set. The includes arent edited, but are used to define variable types, natives, forwards, etc.
  3. Click the button, and find the .sp file you want converted, and click ok.
  4. The file will now be processed. The original file is left as is, and the new one is in the same location and has the text " newsyntax" added to the end. After this, the tool is done.
  5. After processing, you will see the following at the top of the code:
    PHP Code:

    /* put the line below after all of the includes!
    #pragma newdecls required
    */ 

    Move the line of code (#pragma newdecls required) to be just past the last inlude. I may automate this step in the future as well.
  6. Make final edits for anything not handled by the processor (see original post for what all that is) until it compiles.

vortex. 07-14-2017 18:42

Re: TOGs SourcePawn Syntax Converter [MS Excel Based for now]
 
Cool! Thank you.


All times are GMT -4. The time now is 03:08.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.