delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1995/02/18/01:37:41

Date: Sat, 18 Feb 1995 01:59:03 -0400 (AST)
From: Bill Davidson <bdavidson AT ra DOT isisnet DOT com>
Subject: Re: Flex rules
To: Bryan Russell <BRYAN-R AT mis DOT scitec DOT com DOT au>
Cc: John Bodfish <bodfish AT austen DOT notis DOT com>, djgpp AT sun DOT soe DOT clarkson DOT edu


On Fri, 17 Feb 1995, Bryan Russell wrote:

> and the rule was really [A-Z][A-Za-z0-9-_] which is supposed to read as 
> Starting letter of A to Z, the rest of the leters consisting of A to Z or a to
> z or - or _. I now know why the resulting script compiler didn't work as the
> first line of the test source script had a '-' in it. 
> 
> Is there some sort of special delimiter to include '-' in the rule or should 
> the context sort it out?

I am sure you have this figured out by now, but let me quote from "UNIX 
Programmer's Manual", Vol. 5, "Languages and Support Tools", (AT&T, 
1986), Lexical Analyzer Generator (LEX), p. 522 (LEX Regular Expressions, 
Character Classes):

"Within square brackets, most operator meanings are ignored.  Only three 
characters are special; these are \, -, and ^.  The - character indicates 
ranges.  For example

	[a-z0-9<>_]

indicates the character class containing all the lowercase letters, the 
digits, the angle brckets, and underline.  Ranges may be given in either 
order.  Using - between any pair of characters which are not both 
uppercase letters, both lowercase letters, or both digits is 
implementation dependent and gets a warning message...  If it is desired 
to include the character - in a character class, it should be first or 
last; thus:

	[-+0=9]

matches all the digits and the two signs."

I hope this clears up your problem.  As an aside, anytime you see 
"implemntation dependent", assume it will result in an error!

Bill Davidson
bdavidson AT ra DOT isisnet DOT com

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019