[MLton] MLton wiki
Brent Fulgham
bfulgham@debian.org
Mon, 1 Nov 2004 23:35:05 -0800
--Boundary-00=_pizhBrHv6c408JC
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
On Monday 01 November 2004 07:13 pm, Matthew Fluet wrote:
> http://wiki.mlton.org/TypeChecking
Attached is a revised states file, with both Matthew and my mark-up.
-Brent
--Boundary-00=_pizhBrHv6c408JC
Content-Type: text/x-csrc;
charset="iso-8859-1";
name="sml.st"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
filename="sml.st"
/**
* Name: sml
* Description: Standard ML Programming Language.
* Author: Matthew Fluet <mfluet@acm.org>
* Brent Fulgham <bfulgham@debian.org>
*
*/
sml_builtins =
/* Builtins */
/\b(functor|lambda|s(ig(|nature)|truct(|ure))|NONE|SOME)\b/;
sml_types =
/* Types */
/\b(\'(a|b|c|d)|array|bool|char|int|list|real|string|unit|vector|word)\b/;
sml_keywords =
/* Keywords */
/\b(a(bs(traction|type)|nd(|also)|s|toi)|before|c(ase|oncat)|d(o|atatype)\
|e(lse|nd|qtype|xception)|f(n|un(|sig))|handle|i(f|n(|clude|fix(|r)))\
|l(et|ocal)|nonfix|o(|f|p(|en)|relse|verload)|print|r(aise|ec|ef)|sharing\
|t(hen|ype)|val|w(h(ere|ile)|ith(|type)))\b/ ;
/*
digit = [0-9];
*/
sml_digit_str = "[0-9]";
sml_digit_re = regexp(sml_digit_str);
/*
hexdigit = [0-9a-fA-F];
*/
sml_hexdigit_str = "[0-9a-fA-F]";
sml_hexdigit_re = regexp(sml_hexdigit_str);
/*
posdecint = {digit}+;
*/
sml_posdecint_str = sprintf("(%s)+",sml_digit_str);
sml_posdecint_re = regexp(sml_posdecint_str);
/*
poshexint = "0x"{hexdigit}+;
*/
sml_poshexint_str = sprintf("0x(%s)+",sml_hexdigit_str);
sml_poshexint_re = regexp(sml_poshexint_str);
/*
negdecint = "~"{posdecint};
*/
sml_negdecint_str = sprintf("~(%s)",sml_posdecint_str);
sml_negdecint_re = regexp(sml_negdecint_str);
/*
neghexint = "~"{poshexint};
*/
sml_neghexint_str = sprintf("~(%s)",sml_poshexint_str);
sml_neghexint_re = regexp(sml_neghexint_str);
/*
decint = {posdecint} | {negdecint};
*/
sml_decint_str = sprintf("(%s)|(%s)",sml_posdecint_str,sml_negdecint_str);
sml_decint_re = regexp(sml_decint_str);
/*
hexint = {poshexint} | {neghexint};
*/
sml_hexint_str = sprintf("(%s)|(%s)",sml_poshexint_str,sml_negdecint_str);
sml_hexint_re = regexp(sml_hexint_str);
/*
int = {decint} | {hexint}
*/
sml_int_str = sprintf("(%s)|(%s)",sml_decint_str,sml_hexint_str);
sml_int_re = regexp(sml_int_str);
/*
decword = "0w"{digit}+;
*/
sml_decword_str = sprintf("0w(%s)+",sml_digit_str);
sml_decword_re = regexp(sml_decword_str);
/*
hexword = "0wx"{hexdigit}+;
*/
sml_hexword_str = sprintf("0wx(%s)+",sml_hexdigit_str);
sml_hexword_re = regexp(sml_hexword_str);
/*
word = {decword} | {hexword}
*/
sml_word_str = sprintf("(%s)|(%s)",sml_decword_str,sml_hexword_str);
sml_word_re = regexp(sml_word_str);
/*
exp = "E" | "e";
*/
sml_exp_str = "E|e";
sml_exp_re = regexp(sml_exp_str);
/*
real = ({decint}"."{digit}+ ({exp}{decint})?) | ({decint}{exp}{decint});
*/
sml_real_str = sprintf("((%s)\\.(%s)+((%s)(%s))?)|((%s)(%s)(%s))",
sml_decint_str,sml_digit_str,sml_exp_str,sml_decint_str,
sml_decint_str,sml_exp_str,sml_decint_str);
sml_real_re = regexp(sml_real_str);
/*
num_const = {int} | {word} | {real}
*/
sml_num_const_str = sprintf("\\b((%s)|(%s)|(%s))\\b",
sml_int_str,sml_word_str,sml_real_str);
sml_num_const_re = regexp(sml_num_const_str);
/*
* Comments
*/
state sml_comment extends Highlight
{
BEGIN {
sml_comment_depth = 1;
}
/\(\*/ {
sml_comment_depth += 1;
language_print ($0);
}
/\*\)/ {
sml_comment_depth -= 1;
language_print ($0);
if (sml_comment_depth == 0)
return;
}
}
/*
* Strings
*/
state sml_string extends Highlight
{
/\\\\./ {
language_print ($0);
}
/\"/ {
language_print ($0);
return;
}
}
state sml extends HighlightEntry
{
/* Comments. */
/\(\*/ {
comment_face (true);
language_print ($0);
call (sml_comment);
comment_face (false);
}
/* Keywords. */
sml_keywords {
keyword_face (true);
language_print ($0);
keyword_face (false);
}
/* Numerical Constants */
sml_num_const_re {
highlight_face (true);
language_print ($0);
highlight_face (false);
}
/* String constants. */
/\"/ {
string_face (true);
language_print ($0);
call (sml_string);
string_face (false);
}
/* Types. */
sml_types {
type_face (true);
language_print ($0);
type_face (false);
}
/* Structure support */
sml_builtins {
reference_face (true);
language_print ($0);
reference_face (false);
}
/(#)(\") / {
language_print ($1);
string_face (true);
language_print ($2);
call (sml_string);
string_face (false);
}
/* Character constants. */
/'.'|'\\\\.'/ {
string_face (true);
language_print ($0);
string_face (false);
}
/* Symbols, etc. */
/:=|>|>=|==|<=|<>|=|!|::|@|\+|\-|\^|\/|\*|\||\b(quot|rem|div|mod\
|hd|tl)\b/ {
reference_face (true);
language_print ($0);
reference_face (false);
}
/*
* Function definitions, with args
* fct_name (args...) is
*/
/([ \t]*f[u]n[ \t]+)(\w+)([ \t]*)/ {
keyword_face (true);
language_print ($1);
keyword_face (false);
function_name_face (true);
face_on(face_bold_italic);
language_print ($2);
face_off(face_bold_italic);
function_name_face (false);
language_print ($3);
}
}
--Boundary-00=_pizhBrHv6c408JC--