[Tutor] parsing--is this right?

Sean 'Shaleh' Perry shalehperry@attbi.com
Mon, 10 Jun 2002 16:49:50 -0700 (PDT)


> 
>> In order to parse this text, I use a counter to count the number
>> of open and closed curly brackets. I am following the tutorial in
>> doing this.
>>
>> However, I am wondering if plex does things the wrong way.
> 
> Plex is a tool for breaking the text into "tokens" that are easier to look
> at.  However, it's not enough.  You'll probably want to use a parsing
> technique like recursive descent, or use a specialized parser-building
> tool.  We can talk about it more if you'd like.
> 
> 

to be more explicit here.  plex is a lexer not a parser.  the lexer reads input
and decides what each piece it sees is.  This information is passed to the
parser.

foo { bar }

would result in:

word
brace
word
brace

being sent to the parser.  This is why you find yourself counting, you are
implementing a parser based on the tokens the lexer is sending you.