Re: [fpc-pascal] Re: Use generic class as parameter (was: how to write enumerator for trees)

2013-03-22 Thread Xiangrong Fang
2013/3/22 Sven Barth 


> > The problem is gone, because PNode is not a generic class, but only a
> record.   However, the following errors are generated:
>
> 2.6.x does not support nested types in generics. Generic fixes and
> improvements are only found in 2.7.1 as most of them were to invasive to be
> merged back.
>
OK, then why this error happened:

demo2.lpr(76,13) Error: Incompatible types: got
"TRoller.TTreap$PPerson$Byte" expected "TRoller"

The problematic lines are:

=== demo2.lpr ===

var
  n: TRoller.PNode;
  r1, r2: TRoller;
begin
  r1 := TRoller.Create;
  with r1 do begin
... ...
 *   r2 := r1.Copy(@OrderByAge);*
... ...
  end;
end.

=== treap.pas ===

function TTreap.Copy(Comp: TComparator): TTreap;
var
  n: PNode;
begin
  if Comp = nil then Comp := FComparator;
  Result := TTreap.Create;
  Result.Comparator := Comp;
  for n in Self do Result.Insert(n^.Key, n^.Value);
end;

I don't see there are "nested types" and why there is a type named:
TRoller.TTreap$PPerson$Byte?
Shouldn't be either
TRoller or TTreap$PPerson$Byte but not both?

Thanks,
Xiangrong
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Amazon S3

2013-03-22 Thread Michael Schnell

On 03/21/2013 11:58 AM, Sven Barth wrote:
Ehm... you do know that "Amazon S3" <> "Samsung Galaxy S3"? Amazon S3 
is the cloud storage solution by Amazon. See also: 
http://en.wikipedia.org/wiki/Amazon_S3



If you see both, you can easily tell them apart :-) :-)

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


Re: [fpc-pascal] How To write an enumerator for trees

2013-03-22 Thread kyan
On Fri, Mar 22, 2013 at 12:39 AM, S. Fisher  wrote:
> --- On Thu, 3/21/13, kyan  wrote:
> Are you the man who created Kyan Pascal?  I used that many
> years ago.

I'd never heard of it till now.

I wish. I'm nowhere nearly that good. :)
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Re: Example: regular expressions and "hash-tables"

2013-03-22 Thread S. Fisher
--- On Thu, 3/21/13, Reinier Olislagers  wrote:

> From: Reinier Olislagers 
> Subject: [fpc-pascal] Re: Example: regular expressions and "hash-tables"
> To: "FPC Mailing list" 
> Date: Thursday, March 21, 2013, 5:35 AM
> On 21-3-2013 2:14, S. Fisher wrote:
> > Not actually a hash-table, but an AvgLvlTree, which can
> be used the
> > same way.  The AvgLvlTree unit comes with Lazarus;
> if you don't have
> > that, you can download avglvltree.pas here:
> > 
> > http://svn.freepascal.org/cgi-bin/viewvc.cgi/trunk/components/lazutils/avglvltree.pas?root=lazarus&view=log
> > 
> > There doesn't seem to be a lot of information available
> on using
> > regular expressions and hash-tables in Free Pascal, so
> I decided to
> > post this.
> 
> If I'm not mistaken, see:
> http://wiki.lazarus.freepascal.org/AVL_Tree
> 
> Thanks,
> Reinier

Yes, that was one of the very few good references that I found.

There doesn't seem to be much demand for hash-tables in the Free
Pascal community.  Hash-tables can be very helpful.  I don't
see a good way to do what my program does without using associative
arrays of some type.

Also, there doesn't seem to be much use of regular expressions.

Anyway, TStringToPointerTree works well and seems very fast
to me.

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


Re: [fpc-pascal] Example: regular expressions and "hash-tables"

2013-03-22 Thread S. Fisher
--- On Wed, 3/20/13, S. Fisher  wrote:

> The program reads a text file and counts the number of
> unique words,
> and also displays the number of times the most common word
> was found.
> 

Added an iterator of sorts for regular expressions.  This allows

if re.exec( line ) then  begin
  si_table_inc( table, re.match[0] );
  while re.execNext do
si_table_inc( table, re.match[0] );
end;

to be replaced by

re_each_match( re, line, @count_the_word );

with no loss of speed.


