Changeset 3977


Ignore:
Timestamp:
Oct 18, 2008, 12:19:25 AM (12 years ago)
Author:
orlov
Message:
  • Modifications to the Earley algorithm in Refal-5 from the meeting with ANdrey.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • applications/trunk/LFC/Earley/Earley.ref

    r3965 r3977  
     1* Practical Earley Parsing
     2* Aycock and Horspool
     3
     4* This version takes any context free grammars but with nullable non-terminals
     5* (rules of a kind [E -> ] are not allowed).
     6
    17Check {
    28  (e.grammar) (TYPE t.name) e.string,
    3     <Parse (e.grammar) (e.string) () (((TYPE 0) DOT (TYPE t.name) ())) () ()> : e.sets (e.last),
     9    <Parse (e.grammar) (e.string) () (((TYPE START) DOT (TYPE t.name) ())) () ()> : e.sets (e.last),
    410    e.last : {
    511      e.l ((TYPE t.name e.info) e.prod DOT ()) e.r = (e.info) (e.prod);
     
    915
    1016Earley {
    11   (e.grammar) t.type e.string = <Parse (e.grammar) (e.string) () (((TYPE 0) DOT t.type ())) () ()>;
     17  (e.grammar) t.type e.string = <Parse (e.grammar) (e.string) () (((TYPE START) DOT t.type ())) () ()>;
    1218}
    1319
     20* In: (e.grammar) (e.string) e.sets (e.rules) (e.current) (e.next)
    1421Parse {
     22  (e.grammar) (e.string) e.sets (e.rules) (e.current) (e.next), <Print (e.grammar) (e.string) e.sets (e.rules) (e.current) (e.next)> : s.x = ;
    1523  (e.grammar) () (e.step) e.sets () (e.current) () = e.sets (e.current);
    16   (e.grammar) (s.char e.string) (e.step) e.sets () (e.current) (e.next) = <Parse (e.grammar) (e.string) (e.step I) e.sets (e.current) (e.next) () ()>;
     24  (e.grammar) (s.char e.string) (e.step) e.sets () (e.current) (e.next) =
     25    <Parse (e.grammar) (e.string) (e.step I) e.sets (e.current) (e.next) () ()>;
    1726  (e.grammar) (e.string) (e.step) e.sets (t.rule e.rules) (e.current) (e.next), t.rule : {
    1827* Scanner
     
    7887
    7988$ENTRY Go {
    80   = <Prout <Check ((PROD (TYPE ('E')) ((TYPE ('E')) '+' (TYPE ('E'))) ('n'))) (TYPE ('E')) 'n+n'>>;
     89  = <Prout
     90* E -> E '+' E | 'n'
     91      <Check ((PROD (TYPE ('E')) ((TYPE ('E')) '+' (TYPE ('E'))) ('n'))) (TYPE ('E')) 'mn'> '\n' >;
     92*      <Check ((PROD (TYPE ('E')) ((TYPE ('E')) '+' (TYPE ('E')))) (PROD (TYPE ('E')) ('n'))) (TYPE ('E')) 'n+n+n'>>;
    8193}
    8294
Note: See TracChangeset for help on using the changeset viewer.