ppfsm.h revision 3f54fd611f536639ec30dd53c48e5ec1897cc7d9
57221209d11b05aa0373cc3892d5df89ba96ebf9Christian Maeder/***********************************************************************
53bd0c89aa4743dc41a6394db5a90717c1ca4517Liam O'Reilly* This software is part of the ast package *
53bd0c89aa4743dc41a6394db5a90717c1ca4517Liam O'Reilly* Copyright (c) 1986-2011 AT&T Intellectual Property *
53bd0c89aa4743dc41a6394db5a90717c1ca4517Liam O'Reilly* and is licensed under the *
98890889ffb2e8f6f722b00e265a211f13b5a861Corneliu-Claudiu Prodescu* Eclipse Public License, Version 1.0 *
53bd0c89aa4743dc41a6394db5a90717c1ca4517Liam O'Reilly* by AT&T Intellectual Property *
53bd0c89aa4743dc41a6394db5a90717c1ca4517Liam O'Reilly* A copy of the License is available at *
53bd0c89aa4743dc41a6394db5a90717c1ca4517Liam O'Reilly* http://www.eclipse.org/org/documents/epl-v10.html *
53bd0c89aa4743dc41a6394db5a90717c1ca4517Liam O'Reilly* (with md5 checksum b35adb5213ca9657e911e9befb180842) *
53bd0c89aa4743dc41a6394db5a90717c1ca4517Liam O'Reilly* Information and Software Systems Research *
53bd0c89aa4743dc41a6394db5a90717c1ca4517Liam O'Reilly* AT&T Research *
33bdce26495121cdbce30331ef90a1969126a840Liam O'Reilly* Florham Park NJ *
57221209d11b05aa0373cc3892d5df89ba96ebf9Christian Maeder* Glenn Fowler <gsf@research.att.com> *
66bc8d6e69cde43f1ccbeb76104cf7b8038acd6cChristian Maeder***********************************************************************/
33bdce26495121cdbce30331ef90a1969126a840Liam O'Reilly * Glenn Fowler
56899f6457976a2ee20f6a23f088cb5655b15715Liam O'Reilly * AT&T Research
a00461fcf7432205a79a0f12dbe6c1ebc58bc000Christian Maeder * preprocessor lexical analyzer definitions
648fe1220044aac847acbdfbc4155af5556063ebChristian Maeder#define BITNONTERM 7 /* bitsof(non-terminal-state) */
d5833d2ee7bafcbf2fdd2bdfd9a728c769b100c7Christian Maeder#define BITTERM 7 /* bitsof(terminal-state) */
7830e8fa7442fb7452af7ecdba102bc297ae367eChristian Maeder#define CODE(tok,act) ((((tok)-N_PP)<<(BITTERM+1))|(act))
fa373bc327620e08861294716b4454be8d25669fChristian Maeder#define NEXT(st) (((st)>>(BITTERM+1))&((1<<BITNONTERM)-1))
036ecbd8f721096321f47cf6a354a9d1bf3d032fChristian Maeder#define QUAL(st) (((st)<<(BITTERM+1))|(S_QUAL))
648fe1220044aac847acbdfbc4155af5556063ebChristian Maeder * NOTE: preserve the ranges
d5833d2ee7bafcbf2fdd2bdfd9a728c769b100c7Christian Maeder#define IDSTATE(x) (((x)>=0&&INQMACRO(fsm[x]))?QID:(x))
9aeda2b3ae8ce0b018955521e4ca835a8ba8a27bLiam O'Reilly#define INCOMMENT(p) ((p)>=fsm[COM2]&&(p)<=fsm[COM7])
9aeda2b3ae8ce0b018955521e4ca835a8ba8a27bLiam O'Reilly#define INCOMMENTXX(p) ((p)>=fsm[COM5]&&(p)<=fsm[COM7])
33bdce26495121cdbce30331ef90a1969126a840Liam O'Reilly#define INQMACRO(p) ((p)>=fsm[MAC0]&&(p)<=fsm[LIT0])
648fe1220044aac847acbdfbc4155af5556063ebChristian Maeder#define INTMACRO(p) ((p)>=fsm[NID]&&(p)<=fsm[LIT])
648fe1220044aac847acbdfbc4155af5556063ebChristian Maeder#define INQUOTE(p) ((p)>=fsm[LIT1]&&(p)<=fsm[LIT2])
33bdce26495121cdbce30331ef90a1969126a840Liam O'Reilly * proto non-terminal states
7830e8fa7442fb7452af7ecdba102bc297ae367eChristian Maeder * quick non-terminal states
648fe1220044aac847acbdfbc4155af5556063ebChristian Maeder * tokenize non-terminal states
fa373bc327620e08861294716b4454be8d25669fChristian Maeder * quick terminal states grouped together
fa373bc327620e08861294716b4454be8d25669fChristian Maeder * and the remaining terminal states
fa373bc327620e08861294716b4454be8d25669fChristian Maeder * the last terminal state (for tracing)
fa373bc327620e08861294716b4454be8d25669fChristian Maeder * pseudo terminal states
fa373bc327620e08861294716b4454be8d25669fChristian Maeder * common lex macros
56899f6457976a2ee20f6a23f088cb5655b15715Liam O'Reilly * NOTE: common local variable names assumed
7830e8fa7442fb7452af7ecdba102bc297ae367eChristian Maeder if ((c = GETCHR()) == EOB && pp.in->type == IN_FILE) \
7830e8fa7442fb7452af7ecdba102bc297ae367eChristian Maeder if (!INCOMMENT(rp) && !(pp.state & (NOTEXT|SKIPCONTROL))) \
7830e8fa7442fb7452af7ecdba102bc297ae367eChristian Maeder if ((pp.in->flags & IN_flush) && pp.level == 1 && !INMACRO(rp) && (!pp.comment || !INCOMMENT(rp)) && (c = op - pp.outbuf) > 0 && *(op - 1) == '\n') \
ace03c3051e5c5144e43ae78cae73f6a29dde6d5Christian Maeder debug((-7, "POP in=%s next=%s state=%s", ppinstr(cur), pptokchr(*prv->nextchr), pplexstr(INDEX(rp)))); \
7830e8fa7442fb7452af7ecdba102bc297ae367eChristian Maeder * fsm implementaion globals
8e9c3881fb6e710b1e08bf5ac8ff9d393df2e74eChristian Maeder * first index is state, second is char, value is next state
8e9c3881fb6e710b1e08bf5ac8ff9d393df2e74eChristian Maeder * except for fsm[TERMINAL] where second is state+1 for EOF transition
a00461fcf7432205a79a0f12dbe6c1ebc58bc000Christian Maeder * the index is char, value is trigraph value for <?><?><char>, 0 if invalid
a00461fcf7432205a79a0f12dbe6c1ebc58bc000Christian Maederextern void refill(int);