Skip to content

Whitespace issue in parser #95

@dcastro

Description

@dcastro

Clarification and motivation

At the moment, the parser only recognizes time references if:

  • they're immediately at the beginning of the message: "9am"
  • or after a space: "I can't go today, let's try 9am tomorrow instead"

This is implemented here:

tzbot/src/TzBot/Parser.hs

Lines 274 to 275 in 0f58a50

-- time reference can be either at the beginning or after a space
. (Whitespace :)

_ <- space

tzbot/src/TzBot/Parser.hs

Lines 339 to 340 in 0f58a50

-- no space here before `timeRefGroupParser` requires a space before the contents
secondGroup <- timeRefGroupParser

The rationale is to avoid parsing things like "The product ID is AEH9AM" as "9AM".

However, there can be situations where a legitimate time reference is not actually preceded by a space:

>>> parseTimeRefs "How about Mike's suggestion (9am tomorrow)?"
[]

We should be able to parse these.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions