|Deterministic Finite Automata: Sub-element captures email@example.com (Alexander Morou) (2009-09-02)|
|Re: Deterministic Finite Automata: Sub-element captures firstname.lastname@example.org (Russ Cox) (2009-09-02)|
|Re: Deterministic Finite Automata: Sub-element captures Danny.Dube@ift.ulaval.ca (2009-09-12)|
|From:||Alexander Morou <email@example.com>|
|Date:||Wed, 2 Sep 2009 08:45:22 -0500|
|Keywords:||DFA, theory, question|
|Posted-Date:||02 Sep 2009 23:39:46 EDT|
I'm curious about regular expression-styled deterministic state
machines, and the groundwork that would be necessary for obtaining
the explicit captures from the regular expression.
Originally, in the project I'm working on, the tokens came in two
varieties: Captures and Enumerations.
Captures were simply a literal capture of the characters that made up
the string that matched; they were simple recognizers.
Enumerators were a simple series of named literals which were useful
for categorizing multiple simple tokens under a common name (example:
keywords); enumerators were transducer type state machines.
I finally produced a nearly complete lexer and integrated the stream
state machine, and realized that I had a transducer state machine of
the language (and could therefore verify if a string was at least
valid), but I needed to properly work out how the functional aspects
of a capturing state machine worked before I could build the final
parse graph of a pass over a string from that language.
Let's say you have a token called number:
@'U':Unsigned; @'L':Long;? |
@'U':Unsigned; @'L':Long;? |
@'L':Long; @'U':Unsigned;? |
Where all literals are in single or double quotes, '@' before a
literal means case insensitivity. When an alternation is used, if
two values on either side of the alternation are named the same, they
carry the same identity. For explicit captures within a DFA system,
would the mechanism operate via denoting the start and end of a given
capture's identity; setting/clearing the associated flags to the
capture as its start and end states are entered? Would repetition on
groups increase the rank of all elements, such that were there:
'ACapture' would carry a rank of two (or one, if the desired capture
type for 'ACapture' is a string vs. char). Greater ranks determine
whether the item's capture is cleared upon entering the states or
whether an element is simply added to the list upon entering its exit
The reason I'm curious about such things is the project I'm working
on doesn't have blocks defined which state what to do when a capture
is encountered, so there's a certain level of work I have to do which
I might not otherwise have to. I figure that recognizing 'what' and
'when' is important even if there were match code associated to the
I'm also in the process of rewriting the lexer state machine builder,
so while I'm solving this problem, I want to solve it in both places
instead of just one.
Am I even going in the right direction if I'm interested in capturing
the sub-elements of a token or production using a deterministic state
Alexander [Allen C. Copeland Jr.] Morou
PS: Is Regular Language more appropriate to use than Regular
Return to the
Search the comp.compilers archives again.