ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Hi, i don't if this is the right forum to post but here we go.
I'm trying to make (actually start making) a php editor. I wanna know how can i insert all php funcions (all of them) into my editor.
For example, quanta highlights php funcions and explains it, but the programmer didn't inserted it in a "manual" way, right?
don't get what you mean, but a code editor is just a text editor that has extra functionality in it.. there's no magic way anything is actually "done"... just coded to do it. you might want to possibly look at the scintilla code engine for a customizable code edit engine.
I'd guess that the language syntax and functions are stored in a file. The program will read this file in and store the data in a data structure (array...) Then when the user starts to type a function name it will search along the array (would be good to store it in alphabetical order) and as it has a match it can display all the possible functions to allow the user to select the most suitable function. Once selected additional information can be displayed.
So you are right in that each function (syntax rule) is not manually added to the program, rather it will be in a structured file that describes the language but the program will have to read in the file and operate on the contents of the language file.
At least one syntax-highlighting editor, nedit, uses customizable regular expressions to detect programming language constructs. These are visible in each users' nedit.rc file. The use of regular expressions is probably a natural way to perform syntax parsing, since many language grammars are defined in terms of regular expressions in lex parsers.
At least one syntax-highlighting editor, nedit, uses customizable regular expressions to detect programming language constructs. These are visible in each users' nedit.rc file. The use of regular expressions is probably a natural way to perform syntax parsing, since many language grammars are defined in terms of regular expressions in lex parsers.
--- rod.
A friend tould me that, but my editor is especific to php, so i'm trying to insert all php functions in my program.
Does php.net offers a file where i can have all functions?
Serious, this seen to be harder than i tought it would be
Usually to perform syntax highlighting you use a lexer.
*You listen to the user input text and you parse it and a portion of text already typed in the editor.
*After parsing the text you create tokens which correspond to for example a function name, a variable, etc.
*When you have the tokens, you select the color to apply to tokens.
VIM color codes PHP just fine. look at php.vim (usually stored is /usr/share/vim/syntax/php.vim ... Something like that
It will give you a list of all the function names. It also shows you how it handles constructs like arrays, switches, etc..
Take a look at indent/php.vim for some clues on auto-indention.
You can find documents explaining how to write these files (and conversely, how to read them). Regardless, it should be a good starting spot for program. Why are you trying to re-invent the wheel though?
Last edited by AngryLlama; 05-11-2006 at 05:41 PM.
A friend tould me that, but my editor is especific to php, so i'm trying to insert all php functions in my program.
Does php.net offers a file where i can have all functions?
Serious, this seen to be harder than i tought it would be
But, the point was to do it the same way nedit does it. Use a lexical parser generator like lex (flex, in the linux world) to generate a parser to parse the source code. That will allow you to tokenize the text, and having done so, apply syntax related colors to it. You may have to perform somne level of grammatical analysis, in order to determine from context, what each token represents. When done this way, your editor can determine from the context what tokens are function names. That way, the functions you write yourself will appear in the same color code as built-in function names.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.