File size: 3,115 Bytes
622387b | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 | diff --git a/timefhuman/grammar.lark b/timefhuman/grammar.lark
index dd15d4a..26c15db 100644
--- a/timefhuman/grammar.lark
+++ b/timefhuman/grammar.lark
@@ -7,40 +7,40 @@
// ----------------------
// Month names as a regex token, case-insensitive
-MONTHNAME: /(?i)(january|february|march|april|may|june|july|august|september|october|november|december|jan|feb|mar|apr|jun|jul|aug|sep|oct|nov|dec)/
+MONTHNAME: /(?i)(?<![a-z])(january|february|march|april|may|june|july|august|september|october|november|december|jan|feb|mar|apr|jun|jul|aug|sep|oct|nov|dec)(?![a-z])/
// For weekdays, also as a single regex token, case-insensitive
-WEEKDAY: /(?i)(monday|mon|tuesday|tues|tue|tu|wednesday|wed|thursday|thurs|thur|thu|friday|fri|saturday|sat|sunday|sun)/
+WEEKDAY: /(?i)(?<![a-z])(monday|mon|tuesday|tues|tue|tu|wednesday|wed|thursday|thurs|thur|thu|friday|fri|saturday|sat|sunday|sun)(?![a-z])/
// Meridiem token (am/pm, with optional dots)
-MERIDIEM: /(?i)([ap](\.?m\.?)?)/
+MERIDIEM: /(?i)(?<![a-z])([ap](\.?m\.?)?)(?![a-z])/
// Datename token specifies only day
-DATENAME: /(?i)(today|tomorrow|tmw|yesterday)/
+DATENAME: /(?i)(?<![a-z])(today|tomorrow|tmw|yesterday)(?![a-z])/
// Timename token specifies only time
-TIMENAME: /(?i)(noon|midday|midnight|morning|afternoon|evening|night)/
+TIMENAME: /(?i)(?<![a-z])(noon|midday|midnight|morning|afternoon|evening|night)(?![a-z])/
// Datetimename token specifies date and time
-DATETIMENAME: /(?i)(tonight)/
+DATETIMENAME: /(?i)(?<![a-z])(tonight)(?![a-z])/
// Duration unit (minutes, hours, days, etc.)
-DURATION_UNIT: /(?i)(seconds|second|secs|sec|minutes|mins|min|hours|hour|hrs|hr|h|days|day|weeks|week|wks|wk|months|month|mos|years|year)/
-DURATION_UNIT_LETTER: /(?i)(s|m|h|d|w|mo|y)(?![a-z])/
+DURATION_UNIT: /(?i)(?<![a-z])(seconds|second|secs|sec|minutes|mins|min|hours|hour|hrs|hr|h|days|day|weeks|week|wks|wk|months|month|mos|years|year)(?![a-z])/
+DURATION_UNIT_LETTER: /(?i)(?<![a-z])(s|m|h|d|w|mo|y)(?![a-z])/
// Duration number (digits like "1", or words like "an", "a", "one", "two", etc.)
-DURATION_NUMBER: /(?i)(an|a|one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve|thirteen|fourteen|fifteen|sixteen|seventeen|eighteen|nineteen|twenty|thirty|forty|fifty|sixty|seventy|eighty|ninety)/
+DURATION_NUMBER: /(?i)(?<![a-z])(an|a|one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve|thirteen|fourteen|fifteen|sixteen|seventeen|eighteen|nineteen|twenty|thirty|forty|fifty|sixty|seventy|eighty|ninety)(?![a-z])/
// Day suffix (th, rd, st, nd)
-DAY_SUFFIX: /(?i)(th|rd|st|nd)/
+DAY_SUFFIX: /(?i)(?<![a-z])(th|rd|st|nd)(?![a-z])/
FLOAT_NUMBER: /((\d+\.\d*|\.\d+)(e[-+]?\d+)?|\d+(e[-+]?\d+))/i // from lark
-TIMEZONE: /(?i)((TIMEZONE_MAPPING))/
+TIMEZONE: /(?i)(?<![a-z])((TIMEZONE_MAPPING))(?![a-z])/
-MODIFIER: /(?i)(next|last|this|upcoming|previous|past)/
+MODIFIER: /(?i)(?<![a-z])(next|last|this|upcoming|previous|past)(?![a-z])/
-POSITION: /(?i)(first|second|third|fourth|last)/
+POSITION: /(?i)(?<![a-z])(first|second|third|fourth|last)(?![a-z])/
// ----------------------
// PARSER RULES
|