1(* 2 Copyright (c) 2009, 2015-16 David C.J. Matthews 3 4 This library is free software; you can redistribute it and/or 5 modify it under the terms of the GNU Lesser General Public 6 License version 2.1 as published by the Free Software Foundation. 7 8 This library is distributed in the hope that it will be useful, 9 but WITHOUT ANY WARRANTY; without even the implied warranty of 10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 Lesser General Public License for more details. 12 13 You should have received a copy of the GNU Lesser General Public 14 License along with this library; if not, write to the Free Software 15 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 16*) 17 18signature LEXSIG = 19(*****************************************************************************) 20(* LEX export signature *) 21(*****************************************************************************) 22sig 23 type lexan; 24 type sys; 25 type pretty; 26 27 type location = 28 { file: string, startLine: FixedInt.int, startPosition: FixedInt.int, 29 endLine: FixedInt.int, endPosition: FixedInt.int } 30 31 val insymbol: lexan -> unit; 32 33 (* insymbol sets sy and id which are exported as "read-only" *) 34 35 val sy: lexan -> sys; 36 val id: lexan -> string; 37 val location: lexan -> location; 38 val pushBackSymbol: lexan * sys -> unit; 39 40 val initial: (unit -> char option) * Universal.universal list -> lexan; 41 42 (* Error handling *) 43 val reportError: 44 lexan -> 45 { location: location, hard: bool, message: pretty, context: pretty option } -> unit 46 (* Simple error message. *) 47 val errorMessage: lexan * location * string -> unit 48 (* Simple warning message. *) 49 val warningMessage: lexan * location * string -> unit 50 51 val errorOccurred: lexan -> bool; 52 53 val nullLex: lexan; (* Used when no errors are expected - streams raise exceptions. *) 54 55 (* To save passing an extra argument to many functions we include the 56 debug/control parameters here. *) 57 val debugParams: lexan -> Universal.universal list 58 (* This is also not really part of the lexical analyser. *) 59 val newBindingId: lexan -> FixedInt.int 60 61 val errorDepth: lexan -> FixedInt.int 62 63 (* Print error and warning messages. *) 64 val errorMessageProcTag: 65 ({ location: location, hard: bool, message: pretty, context: pretty option } -> unit) Universal.tag 66 67 (* A null location *) 68 val nullLocation: location 69 70 (* Construct the location that starts at the start of the first location 71 and ends at the end of the second. Used to combine the locations of 72 individual lexical units into a location for a larger syntactic unit. *) 73 val locSpan: location * location -> location 74 75 (* Types that can be shared. *) 76 structure Sharing: 77 sig 78 type pretty = pretty 79 and lexan = lexan 80 and sys = sys 81 end 82 83 84end (* LEX export signature *); 85 86