Re: Terminals, non-terminal, syntax, semantics: some really naive questions

Carl Cerecke <cdc@maxnet.co.nz>
14 Mar 2003 11:22:25 -0500

          From comp.compilers

Related articles
Terminals, non-terminal, syntax, semantics: some really naive questi rmyers1400@attbi.com (Robert Myers) (2003-03-09)
Re: Terminals, non-terminal, syntax, semantics: some really naive qu cdc@maxnet.co.nz (Carl Cerecke) (2003-03-14)
| List of all articles for this month |

From: Carl Cerecke <cdc@maxnet.co.nz>
Newsgroups: comp.compilers
Date: 14 Mar 2003 11:22:25 -0500
Organization: TelstraClear
References: 03-03-039
Keywords: parse
Posted-Date: 14 Mar 2003 11:22:25 EST

Robert Myers wrote:
> Hello, all:
>
> I find myself in the position of needing to know more about compilers
> than I thought I would ever want to know.


Some of us do it for fun!


Forget trees etc. and consider this small example:


This is a grammar that defines a language. S is the start symbol of
the language. All sentences in the language can be derived starting
from S and following the arrows. When you follow an arrow you can
think of it as replacing the symbol on the LHS with the symbol(s) on
the RHS.




S -> A a | B a
A -> x y
B -> z


A symbol that can be replaced is a non-terminal (S, A, B)
A symbol that is a token in the language is a terminal
(a, x, y, z)
All non-terminals must appear at least once on the LHS
of an arrow. No terminals ever appear on the LHS.


You should be able to see reasonably easily that S
derives (and can only derive) the two sentences "xya"
and "za"


Hope that helps,
Cheers,
Carl.


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.