For parsing simple languages you can often get very far without ever using backtracking.
Actually, that's also the case for non simple languages. Perl usually isn't qualified as a simple language, yet parsing it doesn't require backtracking. Many languages, including Perl, use a grammar that requires one token to look ahead -- although sometimes perl cheats and scans (but not tokenizes) the stream ahead.

Limited lookahead parsing means that your grammar is written in such away that the compiler only needs to look at a fixed number of tokens before it can decide which grammar rule it has to apply to continue parsing.

If I were to make a language, be it an embedded one or a standalone, I would want the compiling phase reasonable fast. I certainly don't want any backtracking, so a full blown regexp would be out. I may use a bunch of simple regexes in the tokenizer, but the main parsing loop should be table driven or be expressable in a state machine. But no backtracking.


In reply to Re^2: Creating parser for some syntax by JavaFan
in thread Creating parser for some syntax by andal

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.