Permalink
Browse files

Prevent getting stuck in parser.

  • Loading branch information...
1 parent 7039418 commit 58a69dd16e198282d71c09ce688d0e8c062ba165 @let-def let-def committed Mar 30, 2013
Showing with 14 additions and 1 deletion.
  1. +9 −1 command.ml
  2. +3 −0 tests/termination_01.in
  3. +2 −0 tests/termination_01.out
View
@@ -114,8 +114,16 @@ let command_tell = {
let chunks = Chunk.sync outlines chunks in
let types = Typer.sync chunks types in
let pos = !bufpos in
+ (* If token list didn't change, move forward anyway
+ * to prevent getting stuck *)
+ let stuck = state.tokens = tokens in
+ let tokens =
+ if stuck
+ then (try List.tl tokens with _ -> tokens)
+ else tokens
+ in
let state' = { tokens ; outlines ; chunks ; types ; pos } in
- if !eod || (!eot && state.tokens = state'.tokens)
+ if !eod || (!eot && stuck)
then state'
else loop state'
in
@@ -0,0 +1,3 @@
+["tell", "struct", "let x = function\n | a -> ()\n | b -> ()\n | c -> ()\n | d -> ()\nend\n | P of int\n"]
+["tell", "struct", null]
+
@@ -0,0 +1,2 @@
+["return",false]
+["return",true]

0 comments on commit 58a69dd

Please sign in to comment.