« first day (4 days earlier)      last day (58 days later) » 

3:26 AM
@user ok for that: since WS borrows syntax from C like languages, i think its fine to have only while loops
 
 
2 hours later…
5:13 AM
val collatz = (n: Integer) -> {
    var ar = [];
    while (n > 1) ar = ar.tack(n =
        n % 2 ?
        1 + 3 * n :
        n / 2
    );
    return ar;
}
@user @des54321 ^ new version with immutable arrays
 
5:43 AM
ok time to test the lexer
eh works
val collatz = (n: Integer) -> {
    var ar = [];
    while (n > 1) ar = ar.tack(n =
        n % 2 ?
        1 + 3 * n :
        n / 2
    ); return ar;
}

LexToken("val")
LexToken("collatz")
LexToken("=")
LexToken("(")
LexToken("n")
LexToken(":")
LexToken("Integer")
LexToken(")")
LexToken("-")
LexToken(">")
LexToken("{")
LexToken("var")
LexToken("ar")
LexToken("=")
LexToken("[")
LexToken("]")
LexToken(";")
LexToken("while")
LexToken("(")
LexToken("n")
LexToken(">")
LexToken("1")
LexToken(")")
LexToken("ar")
it works!
 
6:03 AM
Nice! Are you going to start attaching metadata now?
 
@emanresuA what is metadata?
val collatz = (n: Integer) -> {
    var ar = [];
    while (n > 1) ar = ar.tack(n =
        n % 2 ?
        1 + 3 * n :
        n / 2
    ); return ar;
}

LexToken("val",LexType.KEYWORD)
LexToken("collatz",LexType.IDENTIFIER)
LexToken("=",LexType.OPERATOR)
LexToken("(",LexType.OPERATOR)
LexToken("n",LexType.IDENTIFIER)
LexToken(":",LexType.OPERATOR)
LexToken("Integer",LexType.IDENTIFIER)
LexToken(")",LexType.OPERATOR)
LexToken("-",LexType.OPERATOR)
LexToken(">",LexType.OPERATOR)
LexToken("{",LexType.OPERATOR)
 
That, pretty muuch
 
oh
@emanresuA i didnt print it before
i just edited the format string to print that also
 
Except ; shouldn't be an operator and return shouldn't be an identifier and . shouldn't be a number in that context
 
@emanresuA yeah ..
 
6:05 AM
So, a bit more work needed :P
 
KEYWORDS = ["val", "var", "type", "while", "return"]
problem 2 fixed
@emanresuA what should ; be?
 
Cool :)
@PyGamer0 You could always ignore it
 
why?
 
In the correct context, it's just a statement separator, right?
 
yeah
 
6:07 AM
So, like a newline it probably should just be ignroed
 
val collatz = (n: Integer) -> {
    var ar = [];
    while (n > 1) ar = ar.tack(n =
        n % 2 ?
        1 + 3 * n :
        n / 2
    ); return ar;
}

LexToken("val",LexType.KEYWORD)
LexToken("collatz",LexType.IDENTIFIER)
LexToken("=",LexType.OPERATOR)
LexToken("(",LexType.OPERATOR)
LexToken("n",LexType.IDENTIFIER)
LexToken(":",LexType.OPERATOR)
LexToken("Integer",LexType.IDENTIFIER)
LexToken(")",LexType.OPERATOR)
LexToken("-",LexType.OPERATOR)
LexToken(">",LexType.OPERATOR)
LexToken("{",LexType.OPERATOR)
@emanresuA no; whitespace doesnt matter in this language
 
Oh :P
 
@emanresuA fixed the .
hi razetime
 
@PyGamer0 You could always make ar.tack a single identifier
 
yeah... will require some more work i think
no wait thats easy
val collatz = (n: Integer) -> {
    var ar = [];
    while (n > 1) ar = ar.tack(n =
        n % 2 ?
        1 + 3 * n :
        n / 2
    ); return ar;
}

LexToken("val",LexType.KEYWORD)
LexToken("collatz",LexType.IDENTIFIER)
LexToken("=",LexType.OPERATOR)
LexToken("(",LexType.OPERATOR)
LexToken("n",LexType.IDENTIFIER)
LexToken(":",LexType.OPERATOR)
LexToken("Integer",LexType.IDENTIFIER)
LexToken(")",LexType.OPERATOR)
LexToken("-",LexType.OPERATOR)
LexToken(">",LexType.OPERATOR)
LexToken("{",LexType.OPERATOR)
@emanresuA done
 
6:11 AM
Cool :)
Although maybe I shouldn't've said that, because what about (foo).bar?
I'm afraid I don't have a solution to this one
 
o_o
@emanresuA let the parser handle those
lexer just tokenises
no need to make it harder
 
Yeah, but I'm wondering how .bar should be tokenised
 
val collatz = (n: Integer) -> {
    var ar = [];
    while (n > 1) ar = ar.tack(n =
        n % 2 ?
        1 + 3 * n :
        n / 2
    ); return ar;
}

LexToken("val",LexType.KEYWORD)
LexToken("collatz",LexType.IDENTIFIER)
LexToken("=",LexType.OPERATOR)
LexToken("(",LexType.OPERATOR)
LexToken("n",LexType.IDENTIFIER)
LexToken(":",LexType.OPERATOR)
LexToken("Integer",LexType.IDENTIFIER)
LexToken(")",LexType.OPERATOR)
LexToken("-",LexType.OPERATOR)
LexToken(">",LexType.OPERATOR)
LexToken("{",LexType.OPERATOR)
 
 
5 hours later…
11:02 AM
Nice
 
11:30 AM
now time for the hard part:
parser
actually
no i need to think about the grammar
 
12:23 PM
That would be a good idea
Have you looked at Ocaml syntax yet btw? I think it could be really good
It’s (relatively) easy for you to parse and easy for people writing Ocaml code
@PyGamer0 i don’t understand that line of reasoning but okay
Do note that you can have while loops not baked into the language (though you won’t have break or continue)
Like val while = (cond,body)if(cond)body;while(cond,body)else ()
 
12:51 PM
@user looking at it rn
looms good
i should use := for assignment and = to denote equality
 
 
2 hours later…
2:40 PM
@user should i do ^
will people hate me
@user ok let me reword that: since WS has imperative language like Syntax i think loops are fine
so i will only have the while loop
 
 
1 hour later…
4:05 PM
@PyGamer0 Ah if you want to make it imperative then while loops make sense
@PyGamer0 I can't speak for everyone, but I won't. It wouldn't be that bad
It's possible for a user to define while loops in Scala and have the same functionality (Scala's own while loops don't have break or continue). No one complains (much) about that
 
oh ok
maybe while loop will be implemented in the std library?
 
 
2 hours later…
6:38 PM
@PyGamer0 random little thing but i feel like -> should be lexed as a single token rather than two tokens, as its a single operator?
 
6:56 PM
+1
 

« first day (4 days earlier)      last day (58 days later) »