Tool Galaxy parser

phyrex1an

Staff Member and irregular helper
Reaction score
446
What exactly does it parse into? o_O
A haskell data structure. Check src/Galaxy/SyntaxTree.hs. As such, this doesn't really do that much. Think of it as a library for more useful tools.

Can we has [GALAXY] tagz nao? :)
They can has highlight native list.
This is not really related to a syntax highlighter but yeah, it is coming.
 

phyrex1an

Staff Member and irregular helper
Reaction score
446
Parser has been updated based on j4l's array example.

@Jesus4Lyf: Have you tried to get the parser running? It should function as a poor syntax checker (with plenty of false positives/negatives and somewhat cryptic error messages). I guess that you don't get any error reporting from sc2 itself so it should be an improvement :p
 

Jesus4Lyf

Good Idea™
Reaction score
397
@Jesus4Lyf: Have you tried to get the parser running? It should function as a poor syntax checker (with plenty of false positives/negatives and somewhat cryptic error messages). I guess that you don't get any error reporting from sc2 itself so it should be an improvement :p
I can't be stuffed trying to compile it. >.<' (ie. I can't double click it, so I'm not sure what to do. ;))
So far I'm just writing in Notepad++, importing into a map with Ladik's, then having it run in SC2 BETA, and seeing if it works... :p
 

Jesus4Lyf

Good Idea™
Reaction score
397
Failed to parse this:
JASS:
//==================================================================================================
// 
// Generated Map Script
// 
// Name:   First TD
// Author: Jesus4Lyf
// 
//==================================================================================================
include &quot;TriggerLibs/NativeLib&quot;
//include &quot;TriggerLibs/natives&quot;

//--------------------------------------------------------------------------------------------------
// Library Initialization
//--------------------------------------------------------------------------------------------------
void InitLibs () {
    libNtve_InitLib();
}

//--------------------------------------------------------------------------------------------------
// Snippets
//--------------------------------------------------------------------------------------------------
unitgroup PlayerUnits(int player){
	return AIFindUnits(player,null,Point(0,0),500000,c_noMaxCount);
}


//--------------------------------------------------------------------------------------------------
// Trigger Variables
//--------------------------------------------------------------------------------------------------
trigger gt_MeleeInitialization;

void testFunc(){
	unitgroup GG=PlayerUnits(1);
	UIDisplayMessage(PlayerGroupAll(), c_messageAreaSubtitle, StringToText(IntToString(UnitGroupCount(GG,c_unitCountAll))));
}

/////
// Super cool
bool gt_OnChat_Func (bool testConds, bool runActions) {
	int i=32;
	
	testFunc();
	
//	while (i&gt;0){
//		i-=1;
//		UIDisplayMessage(PlayerGroupAll(), c_messageAreaSubtitle, StringToText(IntToString(i)));
//		UIDisplayMessage(PlayerGroupAll(), 3, StringToText(IntToString(i)));
//		Wait(0,0);
//	}
	
	return true;
}

//--------------------------------------------------------------------------------------------------
// Trigger: Melee Initialization
//--------------------------------------------------------------------------------------------------
bool gt_MeleeInitialization_Func (bool testConds, bool runActions) {
    // Actions
    if (runActions) {
        MeleeInitResources();
        MeleeInitUnits();
        MeleeInitAI();
        MeleeInitOptions();
    }
	gt_OnChat_Func(false,false);
    return true;
}

//--------------------------------------------------------------------------------------------------
void gt_MeleeInitialization_Init () {
    gt_MeleeInitialization = TriggerCreate(&quot;gt_MeleeInitialization_Func&quot;);
    TriggerAddEventMapInit(gt_MeleeInitialization);
	
	TriggerAddEventChatMessage(TriggerCreate(&quot;gt_OnChat_Func&quot;), 1, &quot;&quot;, false);
	TriggerAddEventChatMessage(TriggerCreate(&quot;gt_OnChat_Func&quot;), 1, &quot;&quot;, true);
}

//--------------------------------------------------------------------------------------------------
// Trigger Initialization
//--------------------------------------------------------------------------------------------------
void InitTriggers () {
    gt_MeleeInitialization_Init();
}

//--------------------------------------------------------------------------------------------------
// Map Initialization
//--------------------------------------------------------------------------------------------------
void InitMap () {
    InitLibs();
    InitTriggers();
}

