home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / theory / 1912 < prev    next >
Encoding:
Text File  |  1992-09-11  |  2.9 KB  |  51 lines

  1. Newsgroups: comp.theory
  2. Path: sparky!uunet!secapl!Cookie!frank
  3. From: frank@Cookie.secapl.com (Frank Adams)
  4. Subject: Re: What kind of an automaton is this?
  5. Message-ID: <1992Sep11.203951.60472@Cookie.secapl.com>
  6. Date: Fri, 11 Sep 1992 20:39:51 GMT
  7. References: <4QU69WW@math.fu-berlin.de> <92Sep11.123701edt.47914@neat.cs.toronto.edu>
  8. Organization: Security APL, Inc.
  9. Lines: 40
  10.  
  11. In article <92Sep11.123701edt.47914@neat.cs.toronto.edu> mdhutton@cs.toronto.edu (Mike Hutton) writes:
  12. >In article <4QU69WW@math.fu-berlin.de> dww@inf.fu-berlin.de writes:
  13. >>We've been discussing on comp.compilers the kind of parsing automaton that is described in
  14. >>DeRemer[CACM 71] as being an SLR-Parser. It is not the kind of PDA I
  15. >>learned about when I studied Automata Theory with the next state and the
  16. >>output being determined by the current state, the top of the stack, and
  17. >>the current symbol in the input. In this "strange" automaton the lhs of
  18. >>the production being reduced is returned to the input after the stack
  19. >>has been popped. This is not just backing up over input, but non-terminals
  20. >>can be built up on the input, perhaps with a number of epsilon productions.
  21. >
  22. >To disagree with the previous two responses, even if you extend to allow
  23. >noncanonical lookahead (i.e. allow 2 stacks to go through the
  24. >input and put nonterminals back on the input stack), you still have a
  25. >context-free-like grammar (just with a more powerful lookahead 
  26. >ability) defining the language.  That the noncanonical parser *uses* two 
  27. >stacks doesn't imply that any language acceptable by an arbitrary
  28. >2-stack automaton (i.e. Turing Machine) can be expressed with an appropriate 
  29. >NLR(k) or NSLR(k) grammar---you still have k-bounded lookahead, even if 
  30. >it can also include nonterminals.
  31.  
  32. This is correct as far as it goes.  However, as I noted, the machine *can*
  33. in fact perform (almost) arbitrary stack operations on the two stacks.  (The
  34. pushdown-machine stack cannot be left empty, but this is a detail.)  To get
  35. full Turing-machine compatibility, you have to encode the Turing-machine
  36. state in the symbols on top of the stacks; this gets messy, but is quite
  37. doable.
  38.  
  39. To approach it in terms of the lookahead, you can look ahead more than k
  40. symbols by shifting input symbols onto the stack, deciding what you want to
  41. do, and then moving those symbols back to the input via unit productions.
  42. What you push back may not be *exactly* what you originally read, but it can
  43. function like what you originally read for subsequent processing.
  44.  
  45. (If k=0, the situation is quite different.  In this case, the symbol on top
  46. of the stack after a special reduction must be a shift state, since a shift
  47. was done in it before (unless this is an epsilon-production; but then an
  48. infinite loop ensues).  Hence the next operation will be a shift, and you
  49. might as well have just put the lhs on the stack in the first place.
  50. However, 0-symbol lookahead pdm's are not very practical.)
  51.