Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!iuvax!bsu-cs!dhesi From: dhesi@bsu-cs.bsu.edu (Rahul Dhesi) Newsgroups: comp.lang.misc Subject: Re: Language Design, or: is C's Grammar Context Free Keywords: BNF, Grammars, Silliness Message-ID: <6597@bsu-cs.bsu.edu> Date: 7 Apr 89 02:07:59 GMT References: <5200040@m.cs.uiuc.edu> <12443@watdragon.waterloo.edu> <6541@bsu-cs.UUCP> <3718@ficc.uu.net> Reply-To: dhesi@bsu-cs.UUCP (Rahul Dhesi) Organization: CS Dept, Ball St U, Muncie, Indiana Lines: 21 In article <3718@ficc.uu.net> peter@ficc.uu.net (Peter da Silva) writes: >If 'c's grammar is context free, and the context sensitivity is in the >semantics, tell me if the following is a syntax error... It depends on which context-free grammar you are using. Here's a simple one: program ::= char charlist charlist ::= .null. | charlist char char ::= 'a' | 'b' | ... '0' | '1' | ... '#' | '(' | .... blank | tab ... etc. (.null. means empty string.) My lexical analyzer always returns a single character or EOF. My parser is pretty simple. There is only one possible error during parsing: "premature EOF". Semantic analysis is a nightmare :-). -- Rahul Dhesi UUCP: !{iuvax,pur-ee}!bsu-cs!dhesi ARPA: dhesi@bsu-cs.bsu.edu