Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1345 lines
38 KiB

  1. /*****************************************************************************
  2. ** Microsoft LAN Manager
  3. ** Copyright(c) Microsoft Corp., 1987-1999
  4. *****************************************************************************/
  5. /*****************************************************************************
  6. File : acfgram.y
  7. Title : the acf grammar file
  8. Description : contains the syntactic and semantic handling of the
  9. : acf file
  10. History :
  11. 26-Dec-1990 VibhasC Started rewrite of acf
  12. *****************************************************************************/
  13. %{
  14. /****************************************************************************
  15. *** local defines
  16. ***************************************************************************/
  17. #define pascal
  18. #define FARDATA
  19. #define NEARDATA
  20. #define FARCODE
  21. #define NEARCODE
  22. #define NEARSWAP
  23. #define YYFARDATA
  24. #define PASCAL pascal
  25. #define CDECL
  26. #define VOID void
  27. #define CONST const
  28. #define GLOBAL
  29. #define YYSTYPE lextype_t
  30. #define YYNEAR NEARCODE
  31. #define YYPASCAL PASCAL
  32. #define YYPRINT printf
  33. #define YYSTATIC static
  34. #define YYCONST static const
  35. #define YYLEX yylex
  36. #define YYPARSER yyparse
  37. #define yyval yyacfval
  38. // enable compilation under /W4
  39. #pragma warning ( disable : 4514 4710 4244 4706 )
  40. #include "nulldefs.h"
  41. extern "C" {
  42. #include <stdio.h>
  43. #include <stdlib.h>
  44. #include <string.h>
  45. #include <ctype.h>
  46. #define yyparse yyacfparse
  47. int yyacfparse();
  48. }
  49. #include "allnodes.hxx"
  50. #include "lexutils.hxx"
  51. #include "gramutil.hxx"
  52. #include "filehndl.hxx"
  53. #include "control.hxx"
  54. #include "cmdana.hxx"
  55. extern "C" {
  56. #include "lex.h"
  57. }
  58. /****************************************************************************
  59. *** local defines contd..
  60. ***************************************************************************/
  61. #define PUSH_SYMBOL_TABLE(pName, Tag, pSymTbl) \
  62. { \
  63. pSymTbl = pBaseSymTbl; \
  64. SymKey SKey( pName, Tag ); \
  65. pSymTbl->EnterScope(SKey, &pSymTbl);\
  66. }
  67. #define POP_SYMBOL_TABLE( pSymTbl ) \
  68. pSymTbl->ExitScope(&pSymTbl)
  69. /****************************************************************************
  70. *** local data
  71. ***************************************************************************/
  72. node_proc * pAcfProc;
  73. int iParam;
  74. int cParams;
  75. node_interface * pCurInterfaceNode;
  76. /****************************************************************************
  77. *** extern procs
  78. ***************************************************************************/
  79. extern void yyunlex( token_t );
  80. extern char * GenTempName();
  81. extern STATUS_T GetBaseTypeNode(node_skl**,short,short,short, short);
  82. extern short CheckValidAllocate( char * );
  83. extern void SyntaxError( STATUS_T, short );
  84. extern short PossibleMissingToken( short, short );
  85. extern CMD_ARG * pCommand;
  86. /****************************************************************************
  87. *** local data
  88. ***************************************************************************/
  89. /****************************************************************************
  90. *** extern data
  91. ***************************************************************************/
  92. extern SymTable * pBaseSymTbl;
  93. extern NFA_INFO * pImportCntrl;
  94. extern PASS_2 * pPass2;
  95. %}
  96. %start AcfFile
  97. %token KWINTERFACE
  98. %token KWIMPORT
  99. %token KWIMPORTODLBASE
  100. %token KWCPPQUOTE
  101. %token KWCPRAGMA
  102. %token KWCPRAGMAPACK
  103. %token KWMPRAGMAIMPORT
  104. %token KWMPRAGMAECHO
  105. %token KWMPRAGMAIMPORTCLNTAUX
  106. %token KWMPRAGMAIMPORTSRVRAUX
  107. %token KWMIDLPRAGMA
  108. %token TYPENAME
  109. %token LIBNAME
  110. %token KWVOID
  111. %token KWUNSIGNED
  112. %token KWSIGNED
  113. %token KWFLOAT
  114. %token KWDOUBLE
  115. %token KWINT
  116. %token KWBYTE
  117. %token KWCHAR
  118. %token KWSMALL
  119. %token KWLONG
  120. %token KWSHORT
  121. %token KWHYPER
  122. %token KWINT32
  123. %token KWINT3264
  124. %token KWINT64
  125. %token KWINT128
  126. %token KWFLOAT80
  127. %token KWFLOAT128
  128. %token KWSTRUCT
  129. %token KWUNION
  130. %token KWENUM
  131. %token KWSHORTENUM
  132. %token KWLONGENUM
  133. %token KWCONST
  134. %token KWVOLATILE
  135. %token KW_C_INLINE
  136. %token KWTYPEDEF
  137. %token KWDECLGUID
  138. %token KWEXTERN
  139. %token KWSTATIC
  140. %token KWAUTO
  141. %token KWREGISTER
  142. %token KWERRORSTATUST
  143. %token KWBOOLEAN
  144. %token KWISOLATIN1
  145. %token KWPRIVATECHAR8
  146. %token KWISOMULTILINGUAL
  147. %token KWPRIVATECHAR16
  148. %token KWISOUCS
  149. %token KWPIPE
  150. %token KWSWITCH
  151. %token KWCASE
  152. %token KWDEFAULT
  153. %token KWUUID
  154. %token KWASYNCUUID
  155. %token KWVERSION
  156. %token KWSTRING
  157. %token KWBSTRING
  158. %token KWIN
  159. %token KWOUT
  160. %token KWPARTIALIGNORE
  161. %token KWIIDIS
  162. %token KWFIRSTIS
  163. %token KWLASTIS
  164. %token KWMAXIS
  165. %token KWMINIS
  166. %token KWLENGTHIS
  167. %token KWSIZEIS
  168. %token KWRANGE
  169. /* start of ODL key words */
  170. %token KWID
  171. %token KWHC /* helpcontext attribute */
  172. %token KWHSC /* helpstring context attribute */
  173. %token KWLCID
  174. %token KWDLLNAME
  175. %token KWHELPSTR
  176. %token KWHELPFILE
  177. %token KWHELPSTRINGDLL
  178. %token KWENTRY
  179. %token KWPROPGET
  180. %token KWPROPPUT
  181. %token KWPROPPUTREF
  182. %token KWOPTIONAL
  183. %token KWVARARG
  184. %token KWAPPOBJECT
  185. %token KWRESTRICTED
  186. %token KWPUBLIC
  187. %token KWREADONLY
  188. %token KWODL
  189. %token KWSOURCE
  190. %token KWBINDABLE
  191. %token KWREQUESTEDIT
  192. %token KWDISPLAYBIND
  193. %token KWDEFAULTBIND
  194. %token KWLICENSED
  195. %token KWPREDECLID
  196. %token KWHIDDEN
  197. %token KWRETVAL
  198. %token KWCONTROL
  199. %token KWDUAL
  200. %token KWPROXY
  201. %token KWNONEXTENSIBLE
  202. %token KWNONCREATABLE
  203. %token KWOLEAUTOMATION
  204. %token KWLIBRARY
  205. %token KWMODULE
  206. %token KWDISPINTERFACE
  207. %token KWCOCLASS
  208. %token KWMETHODS
  209. %token KWPROPERTIES
  210. %token KWIMPORTLIB
  211. %token KWFUNCDESCATTR
  212. %token KWIDLDESCATTR
  213. %token KWTYPEDESCATTR
  214. %token KWVARDESCATTR
  215. %token KWSAFEARRAY
  216. %token KWAGGREGATABLE
  217. %token KWUIDEFAULT
  218. %token KWNONBROWSABLE
  219. %token KWDEFAULTCOLLELEM
  220. %token KWDEFAULTVALUE
  221. %token KWCUSTOM
  222. %token KWDEFAULTVTABLE
  223. %token KWIMMEDIATEBIND
  224. %token KWUSESGETLASTERROR
  225. %token KWREPLACEABLE
  226. /* end of ODL key words */
  227. %token KWHANDLET /* Formerly RPCHNDL */
  228. %token KWHANDLE /* Formerly GEN_HNDL */
  229. %token KWCONTEXTHANDLE /* Aka LRPC_CTXT_HNDL */
  230. %token KWMSUNION
  231. %token KWMS_CONF_STRUCT
  232. %token KWENDPOINT
  233. %token KWDEFAULTPOINTER
  234. %token KWLOCAL
  235. %token KWSWITCHTYPE
  236. %token KWSWITCHIS
  237. %token KWTRANSMITAS
  238. %token KWWIREMARSHAL
  239. %token KWIGNORE
  240. %token KWREF
  241. %token KWUNIQUE
  242. %token KWPTR
  243. %token KWV1ARRAY
  244. %token KWV1STRUCT
  245. %token KWV1ENUM
  246. %token KWV1STRING
  247. %token KWIDEMPOTENT
  248. %token KWBROADCAST
  249. %token KWMAYBE
  250. %token KWASYNC
  251. %token KWINPUTSYNC
  252. %token KWCALLBACK
  253. %token KWALIGN
  254. %token KWUNALIGNED
  255. %token KWOPTIMIZE
  256. %token KWMESSAGE
  257. %token STRING
  258. %token WIDECHARACTERSTRING
  259. %token FLOATCONSTANT
  260. %token DOUBLECONSTANT
  261. %token KWTOKENNULL
  262. %token NUMERICCONSTANT
  263. %token NUMERICUCONSTANT
  264. %token NUMERICLONGCONSTANT
  265. %token NUMERICULONGCONSTANT
  266. %token HEXCONSTANT
  267. %token HEXUCONSTANT
  268. %token HEXLONGCONSTANT
  269. %token HEXULONGCONSTANT
  270. %token OCTALCONSTANT
  271. %token OCTALUCONSTANT
  272. %token OCTALLONGCONSTANT
  273. %token OCTALULONGCONSTANT
  274. %token CHARACTERCONSTANT
  275. %token WIDECHARACTERCONSTANT
  276. %token IDENTIFIER
  277. %token KWSIZEOF
  278. %token KWALIGNOF
  279. %token TOKENTRUE
  280. %token TOKENFALSE
  281. /* These are Microsoft C abominations */
  282. %token KWMSCDECLSPEC
  283. %token MSCEXPORT
  284. %token MSCFORTRAN
  285. %token MSCCDECL
  286. %token MSCSTDCALL
  287. %token MSCLOADDS
  288. %token MSCSAVEREGS
  289. %token MSCFASTCALL
  290. %token MSCSEGMENT
  291. %token MSCINTERRUPT
  292. %token MSCSELF
  293. %token MSCNEAR
  294. %token MSCFAR
  295. %token MSCUNALIGNED
  296. %token MSCHUGE
  297. %token MSCPTR32
  298. %token MSCPTR64
  299. %token MSCPASCAL
  300. %token MSCEMIT
  301. %token MSCASM
  302. %token MSCW64
  303. /* Microsoft proposed extentions to MIDL */
  304. %token KWNOCODE /* Allowed in .IDL in addition to .ACF */
  305. /* These are residual C tokens I'm not sure we should even allow */
  306. %token POINTSTO
  307. %token INCOP
  308. %token DECOP
  309. %token MULASSIGN
  310. %token DIVASSIGN
  311. %token MODASSIGN
  312. %token ADDASSIGN
  313. %token SUBASSIGN
  314. %token LEFTASSIGN
  315. %token RIGHTASSIGN
  316. %token ANDASSIGN
  317. %token XORASSIGN
  318. %token ORASSIGN
  319. %token DOTDOT
  320. %token LTEQ
  321. %token GTEQ
  322. %token NOTEQ
  323. %token LSHIFT
  324. %token RSHIFT
  325. %token ANDAND
  326. %token EQUALS
  327. %token OROR
  328. /* used by lex internally to signify "get another token" */
  329. %token NOTOKEN
  330. /* garbage token - should cause parse errors */
  331. %token GARBAGETOKEN
  332. /* OLE extensions */
  333. %token KWOBJECT
  334. /* Note that we're assuming that we get constants back and can check
  335. bounds (e.g. "are we integer") in the semantic actoins.
  336. */
  337. /*
  338. ACF - Specific Tokens
  339. */
  340. %token KWSHAPE
  341. %token KWBYTECOUNT
  342. %token KWIMPLICITHANDLE
  343. %token KWAUTOHANDLE
  344. %token KWEXPLICITHANDLE
  345. %token KWREPRESENTAS
  346. %token KWCALLAS
  347. %token KWCODE
  348. %token KWINLINE
  349. %token KWOUTOFLINE
  350. %token KWINTERPRET
  351. %token KWNOINTERPRET
  352. %token KWCOMMSTATUS
  353. %token KWFAULTSTATUS
  354. %token KWHEAP
  355. %token KWINCLUDE
  356. %token KWPOINTERSIZE
  357. %token KWOFFLINE
  358. %token KWALLOCATE
  359. %token KWENABLEALLOCATE
  360. %token KWMANUAL
  361. %token KWNOTIFY
  362. %token KWNOTIFYFLAG
  363. %token KWUSERMARSHAL
  364. %token KWENCODE
  365. %token KWDECODE
  366. %token KWSTRICTCONTEXTHANDLE
  367. %token KWNOSERIALIZE
  368. %token KWSERIALIZE
  369. %token KWCSCHAR
  370. %token KWCSDRTAG
  371. %token KWCSRTAG
  372. %token KWCSSTAG
  373. %token KWCSTAGRTN
  374. %token KWFORCEALLOCATE
  375. /* Currently Unsupported Tokens */
  376. %token KWBITSET
  377. %token UUIDTOKEN
  378. %token VERSIONTOKEN
  379. %token EOI
  380. %token LASTTOKEN
  381. /***************************************************************************
  382. * acf specific parse stack data types
  383. ***************************************************************************/
  384. %type <yy_short> AcfAllocationUnitList
  385. %type <yy_short> AcfAllocationUnit
  386. %type <yy_short> AcfBodyElement
  387. %type <yy_attr> AcfEnumSizeAttr
  388. %type <yy_attr> AcfHandleAttr
  389. %type <yy_graph> AcfHandleTypeSpec
  390. %type <yy_attr> AcfImplicitHandleSpec
  391. %type <yy_graph> AcfInclude
  392. %type <yy_graph> AcfIncludeList
  393. %type <yy_string> AcfIncludeName
  394. %type <yy_attr> AcfAttr
  395. %type <yy_attrlist> AcfAttrList
  396. %type <yy_attrlist> AcfAttrs
  397. %type <yy_string> AcfInterfaceName
  398. %type <yy_attr> AcfOpAttr
  399. %type <yy_attr> AcfOptimizationAttr
  400. %type <yy_attrlist> AcfOptionalAttrList
  401. %type <yy_attr> AcfParamAttr
  402. %type <yy_attr> AcfRepresentType
  403. %type <yy_attr> AcfUserMarshalType
  404. %type <yy_attr> AcfCallType
  405. %type <yy_graph> AcfType
  406. %type <yy_attr> AcfTypeAttr
  407. %type <yy_tnlist> AcfTypeNameList
  408. %type <yy_attr> AcfUnimplementedAttr
  409. %type <yy_modifiers> FuncModifier
  410. %type <yy_modifiers> FuncModifiers
  411. %type <yy_modifiers> OptFuncModifiers
  412. %type <yy_modifiers> MscDeclSpec
  413. %type <yy_modifiers> KWMSCDECLSPEC
  414. %type <yy_string> IDENTIFIER
  415. %type <yy_string> ImplicitHandleIDName
  416. %type <yy_numeric> NUMERICCONSTANT
  417. %type <yy_string> STRING
  418. %type <yy_graph> TYPENAME
  419. %%
  420. AcfFile:
  421. AcfInterfaceList EOI
  422. ;
  423. AcfInterfaceList:
  424. AcfInterfaceList AcfInterface
  425. {
  426. if( !pCommand->IsSwitchDefined( SWITCH_MS_EXT ) )
  427. {
  428. ParseError( MULTIPLE_INTF_NON_OSF, NULL );
  429. }
  430. }
  431. | AcfInterface
  432. ;
  433. AcfInterface:
  434. AcfInterfaceHeader '{' AcfOptionalInterfaceBody '}'
  435. | AcfInterfaceHeader ';'
  436. | AcfBodyElement
  437. ;
  438. AcfInterfaceHeader:
  439. AcfOptionalAttrList KWINTERFACE AcfInterfaceName
  440. {
  441. named_node * pNode;
  442. // the user MUST have defined the type.
  443. SymKey SKey( $3, NAME_DEF );
  444. //Search for an interface_reference node in the symbol table.
  445. pNode = pBaseSymTbl->SymSearch( SKey );
  446. if ( pNode )
  447. pNode = ( (node_interface_reference *)pNode )->GetRealInterface();
  448. //If the acf switch is specified and there is only one interface
  449. //in the IDL file, then tolerate mismatches in the interface name.
  450. if ( (!pNode) && pCommand->IsSwitchDefined( SWITCH_ACF ) )
  451. {
  452. node_file *pFileNode = pPass2->GetFileNode();
  453. node_interface *pFirst;
  454. pFirst = (node_interface *) pFileNode->GetFirstMember();
  455. if(pFirst && pFirst->GetSibling())
  456. pNode = 0;
  457. else
  458. pNode = pFirst;
  459. }
  460. if ( (!pNode) || ( !pNode->IsInterfaceOrObject() ) )
  461. {
  462. ParseError( ACF_INTERFACE_MISMATCH, $3 );
  463. returnflag = 1;
  464. return;
  465. }
  466. pCurInterfaceNode = (node_interface *)pNode;
  467. if( $1.NonNull() )
  468. {
  469. pCurInterfaceNode->AddAttributes( $1 );
  470. if ( pCurInterfaceNode->FInSummary( ATTR_ENCODE ) ||
  471. pCurInterfaceNode->FInSummary( ATTR_DECODE ) )
  472. {
  473. pCurInterfaceNode->SetPickleInterface();
  474. }
  475. }
  476. }
  477. ;
  478. AcfOptionalAttrList:
  479. AcfAttrList
  480. | /* Empty */
  481. {
  482. $$.MakeAttrList();
  483. }
  484. ;
  485. AcfAttrList:
  486. '[' AcfAttrs ']'
  487. {
  488. $$ = $2;
  489. }
  490. ;
  491. AcfAttrs:
  492. AcfAttrs ',' AcfAttr
  493. {
  494. ($$ = $1).SetPeer( $3 );
  495. }
  496. | AcfAttr
  497. {
  498. $$.MakeAttrList( $1 );
  499. }
  500. ;
  501. /*** Interface attributes ***/
  502. AcfAttr:
  503. AcfHandleAttr
  504. {
  505. $$ = $1;
  506. }
  507. | AcfTypeAttr
  508. {
  509. $$ = $1;
  510. }
  511. | AcfEnumSizeAttr
  512. {
  513. $$ = $1;
  514. }
  515. | AcfParamAttr
  516. {
  517. $$ = $1;
  518. }
  519. | AcfOpAttr
  520. {
  521. $$ = $1;
  522. }
  523. | AcfUnimplementedAttr
  524. {
  525. ParseError(IGNORE_UNIMPLEMENTED_ATTRIBUTE, ((node_base_attr *)$1)->GetNodeNameString());
  526. $$ = $1;
  527. }
  528. | AcfOptimizationAttr
  529. {
  530. $$ = $1;
  531. }
  532. ;
  533. AcfEnumSizeAttr:
  534. KWSHORTENUM
  535. {
  536. ParseError( IGNORE_UNIMPLEMENTED_ATTRIBUTE, "[short_enum]" );
  537. $$ = NULL;
  538. }
  539. | KWLONGENUM
  540. {
  541. ParseError( IGNORE_UNIMPLEMENTED_ATTRIBUTE, "[long_enum]" );
  542. $$ = NULL;
  543. }
  544. ;
  545. AcfOptimizationAttr:
  546. KWOPTIMIZE '(' STRING ')'
  547. {
  548. unsigned short OptFlags = OPTIMIZE_NONE;
  549. OPT_LEVEL_ENUM OptLevel;
  550. OptLevel = ParseAcfOptimizationAttr( $3, &OptFlags );
  551. $$ = new node_optimize( OptLevel, OptFlags );
  552. }
  553. ;
  554. AcfUnimplementedAttr:
  555. KWPOINTERSIZE '(' AcfPtrSize ')'
  556. {
  557. $$ = new acf_attr( ATTR_PTRSIZE );
  558. }
  559. ;
  560. /**** Implicit and Auto Handle ****/
  561. AcfHandleAttr:
  562. KWEXPLICITHANDLE
  563. {
  564. $$ = new acf_attr( ATTR_EXPLICIT );
  565. }
  566. | KWIMPLICITHANDLE '(' AcfImplicitHandleSpec ')'
  567. {
  568. $$ = $3;
  569. }
  570. | KWAUTOHANDLE
  571. {
  572. $$ = new acf_attr( ATTR_AUTO );
  573. }
  574. | KWHANDLE
  575. {
  576. $$ = new battr( ATTR_HANDLE );
  577. }
  578. | KWSTRICTCONTEXTHANDLE
  579. {
  580. $$ = new acf_attr( ATTR_STRICT_CONTEXT_HANDLE );
  581. }
  582. ;
  583. AcfImplicitHandleSpec:
  584. AcfOptionalAttrList AcfHandleTypeSpec ImplicitHandleIDName
  585. {
  586. node_id_fe * pId = new node_id_fe( $3 );
  587. // if he has specified the handle attribute, the type must have
  588. // the handle attribute too!
  589. if( $2 && ($2->NodeKind() == NODE_FORWARD ) )
  590. {
  591. ParseError( IMPLICIT_HDL_ASSUMED_GENERIC,
  592. ((node_forward *) $2)->GetSymName());
  593. }
  594. //
  595. // if the handle is a context handle type, disallow it. Do that only
  596. // if the current interface node is the base interface node.
  597. //
  598. pId->AddAttributes( $1 );
  599. // generate the new implicit handle attribute
  600. $$ = new node_implicit( $2, pId );
  601. }
  602. ;
  603. ImplicitHandleIDName:
  604. IDENTIFIER
  605. {
  606. $$ = $1;
  607. }
  608. | KWHANDLE
  609. {
  610. $$ = "handle";
  611. }
  612. ;
  613. AcfHandleTypeSpec:
  614. KWHANDLET
  615. {
  616. // return the base type node for handle_t
  617. GetBaseTypeNode( &($$),SIGN_UNDEF,SIZE_UNDEF,TYPE_HANDLE_T, 0 );
  618. }
  619. | TYPENAME
  620. | IDENTIFIER
  621. {
  622. SymKey SKey( $1, NAME_DEF );
  623. if( ($$ = pBaseSymTbl->SymSearch( SKey ) ) == (node_skl *)0 )
  624. {
  625. node_forward * pFwd;
  626. SymKey SKey( $1, NAME_DEF );
  627. pFwd = new node_forward( SKey , pBaseSymTbl );
  628. pFwd->SetSymName( $1 );
  629. $$ = pFwd;
  630. }
  631. }
  632. ;
  633. /*** Parameterized (non handle) interface attribute ***/
  634. AcfPtrSize:
  635. KWSHORT
  636. | KWLONG
  637. | KWHYPER
  638. ;
  639. /**** Could ID already be a lexeme? ****/
  640. AcfInterfaceName:
  641. IDENTIFIER
  642. | TYPENAME
  643. {
  644. /** this production is necessitated for the hpp switch, which has the
  645. ** interface name as a predefined type(def).
  646. **/
  647. // $$ = $1;
  648. $$ = $1->GetSymName();
  649. }
  650. ;
  651. /* Note that I DON'T make InterfaceBody a heap-allocated entity.
  652. Should I do so?
  653. */
  654. AcfOptionalInterfaceBody:
  655. AcfBodyElements
  656. | /* Empty */
  657. ;
  658. AcfBodyElements:
  659. AcfBodyElements AcfBodyElement
  660. | AcfBodyElement
  661. ;
  662. /* Note that for type declaration and the operation declarations,
  663. we don't really have to propagate anythign up.
  664. (Everything's already been done via side-effects).
  665. We might want to change the semantic actions to
  666. reflect this fact.
  667. */
  668. AcfBodyElement:
  669. AcfInclude ';'
  670. {
  671. }
  672. | AcfTypeDeclaration ';'
  673. {
  674. }
  675. | Acfoperation ';'
  676. {
  677. }
  678. ;
  679. /* What should I do for this?: Should there be a node type? */
  680. AcfInclude:
  681. KWINCLUDE AcfIncludeList
  682. {
  683. $$ = $2;
  684. }
  685. ;
  686. AcfIncludeList:
  687. AcfIncludeList ',' AcfIncludeName
  688. {
  689. }
  690. | AcfIncludeName
  691. {
  692. }
  693. ;
  694. AcfIncludeName:
  695. STRING
  696. {
  697. // add a file node to the acf includes list. This file node
  698. // must have a NODE_STATE_IMPORT for the backend to know that this
  699. // is to be emitted like an include. Make the file look like it
  700. // has been specified with an import level > 0
  701. unsigned short importlvl = pCurInterfaceNode->GetFileNode()->
  702. GetImportLevel();
  703. node_file * pFile = new node_file( $1, importlvl + 1);
  704. pPass2->InsertAcfIncludeFile( pFile );
  705. }
  706. ;
  707. /*** Type declaration ***/
  708. AcfTypeDeclaration:
  709. KWTYPEDEF AcfOptionalAttrList AcfTypeNameList
  710. {
  711. node_def * pDef;
  712. if( $2.NonNull() )
  713. {
  714. while( $3->GetPeer( (node_skl **) &pDef ) == STATUS_OK )
  715. {
  716. pDef->AddAttributes( $2 );
  717. if ( pDef->FInSummary( ATTR_ENCODE ) ||
  718. pDef->FInSummary( ATTR_DECODE ) )
  719. {
  720. pCurInterfaceNode->SetPickleInterface();
  721. }
  722. }
  723. }
  724. else
  725. {
  726. pDef = NULL;
  727. $3->GetPeer( (node_skl **) &pDef );
  728. if ( pDef )
  729. ParseError( NO_ATTRS_ON_ACF_TYPEDEF, pDef->GetSymName() );
  730. }
  731. }
  732. ;
  733. AcfTypeNameList:
  734. AcfTypeNameList ',' AcfType
  735. {
  736. $$ = $1;
  737. if ( $3 )
  738. {
  739. SymKey SKey( $3->GetSymName(), NAME_DEF );
  740. node_skl * pDef = (node_skl *) pBaseSymTbl->SymSearch( SKey );
  741. // pDef will not be null.
  742. $$->SetPeer( pDef );
  743. }
  744. }
  745. | AcfType
  746. {
  747. $$ = new type_node_list;
  748. if( $1 )
  749. $$->SetPeer( $1 );
  750. }
  751. ;
  752. AcfType:
  753. TYPENAME
  754. | IDENTIFIER
  755. {
  756. ParseError( UNDEFINED_TYPE, $1 );
  757. $$ = (node_skl *)0;
  758. }
  759. ;
  760. /*** Type attributes ***/
  761. AcfTypeAttr:
  762. KWREPRESENTAS '(' AcfRepresentType ')'
  763. {
  764. $$ = $3;
  765. }
  766. | KWUSERMARSHAL '(' AcfUserMarshalType ')'
  767. {
  768. $$ = $3;
  769. }
  770. | KWCALLAS '(' AcfCallType ')'
  771. {
  772. $$ = $3;
  773. }
  774. | KWINLINE
  775. {
  776. node_base_attr * pN = new acf_attr( ATTR_NONE );
  777. ParseError( IGNORE_UNIMPLEMENTED_ATTRIBUTE, "[inline]" );
  778. $$ = pN;
  779. }
  780. | KWOUTOFLINE
  781. {
  782. node_base_attr * pN = new acf_attr( ATTR_NONE );
  783. ParseError( IGNORE_UNIMPLEMENTED_ATTRIBUTE, "[out_of_line]" );
  784. $$ = pN;
  785. }
  786. | KWALLOCATE '(' AcfAllocationUnitList ')'
  787. {
  788. node_allocate * pN = new node_allocate( $3 );
  789. ParseError( ALLOCATE_INVALID, pN->GetNodeNameString() );
  790. #ifdef RPCDEBUG
  791. short s = pN->GetAllocateDetails();
  792. #endif // RPCDEBUG
  793. $$ = pN;
  794. }
  795. | KWOFFLINE
  796. {
  797. ParseError( IGNORE_UNIMPLEMENTED_ATTRIBUTE, "offline" );
  798. $$ = new acf_attr( ATTR_NONE );
  799. }
  800. | KWHEAP
  801. {
  802. $$ = new acf_attr( ATTR_HEAP );
  803. }
  804. | KWENCODE
  805. {
  806. $$ = new acf_attr( ATTR_ENCODE );
  807. }
  808. | KWDECODE
  809. {
  810. $$ = new acf_attr( ATTR_DECODE );
  811. }
  812. | KWNOSERIALIZE
  813. {
  814. $$ = new acf_attr( ATTR_NOSERIALIZE );
  815. }
  816. | KWSERIALIZE
  817. {
  818. $$ = new acf_attr( ATTR_SERIALIZE );
  819. }
  820. /*
  821. Support for [cs_char] and related attributes has been removed because
  822. of problems with the DCE spec
  823. | KWCSCHAR '(' TYPENAME ')'
  824. {
  825. $$ = new node_cs_char( $3 );//->GetSymName() );
  826. }
  827. */
  828. ;
  829. AcfRepresentType:
  830. IDENTIFIER
  831. {
  832. // only non-typedefs get here, so it must be unknown...
  833. $$ = new node_represent_as( $1, NULL );
  834. }
  835. | TYPENAME
  836. {
  837. $$ = new node_represent_as( $1->GetSymName(), $1 );
  838. }
  839. ;
  840. AcfUserMarshalType:
  841. IDENTIFIER
  842. {
  843. // only non-typedefs get here, so it must be unknown...
  844. $$ = new node_user_marshal( $1, NULL );
  845. }
  846. | TYPENAME
  847. {
  848. $$ = new node_user_marshal( $1->GetSymName(), $1 );
  849. }
  850. ;
  851. AcfCallType:
  852. IDENTIFIER
  853. {
  854. // search for a matching proc in our interface
  855. SymKey SKey( $1, NAME_PROC );
  856. named_node * pCur =
  857. pCurInterfaceNode->GetProcTbl()->SymSearch( SKey );
  858. $$ = new node_call_as( $1, pCur );
  859. }
  860. ;
  861. AcfAllocationUnitList:
  862. AcfAllocationUnitList ',' AcfAllocationUnit
  863. {
  864. $$ |= $3;
  865. }
  866. | AcfAllocationUnit
  867. ;
  868. AcfAllocationUnit:
  869. IDENTIFIER
  870. {
  871. $$ = CheckValidAllocate( $1 );
  872. }
  873. ;
  874. /* Again, there's not really much to propagate upwards */
  875. /*** Operation declaration ***/
  876. Acfoperation:
  877. AcfOptionalAttrList OptFuncModifiers IDENTIFIER
  878. {
  879. SymKey SKey( $3, NAME_PROC );
  880. // the proc must be defined in the idl file and it must not have the
  881. // local attribute
  882. if ( pCurInterfaceNode )
  883. {
  884. pAcfProc = (node_proc *)
  885. pCurInterfaceNode->GetProcTbl()->SymSearch( SKey );
  886. }
  887. else
  888. pAcfProc = NULL;
  889. if( pAcfProc )
  890. {
  891. if( pAcfProc->FInSummary( ATTR_LOCAL ) )
  892. {
  893. ParseError( LOCAL_PROC_IN_ACF, $3 );
  894. }
  895. else
  896. {
  897. if($1)
  898. {
  899. pAcfProc->AddAttributes( $1 );
  900. if ( pAcfProc->FInSummary( ATTR_ENCODE ) ||
  901. pAcfProc->FInSummary( ATTR_DECODE ) )
  902. {
  903. pCurInterfaceNode->SetPickleInterface();
  904. }
  905. }
  906. pAcfProc->GetModifiers().Merge( $2 );
  907. // prepare for parameter matching
  908. iParam = 0;
  909. }
  910. }
  911. else if ( pPass2->GetFileNode()->GetImportLevel() == 0 )
  912. {
  913. ParseError( UNDEFINED_PROC, $3 );
  914. }
  915. }
  916. '(' AcfOptionalParameters ')'
  917. {
  918. pAcfProc = (node_proc *)NULL;
  919. }
  920. ;
  921. /*** Operation attributes ***/
  922. AcfOpAttr:
  923. KWCOMMSTATUS
  924. {
  925. $$ = new acf_attr( ATTR_COMMSTAT );
  926. }
  927. | KWFAULTSTATUS
  928. {
  929. $$ = new acf_attr( ATTR_FAULTSTAT );
  930. }
  931. | KWCODE
  932. {
  933. $$ = new acf_attr( ATTR_CODE );
  934. }
  935. | KWNOCODE
  936. {
  937. $$ = new acf_attr( ATTR_NOCODE );
  938. }
  939. | KWENABLEALLOCATE
  940. {
  941. $$ = new acf_attr( ATTR_ENABLE_ALLOCATE );
  942. }
  943. | KWNOTIFY
  944. {
  945. $$ = new acf_attr( ATTR_NOTIFY );
  946. }
  947. | KWNOTIFYFLAG
  948. {
  949. $$ = new acf_attr( ATTR_NOTIFY_FLAG );
  950. }
  951. | KWASYNC
  952. {
  953. if ( pCommand->GetNdrVersionControl().TargetIsLessThanNT50() )
  954. ParseError( INVALID_FEATURE_FOR_TARGET, "[async]");
  955. $$ = new acf_attr( ATTR_ASYNC );
  956. }
  957. /*
  958. Support for [cs_char] and related attributes has been removed because
  959. of problems with the DCE spec
  960. | KWCSTAGRTN '(' IDENTIFIER ')'
  961. {
  962. SymKey SKey( $3, NAME_PROC );
  963. node_skl *pTagRoutine;
  964. pTagRoutine = pBaseSymTbl->SymSearch( SKey );
  965. if( NULL == pTagRoutine )
  966. ParseError( UNDEFINED_PROC, $3 );
  967. $$ = new node_cs_tag_rtn( pTagRoutine );
  968. }
  969. */
  970. ;
  971. AcfOptionalParameters:
  972. Acfparameters
  973. {
  974. /*************************************************************
  975. *** we do not match parameters by number yet, so disable this
  976. if( iParam != cParams )
  977. {
  978. ParseError(PARAM_COUNT_MISMATCH, (char *)NULL );
  979. }
  980. *************************************************************/
  981. }
  982. | /* Empty */
  983. {
  984. /*************************************************************
  985. *** we do not match parameters by number yet, so disable this
  986. if( cParams )
  987. {
  988. ParseError(PARAM_COUNT_MISMATCH, (char *)NULL );
  989. }
  990. *************************************************************/
  991. }
  992. ;
  993. /***
  994. *** this production valid only if we allow param matching by position
  995. ***
  996. Acfparameters:
  997. Acfparameters ',' Acfparameter
  998. | Acfparameters ','
  999. | Acfparameter
  1000. | ','
  1001. ;
  1002. ***/
  1003. Acfparameters:
  1004. Acfparameters ',' Acfparameter
  1005. {
  1006. iParam++;
  1007. }
  1008. | Acfparameter
  1009. {
  1010. iParam++;
  1011. }
  1012. ;
  1013. Acfparameter:
  1014. AcfOptionalAttrList IDENTIFIER
  1015. {
  1016. // any ordering of parameters is ok here...
  1017. if( pAcfProc )
  1018. {
  1019. node_param * pParam;
  1020. if( (pParam = pAcfProc->GetParamNode( $2 ) ) )
  1021. {
  1022. if( $1.NonNull() )
  1023. pParam->AddAttributes( $1 );
  1024. }
  1025. else if ( $1.FInSummary( ATTR_COMMSTAT ) ||
  1026. $1.FInSummary( ATTR_FAULTSTAT ) )
  1027. {
  1028. // add parameter to end of param list
  1029. pAcfProc->AddStatusParam( $2, $1 );
  1030. }
  1031. else
  1032. ParseError( UNDEF_PARAM_IN_IDL, $2 );
  1033. }
  1034. }
  1035. /**
  1036. ** this prodn valid only if parameter matching by position is in effect **
  1037. **
  1038. | AcfParamAttrList
  1039. **/
  1040. /*** Parameter attributes ***/
  1041. AcfParamAttr:
  1042. KWBYTECOUNT '(' IDENTIFIER ')'
  1043. {
  1044. node_param * pParam = NULL;
  1045. if (pAcfProc)
  1046. {
  1047. pParam = pAcfProc->GetParamNode( $3 );
  1048. }
  1049. $$ = new node_byte_count( pParam );
  1050. }
  1051. | KWMANUAL
  1052. {
  1053. ParseError( IGNORE_UNIMPLEMENTED_ATTRIBUTE, "manual" );
  1054. $$ = new acf_attr( ATTR_NONE );
  1055. }
  1056. /*
  1057. Support for [cs_char] and related attributes has been removed because
  1058. of problems with the DCE spec
  1059. | KWCSDRTAG
  1060. {
  1061. $$ = new acf_attr( ATTR_DRTAG );
  1062. }
  1063. | KWCSRTAG
  1064. {
  1065. $$ = new acf_attr( ATTR_RTAG );
  1066. }
  1067. | KWCSSTAG
  1068. {
  1069. $$ = new acf_attr( ATTR_STAG );
  1070. }
  1071. */
  1072. | KWFORCEALLOCATE
  1073. {
  1074. $$ = new acf_attr( ATTR_FORCEALLOCATE );
  1075. }
  1076. ;
  1077. OptFuncModifiers:
  1078. FuncModifiers
  1079. | /* Empty */
  1080. {
  1081. $$.Clear();
  1082. }
  1083. FuncModifiers:
  1084. FuncModifiers FuncModifier
  1085. {
  1086. $$ = $1;
  1087. $$.Merge( $2 );
  1088. }
  1089. | FuncModifier
  1090. ;
  1091. FuncModifier:
  1092. MSCPASCAL
  1093. {
  1094. $$ = INITIALIZED_MODIFIER_SET(ATTR_PASCAL);
  1095. ParseError( BAD_CON_MSC_CDECL, "__pascal" );
  1096. }
  1097. | MSCFORTRAN
  1098. {
  1099. $$ = INITIALIZED_MODIFIER_SET(ATTR_FORTRAN);
  1100. ParseError( BAD_CON_MSC_CDECL, "__fortran" );
  1101. }
  1102. | MSCCDECL
  1103. {
  1104. $$ = INITIALIZED_MODIFIER_SET(ATTR_CDECL);
  1105. ParseError( BAD_CON_MSC_CDECL, "__cdecl" );
  1106. }
  1107. | MSCSTDCALL
  1108. {
  1109. $$ = INITIALIZED_MODIFIER_SET(ATTR_STDCALL);
  1110. ParseError( BAD_CON_MSC_CDECL, "__stdcall" );
  1111. }
  1112. | MSCLOADDS /* potentially interesting */
  1113. {
  1114. $$ = INITIALIZED_MODIFIER_SET(ATTR_LOADDS);
  1115. ParseError( BAD_CON_MSC_CDECL, "__loadds" );
  1116. }
  1117. | MSCSAVEREGS
  1118. {
  1119. $$ = INITIALIZED_MODIFIER_SET(ATTR_SAVEREGS);
  1120. ParseError( BAD_CON_MSC_CDECL, "__saveregs" );
  1121. }
  1122. | MSCFASTCALL
  1123. {
  1124. $$ = INITIALIZED_MODIFIER_SET(ATTR_FASTCALL);
  1125. ParseError( BAD_CON_MSC_CDECL, "__fastcall" );
  1126. }
  1127. | MSCSEGMENT
  1128. {
  1129. $$ = INITIALIZED_MODIFIER_SET(ATTR_SEGMENT);
  1130. ParseError( BAD_CON_MSC_CDECL, "__segment" );
  1131. }
  1132. | MSCINTERRUPT
  1133. {
  1134. $$ = INITIALIZED_MODIFIER_SET(ATTR_INTERRUPT);
  1135. ParseError( BAD_CON_MSC_CDECL, "__interrupt" );
  1136. }
  1137. | MSCSELF
  1138. {
  1139. $$ = INITIALIZED_MODIFIER_SET(ATTR_SELF);
  1140. ParseError( BAD_CON_MSC_CDECL, "__self" );
  1141. }
  1142. | MSCEXPORT
  1143. {
  1144. $$ = INITIALIZED_MODIFIER_SET(ATTR_EXPORT);
  1145. ParseError( BAD_CON_MSC_CDECL, "__export" );
  1146. }
  1147. | MscDeclSpec
  1148. | MSCEMIT NUMERICCONSTANT
  1149. {
  1150. $$ = INITIALIZED_MODIFIER_SET(ATTR_NONE);
  1151. ParseError( BAD_CON_MSC_CDECL, "__emit" );
  1152. }
  1153. ;
  1154. MscDeclSpec:
  1155. KWMSCDECLSPEC
  1156. {
  1157. ParseError( BAD_CON_MSC_CDECL, "__declspec" );
  1158. $$ = $1;
  1159. }
  1160. ;
  1161. %%