Re: True Name Spaces, when?



Hans-Peter Diettrich wrote:
L wrote:

Just to confuse people.. I want to clear (or not clear) something up about single pass parsers.

The whole "single pass" phrase is kind of a misleading term..IMO.

Well, I never found "single pass" applied to parsers, only to compilers.


Parsers and Compilers are the same things...
In many senses.

The line is murky between parser and compiler.

I scan/parse/compiles stuff for a living.. at least some of it.


In the early days of computing a complete compiler didn't fit into memory, so it had to be splitted into multiple passes. In this case every pass used the output of the preceding passes, and did *not* parse the source files again.

IMO, during parsing there are several "inner sub passes" to make sure syntax is right.. and things get fastforwarded/rewound while you are analyzing stuff after or during the pass.. so it is not really a single pass at all.

Then you'd have two distinct parsers, derived from distinct grammars. The first one checks for correct syntax only, the second one only processes syntactically correct source files.

Of course there must exist backtracking or other techniques, when a grammar requires lookahead in order to determine the applicable rules. The improper use of "productions" for parsing rules results from the concept of languages, whose grammars can be used to either produce or analyze sentences of the language. A parser instead does not produce sentences, it only processes given sentences.


There are many cases for example when someone uses a StringReplace() during a parse, which is actually is reseting part of the pass to not be a single pass any more... since you are rewinding when a replace is done.

A parser never modifies the source. What you mean is an application, that makes use of an parser. When that application modifies the input, it must resume parsing of the modified source at an appropriate place.


StringReplace or Pos() on a temporary buffer while passing.

There is no such thing as passing by once without analyzing things within the pass... unless what you are parsing/compiling is extremely trivial. At least, this is my experience with parsing.. but I also am greatly familiar with compilers, esp. the FPC sources and a Qompute language mode I have worked on for a few years off and on.

.



Relevant Pages

  • Re: does tex implements a LR(1) parser?
    ... context-free grammar for a language of a special form and a word, ... by a LRparser? ... parsing routines and intersperses parsing and execution, ...
    (comp.text.tex)
  • Re: OFF-TOPIC:: Why Lisp is not my favorite programming language
    ... The interpreter would be written in C. ... It is always possible to beat any interpreted language for speed using ... >at me for calling lisp a parsing language... ... I would write a parser to do so. ...
    (comp.lang.python)
  • Re: "Intro to Pyparsing" Article at ONLamp
    ... and then construct the corresponding grammar parser. ... > With data-driven parsing, you are starting with data to be parsed, and you ... I'd like to add another parser type, lets call this a natural language ...
    (comp.lang.python)
  • Re: What is the fastest method of parsing scheme?
    ... Recursive descent parsing is O, ... used to compile the parser, and the hardware used to run ... has been about performance of compilers and interpreters: ...
    (comp.lang.scheme)
  • Re: how to store list of varying types
    ... The cost of parsing what is essentially a "flat" structure is ... I wrote an XML parser from scratch for a complex nested structure in six ... you are superior of the "average programmer". ...
    (microsoft.public.vc.mfc)