Re: [問題] 在自製語言中,如何表示函數和物件

作者: descent (「雄辯是銀,沉默是金」)   2017-04-24 21:25:17
你目前可以使用變數嗎?
ex:
int c;
c=5;
c+3*2;
這需要使用"環境"
ref: http://descent-incoming.blogspot.tw/2016/07/compiler-4.html
這篇有點錯誤, 但概念就是那樣。
因為得會處理變數, 才能處理函數,
函數的定義 AST ref:
http://descent-incoming.blogspot.tw/2017/02/compiler-26-variable-function.html
抱歉, 貼錯, 這是 function call
http://descent-incoming.blogspot.tw/2017/03/compiler-39-function-call-ast.html
最後提供我的學習心得以及購買的書籍
http://descent-incoming.blogspot.tw/2017/01/blog-post.html
物件我就沒研究了。
※ 引述《Neisseria (Neisseria)》之銘言:
: 小弟先前沒事寫一個計算機
: 目前寫了 lexer, parser, interpreter
: 有自製的 AST (abstract syntax tree)
: 為了練功,這些功能沒依賴 yacc 或其他外部套件
: 有以下功能:
: - 可處理整數和浮點數
: - 簡易代數運算,像 (123 + 45)**(5 % 3)
: - 常見數學公式,像指對數、三角函數等
: (直接 call host language 的相關功能)
: 卡在函數 (function) 和物件 (class) 不知道如何表示
: 希望板上各位大大提示一些方向
: 目前先以 interpreter 為目標
: 因 compiler 還牽涉到轉機械碼的過程
: 目前對小弟來說太硬了
: 先在這裡謝過各位大大

Links booklink

Contact Us: admin [ a t ] ucptt.com