(Just some demo code I'm working on, mindlessly. It compiles in SC2 beta.)
 

Renendaru

(Evol)ution is nothing without love.
Reaction score
309
Galaxy looks really promising, hopefully it follows through at release. :s
 

Jesus4Lyf

Good Idea™
Reaction score
397
Umm.
JASS:
typedef int[3] ArrType;

Works.
JASS:
void readattwo (ArrType ar){
	UIDisplayMessage(PlayerGroupAll(), c_messageAreaSubtitle, StringToText(IntToString(ar[2])));
}

Works.
JASS:
void readattwo (int[3] ar){
	UIDisplayMessage(PlayerGroupAll(), c_messageAreaSubtitle, StringToText(IntToString(ar[2])));
}

Works.
JASS:
void readattwo (int[] ar){
	UIDisplayMessage(PlayerGroupAll(), c_messageAreaSubtitle, StringToText(IntToString(ar[2])));
}

Does not work.
JASS:
ArrType someVar;
readattwo(someVar);

Does not work. o_O

So I think it's half implemented.

Edit:
Holy crap, this compiles:
JASS:
typedef int[3] ArrType;
void readattwo (ArrType* ar){
	//UIDisplayMessage(PlayerGroupAll(), c_messageAreaSubtitle, StringToText(IntToString(ar[2])));
}

:D
>Galaxy looks really promising
Does now.

Edit: WINNER!
Figured out pointer syntax.
JASS:
typedef int[3] ArrType;
ArrType testArr;
void readattwo (ArrType* ar){
	UIDisplayMessage(PlayerGroupAll(), c_messageAreaSubtitle, StringToText(IntToString((*ar)[2])));
}
bool testthings (bool testConds, bool runActions) {
	ArrType* someVar = &amp;testArr;
	testArr[2]=7;
	testArr[1]=9;
	testArr[0]=3;
	readattwo(someVar);
    return true;
}

Compiles. This is getting cooler and cooler. :D

Whee. I'm the first person to use array pointers in SC2 and post about it online... :p
 

Lyerae

I keep popping up on this site from time to time.
Reaction score
105
What are pointers in Galaxy? They can't be like C ones... Can they? o_O
 

Renendaru

(Evol)ution is nothing without love.
Reaction score
309
Ooo.. Maybe I should start playing around with this.
 

Jesus4Lyf

Good Idea™
Reaction score
397
WIN
JASS:
struct murder {
    string means;
    string time;
};
murder[128] pool;
void apply(murder* attempt, string target){
    UIDisplayMessage(PlayerGroupAll(), c_messageAreaSubtitle, StringToText(target+&quot; has died at &quot;+attempt-&gt;time+&quot; by: &quot;+attempt-&gt;means+&quot;.&quot;));
}
bool testthings (bool testConds, bool runActions) {
    murder* how=&amp;(pool[0]);
    how-&gt;time=&quot;midnight&quot;;
    how-&gt;means=&quot;axe to the fricking face&quot;;
    apply(how,&quot;A young boy&quot;);
    return true;
}

Compiles. The first example of structs in Galaxy! Just took 5 hours or so of sitting here trial and erroring. :D

Now I have to say... the learning curve is huge for newbies. People are gonna struggle.. =/

>Wait, your saying they ARE like in C?
Yes.
 

Lyerae

I keep popping up on this site from time to time.
Reaction score
105
Oh damn. I think we're going to have some fun with this.
 

Renendaru

(Evol)ution is nothing without love.
Reaction score
309
Jesus is the first coder. Watch he figures out bytecode all over again. That would be hilarious.
 

Jesus4Lyf

Good Idea™
Reaction score
397
Jesus is the first coder. Watch he figures out bytecode all over again.
I'm already giving that a shot.
JASS:
int[128] byteCode;
bool testthings (bool testConds, bool runActions) {
    trigger t=TriggerCreate(&quot;byteCode&quot;);
    if (t!=null){
        UIDisplayMessage(PlayerGroupAll(), c_messageAreaSubtitle, StringToText(&quot;Problems.&quot;));
    }
    TriggerAddEventChatMessage(t, 1, &quot;&quot;, false);
    return true;
}

Amusingly enough, this spells problems. But it also throws a function not found error, so I'm not sure if something can be done with it..
 

Lyerae

I keep popping up on this site from time to time.
Reaction score
105
How are you trying all this? Inserting the code into a map and running it?
 

Jesus4Lyf

Good Idea™
Reaction score
397
Inserting the code into a map and running it?
Yeah. Using Ladik's MPQ to import it into the galaxy mapscript of a map. It's kind of tedious... There's no syntax error messages, any syntax errors causes the entire script to be discarded. Actually, I found any XML errors cause the XML data files to be discarded, also, it seems...
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top