Interpreted languages

From PC2wiki
Jump to: navigation, search

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

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


PC² up to and through version 9.2.0 must use a script to create an executable file for interpreted languages to work.

Version 9.3 and later

Any version of pc2 at or after build 2321 (version 9.3 or later) has simplified the configuration using interpreted languages. With Version 9.3 there are new auto populate language entries for:

  • PHP
  • Perl
  • Python
  • Ruby

To use another interpreted language, use one of the languages above and customize it as necessary.

A testing version of PC^sup2; Version 9.3 is now available on the Nightly Builds on the TUG page.

Version 9.2.0 and earlier

PC² checks for an executable (Executable Name) to determine whether the compiler actually created an executable file. Since an interpreted language does not produce an executable file, PC² will indicate that there was no executable file with messages like:

Problem executing compiler, contact staff.


PC2: execution of program did not generate any output

How to configure an interpreted language

Since PC² requires the creation of an executable file, a stub/fake file must be created using a script.

The steps to configure an interpreted language are:

  1. Create a compile script like samps/compilePerl
  2. Insure that compilePerl is in the PATH
  3. Use compilePerl in the Language Compiler Call field
  4. Use OK (the file created by compilePerl) in the Executable Name field

In the samps directory are both compilePerl and compilePerl.bat as examples.

PERL example language definition

To use PERL in PC² use the Edit Language feature.

For Unix the fields would be:

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

For Win32/DOS the fields would be:

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

Example Scripts

The scripts will check compile the source code and if the file compiles create the file OK.

Example Unix script (samps/compilePerl)

perl -c $*

if ($? == 0) then
    touch OK

# eof compilePerl $Id: compilePerl 575 2007-05-04 23:28:56Z laned $

Example Win32/DOS batch file (from samps/compilePerl.bat)

if exist %1 goto compile:

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

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

if ERRORLEVEL 0 echo > OK


rem eof compilePerl $Id: compilePerl.bat 573 2007-05-04 22:39:22Z laned $

See Also