Recent

Author Topic: Interpret string as Pascal?  (Read 3876 times)

Trenatos

  • Hero Member
  • *****
  • Posts: 537
    • MarcusFernstrom.com
Interpret string as Pascal?
« on: July 10, 2015, 04:48:35 pm »
Is it possible to interpret a string as pascal code?

IE. could I read a string from a file and run it?

Handoko

  • Hero Member
  • *****
  • Posts: 5529
  • My goal: build my own game engine using Lazarus
Re: Interpret string as Pascal?
« Reply #1 on: July 10, 2015, 05:08:04 pm »
Not very sure, I never tried. But I think this might be the thing you're looking for:
http://wiki.freepascal.org/Pascal_Script

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 12770
  • FPC developer.
Re: Interpret string as Pascal?
« Reply #2 on: July 10, 2015, 07:08:57 pm »
Is it possible to interpret a string as pascal code?

IE. could I read a string from a file and run it?

Not directly, Pascal is generally a compiled language.

However there are escapes, you could use an interpreter that interprets a subset of Pascal like PascalScript.

In the future maybe dynamic loading pascal packages will be possible, but for that, you would need to ship .ppu's for what you link to.

In theory you can also work with plain DLLs/shared libs, but since then automated types and other RTL state are a problem, that is only for exceptional cases.

Leledumbo

  • Hero Member
  • *****
  • Posts: 8836
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: Interpret string as Pascal?
« Reply #3 on: July 10, 2015, 09:22:58 pm »
Generally, you need a Pascal interpreter, which is callable from Pascal compiled code like Script Engine II, but it has a big limitation being 32-bit windows only due to assembler hacks. Lape is another good one (it even has a tutorial!), and it doesn't seem to have Script Engine II limitation. Another candidate would be DWScript (unsure about FPC compatiblity), PascalScript (very limited in terms of supported language construct) and FastScript (proprietary). Choose wisely.

Trenatos

  • Hero Member
  • *****
  • Posts: 537
    • MarcusFernstrom.com
Re: Interpret string as Pascal?
« Reply #4 on: July 15, 2015, 03:19:38 pm »
Thanks guys, so this will be something later then, but cool that there are some options, it gives interesting ideas

 

TinyPortal © 2005-2018