亚洲av成人无遮挡网站在线观看,少妇性bbb搡bbb爽爽爽,亚洲av日韩精品久久久久久,兔费看少妇性l交大片免费,无码少妇一区二区三区

  免費(fèi)注冊 查看新帖 |

Chinaunix

  平臺 論壇 博客 文庫
最近訪問板塊 發(fā)新帖
查看: 3015 | 回復(fù): 4
打印 上一主題 下一主題

請教GCC的treelang語言的前端分析流程? [復(fù)制鏈接]

論壇徽章:
0
跳轉(zhuǎn)到指定樓層
1 [收藏(0)] [報告]
發(fā)表于 2009-01-17 00:33 |只看該作者 |倒序瀏覽
treelang語法分析的大致處理流程如下
main (argc, argv)-> toplev_main (argc, argv) -> do_compile ()
-> compile_file () -> lang_hooks.parse_file (set_yydebug)

lang_hooks注冊鉤子
const struct lang_hooks lang_hooks = LANG_HOOKS_INITIALIZER;

parse_file實際調(diào)用treelang_parse_file
LANG_HOOKS_INITIALIZER . LANG_HOOKS_PARSE_FILE
#define LANG_HOOKS_PARSE_FILE treelang_parse_file

調(diào)用bison 的parser提取語法tree。GCC真正用的是自己實現(xiàn)的parser,沒用bison的。
treelang_parse_file() -> yyparse ()

這里是parse函數(shù)定義,
int
yyparse (YYPARSE_PARAM_ARG)
     YYPARSE_PARAM_DECL

{
  /* If reentrant, generate the variables here. */
#if YYPURE
  YY_DECL_VARIABLES
#endif  /* !YYPURE */

  register int yystate;
  register int yyn;
...
...
...
}

#ifdef YYPARSE_PARAM
# if defined (__STDC__) || defined (__cplusplus)
#  define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
#  define YYPARSE_PARAM_DECL
# else
#  define YYPARSE_PARAM_ARG YYPARSE_PARAM
#  define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
# endif
#else /* !YYPARSE_PARAM */
# define YYPARSE_PARAM_ARG
# define YYPARSE_PARAM_DECL
#endif /* !YYPARSE_PARAM */

/* Prevent warning if -Wstrict-prototypes.  */
#ifdef __GNUC__
# ifdef YYPARSE_PARAM
int yyparse (void *);
# else
int yyparse (void);
# endif
#endif

#line 315 "/usr/local/share/bison/bison.simple"
#line 175 "plural.y"
#line 183 "plural.y"



有兩個疑惑:
1.在
int yyparse (YYPARSE_PARAM_ARG)
     YYPARSE_PARAM_DECL

中有這種函數(shù)聲明
int yyparse (arg) void *
C語言中有這種語法嗎?
2.像__GNUC__,__LINE__這些宏說是操作系統(tǒng)內(nèi)置的,不知道怎么理解?

[ 本帖最后由 fineamy 于 2009-1-17 00:36 編輯 ]

論壇徽章:
3
2015年迎新春徽章
日期:2015-03-04 09:56:11數(shù)據(jù)庫技術(shù)版塊每日發(fā)帖之星
日期:2016-08-03 06:20:00數(shù)據(jù)庫技術(shù)版塊每日發(fā)帖之星
日期:2016-08-04 06:20:00
2 [報告]
發(fā)表于 2009-01-17 11:10 |只看該作者
1.gcc帶了一些擴(kuò)展,但即便如此,1也編譯不過去吧,預(yù)處理之后就長這樣?
2.這種宏去OS其實是沒有什么關(guān)系的,只與編譯器有關(guān)系

論壇徽章:
0
3 [報告]
發(fā)表于 2009-01-17 11:46 |只看該作者

回復(fù) #2 cjaizss 的帖子

# else
#  define YYPARSE_PARAM_ARG YYPARSE_PARAM
#  define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
# endif
取這個分支就變成那樣了。
記得內(nèi)核中也有類似函數(shù)定義形式。

論壇徽章:
3
2015年迎新春徽章
日期:2015-03-04 09:56:11數(shù)據(jù)庫技術(shù)版塊每日發(fā)帖之星
日期:2016-08-03 06:20:00數(shù)據(jù)庫技術(shù)版塊每日發(fā)帖之星
日期:2016-08-04 06:20:00
4 [報告]
發(fā)表于 2009-01-17 11:55 |只看該作者
那是類似
int yyparse (arg) void *arg;
這對于gcc是當(dāng)然支持的,這種語法很古老,為了代碼兼容,所以現(xiàn)在還在支持

論壇徽章:
0
5 [報告]
發(fā)表于 2009-01-17 12:44 |只看該作者

回復(fù) #4 cjaizss 的帖子

哦,謝謝。以前沒見過這種寫法。
您需要登錄后才可以回帖 登錄 | 注冊

本版積分規(guī)則 發(fā)表回復(fù)

  

北京盛拓優(yōu)訊信息技術(shù)有限公司. 版權(quán)所有 京ICP備16024965號-6 北京市公安局海淀分局網(wǎng)監(jiān)中心備案編號:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年舉報專區(qū)
中國互聯(lián)網(wǎng)協(xié)會會員  聯(lián)系我們:huangweiwei@itpub.net
感謝所有關(guān)心和支持過ChinaUnix的朋友們 轉(zhuǎn)載本站內(nèi)容請注明原作者名及出處

清除 Cookies - ChinaUnix - Archiver - WAP - TOP