[MLton-commit] r5053
Vesa Karvonen
vesak at mlton.org
Fri Jan 12 04:35:17 PST 2007
Initial commit of a lib of misc utils to be refactored.
----------------------------------------------------------------------
A mltonlib/trunk/com/ssh/misc-util/unstable/sml-syntax.sml
----------------------------------------------------------------------
Added: mltonlib/trunk/com/ssh/misc-util/unstable/sml-syntax.sml
===================================================================
--- mltonlib/trunk/com/ssh/misc-util/unstable/sml-syntax.sml 2007-01-12 12:34:47 UTC (rev 5052)
+++ mltonlib/trunk/com/ssh/misc-util/unstable/sml-syntax.sml 2007-01-12 12:35:12 UTC (rev 5053)
@@ -0,0 +1,35 @@
+(* Copyright (C) 2007 SSH Communications Security, Helsinki, Finland
+ *
+ * This code is released under the MLton license, a BSD-style license.
+ * See the LICENSE file or http://mlton.org/License for details.
+ *)
+
+(*
+ * Utilities for dealing with the syntax of Standard ML.
+ *)
+
+structure SmlSyntax :> sig
+ (** == PREDICATES FOR IDENTIFIERS == *)
+
+ val isAlphaNumId : String.t UnPr.t
+ val isId : String.t UnPr.t
+ val isLabel : String.t UnPr.t
+ val isLongId : String.t UnPr.t
+ val isNumLabel : String.t UnPr.t
+end = struct
+ structure C = Char and L = List and S = String
+ val isSym = C.contains "!%&$#+-/:<=>?@\\~`^|*"
+ val isntEmpty = 0 <\ op < o size
+ val isSymId = isntEmpty andAlso S.all isSym
+ val isAlphaNumId = isntEmpty
+ andAlso C.isAlpha o S.sub /> 0
+ andAlso S.all (C.isAlphaNum
+ orElse #"'" <\ op =
+ orElse #"_" <\ op =)
+ val isNumLabel = isntEmpty
+ andAlso #"0" <\ op <> o S.sub /> 0
+ andAlso S.all C.isDigit
+ val isId = isAlphaNumId orElse isSymId
+ val isLongId = L.all isId o S.fields (#"." <\ op =)
+ val isLabel = isId orElse isNumLabel
+end
Property changes on: mltonlib/trunk/com/ssh/misc-util/unstable/sml-syntax.sml
___________________________________________________________________
Name: svn:eol-style
+ native
More information about the MLton-commit
mailing list