[fpc-pascal] Any command line interpreters for Free Pascal?

Roland Schäfer roland.schaefer at fu-berlin.de
Sat Oct 15 09:10:25 CEST 2011


I get the impression that you want to use Pascal for something it wasn't
designed for. Even if you can find some kind of solution, it will
probably be a bad hack. But that question is probably for fpc-other.

So anyway, the only solution I can think of is to automatically comment
out the shebang by calling sed or something from your makefile if you
"compile as a program". (As fas as I understand, this is exactly
equivalent to what instantfpc does in the background, since it is NOT an
interpreter. So what you do is in fact make a lot of fuss about two
different ways of generating and running exactly the same executable.)
You can even remove the comment after compilation again. This is as bad
style as using the old #if 0 construction for debug code in C, though.

Good look,
Roland

On 10/15/2011 12:56 AM, Andrew Pennebaker wrote:
> Yeah, I know to chmod my scripts before dot-slashing them. It's just that
> fpc can't handle shebangs, and I don't want to have to choose either
> scripting or compiled. I like my Pascal code to be work in either mode.
> 
> Cheers,
> 
> Andrew Pennebaker
> www.yellosoft.us
> 
> On Fri, Oct 14, 2011 at 6:49 PM, ik <idokan at gmail.com> wrote:
> 
>> On Sat, Oct 15, 2011 at 00:48, ik <idokan at gmail.com> wrote:
>>
>>> On Sat, Oct 15, 2011 at 00:43, Andrew Pennebaker <
>>> andrew.pennebaker at gmail.com> wrote:
>>>
>>>> Thanks ik. Merf, it appears fpc can't compile when a shebang is added. In
>>>> future versions, can fpc treat shebangs as comments so that instantfpc code
>>>> could be compiled like normal Free Pascal code?
>>>>
>>>>  $ cat hello.pas
>>>> #!/usr/bin/env instantfpc
>>>> program Hello;
>>>> begin
>>>> writeln('Hello World!')
>>>> end.
>>>>
>>>>
>>> $ chmpd +x hello.pas
>>>
>>
>> Opps,
>> $ chmod +x hello.pas
>>
>>
>>>  $ ./hello.pas
>>>
>>>
>>>
>>>
>>>> $ fpc hello.pas
>>>> Free Pascal Compiler version 2.4.4 [2011/05/01] for i386
>>>> Copyright (c) 1993-2010 by Florian Klaempfl
>>>> Target OS: Darwin for i386
>>>> Compiling hello.pas
>>>> hello.pas(1,1) Error: Illegal char constant
>>>> hello.pas(1,2) Fatal: Syntax error, "BEGIN" expected but "const string"
>>>> found
>>>> Fatal: Compilation aborted
>>>> Error: /usr/local/bin/ppc386 returned an error exitcode (normal if you
>>>> did not specify a source file to be compiled)
>>>>
>>>> Cheers,
>>>>
>>>> Andrew Pennebaker
>>>> www.yellosoft.us
>>>>
>>>> On Fri, Oct 14, 2011 at 6:29 PM, ik <idokan at gmail.com> wrote:
>>>>
>>>>>
>>>>> On Sat, Oct 15, 2011 at 00:25, Andrew Pennebaker <
>>>>> andrew.pennebaker at gmail.com> wrote:
>>>>>
>>>>>> E.g., if fpi existed, I would add a shebang like this to my code:
>>>>>>
>>>>>> #!/usr/bin/env fpi
>>>>>>
>>>>>>
>>>>> InstantFPC <http://wiki.freepascal.org/InstantFPC>
>>>>>
>>>>>
>>>>>> Cheers,
>>>>>>
>>>>>>
>>>>>> Andrew Pennebaker
>>>>>> www.yellosoft.us



More information about the fpc-pascal mailing list