aboutsummaryrefslogtreecommitdiff
path: root/dtc
diff options
context:
space:
mode:
authorMarkus Armbruster <armbru@redhat.com>2018-08-31 09:58:38 +0200
committerMarkus Armbruster <armbru@redhat.com>2018-09-24 18:06:09 +0200
commitc0ee3afa7fa2547b5766dd25e52ced292c204d4e (patch)
treeed7c00a7a0a246f83c2242878bd5883def2e4e47 /dtc
parent852dfa76b85c5d23541377809aa4bcfb4fc037db (diff)
json: Make lexer's "character consumed" logic less confusing
The lexer uses macro TERMINAL_NEEDED_LOOKAHEAD() to decide whether a state transition consumes the input character. It returns true when the state transition is defined with the TERMINAL() macro. To detect that, it checks whether input '\0' would have resulted in the same state transition, and the new state is not IN_ERROR. Why does that even work? For all states, the new state on input '\0' is either IN_ERROR or defined with TERMINAL(). If the state transition equals the one we'd get for input '\0', it goes to IN_ERROR or to the argument of TERMINAL(). We never use TERMINAL(IN_ERROR), because it makes no sense. Thus, if it doesn't go to IN_ERROR, it must be defined with TERMINAL(). Since this isn't quite confusing enough, we negate the result to get @char_consumed, and ignore it when @flush is true. Instead of deriving the lookahead bit from the state transition, make it explicit. This is easier to understand, and a bit more flexible, too. Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Message-Id: <20180831075841.13363-4-armbru@redhat.com>
Diffstat (limited to 'dtc')
0 files changed, 0 insertions, 0 deletions