curimit / SugarCpp

SugarCpp is a language which can compile to C++11.
135 stars 13 forks source link

Support `long long` type #8

Closed vuryleo closed 11 years ago

vuryleo commented 11 years ago

When testing with

import "cstdlib"

using namespace std

a : long long (0)

It gives

`` cpp Compile Error: line 5:10 no viable alternative at input 'long'



For more example, `long int` doesn't work as well.
curimit commented 11 years ago

Thank you, this bug has been fixed.

a: int
a: unsigned int
a: bool
a: char
a: signed char
a: unsigned char
a: short
a: unsigned short
a: long
a: unsigned long
a: long int
a: long long
a: long long long
a: long long int
a: unsigned long long
a: float
a: double
a: long double
vuryleo commented 11 years ago

Can't use type long long as the function return type now. For example

long long getE()
    return 0

Compiler gives

Compile Error:
line 1:16 mismatched input ')' expecting set 
line 2:5 mismatched input 'NEWLINE' expecting '('
line 2:5 missing EndOfFile at 'INDENT'
curimit commented 11 years ago

I decided to use go style int64 to distinguish different kind of integer types.

include "cstdint"

import "cstdint"

a: bool
b: char
c: uchar
d: int
e: uint
f: int8
g: int16
h: uint16
i: int32
j: uint32
k: int64
l: uint64
m: float
n: double
o: long double

int main()
    a = true

Translate into

#include "cstdint"

bool a;
char b;
unsigned char c;
int d;
unsigned int e;
int8_t f;
int16_t g;
uint16_t h;
int32_t i;
uint32_t j;
int64_t k;
uint64_t l;
float m;
double n;
long double o;

int main() {
    a = true;
}