src/Pure/Syntax/parser.ML
changeset 32738 15bb09ca0378
parent 30189 3633f560f4c3
child 33037 b22e44496dc2
equal deleted inserted replaced
32737:76fa673eee8b 32738:15bb09ca0378
    15   datatype parsetree =
    15   datatype parsetree =
    16     Node of string * parsetree list |
    16     Node of string * parsetree list |
    17     Tip of Lexicon.token
    17     Tip of Lexicon.token
    18   val parse: gram -> string -> Lexicon.token list -> parsetree list
    18   val parse: gram -> string -> Lexicon.token list -> parsetree list
    19   val guess_infix_lr: gram -> string -> (string * bool * bool * int) option
    19   val guess_infix_lr: gram -> string -> (string * bool * bool * int) option
    20   val branching_level: int ref
    20   val branching_level: int Unsynchronized.ref
    21 end;
    21 end;
    22 
    22 
    23 structure Parser: PARSER =
    23 structure Parser: PARSER =
    24 struct
    24 struct
    25 
    25 
   688         (B, j, tss @ t, sa, id, i) ::
   688         (B, j, tss @ t, sa, id, i) ::
   689           movedot_lambda (B, j, tss, Nonterminal (A, k) :: sa, id, i) ts
   689           movedot_lambda (B, j, tss, Nonterminal (A, k) :: sa, id, i) ts
   690       else movedot_lambda (B, j, tss, Nonterminal (A, k) :: sa, id, i) ts;
   690       else movedot_lambda (B, j, tss, Nonterminal (A, k) :: sa, id, i) ts;
   691 
   691 
   692 
   692 
   693 val branching_level = ref 600;                   (*trigger value for warnings*)
   693 val branching_level = Unsynchronized.ref 600;   (*trigger value for warnings*)
   694 
   694 
   695 (*get all productions of a NT and NTs chained to it which can
   695 (*get all productions of a NT and NTs chained to it which can
   696   be started by specified token*)
   696   be started by specified token*)
   697 fun prods_for prods chains include_none tk nts =
   697 fun prods_for prods chains include_none tk nts =
   698 let
   698 let
   819     val S0 = [(~1, 0, [], [Nonterminal (start_tag, 0), Terminal eof], "", 0)];
   819     val S0 = [(~1, 0, [], [Nonterminal (start_tag, 0), Terminal eof], "", 0)];
   820     val s = length indata + 1;
   820     val s = length indata + 1;
   821     val Estate = Array.array (s, []);
   821     val Estate = Array.array (s, []);
   822   in
   822   in
   823     Array.update (Estate, 0, S0);
   823     Array.update (Estate, 0, S0);
   824     get_trees (produce (ref false) prods tags chains Estate 0 indata eof)
   824     get_trees (produce (Unsynchronized.ref false) prods tags chains Estate 0 indata eof)
   825   end;
   825   end;
   826 
   826 
   827 
   827 
   828 fun parse (Gram {tags, prods, chains, ...}) start toks =
   828 fun parse (Gram {tags, prods, chains, ...}) start toks =
   829   let
   829   let