Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.compilers > #2671
| From | Christopher F Clark <christopher.f.clark@compiler-resources.com> |
|---|---|
| Newsgroups | comp.compilers |
| Subject | RE: About finding the start symbol of a grammar |
| Date | 2021-05-22 12:14 +0300 |
| Organization | Compilers Central |
| Message-ID | <21-05-020@comp.compilers> (permalink) |
As Dodi noted, this is basically a graph analysis problem and the graph may be disconnected (a forest). And our moderator has added several insightful comments. E.g. you can "declare" a start symbol and if not present default to some symbol, either the first one in the grammar, or some symbol from which all other symbols are reachable (presuming the graph isn't disconnected), and the start symbol can be recursively defined, etc. However, there is one particular curious aspect if you are writing a translator to a recursive descent parser, one generally makes a function of each rule, as a result one can consider each symbol a start symbol for whatever sub-graph is reachable from it. With a table driven parser, one has to make a table of entries into the parsing table to achieve the same effect, but that is not difficult to do, although that may require additional table rows if the symbol behaves slightly differently when used as a start symbol rather than in the context of other rules (e.g. follow symbols). So, in that sense, a start symbol is simply what one wants to parse. -- ****************************************************************************** Chris Clark email: christopher.f.clark@compiler-resources.com Compiler Resources, Inc. Web Site: http://world.std.com/~compres 23 Bailey Rd voice: (508) 435-5016 Berlin, MA 01503 USA twitter: @intel_chris ------------------------------------------------------------------------------
Back to comp.compilers | Previous | Next — Next in thread | Find similar
RE: About finding the start symbol of a grammar Christopher F Clark <christopher.f.clark@compiler-resources.com> - 2021-05-22 12:14 +0300 Re: About finding the start symbol of a grammar gah4 <gah4@u.washington.edu> - 2021-05-22 13:17 -0700
csiph-web