Retrieving arduino program storage space

I am currently writing my own language, which have to be compiled to .ino. A part of the compiler needs to evaluate the storage usage of the .ino file, however i am unsure how the storage usage of a sketch is calculated. I have looked on the source code for the IDE without luck.
Any ideas to how i can calculate storage without using the IDE?

Any answer will be much appreciated

You can run avr-size on the *.elf file (text + data) or the *.hex file (data). The avr-size utility is included with the IDE in the same place as avr-gcc and the other gcc tools.

avr-size -B blinker.elf
text data bss dec hex filename
188 2 0 190 be blinker.elf

avr-size -B blinker.hex
text data bss dec hex filename
0 190 0 190 be blinker.hex