Giter Site home page Giter Site logo

k-john-gough / gpcp Goto Github PK

View Code? Open in Web Editor NEW
58.0 10.0 16.0 721 KB

Gardens Point Component Pascal is an implementation of the Component Pascal Language (CP). There are implementations for both the CLR and the JVM.

License: Other

Java 8.83% Component Pascal 85.44% C++ 0.30% Batchfile 0.52% C# 2.89% Rich Text Format 1.65% Shell 0.37%

gpcp's Introduction

Gardens Point Component Pascal (GPCP)

Getting Started

Project Description

Gardens Point Component Pascal is an implementation of the Component Pascal Language (CP). There are implementations for both the CLR and the JVM.

Component Pascal is an object oriented language in the Pascal family. Its closest relatives are Oberon-2 and Oberon.

Gardens Point Component Pascal (gpcp) is an implementation of the language which was created for both the .NET and JVM. Both versions are here.

gpcp for .NET was one of the language implementations created for the .NET platform as part of Microsoft's "Project-7" which demonstrated the cross-language capability of .NET. The first release of the language was in mid-2000, at the Professional Developer's Conference, where .NET was announced. The language was also used as the running example in the book "Compiling for the .NET Common Language Runtime" (Prentice-Hall 2002).

gpcp provides a number of extensions to the standard Component Pascal language. These extensions are provided to allow programs to access the rich capabilities of the base class libraries of the .NET system. Thus types defined in gpcp programs are able to declare that they implement interfaces, or provide methods that override protected methods defined in other languages. Although Component Pascal does not allow the definition of overloaded methods, overloaded methods may be called from Component Pascal code. All such language extensions may be turned off by a command line option.

As well as the compiler, the distribution contains a number of other utilities

  • The program CPMake which performs a minimal consistent compilation of a set of Component Pascal modules, respecting the module dependencies explicitly declared in the source files.
  • The program PeToCps (for the .NET version) which creates a gpcp symbol file from a nominated "foreign language" PE file. Such symbol files are used by gpcp to perform type-safe separate compilation of Component Pascal modules that import foreign language libraries.
  • The program J2CPS (for the JVM version) which creates gpcp symbol files from a nominated java package. Such symbol files are used by gpcp to perform type-safe separate compilation of Component Pascal modules that import foreign language libraries.
  • The program Browse produces a readable, hyperlinked representation of gpcp symbol files.
  • The program MakeIndex which creates an index for all the html files created by Browse in a directory.

Special Note

Almost all of the sources of the gpcp tools are written in Component Pascal. It is not possible to use gpcp until you have executable code of the tools. And you cannot build the executables from this source repository unless you already have a Component Pascal compiler. Most users should start by downloading a recent release distribution from the link above. The releases have documentation, usage information and example programs.

gpcp's People

Contributors

k-john-gough avatar mguntli avatar proberon avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

gpcp's Issues

Goodbye!

I decided to switch to PascalABC.NET. Component Pascal as a language is already very limited, that it's only suitable for embedded programming like Astrobe is currently doing now. The integration with .NET is also too poor. The language lacked many features to leverage the power of the .NET framework standard library. I have tried my best, but I can't find the workaround for the limitations of the language. I still keep my PRs open, though. Goodbye.

Where could I found more information about gpcp?

For example, the API docs and what is and how to use the scripts in the bin directory. The documentation directory only has an Oberon report (language specification) but no other information about the API, e.g: what is CPMain, which procedures contained inside the Console module... The scripts inside bin give very limited information about what is their functionality and how to use them, apart from the obvious are gpcp (compiler), cprun (run), cpmake (make). I currently can't write new code but just compiling examples shipped with gpcp.

Incorporate the changes from @pahihu to support Java 11 and Java 17

I'm very glad to see @k-john-gough still around and accepting pull requests. @pahihu didn't fork from this repo, he populated his repo with the source code from the released zip archive. This make doing a pull request to incorporate his changes to this repo more difficult. I attempted to do only to realize I don't understand Java and know nothing about gpcp's internals. Anyone still around please consider making a pull request to incorporate @pahihu's changes. Thank you very much.

@proberon Please have a look at https://github.com/pahihu/gpcp-JVM, there are only 9 commits, but I don't understand anything to help. I don't want myself to create a mess for you all.

p/s: This commit should be skipped: pahihu/gpcp-JVM@116c8c8 as that document has nothing to do with gpcp: pahihu/gpcp-JVM#2

LOOP-END bug?

MODULE FailTest;

  IMPORT CPmain;

BEGIN
  LOOP END
