Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Project] Frontend #50

Open
o- opened this issue Feb 9, 2017 · 0 comments
Open

[Project] Frontend #50

o- opened this issue Feb 9, 2017 · 0 comments

Comments

@o-
Copy link
Contributor

o- commented Feb 9, 2017

It would be nice to have a frontend for sourir as a usecase. I see several possible levels:

Syntactic Sugar

The language could be just syntactic sugar on top of sourir.

i = read()
sum = 0
for j in 0 to i:
  sum += i

Dynamic Types

The language could have dynamic types.

if (read() == 0)
  i = "foo"
else
  i = 2
print i + i

In sourir the primitive operations like '+' only work on one primitive type (eg. + only on integers). Lets assume we want a programming language L where primops are generic. For example you can write 2+2 as well as "foo"+"foo". And lets assume we want it to be dynamically typed and not type-inferred (ie. like in the example above at compile time it is not yet clear if the integer+ or the string+ is required).

For a compiler from L to sourir the idea is to keep type tags. This means that every value is stored along information about its type. For example i = 2 creates a heap cell with the content <int, 2>. To support the generic + a dispatch table is needed. For example something like if a.1 == int && b.i == int then res = <int, a.2 (integer+) b.2>

To support such a language sourir needs to be extended a bit. Either with tuples (like in the example above) or (simpler) a type-testing primop.

Functions

If the source language should have functions (which would be very nice) then we'll need to extend sourir a bit. Though maybe not that much. Using segments + some cps encoding it should be possible to simulate functions.

@o- o- changed the title Frontend [Project] Frontend Feb 9, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant