Interpreted languages

From PC2wiki
Revision as of 16:48, 1 March 2010 by Doug Lane (talk | contribs) (initial draft)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Interpreted programming Languages do not produce an executable. The code is executed by an interpreter.

Examples of interpreted languages are: PERL, PHP, Ruby, and shell languages (ksh, csh, bash, etc).

PC² up to and through version 9.1.x must use a work around for interpreted languages to work.

How PC² creates an executable

PC² performs two compile steps before executing a program:

  1. compile the source code into an executable program
  2. check for the existence of that executable program

There are two Language fields that are used for each of these steps

  1. Compile Cmd Line - instruction to compile a source file
  2. Executable Filename - expected name of executable

PERL example language definition

To use PERL in PC² use the Edit Languge feature and use the following field values, this example is Unix.

Language Name       : Perl
Compiler Call       : compilePerl
Executable Name     : OK
Execute command line: perl {:mainfile}

The final step to get this to work is to insure that compilePerl (or compilePerl.bat) is in the PATH (or the absolute path and filename are put into the Compiler Call field).

Example shell script to create OK file (from the compilePerl script in samples)

#!/bin/csh

perl –c $*
if ($? == 0) then
   touch OK
endif

Example Win32/DOS batch file to create OK file (from compilePerl.bat from samples)

if exist %1 goto compile:

echo No perl source specified or file '%1' does not exist

goto end:
:compile
perl -c %1 %2 %3

if ERRORLEVEL 0 echo > OK

:end 

Future Improvements

bug 479 - Add feature to support interpreted languages better, has been created to avoid the workaround described above.

See Also