Open desarrollo03TR opened 6 years ago
Hello,
Some of the packages you mention are not extensions but the libs you'd need to build your own languages. The rest are indeed extensions:
I hope this is useful, please feel free to ask any questions, in particular if you are interested in creating languages.
Best Regards, Emilio Santos
On Thu, Jan 4, 2018 at 7:31 PM, desarrollo03TR notifications@github.com wrote:
Hi! your project looks great, but I need your help because I don't know how to use the vs extension.
After install the vs extensions I created a new project, then, I'm trying following this:
1- Add a .xs file to your project. 2- Install extensions as Nuget packages. 3- Include the extensions you need with using xs.
The step 1 is done, no problem, but I don't know which nuget packages I need to install. I Found the Excess.Extensions, the Excess.Runtime, Excess.Compiler and another packages.
Thanks!
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/xs-admin/Excess/issues/3, or mute the thread https://github.com/notifications/unsubscribe-auth/AJ0jAuj-yeRakhFAYCiAn7Ys-dNh5bUXks5tHXuDgaJpZM4RT7Ox .
Then, I need to add ".xs" files with my own languages? I this related with the code in the http://xslang.azurewebsites.net website?
No, your languages are written in C# as nay of the extensions I listed before. You'd be using the Excess.Compiler library and using one (or many) of our compiler helpers. When you are done, you can publish it as a nuget packages for anyone to use, If you give me more info about the language you intend to create I could likely point you to something similar already in existence.
http://xslang.azurewebsites.net is a basic web compiler that internally uses excess, but it is not an extension language itself.
On Thu, Jan 4, 2018 at 8:03 PM, desarrollo03TR notifications@github.com wrote:
Then, I need to add ".xs" files with my own languages? I this related with the code in the http://xslang.azurewebsites.net website?
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/xs-admin/Excess/issues/3#issuecomment-355453465, or mute the thread https://github.com/notifications/unsubscribe-auth/AJ0jAqdjjAOXw1dSUqmzOx8VUyknq9f_ks5tHYMGgaJpZM4RT7Ox .
Thanks! I don't know how far I can go with language extensions, what I need is to extend c# language because I have several functions that I use on all my programs, for example, an "if" replacement as expression and not as statement, instead writing:
var x = 0;
if (!something)
x = 5;
else
x = 10;
I write:
var x = If(!something, 5, 10);
And would be great if I can write something like:
var x = if (!something) then 5 else 10;
Or similar, or convert the switch statement in an expression match:
var x =
match(month)
{
case 0: "January";
case 1: "February";
...
default: "Not a month";
}
Transformed to:
var x = Function(() =>
{
switch(month)
{
case 0: return "January";
...
}
return "Not a month";
}
Basically I need to replace some custom statement with my functions, "syntactic sugar", but I don't know if it is possible.
This is definitively possible, your first grammar If(condition, then, else) is very easy, you'd register a syntax match where you watch for invocations where the function name is "If" and then you replace that expression with a proper if statement.
The second If() then ... else ...; is also possible, though I'm not sure it is advisable, in this case you'd write a lexical extension (that deals with tokens instead of AST nodes) that would look something like:
lexical
.match()
.token("If")
.enclosed('(', ')', named: "condition")
.token('then')
.until("else", named: "then_expression")
.until(';', named: "else_expression")
.then(YourFunction)
This of course you have to play with, but the gist is: in "YourFunction" you will receive the results of parsing (including condition, then_expression, else_expression) and you will build a Roslyn IfStatement with it.
Hope it helps.
On Thu, Jan 4, 2018 at 8:27 PM, desarrollo03TR notifications@github.com wrote:
Thanks! I don't know how far I can go with language extensions, what I need is to extend c# language because I have several functions that I use on all my programs, for example, an "if" replacement as expression and not as statement, instead writing:
var x = 0; if (!something) x = 5; else x = 10;
I write:
var x = If(!something, 5, 10);
And would be great if I can write something like:
var x = If (!something) then 5 else 10;
Or similar. Basically I need to replace some custom statement with my functions.
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/xs-admin/Excess/issues/3#issuecomment-355456572, or mute the thread https://github.com/notifications/unsubscribe-auth/AJ0jAmA8BL16X_bndne80k_41nMsZJsnks5tHYiDgaJpZM4RT7Ox .
Thanks. Can you share an project example?
You could look at the "function" implementation here:
https://github.com/xs-admin/Excess/blob/master/Excess.Compiler/xslang/Functions.cs
And, in reality, all the files in the folder
https://github.com/xs-admin/Excess/blob/master/Excess.Compiler/xslang
I recommend you use tests like this one to test your language:
https://github.com/xs-admin/Excess/blob/master/Excess.Compiler/Tests/FunctionTests.cs
Hope it helps!
On Thu, Jan 4, 2018 at 9:05 PM, desarrollo03TR notifications@github.com wrote:
Thanks. Can you share an project example?
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/xs-admin/Excess/issues/3#issuecomment-355461461, or mute the thread https://github.com/notifications/unsubscribe-auth/AJ0jAi__RsHxd9PbUDIh1sIr9pYMczEOks5tHZFsgaJpZM4RT7Ox .
Thanks a lot! I'll try to develop my own library.
Please let me know how it goes
On Thu, Jan 4, 2018 at 9:15 PM, desarrollo03TR notifications@github.com wrote:
Thanks a lot! I'll try to develop my own library.
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/xs-admin/Excess/issues/3#issuecomment-355462671, or mute the thread https://github.com/notifications/unsubscribe-auth/AJ0jArL3cWwfcVHVUe8tc31LlRqo2iBYks5tHZPUgaJpZM4RT7Ox .
Another question: if I want to use the dapper extensions (or another extensions), how can I use it? Is it possible to use it?
EDIT: after some testing, I can use the arrays, match and function extensions, but contract and typedef are not working (or I don't know how to use it).
you use it by including it in your .xs file:
using xs.extension_name;
On Fri, Jan 5, 2018 at 10:49 AM, desarrollo03TR notifications@github.com wrote:
Another question: if I want to use the dapper extensions (or another extensions), how can I use it? Is it possible to use it?
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/xs-admin/Excess/issues/3#issuecomment-355604397, or mute the thread https://github.com/notifications/unsubscribe-auth/AJ0jAgfGa6q2o2Z8yH-ck-bbgcTa557vks5tHlK3gaJpZM4RT7Ox .
Thanks, after some testing, everything except typedef is working.
Yes, in retrospect I should remove the typedef, there is not enough advantages to keep it.
On Fri, Jan 5, 2018 at 5:07 PM, desarrollo03TR notifications@github.com wrote:
Thanks, after some testing everything except typedef is working.
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/xs-admin/Excess/issues/3#issuecomment-355689930, or mute the thread https://github.com/notifications/unsubscribe-auth/AJ0jAufod2-vzKsB6IxRs6SFbn2tXjAdks5tHqs8gaJpZM4RT7Ox .
typedef could be useful if it create a really new type, for example, a type definition like this:
typedef byte Age;
could be transpiled to:
public partial struct Age : IEquatable<Age>, IEquatable<byte>, IComparable<byte>, IComparable<Age>, IConvertible, IFormattable
{
private readonly byte value;
public byte Value { get { return value; }}
public Age(byte value)
{
this.value = value;
}
// all the equality and comparision methods
}
A great option for value types creation.
That is a very good point, when initially implemented I was playing with extension cooperation (multiple .xs files sharing the typedefs) but I have desisted on that idea so far. Things get very complicated in those scenarios.
On Sat, Jan 6, 2018 at 1:10 PM, desarrollo03TR notifications@github.com wrote:
typedef could be useful is it create a really new type, for example, a type definition like this:
typedef byte age;
and be transpiled to:
public partial struct Age : IEquatable
, IEquatable , IComparable , IComparable , IConvertible, IFormattable { private readonly byte value; public byte Value { get { return value; }} public Age(byte value) { this.value = value; } // all the equality and comparision methods
}
A great option for create value types.
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/xs-admin/Excess/issues/3#issuecomment-355768505, or mute the thread https://github.com/notifications/unsubscribe-auth/AJ0jAmhqj8fVL5_DNG0UceYgMX25rJvlks5tH8UegaJpZM4RT7Ox .
Hi! your project looks great, but I need your help because I don't know how to use the vs extension.
After install the vs extensions I created a new project, then, I'm trying following this:
1- Add a .xs file to your project. 2- Install extensions as Nuget packages. 3- Include the extensions you need with using xs.
The step 1 is done, no problem, but I don't know which nuget packages I need to install. I Found the Excess.Extensions, the Excess.Runtime, Excess.Compiler and another packages.
Thanks!