[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 4/8] dfa: refactor common context computations
From: |
Jim Meyering |
Subject: |
Re: [PATCH 4/8] dfa: refactor common context computations |
Date: |
Sun, 22 Jan 2012 10:44:18 +0100 |
Paolo Bonzini wrote:
> * src/dfa.c (CTX_ANY, charclass_context, state_wanted_contexts): New.
> (dfaanalyze): Use state_wanted_contexts.
> (dfastate): Use charclass_context and state_wanted_contexts.
Nice factorization/clean-up.
> src/dfa.c | 75 ++++++++++++++++++++++++++++++++++++++----------------------
...
It'd be nice to add a brief comment here.
> +int
> +charclass_context(charclass c)
s/(/ (/
Oh. add "static", too.
> +{
> + int context = 0;
> + int j;
Please use "unsigned int" for j.
> + if (tstbit(eolbyte, c))
s/(e/ (e/
> + context |= CTX_NEWLINE;
> +
> + for (j = 0; j < CHARCLASS_INTS; ++j)
> + {
> + if (c[j] & letters[j])
> + context |= CTX_LETTER;
> + if (c[j] & ~(letters[j] | newline[j]))
> + context |= CTX_NONE;
> + }
> +
> + return context;
> +}
It'd be nice to add a comment here, too.
> +int state_wanted_contexts(position_set *s, int possible_contexts)
Add "static" and adjust formatting:
static int
state_wanted_contexts (position_set *s, int possible_contexts)
> +{
> + int wanted_context = 0;
> + int j;
Please use "unsigned int" for j.
> + for (j = 0; j < s->nelem; ++j)
> + {
> + if ((possible_contexts & CTX_NEWLINE)
> + && PREV_NEWLINE_DEPENDENT(s->elems[j].constraint))
> + wanted_context |= CTX_NEWLINE;
> + if ((possible_contexts & CTX_LETTER)
> + && PREV_LETTER_DEPENDENT(s->elems[j].constraint))
> + wanted_context |= CTX_LETTER;
> + }
> +
> + return wanted_context;
> +}
...
- [PATCH 8/8] dfa: merge calls to SUCCEEDS_IN_CONTEXT, (continued)
- [PATCH 8/8] dfa: merge calls to SUCCEEDS_IN_CONTEXT, Paolo Bonzini, 2012/01/20
- [PATCH 1/8] dfa: remove useless check, Paolo Bonzini, 2012/01/20
- [PATCH 2/8] dfa: introduce contexts for the values in d->success, Paolo Bonzini, 2012/01/20
- [PATCH 5/8] dfa: change meaning of a state context, Paolo Bonzini, 2012/01/20
- [PATCH 3/8] dfa: change newline/letter to a single context value, Paolo Bonzini, 2012/01/20
- [PATCH 6/8] dfa: do not use MATCHES_*_CONTEXT directly, Paolo Bonzini, 2012/01/20
- [PATCH 4/8] dfa: refactor common context computations, Paolo Bonzini, 2012/01/20
- Re: [PATCH 4/8] dfa: refactor common context computations,
Jim Meyering <=
- Re: [PATCH 0/8] fix problems with ^ and $ together with \< and \>, Paul Eggert, 2012/01/20