Source

ocaml-lib / dcg / matcher.ml

Diff from to

dcg/matcher.ml

   object
     method virtual get : Str.regexp -> int -> string option
     method virtual look : string -> int -> bool
-    method virtual at_eof : int -> bool
+    method virtual eof : int -> bool
+(*    method virtual at_eof : int -> bool *)
     method virtual at_init : int -> bool
     method virtual set_init : int -> unit
   end
       let l = String.length m in
       p+l <= len && String.sub s p l = m
 
-    method at_eof p = (p >= len)
+    method eof p = (p >= len)
+
+(*    method at_eof p = (p >= len) *)
 
     method at_init p = (p <= offset)
 
       done;
       pos+l <= len && String.sub s pos l = m
 
+    method eof p =
+      let pos = p-offset in
+      assert (pos >= 0 && pos <= len);
+      while not eof && pos+1 > len do
+	self#expand
+      done;
+      eof && pos >= len
+
+(*
     method at_eof p =
       let pos = p-offset in
       eof && pos >= len
+*)
 
     method at_init p =
       let pos = p-offset in
 
     method look (m : string) : bool = str#look m p
 
-    method at_eof : bool = str#at_eof p
+    method eof : bool = str#eof p
+
+(*    method at_eof : bool = str#at_eof p *)
 
     method at_init : bool = str#at_init p
 
       | `Begin ->
 	  state <- `End;
 	  let cursor = cursor#skip in
-	  if cursor#at_eof
+	  if cursor#eof
 	  then Parsed (ctx, ("<EOF>", cursor#coord), cursor)
 	  else Failed [Msg.make "<EOF> expected" [||] (Msg.Locator.Point cursor#coord)]
       | `End -> Failed []
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.