Jump to content

Recommended Posts

Is the internet getting boring or is it just me? There isn't a Web site with that excitement anymore. Myspace is getting boring and so is facebook. Youtube is ok but the same video is getting old fast. Yahoo has been the same , no changes. Google, well, I just use it for research, so is the Internet getting boring or it just me?

Link to comment
https://forums.phpfreaks.com/topic/71596-the-internet-boring/
Share on other sites

I'm working on creating a programming langauge using the PHP Engine since PHP can be a stand-alone engine Smiley  I dont' know if this is possible yet, but it makes for great research.

 

In order to create a programming language you must do (at least) the following (I'm a bit rusty so there might be more):

* Develop a grammar; this can be done on pen & paper

* Write a parser / tokenizer; this is what opens the source files and structures their contents for processing

 

The next step depends on if you're creating an interpreted or compiled language.  If an interpreted language, like PHP, you execute the instructions represented by the data structures created from parsing.

 

If you are creating a compiled language you translate the instructions represented by the data structures from the parsing step into binary instructions for your platform and dump them into a file.  This means you need to learn about that platform's expected executable file format.

 

Most compilers, not sure about interpreters, won't go directly from parsing to executable.  They'll create an intermediate source file that is basically a generic form of assembly (I think it's referred to as byte code).  What this means is its cryptic like assembly (ADD, SUB, MUL, DIV, MOV, etc) and uses fake registers ($R1-$RI, $S1-$S8 as examples) but most assemblers won't be able to assemble (compile) it.  The reason they do this is it helps with code optimization.  As a quick example, let's say we had the following intermediary source:

  mov $r2, $r1 # Move $r1 into $r2
  # 100 lines of source code
  mov $r2, $r6 # Move $r6 into $r2

Both of those mov statements assign to the same register, $r2.  However, if we can determine that in the 100 lines of commented code that $r2 is never used, we can safely remove the first assignment and save ourselves an instruction.

 

From this assembler-like intermediary code, I think most compilers will then convert into correct assembler for the target platform.  Another stage of optimization will occur.  During this stage instructions are re-ordered where possible to take advantage of the CPU pipeline.

 

That's most of what I can remember when I studying this stuff in college.  I can assure you, ronald, that this can all be accomplished in PHP.  :D

Link to comment
https://forums.phpfreaks.com/topic/71596-the-internet-boring/#findComment-361192
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.