END FailTest.
deaddoomer@sun otc $ gpcp -version FailTest.cp
#gpcp: jvm version 1.4.04 of 07 August 2017
#gpcp: Using AsmUtil - default (V1_7) emitter
#gpcp: <FailTest> No errors
deaddoomer@sun otc $ cprun FailTest
Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.VerifyError: Expecting a stack map frame
Exception Details:
  Location:
    CP/FailTest/FailTest.main([Ljava/lang/String;)V @8: return
  Reason:
    Error exists in the bytecode
  Bytecode:
    0x0000000: 2ab8 0013 00a7 ffff b1                 
  Stackmap Table:
    same_frame(@4)

	at java.lang.Class.getDeclaredMethods0(Native Method)
	at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
	at java.lang.Class.privateGetMethodRecursive(Class.java:3048)
	at java.lang.Class.getMethod0(Class.java:3018)
	at java.lang.Class.getMethod(Class.java:1784)
	at sun.launcher.LauncherHelper.validateMainClass(LauncherHelper.java:544)
	at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:526)
deaddoomer@sun otc $ java -version
openjdk version "1.8.0_144"
OpenJDK Runtime Environment (IcedTea 3.5.1) (CRUX)
OpenJDK 64-Bit Server VM (build 25.144-b01, mixed mode)

With -asm5, -asm6 or -legacy everythin ok.

Will any of you update it to work with .NET Core?

Need build docs

It would be great if README.md pointed us to a BUILD.txt file.

Some rough usage docs would be great too.

Emitting Code for a 3-register machine (RISC-V, ARM)

Dear John
would it be possible to add more or less easily an emitter for a 3-register machine? Like ...
ADD R1, R2, R3
OR R1, R2, R3
LW R1, r2(8)
. . .
Of course there is some runtime facilities (GC etc.) needed if the NEW(..) keyword is used.

We at IMT (www.imt.ch) work currently with an ETH Compiler for the Oberon A2-System called FOX.. maintained by Dr. Friedrich.

It would be very helpfull if we could emitt directly ARM/RISC-V - binary code.

With regards,

Jakob

Cannot compile form.cp example with v1.4.07

When I run the gpcp compiler from the command line on the form.cp example that comes with gpcp I get these errors:


C:\GPCP-v1.4.07\documentation\Examples>gpcp /hsize=20000 form.cp

20 WinMain;

**** Cannot open symbol file <mscorlib_System_Collections_ObjectModel.cps>

37 bf.Dispose^(disposing);

**** --------------------^
**** Empty or abstract methods cannot be called by super-call

#gpcp: <Form> There were 2 errors


It is the import of "system.windows.forms]System.Windows.Forms" that leads to the import attempt of "mscorlib_System_Collections_ObjectModel"
The release notes say that v4.5 of the .NET framework is required but I have got v4.7 installed. I understood them to be backwards-compatible.

Could you make gpcp jvm work on Linux?

I know there are limitations on .NET implementations on Linux but the JVM is already worked very well. I found that gpcp doesn't work on Linux, even with the jvm version. Please consider support Linux, it's an awesome system. From my limited knowledge I think we only have to create the equivalent shell scripts of the batch files and everything would work but it turned out to be wrong. I don't understand the internals of gpcp so I can only ask for your help.

Looking forward to your answer,
jiaxing.

Compiler crash when use uplevel addressing

First case

MODULE Strings;

  PROCEDURE SetToString* (x: SET; OUT str: ARRAY OF CHAR);
    VAR
      len, i: INTEGER;

    PROCEDURE AppendChar(ch: CHAR);
    BEGIN ASSERT(len < LEN(str), 23); str[len] := ch; INC(len)   
    END AppendChar;

    PROCEDURE AppendInt (x: INTEGER);
      VAR i: INTEGER; ch: CHAR; buf: ARRAY 32 OF CHAR;
    BEGIN
      (* IntToString(x, buf); *)
      ch := buf[0]; i := 0;
      WHILE ch # 0X DO AppendChar(ch); INC(i); ch := buf[i] END
    END AppendInt;

  BEGIN
    len := 0; AppendChar('{'); i := MIN(SET);
    WHILE x # {} DO
      IF i IN x THEN AppendInt(i); EXCL(x, i);
        IF (i <= MAX(SET) - 2) & (i+1 IN x) & (i+2 IN x) THEN AppendChar('.'); AppendChar('.');
          x := x - {i+1, i+2}; INC(i, 3);
          WHILE (i <= MAX(SET)) & (i IN x) DO EXCL(x, i); INC(i) END;
          AppendInt(i-1)
        END;
        IF x # {} THEN AppendChar(","); AppendChar(" ") END
      END;
      INC(i)
    END;
    AppendChar("}"); AppendChar(0X)
  END SetToString;

END Strings.
deaddoomer@sun Tests $ gpcp -version -nowarn Strings.cp
#gpcp: jvm version 1.4.04 of 07 August 2017
#gpcp: Using AsmUtil - default (V1_7) emitter
Exception in thread "main" java.lang.Exception: Vector index out of bounds
	at CP.AsmFrames.AsmFrames_MethodFrame.TrackStore(AsmFrames.cp:925)
	at CP.AsmUtil.AsmUtil_AsmEmitter.StoreLocal(AsmUtil.cp:340)
	at CP.JavaUtil.JavaUtil_JavaFile.PutLocal(JavaUtil.cp:1485)
	at CP.JavaUtil.JavaUtil_JavaFile.PutVar(JavaUtil.cp:1500)
	at CP.JavaMaker.JavaMaker_JavaEmitter.ScalarAssign(JavaMaker.cp:2098)
	at CP.JavaMaker.JavaMaker_JavaEmitter.EmitAssign(JavaMaker.cp:2872)
	at CP.JavaMaker.JavaMaker_JavaEmitter.EmitStat(JavaMaker.cp:3784)
	at CP.JavaMaker.JavaMaker_JavaEmitter.EmitBlock(JavaMaker.cp:3751)
	at CP.JavaMaker.JavaMaker_JavaEmitter.EmitStat(JavaMaker.cp:3796)
	at CP.JavaMaker.JavaMaker_JavaEmitter.EmitProc(JavaMaker.cp:722)
	at CP.JavaMaker.JavaMaker_JavaModEmitter.EmitBody(JavaMaker.cp:609)
	at CP.JavaMaker.JavaMaker_JavaEmitter.Emit(JavaMaker.cp:682)
	at CP.JavaMaker.JavaMaker_JavaWorkList.Emit(JavaMaker.cp:228)
	at CP.Target.Target.Emit(Target.cp:51)
	at CP.CPascal.CPascal.Compile(CPascal.cp:161)
	at CP.gpcp.gpcp.main(gpcp.cp:40)

If remove AppendChar() body then everything ok

Second case

MODULE STest;

  PROCEDURE First*;
    VAR
      x: INTEGER;

    PROCEDURE Fold;
    BEGIN x := 0
    END Fold;

  END First;

END STest.
deaddoomer@sun Tests $ gpcp -version -nowarn STest.cp
#gpcp: jvm version 1.4.04 of 07 August 2017
#gpcp: Using AsmUtil - default (V1_7) emitter
Exception in thread "main" java.lang.NullPointerException
	at CP.AsmHelpers.AsmHelpers.tyXtn(AsmHelpers.cp:169)
	at CP.AsmHelpers.AsmHelpers.tyNam(AsmHelpers.cp:218)
	at CP.AsmUtil.AsmUtil_AsmEmitter.CodeT(AsmUtil.cp:1071)
	at CP.JavaUtil.JavaUtil_JavaFile.GetXHR(JavaUtil.cp:1702)
	at CP.JavaUtil.JavaUtil_JavaFile.XhrHandle(JavaUtil.cp:1720)
	at CP.JavaMaker.JavaMaker_JavaEmitter.PushHandle(JavaMaker.cp:2082)
	at CP.JavaMaker.JavaMaker_JavaEmitter.EmitAssign(JavaMaker.cp:2857)
	at CP.JavaMaker.JavaMaker_JavaEmitter.EmitStat(JavaMaker.cp:3784)
	at CP.JavaMaker.JavaMaker_JavaEmitter.EmitProc(JavaMaker.cp:722)
	at CP.JavaMaker.JavaMaker_JavaEmitter.EmitProc(JavaMaker.cp:705)
	at CP.JavaMaker.JavaMaker_JavaModEmitter.EmitBody(JavaMaker.cp:609)
	at CP.JavaMaker.JavaMaker_JavaEmitter.Emit(JavaMaker.cp:682)
	at CP.JavaMaker.JavaMaker_JavaWorkList.Emit(JavaMaker.cp:228)
	at CP.Target.Target.Emit(Target.cp:51)
	at CP.CPascal.CPascal.Compile(CPascal.cp:161)
	at CP.gpcp.gpcp.main(gpcp.cp:40)

PS everything work with -jasmin

Java Error

Hello! I tried to run GPCP-JVM 1.4.07 on Windows 10 x64 and Java 10. I encountered an error when compiling. It was solved only with the installation of Java 8.

Invalid __copy__() in legacy mode

MODULE CopyTest;

  IMPORT CPmain;

  TYPE
    Type* = ARRAY 16 OF CHAR;
    File* = POINTER TO RECORD
      type-: Type;
      init: BOOLEAN;
    END;

  VAR
    a, b: File;

BEGIN
  NEW(a); NEW(b); a^ := b^
END CopyTest.
deaddoomer@sun Tests $ gpcp -version -legacy CopyTest.cp 
#gpcp: jvm version 1.4.04 of 07 August 2017
#gpcp: <CopyTest> No errors
deaddoomer@sun Tests $ cprun CopyTest
Exception in thread "main" java.lang.VerifyError: (class: CP/CopyTest/CopyTest_File, method: __copy__ signature: (LCP/CopyTest/CopyTest_File;)V) Register 0 contains wrong type
	at CP.CopyTest.CopyTest.main(CopyTest.cp:16)

Directory name clash

I try not to use Windows, but some people do. Why would you want to have two directories named:
j2cps
J2CPS

differing only in case???? Windows people can't use this, and it's even confusing to Linux people (me). I suggest something like:

j2cps.old
j2cps.new

etc.

Setting up gpcp-NET to use mono on FreeBSD

I'm trying to setup gpcp using mono on FreeBSD. I placed the distribution under the mono folder in /usr/local/lib/mono/gpcp-NET and set CPSYM and CROOT to /usr/local/lib/mono/gpcp-NET/symfiles and '/usr/local/lib/mono/gpcp-NET, respectively. However, when I run gpcp helloworld.cp` I get the following:

root@blackbird:~/Devel # gpcp helloworld.cp
2 IMPORT CPmain, Console;
**** Cannot open symbol file <Console.cps>
**** Cannot open symbol file <CPmain.cps>
4 Console.WriteString("Hello CP World");
**** ----------^ Identifier not known in qualified scope
5 Console.WriteLn;
**** ----------^ Identifier not known in qualified scope
#gpcp: There were 4 errors

Am I missing something?

Unable to run compiled binaries

This is my environment variables:

set CROOT=%userprofile%\Downloads\gpcp-NET
set PATH=%PATH%;%CROOT%\bin
set CPSYM=.;%CROOT%\symfiles;%CROOT%\symfiles\NetSystem

I compiled Hello.cp example without problems. But when I run it, it failed with:

Unhandled Exception: System.IO.FileNotFoundException: Could not load file or ass
embly 'RTS, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its
 dependencies. The system cannot find the file specified.
   at Hello.Hello..CPmain(String[] A_0)

If I copy Hello.exe into %CROOT%\bin it will run without problems.

Can't compile Form.cp example

gpcp.exe has stopped working

Unhandled Exception: System.NullReferenceException: Object reference not set to
an instance of an object.
   at GPBinFiles.GPBinFiles.findOnPath(Char[] pathName, Char[] fileName) in c:\U
sers\john\CurrentProjects\CVS-GPCP-NET\sources\libs\csharp\GPBinFiles.cs:line 95

   at NewSymFileRW.SymFileReader.Parse(BlkId scope) in NewSymFileRW.cp:line 1162

   at NewSymFileRW.ImpResScope.ReadThisImport(BlkId imp) in NewSymFileRW.cp:line
 2147
   at NewSymFileRW.NewSymFileRW.WalkImports(ScpSeq& imps, BlkId modI) in NewSymF
ileRW.cp:line 2182
   at CPascalP.CPascalP.ImportList(BlkId modScope) in CPascalP.cp:line 467
   at CPascalP.CPascalP.CPmodule() in CPascalP.cp:line 235
   at CPascalP.CPascalP.Module() in CPascalP.cp:line 3437
   at CPascalP.CPascalP.Parse() in CPascalP.cp:line 3457
   at CPascal.CPascal.Compile(Char[] nam, Int32& retVal) in CPascal.cp:line 138
   at gpcp.gpcp..CPmain(String[] A_0) in gpcp.cp:line 42

This is my environment variables:

set CROOT=%userprofile%\Downloads\gpcp-NET
set PATH=%PATH%;%CROOT%\bin
set CPSYM=.;%CROOT%\symfiles;%CROOT%\symfiles\NetSystem

More documents and examples?

I come from Java so I used to Java OOP. I can't wrap my mind around Oberon/CP's OOP way yet. I found there is no Math module like Oberon07 so we have to use the platform (JVM or CLR) specific functions to do it? I found the html Java binding API document for gpcp JVM but I don't know how to use it. I have no idea what is MathContext and how to use it. Please give me more examples. I just want to use the natural logarithm and square root functions from java math. Thanks.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.