2 * Hyper Operating System V4 Advance Configurator
5 * @brief %jp{構文解析クラス}%en{lexer cless}
7 * Copyright (C) 1998-2010 by Project HOS
8 * http://sourceforge.jp/projects/hos/
20 // ステートメントをAPI名とパラメーターに分割
21 int CAnalyze::SplitState(char* pszApiName, char* pszParams, const char *pszState)
26 while ( *pszState != '(' )
28 if ( *pszState == '\0' )
30 return CFG_ERR_SYNTAX;
32 *pszApiName++ = *pszState++;
38 iErr = SearchChar(pszParams, pszState, ')');
39 if ( iErr != CFG_ERR_OK )
45 if ( *pszState != '\0' )
47 return CFG_ERR_SEMICOLON;
55 int CAnalyze::SearchChar(char* pszBuf, const char* &pszText, char c)
65 if ( *pszText == '\0' )
67 iErr = CFG_ERR_SYNTAX;
79 // '\' の次の文字は無条件にエスケープ
82 *pszBuf++ = *pszText++;
89 if ( *pszBuf == '\\' )
91 *pszBuf++ = *pszText++;
97 if ( !blText && *pszText == '\"' || *pszText == '\'' )
99 cDelimiter = *pszText;
100 *pszBuf++ = *pszText++;
108 if ( *pszText == cDelimiter )
110 *pszBuf++ = *pszText++;
115 *pszBuf++ = *pszText++;
121 if ( *pszText == '{' )
123 *pszBuf++ = *pszText++;
124 iErr = SearchChar(pszBuf, pszText, '}');
125 if ( iErr != CFG_ERR_OK )
127 iErr = CFG_ERR_BRACE;
129 pszBuf += strlen(pszBuf);
135 if ( *pszText == '(' )
137 *pszBuf++ = *pszText++;
138 iErr = SearchChar(pszBuf, pszText, ')');
139 if ( iErr != CFG_ERR_OK )
141 iErr = CFG_ERR_PAREN;
143 pszBuf += strlen(pszBuf);
148 *pszBuf++ = *pszText++;
158 int CAnalyze::GetParameter(char* pszBuf, const char* &pszText)
163 iErr = SearchChar(pszBuf, pszText, ',');
164 if ( iErr == CFG_ERR_SYNTAX )
166 // 括弧対応OKで終端ならコンマが見つからなくても可
175 int CAnalyze::DecodeText(char *pszBuf, const char* pszText)
179 if ( *pszText++ != '\"')
186 if ( *pszText == '\0' )
194 *pszBuf++ = *pszText++;
200 if ( *pszText == '\\' )
208 if ( *pszText == '\"' )
214 *pszBuf++ = *pszText++;
218 if ( *pszText != '\0' )
230 void CAnalyze::SpaceCut(char* pszText)
238 while ( *pszTmp == ' ' )
244 while ( *pszTmp != '\0' )
246 pszText[i++] = *pszTmp++;
250 while ( i > 0 && pszText[i - 1] == ' ' )