~ wrote:
The hardest part of a compiler is calculating expressions constructing instructions for the right precedence, variable/function types, intermediate results.
I'm thinking to develop a method of listing elements in a stack and depending on the precedence, pop them to calculate or keep them if the precedence still says to wait for calculating what I haev listed in the stack.
This comment tells me that you
still haven't read
any existing textbooks or other literature on compiler design. Precedence is a
solved problem, solved at a completely different level (with most of it done in the
grammar and the parser for same) and in a vastly easier manner than what you are attempting.
IOW, you are reinventing a square wheel made from cardboard in an era when steel-belted radials are the norm.
READ THAT DAMN BOOK. NOW. STOP TRYING TO HALF-@$$ THIS! Even as a pre-release beta, that book is a million times better than what you are trying to accomplish with your 'stone knives and bear skins' approach.
I, and others such as Solar,
have given you links to a small library of books and
other information sources on several occasions, and yet you still persist in acting as if this is something no one has ever attempted before. This is shooting yourself in the
head, never mind in the foot.
Do you even
have a grammar for the source language (which I assume is C or - Eris help you -
C++) to design your parser from? Because without one, you have a snowball's chance in hell of getting anywhere with your compiler project. It isn't as if
grammars for most major languages aren't readily available, either - the
grammar for C11, along with the
publicly released C11 draft standard update from 2014, is free from the
OpenStandards website, as is the
entire suite of draft C++ standards from 1998 to 2017, and while they aren't the
final standards they are at least usable for your purposes - so there's no reason
not to apply one to your lexer and your parser.