-- -*- Mode: rpl; -*-
--
-- all.rpl Collections of things
--
-- © Copyright IBM Corporation 2017, 2018.
-- LICENSE: MIT License (https://opensource.org/licenses/mit-license.html)
-- AUTHOR: Jamie A. Jennings
package all
import ts, date, time, net, num, id, word
-- Here are some ways of distinguishing identifiers from ordinary words. These are
-- ad hoc patterns, and they may or may not meet your needs.
alias special_char = [_$]
alias id_char = [[:alnum:] special_char]
alias has_special_chars = { special_char+ [:alpha:] id_char* } /
{ [:alpha:] [:alnum:]* special_char id_char* !<":"}
-- Starts with two uppercase letters, OR, 1+ uppercase and contains numbers/special
alias starts_with_uppercase = { {[:upper:]{2,} id_char*}
/ {[:upper:]+ [[:digit:] special_char]+ id_char*} } ~
alias numbers_inside = { [[:alpha:] special_char]+ [:digit:] id_char* }
identifier = starts_with_uppercase / numbers_inside / has_special_chars / id.dotted / id.guid
punct = [:punct:]
unmatched = [:^space:]+
thing = ts.any / -- complete timestamps
date.any /
time.any /
net.any /
identifier / -- will match hex like 'C1'
{![[a-f] [A-F]] num.any} /
word.any /
punct /
unmatched
things = findall:thing
-- test thing includes word.any "face", "a"
-- test thing includes num.float "6.0", "-3.14"