[clean-list] is my lazy parsing effective?

erik.zuurbier at tiscali.nl erik.zuurbier at tiscali.nl
Fri Oct 27 13:10:06 MEST 2006


Jigang

I suggest you google with the keyword parser. You get a wealth of 
material about theory and implementation. I know a lazy girl like 
yourself does not like reading too much, but in a way that could make 
you lazier still: it would prevent you from re-inventing the world. 
Instead you could build on what is already available.

Regards Erik Zuurbier

----Oorspronkelijk bericht----
Van: Jigang.Sun at student.paisley.ac.uk
Datum : 27/10/2006 9:41
Aan: <clean-list at science.ru.nl>
Onderw: [clean-list] is my lazy parsing effective? 

Hi,
I am writing parser by hand. I want to be lazy, i.e. I write less 
code. For example, for the
following grammar

SpecialExpression = BasicValue
| List

BasicValue = INT
|BOOL
|REAL

List = ListDenotation
| DotDotexpression

ListDenotation = "["[ListKind] [{LGraphExpr}-list [: GraphExpr]] 
[SpineStrictness] "]"
LGraphExpr = GraphExpr| CharsDenotation

DotDotexpression = "["[ListKind] GraphExpr [,GraphExpr]..[GraphExpr] 
[SpineStrictness] "]"

the best parsing method is, at each level, to decide exactly the next 
route to go, for 
SpecialExpression = BasicValue
| List

the usual method is: when the parser is at a point to parse 
SpecialExpression, the parser should
check the first token type met,if the token is a token that starts 
BasicValue(is of INT, REAL or
BOOL) then parse BasicValue, if the first token is "[" then parse 
List. 

The method I want to adopt is not do token type checking, instead go 
straight to parse BasicValue,
let BasicValue parsing method check if the first token is of INT, REAL 
or BOOL, if not then return
null; then parse List. The token type checking is done at lowerest 
level, and only once.

The advantage is that the program code is short, because I ommit the 
token type checking that is
repeatedly done at a further lower levels, e.g. at List parsing and 
further down List, i.e.
ListDenotation and DotDotexpression.

Maybe the disadvantage is slower speed.

I am sure if the parsing efficiency is a main concern to a compiler 
overall performance. 

How about the method?

Thanks.
Jigang




_______________________________________________
clean-list mailing list
clean-list at science.ru.nl
http://mailman.science.ru.nl/mailman/listinfo/clean-list







More information about the clean-list mailing list