Page 1 of 2

How to retrieve location of unexpected token?

PostPosted: August 22nd, 2013, 7:08 am
by johnc
I'm trying to run a wordpress plugin that fails to compile when activating.

The error logged is:
[22-Aug-2013 07:03:52] CompileError: Syntax error: unexpected token '}'

I'd like to find where this unexpected token is in the source code (it's many files) and fix it - how can I get Phalanger to tell me the source code file and location within the file that the unexpected token is found in?

Re: How to retrieve location of unexpected token?

PostPosted: August 22nd, 2013, 2:13 pm
by Jakub Misek
Hi,

Good question. Locations in .NET are available if you are compiling in debug mode (so .pdb files are generated).

If you are compiling from command line, using phpc.exe, specify "/debug+" argument.

Otherwise, add folowing into your web.config, into <phpNet><compiler> section:
Code: Select all
<set name="Debug" value="true" />

Please give me know if it works for you,
Thanks

Re: How to retrieve location of unexpected token?

PostPosted: August 22nd, 2013, 4:03 pm
by johnc
I still didn't get any file/position information in the error log.

I've pasted my Web.Config file here: http://privatepaste.com/04694dc213

I think I configured it all properly.

I'm running under mono 3.0.12 (mono 2.10 caused a fatal Emit exception).

Interestingly, compiling the same source files on windows with phpc.exe doesn't give me any compile errors.

Re: How to retrieve location of unexpected token?

PostPosted: August 22nd, 2013, 4:20 pm
by Jakub Misek
if you run <?php phpinfo(); ?> you should see whether you are really in Debug mode or not (right on top, aside of the Phalanger version)

Thanks,

Re: How to retrieve location of unexpected token?

PostPosted: August 22nd, 2013, 4:28 pm
by johnc
It appears I'm not.

I get the Phalanger header with the version and cpu arch, no mention of debug mode.

Re: How to retrieve location of unexpected token?

PostPosted: August 22nd, 2013, 4:40 pm
by Jakub Misek
I've tried to run .php file in debug/release (on Windows), and it is getting me syntax error location in any mode.

Re: How to retrieve location of unexpected token?

PostPosted: August 28th, 2013, 3:08 am
by johnc
We are running on linux under mono. Just can't seem to find out where the error is occuring in order to fix it.

I'd gladly try any suggestions at this point.

EDIT:

I ran the compiler from the command line, compiling just the plugin itself and didn't get the unexpected token error. Maybe the plugin is calling out to some broken WP code?

Re: How to retrieve location of unexpected token?

PostPosted: August 28th, 2013, 1:56 pm
by Jakub Misek
Maybe it is including something out of the plugins directory.

Anyway "unexpected token" error has always the location; I can't find any case where it doesn't.

Do you have a chance of debugging the application? Catching any exception, or put a breakpoint into Phalanger code?

Re: How to retrieve location of unexpected token?

PostPosted: August 30th, 2013, 6:01 am
by johnc
We can't run a debug session locally as we don't own a license for the Phalanger Visual Studio tools yet.

We're in the process of testing the phalanger asp.net hosting component for our wordpress network and, understandably, we can't put down cash for what is a relatively unknown and unproven technology.

We really are anxious to get off php-fpm though so I'm hoping it works out well in the end.

Re: How to retrieve location of unexpected token?

PostPosted: August 30th, 2013, 1:20 pm
by Jakub Misek
I mean debugging Phalanger itself; just attach the debugger to the web server process.

Anyway if you can locate the plugin causing this? I can take a look locally and give you know.

Thanks