[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Scanning of SIGNS





Dear friends,
> 
> during the creation of example specs by Markus, the following
> question arose: is 
> 
> 	name[c1[c2]]
> 
> a legal ID?
Yes, I think that this is a legal ID.

> The parsers in Paris and Amsterdam do accept it,
> but our parser in Bremen recognizes "]]" as a SIGNS, and this
> lexical scanning prevents the above string from being
> recognized as an ID. A similar problem occurs with
> "]=", "{}:" "]:" etc. which are recognized as *one*
> lexical symbol due to the rule on page
> C-10 "The next lexical symbol recognized is as
> long as possible".
> Obviously, this rule is not entirely appropriate
> (unless we require the above to be written
> as "name[c1[c2] ]").
> How should the rules for lexical analysis be modified?
The current version of the parser developed here in Amsterdam recognizes this 
ID
correctly, but substrings as "{}:" can only be recognized if there is a space 
between
the "{}" and the ":".

The problem is the overlap between the characters of SIGNS and certain 
keywords, such
as ":", ";", "=", etc. A possible but not very elegant solution may be that 
the last character
of a SIGNS may not overlap with the first character of keywords. So, "{:}" is 
a legal
SIGNS but "{}:" is not. This would be a solution which would work in our 
parser, but
I do not know whether this poses too many restrictions on the Casl 
specification writer.
But, this solution does not solve the problem of the lexical scanner of Bremen 
with the
ID. A solution for this problem could be to have a so-called ``prefer 
keywords'' mode
in the scanner, if the scanner has the possibility of recognizing a token as a 
keyword
it will prefer this above the possibility to recognize this token as a SIGNS 
for instance.
This is how the scanner in the Asf+Sdf Meta-Environment works.

-- Mark


----------------------------------------------------------------
M.G.J. van den Brand,
Department of Software Engineering
CWI
Kruislaan 413, NL-1098 SJ AMSTERDAM, The Netherlands.

Tel___(+31) 20 5924007  WWW____http://www.cwi.nl/~markvdb/
Fax___(+31) 20 5924199  Email__markvdb@cwi.nl         
----------------------------------------------------------------