Author Topic: PHP lexer  (Read 18365 times)

Offline adam

  • Single posting newcomer
  • *
  • Posts: 7
PHP lexer
« on: November 26, 2006, 12:48:55 pm »
Ok i seem to have gotten this sorta working though there must be an internal issue with wxscintilla. I have the lexer file setup properly and everything. Here is what I've found so far.

In wxscintilla.h:
wxSCI_LEX_PHPSCRIPT 69
Default 118
Start tag 18
Matched Bracket 34
Unmatched Bracket 35
Complex variable 104
Double quote string 119
Single quote string 120
Keyword 121
Number 122
Variable 123
Comment 124
One line comment 125
String variable 126
Operator 127

In  LexHTML.cxx:
static const char * const htmlWordListDesc[] = {
   "HTML elements and attributes", // 0
   "JavaScript keywords", // 1
   "VBScript keywords", // 2
   "Python keywords", // 3
   "PHP keywords", // 4
   "SGML and DTD keywords", // 5
   0,
};

static const char * const phpscriptWordListDesc[] = {
   "", //Unused 0
   "", //Unused 1
   "", //Unused 2
   "", //Unused 3
   "PHP keywords", // 4
   "", //Unused // 5
   0,
};

The text output that I get in cb when i load a php file is something like this
<?php
class database {

}

?>

Though the text color is still black just blue underlined. The <?php and ?> are correct in the coloring that i gave them.

So more info that could help is that when it was on wxSCI_LEX_HTML and you wrote < ?PHP with the space the underlining went away and syntax highlighting work within sets of < > as if it where an HTML tag and like normal if it wasn't within < >. Though keyword highlighting still doesn't work

sethjackson

  • Guest
Re: PHP lexer
« Reply #1 on: November 27, 2006, 09:11:49 pm »
I've tried and tried and tried to get a PHP lexer working, but to no avail. I get the same results you did......
I'm really not sure why this happens. :P

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9693
Re: PHP lexer
« Reply #2 on: November 27, 2006, 09:49:12 pm »
Hehe... I've got a PHP lexer in the backhand for some time now... still struggeling with a similar issue... ;-)
I think the reason is that some lexers in wxScintilla are based on others (e.g. vbscript is based on vb). I believe it has to do with the fact that PHP is somehow based on the HTML lexer which either needs modification or even integration of the PHP part... not sure about this.
With regards, Morten.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline dmoore

  • Developer
  • Lives here!
  • *****
  • Posts: 1576
Re: PHP lexer
« Reply #3 on: November 27, 2006, 10:01:31 pm »
Hehe... I've got a PHP lexer in the backhand for some time now... still struggeling with a similar issue... ;-)
I think the reason is that some lexers in wxScintilla are based on others (e.g. vbscript is based on vb). I believe it has to do with the fact that PHP is somehow based on the HTML lexer which either needs modification or even integration of the PHP part... not sure about this.
With regards, Morten.

The php lexer appears to work just fine in SciTE. As you suspect, Morten, it appears that the php lexer depends on the HTML lexer: In SciTE, to modify php options, you have to open html properties. Perhaps the way to proceed is to extend the html lexer to incorporate php keywords and file extensions using the settings in SciTE as a reference? (NB: pasting some php into an html file in C::B also leads to the same formatting problem that adam reports - i.e. the current html lexer in C::B doesn't understand php either)

sethjackson

  • Guest
Re: PHP lexer
« Reply #4 on: November 27, 2006, 10:33:36 pm »
Hehe... I've got a PHP lexer in the backhand for some time now... still struggeling with a similar issue... ;-)
I think the reason is that some lexers in wxScintilla are based on others (e.g. vbscript is based on vb). I believe it has to do with the fact that PHP is somehow based on the HTML lexer which either needs modification or even integration of the PHP part... not sure about this.
With regards, Morten.

The php lexer appears to work just fine in SciTE. As you suspect, Morten, it appears that the php lexer depends on the HTML lexer: In SciTE, to modify php options, you have to open html properties. Perhaps the way to proceed is to extend the html lexer to incorporate php keywords and file extensions using the settings in SciTE as a reference? (NB: pasting some php into an html file in C::B also leads to the same formatting problem that adam reports - i.e. the current html lexer in C::B doesn't understand php either)

Already tried adding PHP stuff to the HTML lexer. It was a no go. :P

Offline BrianSidebotham

  • Multiple posting newcomer
  • *
  • Posts: 45
Re: PHP lexer
« Reply #5 on: November 28, 2006, 11:11:03 am »
Programmers notepad does php lexxing with scintilla under the html lexxer..

Offline adam

  • Single posting newcomer
  • *
  • Posts: 7
Re: PHP lexer
« Reply #6 on: November 28, 2006, 11:42:46 pm »
With this HTML lexer it still does the weird underlining issue though. Same thing will happen in Visual Studio when you open a PHP file it thinks it is XML tags and uses an XML lexer.

sethjackson

  • Guest
Re: PHP lexer
« Reply #7 on: November 29, 2006, 12:46:19 am »
Yeah the underlining thing is there, and I couldn't get it to recognize keywords inside <?php ?>. :P

Offline Wahooney

  • Multiple posting newcomer
  • *
  • Posts: 34
  • Demon Onion Slayer
    • wahooney.net
Re: PHP lexer
« Reply #8 on: February 20, 2007, 10:11:54 am »
Hey guys, sorry to be a thread bumper, but has anyone been able to resolve this problem yet?

The lexer file that I've made uses the CPP lexer to do the code highlighting, as you can imagine this is very limiting.

Cheers.
Fabricati Diem, Celerata!

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9693
Re: PHP lexer
« Reply #9 on: February 20, 2007, 10:20:21 am »
Hey guys, sorry to be a thread bumper, but has anyone been able to resolve this problem yet?
Nope, unfortunately not. I have attached my "alpha" version to this message for others to play with. It actually *should* really work, but it doesn't and I have no clue why that is. I believe because PHP is actually a "sub-lever" of something else (HTML if I recall correctly).
If someone finds a solution please step forward! ;-)
With regards, Morten.

[attachment deleted by admin]
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