parsetree.h 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772
  1. /*
  2. * Copyright 2001-2006 Adrian Thurston <thurston@complang.org>
  3. */
  4. /* This file is part of Ragel.
  5. *
  6. * Ragel is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * Ragel is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with Ragel; if not, write to the Free Software
  18. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  19. */
  20. #ifndef _PARSETREE_H
  21. #define _PARSETREE_H
  22. #include "ragel.h"
  23. #include "avlmap.h"
  24. #include "bstmap.h"
  25. #include "vector.h"
  26. #include "dlist.h"
  27. struct NameInst;
  28. /* Types of builtin machines. */
  29. enum BuiltinMachine
  30. {
  31. BT_Any,
  32. BT_Ascii,
  33. BT_Extend,
  34. BT_Alpha,
  35. BT_Digit,
  36. BT_Alnum,
  37. BT_Lower,
  38. BT_Upper,
  39. BT_Cntrl,
  40. BT_Graph,
  41. BT_Print,
  42. BT_Punct,
  43. BT_Space,
  44. BT_Xdigit,
  45. BT_Lambda,
  46. BT_Empty
  47. };
  48. struct ParseData;
  49. /* Leaf type. */
  50. struct Literal;
  51. /* Tree nodes. */
  52. struct Term;
  53. struct FactorWithAug;
  54. struct FactorWithRep;
  55. struct FactorWithNeg;
  56. struct Factor;
  57. struct Expression;
  58. struct Join;
  59. struct MachineDef;
  60. struct LongestMatch;
  61. struct LongestMatchPart;
  62. struct LmPartList;
  63. struct Range;
  64. struct LengthDef;
  65. /* Type of augmentation. Describes locations in the machine. */
  66. enum AugType
  67. {
  68. /* Transition actions/priorities. */
  69. at_start,
  70. at_all,
  71. at_finish,
  72. at_leave,
  73. /* Global error actions. */
  74. at_start_gbl_error,
  75. at_all_gbl_error,
  76. at_final_gbl_error,
  77. at_not_start_gbl_error,
  78. at_not_final_gbl_error,
  79. at_middle_gbl_error,
  80. /* Local error actions. */
  81. at_start_local_error,
  82. at_all_local_error,
  83. at_final_local_error,
  84. at_not_start_local_error,
  85. at_not_final_local_error,
  86. at_middle_local_error,
  87. /* To State Action embedding. */
  88. at_start_to_state,
  89. at_all_to_state,
  90. at_final_to_state,
  91. at_not_start_to_state,
  92. at_not_final_to_state,
  93. at_middle_to_state,
  94. /* From State Action embedding. */
  95. at_start_from_state,
  96. at_all_from_state,
  97. at_final_from_state,
  98. at_not_start_from_state,
  99. at_not_final_from_state,
  100. at_middle_from_state,
  101. /* EOF Action embedding. */
  102. at_start_eof,
  103. at_all_eof,
  104. at_final_eof,
  105. at_not_start_eof,
  106. at_not_final_eof,
  107. at_middle_eof
  108. };
  109. /* IMPORTANT: These must follow the same order as the state augs in AugType
  110. * since we will be using this to compose AugType. */
  111. enum StateAugType
  112. {
  113. sat_start = 0,
  114. sat_all,
  115. sat_final,
  116. sat_not_start,
  117. sat_not_final,
  118. sat_middle
  119. };
  120. struct Action;
  121. struct PriorDesc;
  122. struct RegExpr;
  123. struct ReItem;
  124. struct ReOrBlock;
  125. struct ReOrItem;
  126. struct ExplicitMachine;
  127. struct InlineItem;
  128. struct InlineList;
  129. /* Reference to a named state. */
  130. typedef Vector<char*> NameRef;
  131. typedef Vector<NameRef*> NameRefList;
  132. typedef Vector<NameInst*> NameTargList;
  133. /* Structure for storing location of epsilon transitons. */
  134. struct EpsilonLink
  135. {
  136. EpsilonLink( const InputLoc &loc, NameRef &target )
  137. : loc(loc), target(target) { }
  138. InputLoc loc;
  139. NameRef target;
  140. };
  141. struct Label
  142. {
  143. Label( const InputLoc &loc, char *data )
  144. : loc(loc), data(data) { }
  145. InputLoc loc;
  146. char *data;
  147. };
  148. /* Structrue represents an action assigned to some FactorWithAug node. The
  149. * factor with aug will keep an array of these. */
  150. struct ParserAction
  151. {
  152. ParserAction( const InputLoc &loc, AugType type, int localErrKey, Action *action )
  153. : loc(loc), type(type), localErrKey(localErrKey), action(action) { }
  154. InputLoc loc;
  155. AugType type;
  156. int localErrKey;
  157. Action *action;
  158. };
  159. struct ConditionTest
  160. {
  161. ConditionTest( const InputLoc &loc, AugType type, Action *action, bool sense ) :
  162. loc(loc), type(type), action(action), sense(sense) { }
  163. InputLoc loc;
  164. AugType type;
  165. Action *action;
  166. bool sense;
  167. };
  168. struct Token
  169. {
  170. char *data;
  171. int length;
  172. InputLoc loc;
  173. void append( const Token &other );
  174. void set( const char *str, int len );
  175. };
  176. char *prepareLitString( const InputLoc &loc, const char *src, long length,
  177. long &resLen, bool &caseInsensitive );
  178. /* Store the value and type of a priority augmentation. */
  179. struct PriorityAug
  180. {
  181. PriorityAug( AugType type, int priorKey, int priorValue ) :
  182. type(type), priorKey(priorKey), priorValue(priorValue) { }
  183. AugType type;
  184. int priorKey;
  185. int priorValue;
  186. };
  187. /*
  188. * A Variable Definition
  189. */
  190. struct VarDef
  191. {
  192. VarDef( const char *name, MachineDef *machineDef )
  193. : name(name), machineDef(machineDef), isExport(false) { }
  194. /* Parse tree traversal. */
  195. FsmAp *walk( ParseData *pd );
  196. void makeNameTree( const InputLoc &loc, ParseData *pd );
  197. void resolveNameRefs( ParseData *pd );
  198. const char *name;
  199. MachineDef *machineDef;
  200. bool isExport;
  201. };
  202. /*
  203. * LongestMatch
  204. *
  205. * Wherever possible the item match will execute on the character. If not
  206. * possible the item match will execute on a lookahead character and either
  207. * hold the current char (if one away) or backup.
  208. *
  209. * How to handle the problem of backing up over a buffer break?
  210. *
  211. * Don't want to use pending out transitions for embedding item match because
  212. * the role of item match action is different: it may sometimes match on the
  213. * final transition, or may match on a lookahead character.
  214. *
  215. * Don't want to invent a new operator just for this. So just trail action
  216. * after machine, this means we can only use literal actions.
  217. *
  218. * The item action may
  219. *
  220. * What states of the machine will be final. The item actions that wrap around
  221. * on the last character will go straight to the start state.
  222. *
  223. * Some transitions will be lookahead transitions, they will hold the current
  224. * character. Crossing them with regular transitions must be restricted
  225. * because it does not make sense. The transition cannot simultaneously hold
  226. * and consume the current character.
  227. */
  228. struct LongestMatchPart
  229. {
  230. LongestMatchPart( Join *join, Action *action,
  231. InputLoc &semiLoc, int longestMatchId )
  232. :
  233. join(join), action(action), semiLoc(semiLoc),
  234. longestMatchId(longestMatchId), inLmSelect(false) { }
  235. InputLoc getLoc();
  236. Join *join;
  237. Action *action;
  238. InputLoc semiLoc;
  239. Action *setActId;
  240. Action *actOnLast;
  241. Action *actOnNext;
  242. Action *actLagBehind;
  243. int longestMatchId;
  244. bool inLmSelect;
  245. LongestMatch *longestMatch;
  246. LongestMatchPart *prev, *next;
  247. };
  248. /* Declare a new type so that ptreetypes.h need not include dlist.h. */
  249. struct LmPartList : DList<LongestMatchPart> {};
  250. struct LongestMatch
  251. {
  252. /* Construct with a list of joins */
  253. LongestMatch( const InputLoc &loc, LmPartList *longestMatchList ) :
  254. loc(loc), longestMatchList(longestMatchList), name(0),
  255. lmSwitchHandlesError(false) { }
  256. /* Tree traversal. */
  257. FsmAp *walk( ParseData *pd );
  258. void makeNameTree( ParseData *pd );
  259. void resolveNameRefs( ParseData *pd );
  260. void transferScannerLeavingActions( FsmAp *graph );
  261. void runLongestMatch( ParseData *pd, FsmAp *graph );
  262. Action *newAction( ParseData *pd, const InputLoc &loc, const char *name,
  263. InlineList *inlineList );
  264. void makeActions( ParseData *pd );
  265. void findName( ParseData *pd );
  266. void restart( FsmAp *graph, TransAp *trans );
  267. InputLoc loc;
  268. LmPartList *longestMatchList;
  269. const char *name;
  270. Action *lmActSelect;
  271. bool lmSwitchHandlesError;
  272. LongestMatch *next, *prev;
  273. };
  274. /* List of Expressions. */
  275. typedef DList<Expression> ExprList;
  276. struct MachineDef
  277. {
  278. enum Type {
  279. JoinType,
  280. LongestMatchType,
  281. LengthDefType
  282. };
  283. MachineDef( Join *join )
  284. : join(join), longestMatch(0), lengthDef(0), type(JoinType) {}
  285. MachineDef( LongestMatch *longestMatch )
  286. : join(0), longestMatch(longestMatch), lengthDef(0), type(LongestMatchType) {}
  287. MachineDef( LengthDef *lengthDef )
  288. : join(0), longestMatch(0), lengthDef(lengthDef), type(LengthDefType) {}
  289. FsmAp *walk( ParseData *pd );
  290. void makeNameTree( ParseData *pd );
  291. void resolveNameRefs( ParseData *pd );
  292. Join *join;
  293. LongestMatch *longestMatch;
  294. LengthDef *lengthDef;
  295. Type type;
  296. };
  297. /*
  298. * Join
  299. */
  300. struct Join
  301. {
  302. /* Construct with the first expression. */
  303. Join( Expression *expr );
  304. Join( const InputLoc &loc, Expression *expr );
  305. /* Tree traversal. */
  306. FsmAp *walk( ParseData *pd );
  307. FsmAp *walkJoin( ParseData *pd );
  308. void makeNameTree( ParseData *pd );
  309. void resolveNameRefs( ParseData *pd );
  310. /* Data. */
  311. InputLoc loc;
  312. ExprList exprList;
  313. };
  314. /*
  315. * Expression
  316. */
  317. struct Expression
  318. {
  319. enum Type {
  320. OrType,
  321. IntersectType,
  322. SubtractType,
  323. StrongSubtractType,
  324. TermType,
  325. BuiltinType
  326. };
  327. /* Construct with an expression on the left and a term on the right. */
  328. Expression( Expression *expression, Term *term, Type type ) :
  329. expression(expression), term(term),
  330. type(type), prev(this), next(this) { }
  331. /* Construct with only a term. */
  332. Expression( Term *term ) :
  333. expression(0), term(term),
  334. type(TermType) , prev(this), next(this) { }
  335. /* Construct with a builtin type. */
  336. Expression( BuiltinMachine builtin ) :
  337. expression(0), term(0), builtin(builtin),
  338. type(BuiltinType), prev(this), next(this) { }
  339. ~Expression();
  340. /* Tree traversal. */
  341. FsmAp *walk( ParseData *pd, bool lastInSeq = true );
  342. void makeNameTree( ParseData *pd );
  343. void resolveNameRefs( ParseData *pd );
  344. /* Node data. */
  345. Expression *expression;
  346. Term *term;
  347. BuiltinMachine builtin;
  348. Type type;
  349. Expression *prev, *next;
  350. };
  351. /*
  352. * Term
  353. */
  354. struct Term
  355. {
  356. enum Type {
  357. ConcatType,
  358. RightStartType,
  359. RightFinishType,
  360. LeftType,
  361. FactorWithAugType
  362. };
  363. Term( Term *term, FactorWithAug *factorWithAug ) :
  364. term(term), factorWithAug(factorWithAug), type(ConcatType) { }
  365. Term( Term *term, FactorWithAug *factorWithAug, Type type ) :
  366. term(term), factorWithAug(factorWithAug), type(type) { }
  367. Term( FactorWithAug *factorWithAug ) :
  368. term(0), factorWithAug(factorWithAug), type(FactorWithAugType) { }
  369. ~Term();
  370. FsmAp *walk( ParseData *pd, bool lastInSeq = true );
  371. void makeNameTree( ParseData *pd );
  372. void resolveNameRefs( ParseData *pd );
  373. Term *term;
  374. FactorWithAug *factorWithAug;
  375. Type type;
  376. /* Priority descriptor for RightFinish type. */
  377. PriorDesc priorDescs[2];
  378. };
  379. /* Third level of precedence. Augmenting nodes with actions and priorities. */
  380. struct FactorWithAug
  381. {
  382. FactorWithAug( FactorWithRep *factorWithRep ) :
  383. priorDescs(0), factorWithRep(factorWithRep) { }
  384. ~FactorWithAug();
  385. /* Tree traversal. */
  386. FsmAp *walk( ParseData *pd );
  387. void makeNameTree( ParseData *pd );
  388. void resolveNameRefs( ParseData *pd );
  389. void assignActions( ParseData *pd, FsmAp *graph, int *actionOrd );
  390. void assignPriorities( FsmAp *graph, int *priorOrd );
  391. void assignConditions( FsmAp *graph );
  392. /* Actions and priorities assigned to the factor node. */
  393. Vector<ParserAction> actions;
  394. Vector<PriorityAug> priorityAugs;
  395. PriorDesc *priorDescs;
  396. Vector<Label> labels;
  397. Vector<EpsilonLink> epsilonLinks;
  398. Vector<ConditionTest> conditions;
  399. FactorWithRep *factorWithRep;
  400. };
  401. /* Fourth level of precedence. Trailing unary operators. Provide kleen star,
  402. * optional and plus. */
  403. struct FactorWithRep
  404. {
  405. enum Type {
  406. StarType,
  407. StarStarType,
  408. OptionalType,
  409. PlusType,
  410. ExactType,
  411. MaxType,
  412. MinType,
  413. RangeType,
  414. FactorWithNegType
  415. };
  416. FactorWithRep( const InputLoc &loc, FactorWithRep *factorWithRep,
  417. int lowerRep, int upperRep, Type type ) :
  418. loc(loc), factorWithRep(factorWithRep),
  419. factorWithNeg(0), lowerRep(lowerRep),
  420. upperRep(upperRep), type(type) { }
  421. FactorWithRep( FactorWithNeg *factorWithNeg )
  422. : factorWithNeg(factorWithNeg), type(FactorWithNegType) { }
  423. ~FactorWithRep();
  424. /* Tree traversal. */
  425. FsmAp *walk( ParseData *pd );
  426. void makeNameTree( ParseData *pd );
  427. void resolveNameRefs( ParseData *pd );
  428. InputLoc loc;
  429. FactorWithRep *factorWithRep;
  430. FactorWithNeg *factorWithNeg;
  431. int lowerRep, upperRep;
  432. Type type;
  433. /* Priority descriptor for StarStar type. */
  434. PriorDesc priorDescs[2];
  435. };
  436. /* Fifth level of precedence. Provides Negation. */
  437. struct FactorWithNeg
  438. {
  439. enum Type {
  440. NegateType,
  441. CharNegateType,
  442. FactorType
  443. };
  444. FactorWithNeg( const InputLoc &loc, FactorWithNeg *factorWithNeg, Type type) :
  445. loc(loc), factorWithNeg(factorWithNeg), factor(0), type(type) { }
  446. FactorWithNeg( Factor *factor ) :
  447. factorWithNeg(0), factor(factor), type(FactorType) { }
  448. ~FactorWithNeg();
  449. /* Tree traversal. */
  450. FsmAp *walk( ParseData *pd );
  451. void makeNameTree( ParseData *pd );
  452. void resolveNameRefs( ParseData *pd );
  453. InputLoc loc;
  454. FactorWithNeg *factorWithNeg;
  455. Factor *factor;
  456. Type type;
  457. };
  458. /*
  459. * Factor
  460. */
  461. struct Factor
  462. {
  463. /* Language elements a factor node can be. */
  464. enum Type {
  465. LiteralType,
  466. RangeType,
  467. OrExprType,
  468. RegExprType,
  469. ReferenceType,
  470. ParenType,
  471. LongestMatchType,
  472. };
  473. /* Construct with a literal fsm. */
  474. Factor( Literal *literal ) :
  475. literal(literal), type(LiteralType) { }
  476. /* Construct with a range. */
  477. Factor( Range *range ) :
  478. range(range), type(RangeType) { }
  479. /* Construct with the or part of a regular expression. */
  480. Factor( ReItem *reItem ) :
  481. reItem(reItem), type(OrExprType) { }
  482. /* Construct with a regular expression. */
  483. Factor( RegExpr *regExpr ) :
  484. regExpr(regExpr), type(RegExprType) { }
  485. /* Construct with a reference to a var def. */
  486. Factor( const InputLoc &loc, VarDef *varDef ) :
  487. loc(loc), varDef(varDef), type(ReferenceType) {}
  488. /* Construct with a parenthesized join. */
  489. Factor( Join *join ) :
  490. join(join), type(ParenType) {}
  491. /* Construct with a longest match operator. */
  492. Factor( LongestMatch *longestMatch ) :
  493. longestMatch(longestMatch), type(LongestMatchType) {}
  494. /* Cleanup. */
  495. ~Factor();
  496. /* Tree traversal. */
  497. FsmAp *walk( ParseData *pd );
  498. void makeNameTree( ParseData *pd );
  499. void resolveNameRefs( ParseData *pd );
  500. InputLoc loc;
  501. Literal *literal;
  502. Range *range;
  503. ReItem *reItem;
  504. RegExpr *regExpr;
  505. VarDef *varDef;
  506. Join *join;
  507. LongestMatch *longestMatch;
  508. int lower, upper;
  509. Type type;
  510. };
  511. /* A range machine. Only ever composed of two literals. */
  512. struct Range
  513. {
  514. Range( Literal *lowerLit, Literal *upperLit )
  515. : lowerLit(lowerLit), upperLit(upperLit) { }
  516. ~Range();
  517. FsmAp *walk( ParseData *pd );
  518. Literal *lowerLit;
  519. Literal *upperLit;
  520. };
  521. /* Some literal machine. Can be a number or literal string. */
  522. struct Literal
  523. {
  524. enum LiteralType { Number, LitString };
  525. Literal( const Token &token, LiteralType type )
  526. : token(token), type(type) { }
  527. FsmAp *walk( ParseData *pd );
  528. Token token;
  529. LiteralType type;
  530. };
  531. /* Regular expression. */
  532. struct RegExpr
  533. {
  534. enum RegExpType { RecurseItem, Empty };
  535. /* Constructors. */
  536. RegExpr() :
  537. type(Empty), caseInsensitive(false) { }
  538. RegExpr(RegExpr *regExpr, ReItem *item) :
  539. regExpr(regExpr), item(item),
  540. type(RecurseItem), caseInsensitive(false) { }
  541. ~RegExpr();
  542. FsmAp *walk( ParseData *pd, RegExpr *rootRegex );
  543. RegExpr *regExpr;
  544. ReItem *item;
  545. RegExpType type;
  546. bool caseInsensitive;
  547. };
  548. /* An item in a regular expression. */
  549. struct ReItem
  550. {
  551. enum ReItemType { Data, Dot, OrBlock, NegOrBlock };
  552. ReItem( const InputLoc &loc, const Token &token )
  553. : loc(loc), token(token), star(false), type(Data) { }
  554. ReItem( const InputLoc &loc, ReItemType type )
  555. : loc(loc), star(false), type(type) { }
  556. ReItem( const InputLoc &loc, ReOrBlock *orBlock, ReItemType type )
  557. : loc(loc), orBlock(orBlock), star(false), type(type) { }
  558. ~ReItem();
  559. FsmAp *walk( ParseData *pd, RegExpr *rootRegex );
  560. InputLoc loc;
  561. Token token;
  562. ReOrBlock *orBlock;
  563. bool star;
  564. ReItemType type;
  565. };
  566. /* An or block item. */
  567. struct ReOrBlock
  568. {
  569. enum ReOrBlockType { RecurseItem, Empty };
  570. /* Constructors. */
  571. ReOrBlock()
  572. : type(Empty) { }
  573. ReOrBlock(ReOrBlock *orBlock, ReOrItem *item)
  574. : orBlock(orBlock), item(item), type(RecurseItem) { }
  575. ~ReOrBlock();
  576. FsmAp *walk( ParseData *pd, RegExpr *rootRegex );
  577. ReOrBlock *orBlock;
  578. ReOrItem *item;
  579. ReOrBlockType type;
  580. };
  581. /* An item in an or block. */
  582. struct ReOrItem
  583. {
  584. enum ReOrItemType { Data, Range };
  585. ReOrItem( const InputLoc &loc, const Token &token )
  586. : loc(loc), token(token), type(Data) {}
  587. ReOrItem( const InputLoc &loc, char lower, char upper )
  588. : loc(loc), lower(lower), upper(upper), type(Range) { }
  589. FsmAp *walk( ParseData *pd, RegExpr *rootRegex );
  590. InputLoc loc;
  591. Token token;
  592. char lower;
  593. char upper;
  594. ReOrItemType type;
  595. };
  596. /*
  597. * Inline code tree
  598. */
  599. struct InlineList;
  600. struct InlineItem
  601. {
  602. enum Type
  603. {
  604. Text, Goto, Call, Next, GotoExpr, CallExpr, NextExpr, Ret, PChar,
  605. Char, Hold, Curs, Targs, Entry, Exec, LmSwitch, LmSetActId,
  606. LmSetTokEnd, LmOnLast, LmOnNext, LmOnLagBehind, LmInitAct,
  607. LmInitTokStart, LmSetTokStart, Break
  608. };
  609. InlineItem( const InputLoc &loc, char *data, Type type ) :
  610. loc(loc), data(data), nameRef(0), children(0), type(type) { }
  611. InlineItem( const InputLoc &loc, NameRef *nameRef, Type type ) :
  612. loc(loc), data(0), nameRef(nameRef), children(0), type(type) { }
  613. InlineItem( const InputLoc &loc, LongestMatch *longestMatch,
  614. LongestMatchPart *longestMatchPart, Type type ) : loc(loc), data(0),
  615. nameRef(0), children(0), longestMatch(longestMatch),
  616. longestMatchPart(longestMatchPart), type(type) { }
  617. InlineItem( const InputLoc &loc, NameInst *nameTarg, Type type ) :
  618. loc(loc), data(0), nameRef(0), nameTarg(nameTarg), children(0),
  619. type(type) { }
  620. InlineItem( const InputLoc &loc, Type type ) :
  621. loc(loc), data(0), nameRef(0), children(0), type(type) { }
  622. InputLoc loc;
  623. char *data;
  624. NameRef *nameRef;
  625. NameInst *nameTarg;
  626. InlineList *children;
  627. LongestMatch *longestMatch;
  628. LongestMatchPart *longestMatchPart;
  629. Type type;
  630. InlineItem *prev, *next;
  631. };
  632. /* Normally this would be atypedef, but that would entail including DList from
  633. * ptreetypes, which should be just typedef forwards. */
  634. struct InlineList : public DList<InlineItem> { };
  635. #endif