Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Chat / AppGameKit V2 Compiler Test

Author
Message
Paul Johnston
TGC Developer
14
Years of Service
User Offline
Joined: 16th Nov 2002
Location: United Kingdom
Posted: 20th Jun 2014 16:04 Edited at: 24th Jun 2014 05:26
All AppGameKit version 2 backers should now have access to a file named "AGK V2 Compiler Test.zip" in their downloads section, this is the new compiler and interpreter that we have been working on recently.

The zip file should be extracted into the AGK/IDE/Compiler folder and will replace two files and add one file. It is recommended that you backup the files "AGKCompiler.exe" and "interpreters/Windows.exe" from this folder before proceeding so you can reverse the changes. This will update any version of AppGameKit (even version 1) to use the new compiler and interpreter, as such you will also be getting all of the latest version 2 features from Alpha 3 that are not fully tested. So you may see some changes in your project that are not related to the new compiler if you are coming from version 1.

Once extracted the compile/run buttons in the IDE will now use the new version of the compiler and should behave as before. The broadcast ability is not functional at this stage.

The new compiler is stricter than the old one so it may pick up on invalid characters, or uninitialized variables (defining counts as initializing) that previously compiled but may be the source of deeper errors in the code. In particular the previous compiler allowed a variable and array to have the same name, this is no longer supported as arrays can now be used in assignment operations.

If you get any errors messages you think shouldn't be there please reply in this thread. If you get a crash I will need either a small example that replicates the problem or you can email me your project and I'll take a look.

Update 1:
I've uploaded the an updated version named "AGK V2 Compiler Test Update 1.zip" with the following changes
+ Code Snippet

Update 2:
I've uploaded the an updated version named "AGK V2 Compiler Test Update 2.zip" with the following changes
+ Code Snippet
TDavid
4
Years of Service
User Offline
Joined: 7th Feb 2013
Location:
Posted: 20th Jun 2014 16:45
I tried it with my project which compiles fine in AppGameKit v1.021 tier 1. And I get "Process terminated with status -1073741819 (0 minutes, 7 seconds)" when I try to compile.
Paul Johnston
TGC Developer
14
Years of Service
User Offline
Joined: 16th Nov 2002
Location: United Kingdom
Posted: 20th Jun 2014 16:58
Thanks for testing it, can you send me your project so I can replicate the crash?
TDavid
4
Years of Service
User Offline
Joined: 7th Feb 2013
Location:
Posted: 20th Jun 2014 18:15
I'm really sorry but I am not comfortable with sending my code over the internet right now.

I'll gladly send it to you after publication, though. It shouldn't be long now.

Again, sorry and thanks for your wonderful tool and your dedicated work.
Jimmanator
6
Years of Service
User Offline
Joined: 12th Nov 2010
Location:
Posted: 20th Jun 2014 18:46
Hi I was trying to get arrays in types working but this:
+ Code Snippet
Gives Me the Error "Unrecognized array data type"
Paul Johnston
TGC Developer
14
Years of Service
User Offline
Joined: 16th Nov 2002
Location: United Kingdom
Posted: 20th Jun 2014 18:52 Edited at: 20th Jun 2014 19:35
Quote: "Gives Me the Error "Unrecognized array data type""

Thanks, fixed in Update 1.
Marl
5
Years of Service
User Offline
Joined: 19th Nov 2011
Location: Bradford, UK
Posted: 20th Jun 2014 20:29 Edited at: 20th Jun 2014 20:31
It doesn't seem to like then followed by if, as in;
+ Code Snippet
It reports "unexpected Token "if" in ... at line ..." on compiling.
when replaced by;
+ Code Snippet
no error is reported.

There is also an issue with constants with negative values;
+ Code Snippet
reported as "Unexpected token "-" in ... at line ..." which refers to the line where the constant is used, not where it is defined.
A workaround is to add a preceding zero
+ Code Snippet
Alien Menace
AGK Developer
12
Years of Service
User Offline
Joined: 11th Jan 2005
Location: Earth (just visiting)
Posted: 20th Jun 2014 20:52
A couple of variable things I have run into using AppGameKit 2 RLS 3 and the new compiler:

In AppGameKit 1 you could do this:

GLOBAL PLAYERX#=WIDTH#/2

AGK 2 now complains that is isn't a float literal or constant. Easily remedied by...

GLOBAL PLAYERX#
PLAYERX#=WIDTH#/2

But different than before. I would prefer to do expressions when I declare if need be as the original allows (at least some of the time).

Also, this used to be allowed in AppGameKit 1:

DIM RED[20]
GLOBAL RED

I see using the same variable name for both an array and a regular variable no longer is allowed. I can;t comment on the speed increase because I now have to go back and change a bunch of stuff to accommodate the first listed issue above.

Apps published: 4
Scary Little Rabbit
7
Years of Service
User Offline
Joined: 4th Aug 2009
Location: Chelyabinsk, Russian Federation.
Posted: 20th Jun 2014 21:19
thank you, Paul and others, very much.

as I see some hard work was done.
compiler readily finds few errors (which were missed by his old confrere) about defining of arrays and variables which have already been defined.

but unfortunately it has certain issues right now.
I approve issue with constants. and I found another one with empty if-endif conditions. this code not works but it alerts for unexpected token 'endif' and 'else':
+ Code Snippet
+ Code Snippet

it is interesting that this code not has this problem:
+ Code Snippet
but here we have alert about undefined variables 'some' and 'any'.

another one issue: old compiler allows this:
+ Code Snippet
new one alerts us about arrays with undefined size.

I did not make more tests for a time being, sorry, but I may to say that it works (compile and run) in Wine on Ubuntu 14.04 with only one alert about failing to create XAudio2 (error 2147746132).

thank you again.
looks like it's time to dust off my projects. I did not code for two months.

error #1:
"too many stars, too many stares. disembody."
WIP: MIND!! | free fonts for your AGKs
Zerotown
6
Years of Service
User Offline
Joined: 22nd Jan 2011
Location: Netherlands
Posted: 20th Jun 2014 21:32
Hi Paul, thank you for this! I am very pleased and impressed by all the hard work. I've got some questions though:

- When I use a #constant with a negative value (e.g. a declaration along the lines of: '#constant asTerminator -1'), the compiler reports: "Unexpected token "-" in [name.agc] at line [nr.]". It seems to regard the minus sign as a string. Is this normal or a bug?

- When I declare an array to by of the type 'float' (e.g. 'dim SinArray[100] as float', it tells me: "Cannot use a float as an array index, must be an integer in [name.agc] at line [nr.]". Has this functionality been removed?

- When I fill multiple values in an array (e.g. 'DirArray = [0,1,0,-1,0,1,-1,-1,1]'), the compiler reports: "Unexpected token [ in [name.agc] at line [nr.]". Has this type of notation been removed? Is there a substitute?

These are all minor points, and I am actually very glad that the error-reports have advanced so much compared to the old compiler. Still... I am curious if there are workarounds or fixes on the way.
Scary Little Rabbit
7
Years of Service
User Offline
Joined: 4th Aug 2009
Location: Chelyabinsk, Russian Federation.
Posted: 20th Jun 2014 21:36
another interesting thing: try this test of empty lines recognition.
just put new commented line after line 30 to compile it, like this:
+ Code Snippet

we have a new leader, huh?

error #1:
"too many stars, too many stares. disembody."
WIP: MIND!! | free fonts for your AGKs
Jimmanator
6
Years of Service
User Offline
Joined: 12th Nov 2010
Location:
Posted: 21st Jun 2014 00:11 Edited at: 21st Jun 2014 01:32
This Successfully compiles when it should not:
+ Code Snippet


Also this:
+ Code Snippet


gives me the error:"Unexpected token "size",Array dimensions must be integers"


This:
+ Code Snippet
Gives me the Error "Unexpected token ".",function call must end with a close bracket"
Paul Johnston
TGC Developer
14
Years of Service
User Offline
Joined: 16th Nov 2002
Location: United Kingdom
Posted: 21st Jun 2014 03:43 Edited at: 21st Jun 2014 03:43
Quote: "if thisInt > 0 then if getSpriteExists( thisInt ) then ..."


This is no longer supported, please use the block method for nested IF statements.

Quote: "There is also an issue with constants with negative values;"


Thanks, fixed.

Quote: "GLOBAL PLAYERX#=WIDTH#/2"


This is no longer supported as default values are now assigned at compile time, so you can declare global variables any where in your program (including includes) and have their value set when the program starts. To set the value at runtime use
+ Code Snippet at the appropriate time.

Quote: "I found another one with empty if-endif conditions"


Empty IF/ELSE blocks will be accepted in the next update.

Quote: "but here we have alert about undefined variables 'some' and 'any'."


Because you haven't assigned the variables a value anywhere in your code the IF statement reduces to "if 0 = 0" and therefore is likely a mistake, or could be simplified by replacing them with "0".

Quote: "dim m_some[ ac_some ] = [ 0, 1, 2 ]"


Again default values are assigned at compile time, so the compiler doesn't like it, but I guess it could infer the size of the array from the number of values you have provided. You could use a constant here instead, or hard-code the value "3" since you are assigning it 3 values, but I guess there is room for interpretation here.

Quote: "'dim SinArray[100] as float', it tells me: "Cannot use a float as an array index"


I tried declaring a float array but I didn't get the error, are you using the array like this anywhere? + Code Snippet in which case you will need to convert the float to an int like so
+ Code Snippet

Quote: "'DirArray = [0,1,0,-1,0,1,-1,-1,1]'"


I tested this in the old compiler and it also threw an error, so not a bug. However I like the idea of assigning lots of values to an array in a single line like that so I might add it in a future version.

Quote: "function (var as integer)"


Thanks, fixed for the next update.

Quote: "array as integer[size]"


New format arrays are declared once with a default size that is assigned at the start of the program, if you want to change the size at runtime use
+ Code Snippet

Quote: "var1.class=var2 // this should make var1.class.s="jimy""


Thanks, fixed for the next update.
Zerotown
6
Years of Service
User Offline
Joined: 22nd Jan 2011
Location: Netherlands
Posted: 21st Jun 2014 09:38 Edited at: 21st Jun 2014 10:03
@Paul:

Quote: "I tried declaring a float array but I didn't get the error, are you using the array like this anywhere? + Code Snippet in which case you will need to convert the float to an int like so
+ Code Snippet
"


Thanks, it was my declaration that was the culprit (e.g. dim Array[float#] as float instead of dim Array[integer] as float). That said, the compiler didn't like me declaring the array using Ceil etc. I had to something like this:
+ Code Snippet

Quote: "
I tested this in the old compiler and it also threw an error, so not a bug. However I like the idea of assigning lots of values to an array in a single line like that so I might add it in a future version.
"


My apologies for being unclear. Using the old compiler, I declared an array and assigned values on the same line like this:
+ Code Snippet
It seems that this is not allowed anymore. No biggie for me but I'm not sure if it is considered a bug.
Digital Awakening
AGK Developer
14
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Sweden
Posted: 21st Jun 2014 10:56 Edited at: 21st Jun 2014 11:01
Quote: "dim Array[8] as integer = [0,0,1,0,-1,1,1,-1,-1]"


This seems to be very useful. It could even be made to work with multidimensional arrays perhaps?

dim array[3,3] as integer = [ [1,2,3], [4,5,6], [7,8,9] ]


And how abut using it during runtime?

dim array[3] as integer
array[] = [1,2,3]

array[] = [1,2,3,4] // could even alter the length

Paul Johnston
TGC Developer
14
Years of Service
User Offline
Joined: 16th Nov 2002
Location: United Kingdom
Posted: 21st Jun 2014 13:10
Quote: "dim Array[8] as integer = [0,0,1,0,-1,1,1,-1,-1]"


That should work, but it is having trouble with the negative values. I'll get that fixed.

Quote: "And how abut using it during runtime?"


I like the idea, I might add it in at some point.

Quote: "float# = 5.9
tmpValue = ceil(float#)
dim Array[tmpValue] as float"


Worked for me
Blendman
3
Years of Service
User Offline
Joined: 17th Feb 2014
Location: Arkeos
Posted: 21st Jun 2014 16:05
Hi

Thank you for this update. The folding+ Code Snippet doesn't work anymore ?


The line :
+ Code Snippet
or
+ Code Snippet
give me an error message :
Quote: ""invalid escape string, must all be on one line and end with a single with a single quote""


http://www.dracaena-studio.com
Digital Awakening
AGK Developer
14
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Sweden
Posted: 21st Jun 2014 16:15 Edited at: 21st Jun 2014 16:17
Blendman
Single quote marks are now used for strings with escaped characters.

If you are using that for code folding, it will be built into the new IDE coming in Alpha 5.

Blendman
3
Years of Service
User Offline
Joined: 17th Feb 2014
Location: Arkeos
Posted: 21st Jun 2014 16:40
@Digital Awakening : thanks for the answer and the information


I have a new error with that code (work in AppGameKit v1):

+ Code Snippet

http://www.dracaena-studio.com
Digital Awakening
AGK Developer
14
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Sweden
Posted: 21st Jun 2014 18:06
Blendman
The variable "bonus" has not been initialized, try adding this line before the error:
bonus = 0

Digital Awakening
AGK Developer
14
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Sweden
Posted: 21st Jun 2014 18:26
Paul
Is it possible to get =+ and =- (or is it += and -=) added to the new compiler? Or make inc and dec work with more than just integers?

Paul Johnston
TGC Developer
14
Years of Service
User Offline
Joined: 16th Nov 2002
Location: United Kingdom
Posted: 21st Jun 2014 18:47
Quote: "bonus = bonus + player.Bonus.param // error message"

Thanks, types of types caused an error which is now fixed.

Quote: "Is it possible to get =+ and =- (or is it += and -=) added to the new compiler? Or make inc and dec work with more than just integers?"


Inc and Dec should work with expressions already
Jimmanator
6
Years of Service
User Offline
Joined: 12th Nov 2010
Location:
Posted: 21st Jun 2014 21:41
Hi i was wondering if there was a way to get the number of dimentions in an array like array.dimentions because that would be very useful
JimHawkins
7
Years of Service
User Offline
Joined: 26th Jul 2009
Location: Hull - UK
Posted: 22nd Jun 2014 00:22
[quote]wondering if there was a way to get the number of dimentions in an array

There is. It's function ReadYourOwnCode()

-- Jim - When is there going to be a release?
Jimmanator
6
Years of Service
User Offline
Joined: 12th Nov 2010
Location:
Posted: 22nd Jun 2014 01:49
Quote: "There is. It's function ReadYourOwnCode()"

I'm Sorry I got little carried away and had a brain fart.
SamKM
7
Years of Service
User Offline
Joined: 25th May 2009
Location:
Posted: 22nd Jun 2014 02:54 Edited at: 22nd Jun 2014 02:57
A function like that would be useful for resizable arrays, though
Also, it could be easier for when you're not sure what you want the final size of an array to be - For example, in DBPro, you could write this:
for i = 0 to 5 : print datalist$(i) : next i
But if you wanted to change the size of datalist$() later, it might be better to write this:
for i = 0 to array count(datalist$()) : print datalist$(i) : next i
Cuz that way you don't have to come back and change the count value as well

The code never bothered me anyway...
Hodgey
7
Years of Service
User Offline
Joined: 10th Oct 2009
Location: Australia
Posted: 22nd Jun 2014 05:03
SamKM: I heard someone mention that there's now an array.length (or something like that - I could be wrong). It's a good idea to avoid using magic numbers where possible.
swissolo
7
Years of Service
User Offline
Joined: 9th Jan 2010
Location:
Posted: 22nd Jun 2014 08:03 Edited at: 22nd Jun 2014 09:47
Thanks for this I'll have to try it tomorrow. This thread was hidden within all those stickies so I didn't see it I have a little bit of experience in these sort of matters as I put together a simple programming language a while ago in my spare time. I hope you put little emphasis on backwards compatibility. I'm all for changes for the better. Trying to support old projects can really weigh down great tools In with the new!

this
Quote: " uninitialized variables (defining counts as initializing) that previously compiled but may be the source of deeper errors in the code"

sounds absolutely wonderful. So the compiler no longer assumes undeclared/initialized variables are 0? If so, fantastic. That has been my biggest issue with AGK. I could make 1 typo within 1000 lines and spend ages searching for it. Looking forward to trying it! (the AGKv2 compiler, not fixing typos)

Digital Awakening
AGK Developer
14
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Sweden
Posted: 22nd Jun 2014 09:14
SamKM
You can check the length of an array. Which is a must for dynamic arrays. But checking the number of dimensions is something different

swissolo
The only problem I ran into was that arrays and variables can't share names any more. Sure it detected one uninitialized variable and a few errors. But making sure my arrays and globals didn't share names took a little time to fix.

JimHawkins
7
Years of Service
User Offline
Joined: 26th Jul 2009
Location: Hull - UK
Posted: 22nd Jun 2014 09:48
Allowing two declarations to have the same name (unless they're overloaded functions) is a disaster waiting to happen, so I think that's a language improvement. Anything that the compiler can at least warn about at compile time is infinitely better than trying to trap run-time bugs.

-- Jim - When is there going to be a release?
idstam
5
Years of Service
User Offline
Joined: 4th Oct 2011
Location: Upplands Väsby / Sweden
Posted: 22nd Jun 2014 11:25
Invalid integer "3;" in init_game.agc at line 24

From this line:

sheep[1].X = 3; sheep[1].Y = 5



(This used to work.)
idstam
5
Years of Service
User Offline
Joined: 4th Oct 2011
Location: Upplands Väsby / Sweden
Posted: 22nd Jun 2014 11:43 Edited at: 22nd Jun 2014 16:34
Compiler error:
Cannot assign Type to Integer in stack.agc at line 13


+ Code Snippet
ret_board is not used anywhere else in the code.

(Just after posting it struck me that I haven't run this code, but it used to compile.)
idstam
5
Years of Service
User Offline
Joined: 4th Oct 2011
Location: Upplands Väsby / Sweden
Posted: 22nd Jun 2014 12:03 Edited at: 22nd Jun 2014 16:33
How are variables passed by value or reference to a function?
Digital Awakening
AGK Developer
14
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Sweden
Posted: 22nd Jun 2014 18:19
idstam
You are using ; instead of : to separate the lines.

Marl
5
Years of Service
User Offline
Joined: 19th Nov 2011
Location: Bradford, UK
Posted: 23rd Jun 2014 02:02
Quote: "ret_board is not used anywhere else in the code."

Then you need to define ret_board using whatever type is used for ai_board_stack[], otherwise it will default to integer. The error suggests that ai_board_stack[] is not an integer array.
Hockeykid
DBPro Tool Maker
9
Years of Service
User Offline
Joined: 26th Sep 2007
Location:
Posted: 23rd Jun 2014 06:41
Just tried compiling the Space Shooter game in the examples, I get an error saying "Cannot perform operation "Boolean AND" on data type "Float" in player.agc at line 270".

This is line 270:
+ Code Snippet

I was able to get it to compile by changing it to this:
+ Code Snippet

So it would seem you can no longer add floats to integers within an if statement. I'm not sure if this is on purpose or a bug.



Sean

Paul Johnston
TGC Developer
14
Years of Service
User Offline
Joined: 16th Nov 2002
Location: United Kingdom
Posted: 23rd Jun 2014 17:04
Quote: "if ( g_iDelay <> 0 and Timer ( ) + g_iDelay + 2 )"


Try this instead
+ Code Snippet

Quote: "How are variables passed by value or reference to a function?"


To pass by value
+ Code Snippet

To pass by reference
+ Code Snippet
Markus
12
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 23rd Jun 2014 18:38 Edited at: 23rd Jun 2014 18:38
hmm, i had installed v2 alpha 3 and than copy compiler test in it even.


AGK 108 (B)19 : Windows 8.1 Pro 64 Bit : AMD Radeon R7 265

Attachments

Login to view attachments
Naphier
6
Years of Service
User Offline
Joined: 2nd Oct 2010
Location: St Petersburg, Florida
Posted: 23rd Jun 2014 18:49
@Markus - did you try putting something in the if/endif?
I'd want the compiler to tell me if I had an empty conditional like the one you show!

Markus
12
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 23rd Jun 2014 19:00 Edited at: 23rd Jun 2014 19:02
@Paul & Naphier,
it seems the parser needs some improvements or better logic.
this work with a row between.
+ Code Snippet

@Naphier, a warning would be ok at empty if then.

AGK 108 (B)19 : Windows 8.1 Pro 64 Bit : AMD Radeon R7 265
Digital Awakening
AGK Developer
14
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Sweden
Posted: 23rd Jun 2014 19:12
Already fixed for the next update.

JimHawkins
7
Years of Service
User Offline
Joined: 26th Jul 2009
Location: Hull - UK
Posted: 23rd Jun 2014 19:40
An empty if statement is syntax ERROR, not a warning. The compiler is correct.

-- Jim - When is there going to be a release?
Markus
12
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 23rd Jun 2014 19:54
@JimHawkins
if u mean this
If [Then]
End If
i agree, else
its not,
there is nothing wrong in code.
If a = b [Then]
End If

AGK 108 (B)19 : Windows 8.1 Pro 64 Bit : AMD Radeon R7 265
Digital Awakening
AGK Developer
14
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Sweden
Posted: 23rd Jun 2014 20:31
From Paul, earlier in this thread:
Quote: "Empty IF/ELSE blocks will be accepted in the next update"


I find this to be convenient during development.

JimHawkins
7
Years of Service
User Offline
Joined: 26th Jul 2009
Location: Hull - UK
Posted: 23rd Jun 2014 21:11 Edited at: 23rd Jun 2014 21:13
The example wasn't empty! It had a conditional with no outcome, so it was either wrong or pointless.

-- Jim - When is there going to be a release?
Digital Awakening
AGK Developer
14
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Sweden
Posted: 23rd Jun 2014 21:25
Out of context it looks pointless. But maybe I want to add a few IFs during development and intend to fill them in later. It's just convenient. Maybe you throw in ELSE or ELSEIF in there and it stars to look less pointless.

swissolo
7
Years of Service
User Offline
Joined: 9th Jan 2010
Location:
Posted: 23rd Jun 2014 21:39
I would hope you could have empty conditional statements. When I'm building large pieces of code I write out the framework using them and compile it to make sure I don't silly errors before digging in deeper.

Markus
12
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 23rd Jun 2014 21:43
@JimHawkins
what if i remark a block inside?
also during development it can be empty until i fill it.
yes, i want have the freedom to do pointless things.
but the reason why i post this was the compiler gave me a wrong error message because not understand endif.
i test the compiler and inside 5 minutes i had this problem.
just had copy other example code and cleared some rows.
Digital Awakening said its solved in next update.

AGK 108 (B)19 : Windows 8.1 Pro 64 Bit : AMD Radeon R7 265
Digital Awakening
AGK Developer
14
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Sweden
Posted: 23rd Jun 2014 22:20
Quote: "the compiler gave me a wrong error message because not understand endif."

It reported that ENDIF was unexpected. It was expecting something other than ENDIF.

Hockeykid
DBPro Tool Maker
9
Years of Service
User Offline
Joined: 26th Sep 2007
Location:
Posted: 23rd Jun 2014 22:24
When trying to assign the return of a command to a variable such as this:

+ Code Snippet

I get the following error: "Function call must end with a close bracket in main.agc at line 785"

However, something like this will compile fine:
+ Code Snippet


Sean

Login to post a reply

Server time is: 2017-02-19 18:56:37
Your offset time is: 2017-02-19 18:56:37