Regular Expressions in Oberon 
Author Message
 Regular Expressions in Oberon

I noticed some time ago that there was a regular expression tool in
Oberon System 3, but until now I wasn't able to get it to work.  In
fact I used to CRASH my Oberon session!  But I've found the problem
and fixed it.  The application is RX.Arc.  There are two constants in
the file RX.Mod called nofline and nofrepl that at the default values
crash Oberon System 3 for Windows.  The default values are 10000 for
each variable.  When I changed the value to 1000 the program no
longer crashed.

        (* nofline = 32000; *) nofline = 1000;
        (* nofrepl = 32000; *) nofrepl = 1000;

These constants are used when declaring string variables in RX.Mod.
For example :

        sline : ARRAY(nofline+1) OF CHAR;

Does anyone have any idea why the default values crashed Oberon?

RX seems like a useful tool.  For example if you use :

    RX.SetSearch d[d]"."d[d]"."dddd

and then do RX.Search Oberon will find any date such as 12.12.1999
in the window that has the caret set.  Also you can use the module
RXA (which RX imports) to do regular expression searches on strings
in your program.  This is similair to the regular expression objects
in JavaScript and VBScript.  RXA could easily be ported to other
Oberon systems such as BlackBox or OOC since it only imports the
module "Texts" and it only uses "Texts" for dumping out the the
DFA.

Note : I haven't been able to successfully test RX.SetReplase and
RX.Replace yet but at least I have search working and that's a start.

--
Guns don't kill people...bullets do.

Sent via Deja.com http://www.*-*-*.com/
Before you buy.



Sun, 02 Mar 2003 03:00:00 GMT  
 Regular Expressions in Oberon

Quote:

> I noticed some time ago that there was a regular expression tool in
> Oberon System 3, but until now I wasn't able to get it to work.  In
> fact I used to CRASH my Oberon session!  But I've found the problem
> and fixed it.  The application is RX.Arc.  There are two constants in
> the file RX.Mod called nofline and nofrepl that at the default values
> crash Oberon System 3 for Windows.  The default values are 10000 for
> each variable.  When I changed the value to 1000 the program no
> longer crashed.

This problem most certainly did not catch attention because windows
users are not used to use regexes, and in native Oberon, RX works
without Your modification.

I assume that it will work in the ports based on the native sources
as well, which is true for the linux version at last. RX.Replace seems
to work, too.

H.
--
Harald Wagener                        Uni Bremen, Fb3 -- Informatik

Tel: +49 421 2184216                         Mobil: +49 174 7530012



Mon, 03 Mar 2003 03:00:00 GMT  
 Regular Expressions in Oberon


Quote:
> This problem most certainly did not catch attention because windows
> users are not used to use regexes, and in native Oberon, RX works
> without Your modification.

True.  I didn't really think about regular expressions much until
I had to use them in VBScript and JavaScript for validating input
on web pages.  I'm really curious as to what causes this to crash
under Windows.  It seems to be a problem with heap allocation.
Consider the following program :

MODULE Test;

  IMPORT Out;

  CONST
    nofline = 6192;

  PROCEDURE Do*;
  VAR
    strTest : ARRAY nofline OF CHAR;
  BEGIN
    strTest := 'Hello';
    Out.String(strTest); Out.Int(nofline, 5);  Out.Ln();
  END Do;
END Test.

If nofline is set to any number larger than 6192 it will crash
Oberon the first time it is run.  However if you run this once
with nofline at 6192, unload module Test, increase the size of
nofline a reasonable amount, compile and run it again it will
work.  A "reasonable" amount is 1 K.  I tried increasing nofline
by 1K this way all the way up to 20 K without the program crashing.
Curious about this I re-read the Readme.Txt file that comes with
the Oberon Sys 3 for Windows :

=================================================================
Note: oberon does no longer support command line options. The heap
size is automatically increased when oberon runs out of memory.
=================================================================

It seems to me that the only safe thing is to make sure that any
static memory allocation is 6 K or less.

If you declare strTest as POINTER TO ARRAY OF CHAR and allocate
it as NEW(strTest, nofline) then nofline can initially be much
larger.  I tested this with nofline set to 8000.

Quote:
> I assume that it will work in the ports based on the native sources
> as well, which is true for the linux version at last. RX.Replace seems
> to work, too.

> H.

Well it may be just me, but RX.Replace seems to just ignore me.
I tried the following example from the RX.Tool :

RX.SetReplace X0 ".Txt => " X0 ".Text"

Then I set the caret in a window containing "Blah.Txt".  When I
clicked RX.Replace it didn't do anything.  This is in contrast
to RX.SetSearch and RX.Search.  When I did :

RX.SetSearch ( i {i|"."} ) X0 ".Txt"

and did RX.Search it highlighted "Blah.Txt" without any problem.
Any ideas as to what I'm doing wrong?

--
Guns don't kill people...bullets do.

Sent via Deja.com http://www.deja.com/
Before you buy.



Mon, 03 Mar 2003 03:00:00 GMT  
 Regular Expressions in Oberon

Quote:

> Well it may be just me, but RX.Replace seems to just ignore me.
> I tried the following example from the RX.Tool :

> RX.SetReplace X0 ".Txt => " X0 ".Text"

> Then I set the caret in a window containing "Blah.Txt".  When I
> clicked RX.Replace it didn't do anything.  This is in contrast
> to RX.SetSearch and RX.Search.  When I did :

> RX.SetSearch ( i {i|"."} ) X0 ".Txt"

> and did RX.Search it highlighted "Blah.Txt" without any problem.
> Any ideas as to what I'm doing wrong?

After the First RX.Search, just continue with RX.Replace (just the
same usual search/replace semantics. Works for me, at least.

H.

--
Harald Wagener                        Uni Bremen, Fb3 -- Informatik

Tel: +49 421 2184216                         Mobil: +49 174 7530012



Mon, 03 Mar 2003 03:00:00 GMT  
 Regular Expressions in Oberon


Quote:
> After the First RX.Search, just continue with RX.Replace (just the
> same usual search/replace semantics. Works for me, at least.

> H.

Thanks for the help.  I should have read the docs more carefully.
I think I got confused by the example :

RX.SetReplace X0 ".Txt => " X0 ".Text"

That made me think that it was done in one step and that => was
significant.

--
Guns don't kill people...bullets do.

Sent via Deja.com http://www.deja.com/
Before you buy.



Tue, 04 Mar 2003 03:00:00 GMT  
 Regular Expressions in Oberon
Looks like a stack problem. Windows expects you to "grow" the stack in 4K
increments. Try reading single bytes from the end of the array backwards in
steps of 4K at a time.

Andrew Richards

Quote:



> > This problem most certainly did not catch attention because windows
> > users are not used to use regexes, and in native Oberon, RX works
> > without Your modification.

> True.  I didn't really think about regular expressions much until
> I had to use them in VBScript and JavaScript for validating input
> on web pages.  I'm really curious as to what causes this to crash
> under Windows.  It seems to be a problem with heap allocation.
> Consider the following program :

> MODULE Test;

>   IMPORT Out;

>   CONST
>     nofline = 6192;

>   PROCEDURE Do*;
>   VAR
>     strTest : ARRAY nofline OF CHAR;
>   BEGIN
>     strTest := 'Hello';
>     Out.String(strTest); Out.Int(nofline, 5);  Out.Ln();
>   END Do;
> END Test.

> If nofline is set to any number larger than 6192 it will crash
> Oberon the first time it is run.  However if you run this once
> with nofline at 6192, unload module Test, increase the size of
> nofline a reasonable amount, compile and run it again it will
> work.  A "reasonable" amount is 1 K.  I tried increasing nofline
> by 1K this way all the way up to 20 K without the program crashing.
> Curious about this I re-read the Readme.Txt file that comes with
> the Oberon Sys 3 for Windows :

> =================================================================
> Note: oberon does no longer support command line options. The heap
> size is automatically increased when oberon runs out of memory.
> =================================================================

> It seems to me that the only safe thing is to make sure that any
> static memory allocation is 6 K or less.

> If you declare strTest as POINTER TO ARRAY OF CHAR and allocate
> it as NEW(strTest, nofline) then nofline can initially be much
> larger.  I tested this with nofline set to 8000.

> > I assume that it will work in the ports based on the native sources
> > as well, which is true for the linux version at last. RX.Replace seems
> > to work, too.

> > H.

> Well it may be just me, but RX.Replace seems to just ignore me.
> I tried the following example from the RX.Tool :

> RX.SetReplace X0 ".Txt => " X0 ".Text"

> Then I set the caret in a window containing "Blah.Txt".  When I
> clicked RX.Replace it didn't do anything.  This is in contrast
> to RX.SetSearch and RX.Search.  When I did :

> RX.SetSearch ( i {i|"."} ) X0 ".Txt"

> and did RX.Search it highlighted "Blah.Txt" without any problem.
> Any ideas as to what I'm doing wrong?

> --
> Guns don't kill people...bullets do.

> Sent via Deja.com http://www.deja.com/
> Before you buy.



Tue, 18 Mar 2003 03:00:00 GMT  
 Regular Expressions in Oberon

Quote:

> Looks like a stack problem. Windows expects you to "grow" the stack in 4K
> increments. Try reading single bytes from the end of the array backwards in
> steps of 4K at a time.

Yes, this was the problem.  Patrik is fixing the Windows Oberon compiler.

--
Pieter Muller, Institute for Computer Systems, ETH Zurich
Native Oberon OS: http://www.oberon.ethz.ch/native/



Tue, 18 Mar 2003 03:00:00 GMT  
 
 [ 8 post ] 

 Relevant Pages 

1. regular expression matching in J ? (or APL)

2. Tgen, linear algebra, and regular expression package available

3. Regular Expressions

4. Regular Expression Matcher v1.1

5. apl and regular expressions

6. php like regular expressions in apl?

7. Support for regular expressions in APL?

8. Benchmarking Regular Expressions in J3.05

9. regular expression discussion

10. Regular Expressions in J

11. Regular Expression to match HTML elements

12. Using regular expressions to validate data

 

 
Powered by phpBB® Forum Software