{$mode objfpc}

uses
  AvgLvlTree,
  regexpr,
  classes,
  dateutils,
  Sysutils;

const
  file_to_process = 'Bartlett--Quotations.txt';

type
  // string-integer table
  t_si_table = TStringToPointerTree;
  t_si_item = PStringToPointerItem;

procedure si_table_put( table: t_si_table; k: string; v: longint );
begin
  table[ k ] := pointer( v )
end;
function si_table_get( table : t_si_table; key : string ): longint;
begin
  result := longint( table[ key ] )
end;
procedure si_table_inc( table: t_si_table; k: string );
begin
  table[ k ] := pointer( si_table_get( table, k ) + 1 ) ;
end;
function si_table_key( item : t_si_item ): string;
begin
  result := item^.name
end;
function si_table_val( item : t_si_item ): longint;
begin
  result := longint( item^.value )
end;
function si_table_new( sensitive : boolean ): t_si_table;
begin
  result := t_si_table.create( sensitive )
end;


type
  t_regex_proc = procedure( const text : string );

procedure re_each_match( re : TRegExpr;
 const text: string;
 proc: t_regex_proc ); overload;
begin
  if re.exec( text ) then  begin
proc( re.match[0] );
while re.execNext do
  proc( re.match[0] );
  end;
end;
procedure re_each_match( const re_str, text: string;
 proc: t_regex_proc ); overload;
var
  re : TRegExpr;
begin
  re := TRegExpr.Create;
  re.Expression := re_str;
  re_each_match( re, text, proc );
  re.free
end;


var
  table : t_si_table ;
  table_item : t_si_item ;
  line, word : string;
  re : TRegExpr;
  max_count, count : int32;
  lines : TStringList;
  time_1 : TDateTime;

procedure count_the_word( const s : string );
begin
  si_table_inc( table, s )
end;

begin
  time_1 := time;

  re := TRegExpr.Create;
  re.Expression := '(?i)[a-z]+' ;  // case-insensitive

  table := si_table_new( true ) ; // true to make it case-sensitive.

  lines := TStringList.Create;
  lines.LoadFromFile( file_to_process );
  for line in lines do
re_each_match( re, line, @count_the_word );
  lines.free;

  writeln( 'Unique word count: ', table.count );
  max_count := 0;
  for table_item in table do  begin
count := si_table_val( table_item );
if count > max_count then  begin
  word := si_table_key( table_item );
  max_count := count
end;
  end;
  writeln( 'Commonest word: ', word, ' (', max_count, ')' );
  writeln( 'Elapsed time: ',
   milliSecondsBetween( time_1, time ),
   ' milliseconds.' );

  table.free;
  re.free
end.

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


Re: [fpc-pascal] Re: Use generic class as parameter (was: how to write enumerator for trees)

2013-03-22 Thread Sven Barth

Am 22.03.2013 08:13, schrieb Xiangrong Fang:
2013/3/22 Sven Barth >


> The problem is gone, because PNode is not a generic class, but only a
record.   However, the following errors are generated:

2.6.x does not support nested types in generics. Generic fixes and
improvements are only found in 2.7.1 as most of them were to
invasive to be merged back.

OK, then why this error happened:

demo2.lpr(76,13) Error: Incompatible types: got 
"TRoller.TTreap$PPerson$Byte" expected "TRoller"


AFAIR there was also a problem with result types in generics. Could you 
please test your code with 2.7.1 to be sure?


Regards,
Sven
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Re: Example: regular expressions and "hash-tables"

2013-03-22 Thread Mattias Gaertner
On Fri, 22 Mar 2013 01:19:17 -0700 (PDT)
"S. Fisher"  wrote:

> --- On Thu, 3/21/13, Reinier Olislagers  wrote:
> 
> > From: Reinier Olislagers 
> > Subject: [fpc-pascal] Re: Example: regular expressions and "hash-tables"
> > To: "FPC Mailing list" 
> > Date: Thursday, March 21, 2013, 5:35 AM
> > On 21-3-2013 2:14, S. Fisher wrote:
> > > Not actually a hash-table, but an AvgLvlTree, which can
> > be used the
> > > same way.  The AvgLvlTree unit comes with Lazarus;
> > if you don't have
> > > that, you can download avglvltree.pas here:
> > > 
> > > http://svn.freepascal.org/cgi-bin/viewvc.cgi/trunk/components/lazutils/avglvltree.pas?root=lazarus&view=log
> > > 
> > > There doesn't seem to be a lot of information available
> > on using
> > > regular expressions and hash-tables in Free Pascal, so
> > I decided to
> > > post this.
> > 
> > If I'm not mistaken, see:
> > http://wiki.lazarus.freepascal.org/AVL_Tree
> > 
> > Thanks,
> > Reinier
> 
> Yes, that was one of the very few good references that I found.

Thanks. It's a wiki

 
> There doesn't seem to be much demand for hash-tables in the Free
> Pascal community.  Hash-tables can be very helpful.  

There are some hash tables in units "contnrs", "dynhasharray" and
"stringhashlist".


> I don't
> see a good way to do what my program does without using associative
> arrays of some type.

Me too.


> Also, there doesn't seem to be much use of regular expressions.

Well, I guess Pascal programmers prefer readability over shortness.

 
> Anyway, TStringToPointerTree works well and seems very fast
> to me.

Me too.

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


Re: [fpc-pascal] Re: Use generic class as parameter (was: how to write enumerator for trees)

2013-03-22 Thread Xiangrong Fang
I didn't see a DEB package for 2.7.1. I am currently using 2.6.0. Can I
compile 2.7.1 from source with 2.6.0?

2013/3/22 Sven Barth 

>  Am 22.03.2013 08:13, schrieb Xiangrong Fang:
>
> 2013/3/22 Sven Barth 
>
>
>> > The problem is gone, because PNode is not a generic class, but only a
>> record.   However, the following errors are generated:
>>
>> 2.6.x does not support nested types in generics. Generic fixes and
>> improvements are only found in 2.7.1 as most of them were to invasive to be
>> merged back.
>>
> OK, then why this error happened:
>
> demo2.lpr(76,13) Error: Incompatible types: got
> "TRoller.TTreap$PPerson$Byte" expected "TRoller"
>
>
> AFAIR there was also a problem with result types in generics. Could you
> please test your code with 2.7.1 to be sure?
>
> Regards,
> Sven
>
> ___
> fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
>
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Re: Use generic class as parameter (was: how to write enumerator for trees)

2013-03-22 Thread Sven Barth

Am 22.03.2013 10:14, schrieb Xiangrong Fang:
I didn't see a DEB package for 2.7.1. I am currently using 2.6.0. Can 
I compile 2.7.1 from source with 2.6.0?



Yes. In fact you MUST compile with 2.6.0 (or 2.6.2).

Go to the directory of your 2.7.1 source and execute "make all". If your 
test code does only depend on the RTL units then you can compile your 
example without an installation from within the top level directory 
using this command:


=== command begin ===

./compiler/ppc386 -n -Furtl/units/i386-linux -viwn -FEsomeoutputdir 
yourunit.pas


=== comand end ===

If you compiled a 64-bit version you need to use this instead:

=== command begin ===

./compiler/ppcx64 -n -Furtl/units/x86_64-linux -viwn -FEsomeoutputdir 
yourunit.pas


=== command end ===

Regards,
Sven
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


[fpc-pascal] Object Pascal Grammar in EBNF like style

2013-03-22 Thread Graeme Geldenhuys
Hi,

I'm putting together a EBNF like syntax [not strictly EBNF] for the
Object Pascal grammar, as implemented by Free Pascal, using the {$mode
objfpc} compiler mode.

I'm basing the work on FPC 2.6.2 (latest released compiler). The Object
Pascal grammar starts at line 5374.

https://github.com/graemeg/fpGUI/blob/master/docs/fpc_lang_ref.ipf

Any input or corrections will be much appreciated.

Known omissions I must still add:

 * Generics
 * Type Helpers


Is there a wiki pages which lists all new language features and syntax
for FPC 2.6.2?


Regards,
  - Graeme -

-- 
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://fpgui.sourceforge.net/

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


Re: [fpc-pascal] Object Pascal Grammar in EBNF like style

2013-03-22 Thread Sven Barth

Am 21.03.2013 19:42, schrieb Graeme Geldenhuys:

Hi,

I'm putting together a EBNF like syntax [not strictly EBNF] for the
Object Pascal grammar, as implemented by Free Pascal, using the {$mode
objfpc} compiler mode.

