1
1
mirror of https://github.com/tweag/nickel.git synced 2024-09-20 08:05:15 +03:00

Implement the Ident contract

This commit is contained in:
Yann Hamdaoui 2021-02-15 14:36:06 +01:00
parent be8ce6f49e
commit 64312104ce

View File

@ -33,9 +33,12 @@
%blame% (%tag% "not a string" l);
Ident = fun l s =>
let pattern = m#"_?[a-zA-Z][_a-zA-Z0-9]*"#m in
if %isStr% s then
//use regex here
if (%strMatch% s pattern).index > -1 then
s
else
%blame% (%tag% "invalid enum tag" l)
else
%blame% (%tag% "not a string" l);