(* Title: HOL/TPTP/TPTP_Parser/tptp.lex
Author: Nik Sultana, Cambridge University Computer Laboratory
Notes:
* Omit %full in definitions to restrict alphabet to ascii.
* Could include %posarg to ensure that we'd start counting character positions
from 0, but it would punish performance.
* %s AF F COMMENT; -- could improve by making stateful.
Acknowledgements:
* Geoff Sutcliffe for help with TPTP.
* Timothy Bourke for his tips on getting ML-Yacc working with Poly/ML.
* An early version of this was ported from the specification shipped with
Leo-II, written by Frank Theiss.
* Some boilerplate bits were taken from the ml-yacc/ml-lex manual by Roger Price.
* Jasmin Blanchette and Makarius Wenzel for help with Isabelle integration.
*)
structure T = Tokens
type pos = int (* Position in file *)
type lineNo = int
type svalue = T.svalue
type ('a,'b) token = ('a,'b) T.token
type lexresult = (svalue,pos) token
type lexarg = string
type arg = lexarg
val col = ref 0;
val linep = ref 1; (* Line pointer *)
val eolpos = ref 0;
val badCh : string * string * int * int -> unit = fn
(file_name, bad, line, col) =>
TextIO.output(TextIO.stdOut, file_name ^ "["
^ Int.toString line ^ "." ^ Int.toString col
^ "] Invalid character \"" ^ bad ^ "\"\n");
val eof = fn file_name =>
let
val result = T.EOF (!linep,!col);
val _ = linep := 0;
in result end
(*here could check whether file ended prematurely:
see if have open brackets, or if we're in some state other than INITIAL*)
val count_commentlines : string -> unit = fn str =>
let
val str' = String.explode str
val newlines = List.filter (fn x => x = #"\n") str'
in linep := (!linep) + (List.length newlines) end
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.