I'm basing the work on FPC 2.6.2 (latest released compiler). The Object
Pascal grammar starts at line 5374.

https://github.com/graemeg/fpGUI/blob/master/docs/fpc_lang_ref.ipf

Any input or corrections will be much appreciated.

Known omissions I must still add:

  * Generics
  * Type Helpers
If you base the work on 2.6.2 then type helpers don't apply (only record 
and class helpers). Regarding generic syntax not much has changed in 
mode objfpc since 2.6 was branched (only Delphi mode was improved and 
some bugs were squashed).



Is there a wiki pages which lists all new language features and syntax
for FPC 2.6.2?

There didn't happen much: http://wiki.freepascal.org/FPC_New_Features_2.6.2

Regards,
Sven
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Object Pascal Grammar in EBNF like style

2013-03-22 Thread Michael Van Canneyt



On Thu, 21 Mar 2013, Graeme Geldenhuys wrote:


Hi,

I'm putting together a EBNF like syntax [not strictly EBNF] for the
Object Pascal grammar, as implemented by Free Pascal, using the {$mode
objfpc} compiler mode.

I'm basing the work on FPC 2.6.2 (latest released compiler). The Object
Pascal grammar starts at line 5374.

https://github.com/graemeg/fpGUI/blob/master/docs/fpc_lang_ref.ipf

Any input or corrections will be much appreciated.


Hm.

That looks dangerously much, almost verbatim, like the appendix A of the 
Delphi language guide as found in the D7 manual.


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


Re: [fpc-pascal] Object Pascal Grammar in EBNF like style

2013-03-22 Thread Graeme Geldenhuys
On 2013-03-22 12:22, Sven Barth wrote:
>>   * Type Helpers
> If you base the work on 2.6.2 then type helpers don't apply (only record 
> and class helpers).

Good to know, thanks.


> Regarding generic syntax not much has changed in 
> mode objfpc since 2.6 was branched (only Delphi mode was improved and 
> some bugs were squashed).

OK. The original EBNF grammar was based on Delphi 7 & Kylix 3 language
features. I have since modified it to whatever language syntax has
changed and features added for the last few FPC releases. So I'm not
strictly comparing only changes between 2.6.0 and 2.6.2. I am looking at
earlier FPC versions too.


> There didn't happen much: http://wiki.freepascal.org/FPC_New_Features_2.6.2

Thanks for that. I also found the page for 2.6.0, so that will help me a
lot.


Regards,
  - Graeme -

-- 
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://fpgui.sourceforge.net/

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


Re: [fpc-pascal] Object Pascal Grammar in EBNF like style

2013-03-22 Thread Graeme Geldenhuys
On 2013-03-22 13:29, Michael Van Canneyt wrote:
> 
> That looks dangerously much, almost verbatim, like the appendix A of the 
> Delphi language guide as found in the D7 manual.

Umm, I don't have the Delphi manuals, but I do have the Kylix 3 manuals.
I see what you mean. I didn't copy it from the Kylix 3 manual though, I
got it from the following URL:

   http://delphi.wikia.com/wiki/Object_Pascal_Grammar

Would it make a difference though? EBNF for a language grammar should be
pretty much identical to any other EBNF of the same language. The order
of the definitions might change slightly, but the language grammar would
still be the same.


Regards,
  - Graeme -

-- 
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://fpgui.sourceforge.net/

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


Re: [fpc-pascal] Re: Use generic class as parameter (was: how to write enumerator for trees)

2013-03-22 Thread Xiangrong Fang
Hi Sven,

My unite uses contnrs unit, how can I instruct the compiler to use the
contnrs unit (also the Classes and sysutils units) of v2.7.1?  I have
already built 2.7.1 and now try to compile my program in the fpc source dir
as you told.

Thanks

2013/3/22 Xiangrong Fang 

> I didn't see a DEB package for 2.7.1. I am currently using 2.6.0. Can I
> compile 2.7.1 from source with 2.6.0?
>
> 2013/3/22 Sven Barth 
>
>>  Am 22.03.2013 08:13, schrieb Xiangrong Fang:
>>
>> 2013/3/22 Sven Barth 
>>
>>
>>> > The problem is gone, because PNode is not a generic class, but only a
>>> record.   However, the following errors are generated:
>>>
>>> 2.6.x does not support nested types in generics. Generic fixes and
>>> improvements are only found in 2.7.1 as most of them were to invasive to be
>>> merged back.
>>>
>> OK, then why this error happened:
>>
>> demo2.lpr(76,13) Error: Incompatible types: got
>> "TRoller.TTreap$PPerson$Byte" expected "TRoller"
>>
>>
>> AFAIR there was also a problem with result types in generics. Could you
>> please test your code with 2.7.1 to be sure?
>>
>> Regards,
>> Sven
>>
>> ___
>> fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
>> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
>>
>
>
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

[fpc-pascal] Re: Example: regular expressions and "hash-tables"

2013-03-22 Thread S. Fisher
--- On Fri, 3/22/13, Mattias Gaertner  wrote:

> From: Mattias Gaertner 
> Subject: Re: [fpc-pascal] Re: Example: regular expressions and "hash-tables"
> To: fpc-pascal@lists.freepascal.org
> Date: Friday, March 22, 2013, 4:11 AM
> On Fri, 22 Mar 2013 01:19:17 -0700
> (PDT)
> "S. Fisher" 
> wrote:
> 
> > --- On Thu, 3/21/13, Reinier Olislagers 
> wrote:
> > 
> > > From: Reinier Olislagers 
> > > Subject: [fpc-pascal] Re: Example: regular
> expressions and "hash-tables"
> > > To: "FPC Mailing list" 
> > > Date: Thursday, March 21, 2013, 5:35 AM
> > > On 21-3-2013 2:14, S. Fisher wrote:
> > > > Not actually a hash-table, but an AvgLvlTree,
> which can
> > > be used the
> > > > same way.  The AvgLvlTree unit comes with
> Lazarus;
> > > if you don't have
> > > > that, you can download avglvltree.pas here:
> > > > 
> > > > http://svn.freepascal.org/cgi-bin/viewvc.cgi/trunk/components/lazutils/avglvltree.pas?root=lazarus&view=log
> > > > 
> > > > There doesn't seem to be a lot of information
> available
> > > on using
> > > > regular expressions and hash-tables in Free
> Pascal, so
> > > I decided to
> > > > post this.
> > > 
> > > If I'm not mistaken, see:
> > > http://wiki.lazarus.freepascal.org/AVL_Tree
> > > 
> > > Thanks,
> > > Reinier
> > 
> > Yes, that was one of the very few good references that
> I found.
> 
> Thanks. It's a wiki
> 
>  
> > There doesn't seem to be much demand for hash-tables in
> the Free
> > Pascal community.  Hash-tables can be very
> helpful.  
> 
> There are some hash tables in units "contnrs",
> "dynhasharray" and
> "stringhashlist".


http://www.freepascal.org/docs-html/fcl/contnrs/index-4.html

I can't seem to find "dyn" on this page.

TFPStringHashTable won't work for my program because it maps strings
to strings, not to pointers or numbers.  (I wonder if it has an
enumerator.)

I already experimented with TFPDataHashTable.  It won't work for
this program, because, incredibly, there is no way to iterate over
the entries!  The people who write these classes need to have a
wider experience with using hash-tables.  (Become fluent in the tiny
language Awk, for example.)

That's why it seemed that I had to download a file from Lazarus
and compile it in order to have a good associative array that
maps strings to numbers (or pointers).

So, thanks a lot for creating avglvltree. It does the job perfectly.

> 
> 
> > I don't
> > see a good way to do what my program does without using
> associative
> > arrays of some type.
> 
> Me too.
> 
> 
> > Also, there doesn't seem to be much use of regular
> expressions.
> 
> Well, I guess Pascal programmers prefer readability over
> shortness.
> 

I think we can agree 100% that 70-character-long regular
expressions are nightmarish and should definitely be avoided if at
all possible!  Trying to decipher one of those could almost drive
you crazy.

Regular expressions are an absolute necessity for some applications.
The program "grep", for example.  The user can't be expected or
allowed to write a routine in C or Pascal that selects certain
lines, but he can be allowed to supply a regular expression that
does that. The same is true for text editors.  Any halfway decent
editor will let you find a line that contains "foo" followed at some
distance by "bar" by searching for "foo.*bar".  (Even Microsoft Word
lets you do a r.e. search, although they dishonestly call it
something else.)

I know that you're saying that a regexpr engine can't do what a
full-blown parser can.  Very true.  But for some tasks they work
very well.

Let's say we want to find some dates in a string.  The dates will
be like either of these patterns:

  -mm-dd
  /mm/dd

In the r.e., \d represents a digit, and [...] is a character class
or set.  So the r.e. could be

  \d\d\d\d[-/]\d\d[-/]\d\d

Testing that on this string

 '92011-05-22 1999/12/22--2012-02-28; 2000/09/033 2011-07-05::1988/04/06'

we get

2011-05-22
1999/12/22
2012-02-28
2000/09/03
2011-07-05
1988/04/06

Now let's say that we don't want to include the dates that have an
extra digit before the year or after the day.  A non-digit character
is represented by \D, and the beginning of the string is matched
by ^.  Alternation or "or" is indicated by |.  So we prefix this to
the r.e.:

  (^|\D)

It says that the date must be at the very beginning of the string or
it must be preceded by a non-digit.  A $ will match only at the end of
the string, so we append this to the r.e.:

  (\D|$)

It says that the date must be followed by a non-digit or must be at
the very end of the string.  At this point the r.e. looks like this:

  (^|\D)\d\d\d\d[-/]\d\d[-/]\d\d(\D|$)

And the ouput is this:

 1999/12/22-
-2012-02-28;
 2011-07-05:
:1988/04/06

The delimiting characters are now included in the match.  To solve
this, we take advantage of the fact that parentheses in the r.e.
not only create a group, but also make a "capture" of what they
enclose.  So we put them around the part of the pattern that we
want to keep, yielding this

[fpc-pascal] HMAC_SHA1 and FPC

2013-03-22 Thread silvioprog
Hello,

How to get HMAC_SHA1 using native functions of FPC?

HMAC_SHA1:
http://en.wikipedia.org/wiki/Hash-based_message_authentication_code#Examples_of_HMAC_.28MD5.2C_SHA1.2C_SHA256.29

Thank you!

-- 
Silvio Clécio
My public projects - github.com/silvioprog
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Re: Example: regular expressions and "hash-tables"

2013-03-22 Thread Reinier Olislagers
On 23-3-2013 4:25, S. Fisher wrote:
> --- On Fri, 3/22/13, Mattias Gaertner  wrote:
>> From: Mattias Gaertner 
>> Subject: Re: [fpc-pascal] Re: Example: regular expressions and "hash-tables"
>> To: fpc-pascal@lists.freepascal.org
>> Date: Friday, March 22, 2013, 4:11 AM
>> On Fri, 22 Mar 2013 01:19:17 -0700
>> (PDT)
>> "S. Fisher" 
>> wrote:
>>
>>> --- On Thu, 3/21/13, Reinier Olislagers 
>> wrote:
>>>
 From: Reinier Olislagers 
 Subject: [fpc-pascal] Re: Example: regular
>> expressions and "hash-tables"
 To: "FPC Mailing list" 
 Date: Thursday, March 21, 2013, 5:35 AM
 On 21-3-2013 2:14, S. Fisher wrote:
> Not actually a hash-table, but an AvgLvlTree,
>> which can
 be used the
> same way.  The AvgLvlTree unit comes with
>> Lazarus;
 if you don't have
> that, you can download avglvltree.pas here:
>
> http://svn.freepascal.org/cgi-bin/viewvc.cgi/trunk/components/lazutils/avglvltree.pas?root=lazarus&view=log
>
> There doesn't seem to be a lot of information
>> available
 on using
> regular expressions and hash-tables in Free
>> Pascal, so
 I decided to
> post this.

 If I'm not mistaken, see:
 http://wiki.lazarus.freepascal.org/AVL_Tree

 Thanks,
 Reinier
>>>
>>> Yes, that was one of the very few good references that
>> I found.
>>
>> Thanks. It's a wiki

Which means you're encouraged to place your contributions, code snippets
etc there.
It's of course personal taste, but IMO, code snippets/examples are much
better placed there than in a mailing list as they can be more easily
updated, formatted and categorized.

The lengthy article + example you posted on regexes is e.g. a perfect
candidate IMO
http://wiki.lazarus.freepascal.org/Regexpr

Just my 2 cents,

thanks,
Reinier
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal