abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
verParse.c
Go to the documentation of this file.
1 /**CFile****************************************************************
2 
3  FileName [verParse.c]
4 
5  SystemName [ABC: Logic synthesis and verification system.]
6 
7  PackageName [Verilog parser.]
8 
9  Synopsis [Performs some Verilog parsing tasks.]
10 
11  Author [Alan Mishchenko]
12 
13  Affiliation [UC Berkeley]
14 
15  Date [Ver. 1.0. Started - August 19, 2006.]
16 
17  Revision [$Id: verParse.c,v 1.00 2006/08/19 00:00:00 alanmi Exp $]
18 
19 ***********************************************************************/
20 
21 #include "ver.h"
22 
24 
25 
26 ////////////////////////////////////////////////////////////////////////
27 /// DECLARATIONS ///
28 ////////////////////////////////////////////////////////////////////////
29 
30 ////////////////////////////////////////////////////////////////////////
31 /// FUNCTION DEFINITIONS ///
32 ////////////////////////////////////////////////////////////////////////
33 
34 /**Function*************************************************************
35 
36  Synopsis [Skips the comments of they are present.]
37 
38  Description []
39 
40  SideEffects []
41 
42  SeeAlso []
43 
44 ***********************************************************************/
46 {
47  Ver_Stream_t * p = pMan->pReader;
48  char Symbol;
49  // skip spaces
50  Ver_StreamSkipChars( p, " \t\n\r" );
51  if ( !Ver_StreamIsOkey(pMan->pReader) )
52  return 1;
53  // read the first symbol
54  Symbol = Ver_StreamScanChar( p );
55  if ( Symbol != '/' )
56  return 1;
57  Ver_StreamPopChar( p );
58  // read the second symbol
59  Symbol = Ver_StreamScanChar( p );
60  if ( Symbol == '/' )
61  { // skip till the end of line
62  Ver_StreamSkipToChars( p, "\n" );
63  return Ver_ParseSkipComments( pMan );
64  }
65  if ( Symbol == '*' )
66  { // skip till the next occurrence of */
67  Ver_StreamPopChar( p );
68  do {
69  Ver_StreamSkipToChars( p, "*" );
70  Ver_StreamPopChar( p );
71  } while ( Ver_StreamScanChar( p ) != '/' );
72  Ver_StreamPopChar( p );
73  return Ver_ParseSkipComments( pMan );
74  }
75  sprintf( pMan->sError, "Cannot parse after symbol \"/\"." );
77  return 0;
78 }
79 
80 /**Function*************************************************************
81 
82  Synopsis [Parses a Verilog name that can be being with a slash.]
83 
84  Description []
85 
86  SideEffects []
87 
88  SeeAlso []
89 
90 ***********************************************************************/
91 char * Ver_ParseGetName( Ver_Man_t * pMan )
92 {
93  Ver_Stream_t * p = pMan->pReader;
94  char Symbol;
95  char * pWord;
96  pMan->fNameLast = 0;
97  if ( !Ver_StreamIsOkey(p) )
98  return NULL;
99  if ( !Ver_ParseSkipComments( pMan ) )
100  return NULL;
101  Symbol = Ver_StreamScanChar( p );
102  if ( Symbol == '\\' )
103  {
104  pMan->fNameLast = 1;
105  Ver_StreamPopChar( p );
106  pWord = Ver_StreamGetWord( p, " \r\n" );
107  Ver_StreamSkipChars( p, " \r\n" );
108  if ( Ver_StreamScanChar(p) == '[' )
109  {
110  char This, * pEnd = pWord + strlen( pWord );
111  while ( (This = Ver_StreamPopChar(p)) != ']' )
112  *pEnd++ = This;
113  *pEnd++ = This;
114  *pEnd = 0;
115  }
116  }
117  else
118  pWord = Ver_StreamGetWord( p, " \t\n\r(),;" );
119  if ( Ver_StreamIsOkey(p) && !Ver_ParseSkipComments( pMan ) )
120  return NULL;
121  return pWord;
122 }
123 
124 
125 ////////////////////////////////////////////////////////////////////////
126 /// END OF FILE ///
127 ////////////////////////////////////////////////////////////////////////
128 
129 
131 
void Ver_ParsePrintErrorMessage(Ver_Man_t *p)
Definition: verCore.c:278
static Llb_Mgr_t * p
Definition: llb3Image.c:950
char Ver_StreamPopChar(Ver_Stream_t *p)
Definition: verStream.c:275
char * Ver_ParseGetName(Ver_Man_t *pMan)
Definition: verParse.c:91
char * Ver_StreamGetWord(Ver_Stream_t *p, char *pCharsToStop)
Definition: verStream.c:397
char Ver_StreamScanChar(Ver_Stream_t *p)
Definition: verStream.c:258
void Ver_StreamSkipToChars(Ver_Stream_t *p, char *pCharsToStop)
Definition: verStream.c:349
typedefABC_NAMESPACE_HEADER_START struct Ver_Man_t_ Ver_Man_t
INCLUDES ///.
Definition: ver.h:45
#define ABC_NAMESPACE_IMPL_END
Definition: abc_global.h:108
int Ver_StreamIsOkey(Ver_Stream_t *p)
Definition: verStream.c:242
char * sprintf()
#define ABC_NAMESPACE_IMPL_START
Definition: abc_global.h:107
void Ver_StreamSkipChars(Ver_Stream_t *p, char *pCharsToSkip)
Definition: verStream.c:304
ABC_NAMESPACE_IMPL_START int Ver_ParseSkipComments(Ver_Man_t *pMan)
DECLARATIONS ///.
Definition: verParse.c:45
int strlen()