Re: [fpc-pascal] lldb problems with Xcode 8.2.1

2017-02-24 Thread Jonas Maebe

On 24/02/17 08:40, Jonas Maebe wrote:



On 23 Feb 2017, at 19:10, Jeremy Thompson  wrote:

I am experiencing some LLDB problems in macOS Sierra 10.12.3 with Xcode 8.2.1.  
Its running the LLVM compiler with FPC 2.6.4.  I can no longer get breakpoints 
to function, they get skipped over.


Short answer: update to FPC 3.0.2 and use its -godwarfcpp option.

The long answer will have to wait till tonight.


The long answer is that since some people have started working on (very 
preliminary) Pascal support in lldb, at some point they disabled pretty 
much all C/C++ functionality for non-C/C++ languages in lldb. With as a 
result that almost nothing works anymore if the debug information 
specifies that the source language is Pascal, and simply changing it to 
claim that the program was compiled from C or C++ (which is more or less 
what -godwarfcpp does) restores the debugger functionality.



Jonas

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] FreePascal Windows - Force files to write to disk

2017-02-24 Thread James Richters
Thanks for the advice everyone.   It is very much appreciated.   I have been
working on a combination of ideas here.  Currently I am doing an MD5sum of a
string created from all my variables concatenated together and writing that
as the second to the last line of the file, I also am writing some fixed
text at the beginning and end of the file as suggested so I can check for
variables being overwritten in memory, great idea!   I am then reading the
file back to verify it has written properly, making a backup, checking that,
and also using ioresults as below. I will probably rename the file as well,
and exclude it from virus checkers.  When I read the file I can verify the
MD5sum and if that test fails, I'll just automatically try the backup, If
that also fails the MD5sum I'll notify the user.  

Thanks again for all the help

James
-Original Message-
From: fpc-pascal-boun...@lists.freepascal.org
[mailto:fpc-pascal-boun...@lists.freepascal.org] On Behalf Of Klaus Hartnegg
Sent: Thursday, February 23, 2017 6:33 AM
To: fpc-pascal@lists.freepascal.org
Subject: Re: [fpc-pascal] FreePascal Windows - Force files to write to disk

Am 21.02.2017 um 22:12 schrieb James Richters:
>  Assign(BitFile,'BitSave.pax');
{$I-}
>  ReWrite(BitFile);
if ioresult <> 0 then
   writeln ('error opening pax file');
>  WriteLn(BitFile,XADJ:1:8);
>  WriteLn(BitFile,YADJ:1:8);
>  WriteLn(BitFile,ZADJ:1:8);
>  WriteLn(BitFile,WADJ:1:8);
>  WriteLn(BitFile,AADJ:1:8);
>  WriteLn(BitFile,TADJ:1:8);
>  WriteLn(BitFile,VADJ:1:8);
>  WriteLn(BitFile,UADJ:1:8);
>  WriteLn(BitFile,CurrentTool);
>  WriteLn(Bitfile,P_Value[4]);
writeln (bitfile, 'EOF');
if ioresult <> 0 then
   writeln ('error writing pax file');
>  Close(BitFile);
if ioresult <> 0 then
   writeln ('error closing pax file');
{$I+}

This writes something at the end of the file that does not come from a
variable. Next time the error happens, you can check if that is present. 
Then your variables were overwritten in memory. Also it checks for errors.
And I would disable antivirus or at least tell it to not scan this file.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


[fpc-pascal] parser combinator library

2017-02-24 Thread Bernd
Hello,

Eight years ago someone asked whether there is a parser combinator library
for free pascal, nothing like that existed at that time and also does not
seem to exist up to the present day.

While I was reading about parser combinators in functional programming
languages (during my 42nd attempt to learn Haskell) I thought to myself why
not try to implement something like that in Object Pascal, just so see how
far we can push the boundaries of this imperative object oriented language.

This is what I have come up with so far:
https://github.com/prof7bit/fpc_parser_combinators

Since we don't have lambdas I choose the next closest approach to emulate
them with object instances instead. This leads to a lot of boiler plate in
the definition of the elementary parsers and combinators but fortunately it
can all be hidden away in the library and the usage of the combinators
looks quite neat:

 // define the grammar
  EXPR  := Num or _PARENS;
  MULFUNC   := Sym('mul') and EXPR and EXPR;
  ADDFUNC   := Sym('add') and EXPR and EXPR;
  INNER := MULFUNC or ADDFUNC or Num;
  PARENS:= Sym('(') and INNER and Sym(')');

Please also note the unorthodox usage of and/or operators to invoke the
combinators :-)

Please post improvements or variations of this theme, especially I am
interested in how to properly build up a syntax tree in the most generic
and reusable manner, this is something I have not yet completely understood
(because I am myself still quite unfamiliar with this whole parsing
business) currently all my parsers only return arrays of strings that I can
optionally post-process with an optional hook function after a parser has
completed.

Bernd
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal