Re: A Question about TextMappers.Scanner

From: [at]} <Gérard>
Date: Fri, 20 Sep 2002 22:06:58 +0200

----boundary-LibPST-iamunique-1664718915_-_-
Content-type: text/plain

> If I scan the following text via the TextMappers.Scanner
> ... ELSIF sc.string = "SHORTINT" THEN DoSomeThing; ...
> then I receive the token
> 3 ELSIF
> 3 sc
> 1 .
> 3 string
> 1 > 3 SHORTINT
> 3 THEN
> 3 DoSomeThing
> 1 ;
>
> If I scan the following text via the TextMappers.Scanner
> ... ELSIF sc.string = SHORTINT THEN DoSomeThing; ....
> then I receive the token
> 3 ELSIF
> 3 sc
> 1 .
> 3 string
> 1 > 3 SHORTINT
> 3 THEN
> 3 DoSomeThing
> 1 ;
>
> How do I distinguish between ... "SHORTINT" ... and ... SHORTINT ... ?
>
> Regards
>
> Helmut Zinn

You can use the reader included in the scanner to test the first character
of the string. Don't forget to record its last position and to restore it
before scanning again.

Regards.

Gérard

MODULE TestString;

 IMPORT

  StdLog, TextControllers, TextMappers, TextModels;

 CONST

  quotedString*= 2;

 PROCEDURE Try*;

  VAR

   c: TextControllers.Controller;
   s: TextMappers.Scanner;
   r: TextModels.Reader;
   pos, beg, end: INTEGER;

  BEGIN (*Try*)
   c:= TextControllers.Focus();
   IF c# NIL THEN
    StdLog.Open;
    s.ConnectTo(c.text);
    c.GetSelection(beg, end);
    IF beg< end THEN
     s.SetPos(beg);
    END;
    REPEAT
     REPEAT
      s.Scan;
     UNTIL (s.type= TextMappers.eot) OR (s.type= TextMappers.string);
     IF s.type= TextMappers.string THEN
      r:= s.rider;
      pos:= r.Pos();
      r.SetPos(s.start);
      r.Read;
      IF (r.char= '"') OR (r.char= "'") THEN
       StdLog.Int(quotedString);
      ELSE
       StdLog.Int(TextMappers.string);
      END;
      StdLog.Tab;
      StdLog.String(s.string);
      StdLog.Ln;
      r.SetPos(pos);
     END;
    UNTIL s.type= TextMappers.eot;
   END;
  END Try;

 END TestString.

TestString.Try;

--------------------------------------------

To unsubscribe from this mailing list, send a message containing the word "unsubscribe" to:
   blackbox-request{([at]})nowhere.xy

To get a list of valid e-mail commands and instructions on their usage, send a message containing the word "help" to the above address.

Send any problem reports or questions related to this email list to the list owner at
   owner-blackbox{([at]})nowhere.xy

Current posting policy:

a) To post you should use the same address by which you are subscribed to the mailing list. That way, the list server will recognize you as subscriber and forward your posting immediately, without creating any overhead.

b) If, for some reason, you cannot post from the address, by which you are subscribed, your message will be moderated to avoid spam. Please understand that moderation will often cause some delay, in particular over weekends or holydays.


----boundary-LibPST-iamunique-1664718915_-_-
Content-type: application/rtf
Content-transfer-encoding: base64
Content-Disposition: attachment; filename="rtf-body.rtf"

e1xydGYxXGFuc2lcYW5zaWNwZzEyNTJcZnJvbXRleHQgXGRlZmYwe1xmb250dGJsDQp7XGYwXGZz
d2lzc1xmY2hhcnNldDAgQXJpYWw7fQ0Ke1xmMVxmbW9kZXJuIENvdXJpZXIgTmV3O30NCntcZjJc
Zm5pbFxmY2hhcnNldDIgU3ltYm9sO30NCntcZjNcZm1vZGVyblxmY2hhcnNldDAgQ291cmllciBO
ZXc7fX0NCntcY29sb3J0YmxccmVkMFxncmVlbjBcYmx1ZTA7XHJlZDBcZ3JlZW4wXGJsdWUyNTU7
fQ0KXHVjMVxwYXJkXHBsYWluXGRlZnRhYjM2MCBcZjBcZnMyMCA+IElmIEkgc2NhbiB0aGUgZm9s
bG93aW5nIHRleHQgdmlhIHRoZSBUZXh0TWFwcGVycy5TY2FubmVyXHBhcg0KPiAuLi4gRUxTSUYg
c2Muc3RyaW5nID0gIlNIT1JUSU5UIiBUSEVOIERvU29tZVRoaW5nOyAuLi5ccGFyDQo+IHRoZW4g
SSByZWNlaXZlIHRoZSB0b2tlblxwYXINCj4gMyBFTFNJRlxwYXINCj4gMyBzY1xwYXINCj4gMSAu
XHBhcg0KPiAzIHN0cmluZ1xwYXINCj4gMSA9XHBhcg0KPiAzIFNIT1JUSU5UXHBhcg0KPiAzIFRI
RU5ccGFyDQo+IDMgRG9Tb21lVGhpbmdccGF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