Hi Adriaan,
I've try many times to port GPC to MAC OS X / Darwin without the succes I wished, before I fall in Ada language, more strict but more functionnal.
Nevertheless I've modified 'gpcpp.c' the preprocessor source code in order to accept Mac Pascal directives.
If you or any one want it let me know I will put it on my web site.
Best , Pascal Pignard. http://perso.wanadoo.fr/blady Best
Frank Heckenbach wrote:
I.e., we might choose to implement them for compatibility's sake. Then again, how far is GPC compatible to CW in other respects? Is it reasonable to claim (or strive for) compatibility at all?
Well, I don't mind writing different code, where compilers and platforms are different. I am striving for the possibility to do so within one conditionalized source code. One might call this the lowest level of compatibility, the possibilty to write a conditional compiler expression IFxx ELSExx ENDxx in a way that both compilers understand.
In CodeWarrior Pascal, you have the choice between "Apple style" and "BP style" conditional expressions (the latter not strictly BP, but enhanced with Apple-like features) You can use either, but you can't mix them in the same project, e.g.
{$ifc condition} ... {$elsec} ... {$endc}
or either
{$if condition} ... {$else} ... {$endif}
in all sources.
Most Macintosh programmers traditionally will use "Apple style" conditional expressions, since they are used in Apple's Pascal Interfaces to MacOS. I, for one, am lucky to maintain my own Pascal Interfaces to MacOS, so for me the choice is free. Also, I am free to make any changes to those Interfaces, needed for GPC.
To put it in a nutshell, I will be very grateful if GPC supports
{$if condition} ... {$else} ... {$endif}
and it would be nice if
{$ifc condition} ... {$elsec} ... {$endc}
is supported also. The other items from the CodeWarrior Reference are non-essential.
Best regards,
Adriaan van Os
Pascal wrote:
Hi Adriaan,
I've try many times to port GPC to MAC OS X / Darwin without the succes I wished, before I fall in Ada language, more strict but more functionnal.
Nevertheless I've modified 'gpcpp.c' the preprocessor source code in order to accept Mac Pascal directives.
If you or any one want it let me know I will put it on my web site.
Best , Pascal Pignard. http://perso.wanadoo.fr/blady
Best
Being an optimist, I am currently trying to build GPC for Darwin (Mac OS X) myself. I welcome the gpcpp.c changes.
Frank Heckenbach wrote:
I.e., we might choose to implement them for compatibility's sake. Then again, how far is GPC compatible to CW in other respects? Is it reasonable to claim (or strive for) compatibility at all?
I will be pleased to discuss CodeWarrior Pascal, it's EBNF is at the bottom of this message. My goals however, are rather pragmatic (unless somebody else has more ambitious plans).
(1) Try to build GPC on Darwin (Mac OS X) (2) Try to build the Hello program (3) Try to build a sample GUI program (for Mac OS X "Carbon") (4) Try to integrate GPC with Apple's "Project Builder" (4) Try to port a large (300.000 lines) program to GPC (5) Write a compatibilty-report for porting from CodeWarrior Pascal to GPC (6) Same for maintaining a common (conditionalized) source code for CodeWarrior Pascal and GPC (7) Filter out a handful of compiler features that would really assist GPC development on Mac OS X (and porting from CodeWarrior). On this list wil be UNIV parameters, I guess, but this is premature. (8) Either talk to Nick Kledzik (who maintains Apple's Pascal Interfaces) or maintain our own GPC Interfaces for Mac OS X (9) Setup a GPC compatibility website for Mac OS X
I am willing to spend time on this all, except for working in C on the compiler itself. Any help is welcome.
Best regards,
Adriaan van Os
-------------------------------
CodeWarrior Pascal built on a long tradition of Macintosh Pascal compilers: TML Pascal, Think Pascal, MetroWerks Pascal and MPW Pascal. The base for the language is Apple's implementation of UCSD Pascal for the Apple II, way back in 1980. It has many extensions, some of them typical for Macintosh development, e.g. UNIV parameters and facilities to interface with Mac OS system software. Other extensions come from Borland/Turbo Pascal, e.g. CONST parameters and "typed constants". Finally, there are the typical Windows extensions (for the cross compiler) line CDECL, STDCALL, etc.
# Code Warrior Pascal syntax # From the CodeWarrior Pro 1 manual (with some modifications)
1 ActualParameter = Expression | VariableAccess | ProcedureIdentifier | FunctionIdentifier. 2 ActualParameterList = "(" [ ActualParameter { "," ActualParameter } ] ")". 3 ArrayType = "ARRAY" "[" IndexType { "," IndexType } "]" "OF" Type. 4 AssignmentStatement = ( VariableAccess | FunctionIdentifier ) ":=" Expression. 5 AtomicExpression = VariableAccess | UnsignedConstant | FunctionCall. 6 BaseType = TypeIdentifier. 7 Block = { LabeDeclarationPart | ConstantDeclarationPart | TypeDeclarationPart | VariableDeclarationPart | ProcedureFunctionDeclarationPart } StatementPart. 8 Case = ConstantRange { "," ConstantRange } ":" Statement. 9 CaseStatement = "CASE" Expression "OF" Case { ";" Case } [ OtherwiseClause ] [ ";" ] "END". 10 CompoundStatement = "BEGIN" Statement { ";" Statement } "END". 11 Constant = ConstantExpression. 12 ConstantAtomicExpression = UnsignedConstant | FunctionCall. 13 ConstantDeclaration = ConstantIdentifier ( ( "=" Constant ) | ( ":" Type "=" ( Constant | VariableInitialization ) ) ) ";". 14 ConstantDeclarationPart = "CONST" ConstantDeclaration { ConstantDeclaration }. 15 ConstantExpression = SimpleConstantExpression [ ( "=" | "<" | ">" | "<=" | ">=" | "<>" | "IN" ) SimpleConstantExpression ]. 16 ConstantFactor = ConstantAtomicExpression | SetConstructor | "(" ConstantExpression ")" | "NOT" ConstantFactor. 17 ConstantIdentifier = Identifier. 18 ConstantRange = ConstantExpression [ ".." ConstantExpression ]. 19 ConstantTerm = ConstantFactor { ( "*" | "/" | "DIV" | "MOD" | "AND" | "&" | "**" ) ConstantFactor }. 20 ControlVariable = VariableIdentifier. 21 CycleStatement = "CYCLE". 22 Digit = "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9". 23 DigitSequence = Digit { Digit }. 24 EnumeratedType = "(" IdentifierList ")". 25 Expression = SimpleExpression [ ( "=" | "<" | ">" | "<=" | ">=" | "<>" | "IN" ) SimpleExpression ]. 26 Factor = ( [ "@" ] VariableAccess ) | AtomicExpression | SetConstructor | "(" Expression ")" | ( "NOT" Factor ). 27 FieldDeclaration = IdentifierList ":" Type. 28 FieldDesignator = "." Identifier. 29 FieldList = ( VariantPart | ( FixedPart [ ";" VariantPart ] ) ) [ ";" ]. 30 FileBufferSymbol = "^". 31 FileType = "TEXT" | ( "FILE" [ "OF" Type ]). 32 FinalValue = Expression. 33 FixedPart = FieldDeclaration { ";" FieldDeclaration }. 34 ForStatement = "FOR" ControlVariable ":=" InitialValue ( "TO" | "DOWNTO" ) FinalValue [ "BY" StepValue ] "DO" Statement. 35 FormalParameterList = "(" ( ParameterDeclaration | ProcedureHeading | FunctionHeading ) { ";" ( ParameterDeclaration | ProcedureHeading | FunctionHeading ) } ")". 36 FunctionBody = ( [ "ASM" ";" ] Block ) | ( "FORWARD" ) | ( [ "C" ";" ] "EXTERNAL" ) | ( "INLINE" ConstantExpression { "," ConstantExpression } ). 37 FunctionCall = FunctionIdentifier [ ActualParameterList ]. 38 FunctionDeclaration = FunctionHeading ";" FunctionBody ";". 39 FunctionHeading = "FUNCTION" [ ObjectTypeIdentifier "."] Identifier [ FormalParameterList ] ":" TypeIdentifier. 40 FunctionIdentifier = Identifier. 41 FunctionType = "FUNCTION" FormalParameterList ":" TypeIdentifier. 42 GotoStatement = "GOTO" Label. 43 HexDigit = "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" | "A" | "B" | "C" | "D" | "E" | "F". 44 HexDigitSequence = HexDigit { HexDigit }. 45 Identifier = ( Letter | Underscore ) { Letter | Underscore | Digit }. 46 IdentifierList = Identifier { "," Identifier }. 47 IfStatement = "IF" Expression "THEN" Statement [ "ELSE" Statement ]. 48 ImplementationPart = "IMPLEMENTATION" [ [ UsesClause ] { ConstantDeclarationPart | TypeDeclarationPart | VariableDeclarationPart | ProcedureFunctionDeclarationPart } ]. 49 Index = "[" Expression { "," Expression } "]". 50 IndexType = OrdinalTypeIdentifier. 51 InitialValue = Expression. 52 InterfacePart = "INTERFACE" [ [ UsesClause ] { ConstantDeclarationPart | TypeDeclarationPart | VariableDeclarationPart | ProcedureFunctionDeclarationPart } ]. 53 Label = Identifier. 54 LabeDeclarationPart = "LABEL" Label { "," Label } ";". 55 LeaveStatement = "LEAVE". 56 MemberGroup = Expression [ ".." Expression ]. 57 MethodDeclaration = FunctionDeclaration | ProcedureDeclaration. 58 MethodHeading = FunctionHeading | ProcedureHeading. 59 MethodList = MethodHeading [ ";" "OVERRIDE" ] { ";" MethodHeading [ ";" "OVERRIDE" ] } [ ";" ]. 60 NullStatement = ";". 61 ObjectType = "OBJECT" [ "(" ObjectTypeIdentifier ")" ] [ FieldList ] [ MethodList ] "END". 62 ObjectTypeIdentifier = Identifier. 63 OrdinalTypeIdentifier = Identifier. 64 OtherwiseClause = ";" ( "OTHERWISE" | "ELSE" ) Statement. 65 ParameterDeclaration = [ "VAR" | "CONST" ] IdentifierList ":" [ "UNIV" ] TypeIdentifier. 66 PointerSymbol = "^". 67 PointerType = ( PointerSymbol BaseType ) | PointerTypeIdentifier. 68 PointerTypeIdentifier = Identifier. 69 ProcedureFunctionDeclarationPart = { ProcedureDeclaration | FunctionDeclaration | MethodDeclaration }. 70 ProcedureBody = ( ["ASM" ";" ] Block ) | ( "FORWARD" ) | ( [ "C" ";" ] "EXTERNAL" ) | ( "INLINE" ConstantExpression { "," ConstantExpression } ). 71 ProcedureDeclaration = ProcedureHeading ";" ProcedureBody ";". 72 ProcedureHeading = "PROCEDURE" [ ObjectTypeIdentifier "." ] Identifier [ FormalParameterList ]. 73 ProcedureIdentifier = Identifier. 74 ProcedureStatement = ProcedureIdentifier [ ActualParameterList ]. 75 ProcedureType = "PROCEDURE" FormalParameterList. 76 Program = ProgramHeading ";" [ UsesClause ";" ] Block ".". 77 ProgramHeading = "PROGRAM" Identifier [ ( ProgramParameters ) ]. 78 ProgramParameters = IdentifierList. 79 Qualifier = Index | Field Designator | FileBufferSymbol | PointerSymbol. 80 QualifierIdentification = Identifier { "." Identifier }. 81 QuotedCharacterConstant = "'" StringCharacter "'". 82 QuotedStringConstant = "'" { StringCharacter } "'". 83 RealType = RealTypeIdentifier. 84 RealTypeIdentifier = Identifier. 85 RealTypeNumbers = [ Sign ]( "INF" | ( "NaN" [ "(" DigitSequence ")" ] ) | ( DigitSequence [ "." [ DigitSequence ] ] [ "E" [ Sign ] DigitSequence ] ) ). 86 RecordType = "RECORD" [ FieldList ] "END". 87 RepeatStatement = "REPEAT" Statement { ";" Statement } "UNTIL" Expression. 88 ScalarType = SubrangeType | EnumeratedType | OrdinalTypeIdentifier. 89 SetConstructor = "[" [ MemberGroup { "," MemberGroup } ] "]". 90 SetType = "SET" "OF" ScalarType. 91 Sign = "+" | "-". 92 SimpleConstantExpression = [ Sign ] ConstantTerm { ( "+" | "-" | "OR" | "|" ) ConstantTerm }. 93 SimpleExpression = [ Sign ] Term { ( "+" | "-" | "OR" | "|" ) Term }. 94 SimpleType = ScalarType | RealType | StringType. 95 SizeAttribute = ConstantExpression. 96 Statement = AssignmentStatement | CompoundStatement | ProcedureStatement | ForStatement | WhileStatement | RepeatStatement | IfStatement | CaseStatement | GotoStatement | CycleStatement | LeaveStatement | WithStatement | NullStatement. 97 StatementPart = CompoundStatement. 98 StringCharacter = PascalCharacter. 99 StringType = ( "STRING" [ "[" SizeAttribute "]" ] ) | ( StringTypeIdentifier ). 100 StringTypeIdentifier = Identifier. 101 StructuredType = ( [ "PACKED" ] ( ArrayType | SetType | FileType | RecordType ) ) | StructuredTypeIdentifier | ObjectTypeIdentifier. 102 StructuredTypeIdentifier = Identifier. 103 SubrangeType = ConstantExpression ".." ConstantExpression. 104 TagFieldType = OrdinalTypeIdentifier. 105 Term = Factor { ( "*" | "/" | "DIV" | "MOD" | "AND" | "&" | "**" ) Factor }. 106 Type = SimpleType | StructuredType | PointerType | ObjectType | ProcedureType | FunctionType. 107 TypeDeclaration = TypeIdentifier "=" Type ";". 108 TypeDeclarationPart = "TYPE" TypeDeclaration { TypeDeclaration }. 109 TypeIdentifier = Identifier. 110 Underscore = "_". 111 Unit = UnitHeading ";" InterfacePart [ ImplementationPart ] ( CompoundStatement | "END" ) ".". 112 UnitHeading = "UNIT" Identifier. 113 UnsignedConstant = UnsignedNumber | QuotedStringConstant | ConstantIdentifier | "NIL". 114 UnsignedNumber = DigitSequence | ( "$" HexDigitSequence ). 115 UsesClause = "USES" IdentifierList. 116 VariableAccess = ( VariableIdentifier | FunctionCall ) { Qualifier }. 117 VariableDeclaration = IdentifierList ":" Type ";" [ ( "EXTERNAL" | "FAR" ) ";" ]. 118 VariableDeclarationPart = "VAR" VariableDeclaration { VariableDeclaration }. 119 VariableIdentifier = Identifier. 120 VariableInitialization = "(" ( VariableInitialization | Constant ) [ "," VariableInitialization ] ")". 121 Variant = Constant { "," Constant } ":" "(" [ FieldList ] ")". 122 VariantPart = "CASE" [ Identifier ":" ] TagFieldType "OF" Variant { ";" Variant }. 123 WhileStatement = "WHILE" Expression "DO" Statement. 124 WithStatement = "WITH" ( RecordVariableAccess | ObjectReferenceVariableAccess ) { "," ( RecordVariableAccess | ObjectReferenceVariableAccess ) } "DO" Statement.
Adriaan van Os wrote:
I will be pleased to discuss CodeWarrior Pascal, it's EBNF is at the bottom of this message.
As I don't have the time to work through the grammar now, I'll wait for you (or others) to tell me about the features missing (compared to what GPC has, not compared to the standard only).
(7) Filter out a handful of compiler features that would really assist GPC development on Mac OS X (and porting from CodeWarrior). On this list wil be UNIV parameters, I guess, but this is premature.
No idea what they are ...
CodeWarrior Pascal built on a long tradition of Macintosh Pascal compilers: TML Pascal, Think Pascal, MetroWerks Pascal and MPW Pascal. The base for the language is Apple's implementation of UCSD Pascal for the Apple II, way back in 1980. It has many extensions, some of them typical for Macintosh development, e.g. UNIV parameters and facilities to interface with Mac OS system software. Other extensions come from Borland/Turbo Pascal, e.g. CONST parameters and "typed constants".
And GPC has them as well.
Frank