<d_bot>
<eokd7> Hi everyone, I am an Outreachy applicant and looking forward to learn a lot about OCAML and contribute immensely to the project I am on. I will be asking for your support and help with any difficulties I might have. Thank you
<dmbaturin>
Please note that the official styling is OCaml. :)
<d_bot>
<eokd7> Noted😊
bartholin has quit [Ping timeout: 272 seconds]
bartholin has joined #ocaml
troydm has joined #ocaml
quartz has joined #ocaml
<quartz>
Hello. I'm trying to implement python like indentation in my compiler. I'm using this sample code as a reference, but I'm confused on how they did it. can someone explain to me how they implemented indentation? https://bpa.st/YOOQ
<d_bot>
<NULL> The parser has the easy job when it comes to detecting indentation, it just learns when an indentation or a dedentation happens from the lexer
<d_bot>
<NULL> It doesn't detect indentation, it just interprets it
<quartz>
But where in the code that I posted does this happen?
<sleepydog>
it has already happened at this point
<d_bot>
<NULL> The part where indentation is interpreted is everywhere IDENT and DEDENT appear
<sleepydog>
there is a lexer that decides what an indentation is
<d_bot>
<NULL> As sleepydog says, the part where indentation is detected is in the lexer, earlier in the chain
<sleepydog>
python lets devs choose to use any # of spaces or a tab for indentation, so i imagine that part is complicated for python
<sleepydog>
but the lexer would have to keep track of the current level of indentation to detect when a dedent happens. maybe in a global variable
<sleepydog>
ident too, i guess. i dislike significant whitespace :)
<quartz>
Hmmmm OK
<d_bot>
<NULL> If you do it the FP way, it would be an additional argument in the lexer function, this way it's not mutable
<quartz>
Hmmm OK let me try to find the file where they implement the lexer
<d_bot>
<NULL> Look for a mll file
<quartz>
They only have .ml and .mly files
<d_bot>
<NULL> Then the lexer isn't generated through ocamllex, so I guess look for "lexer" or something
<quartz>
Oh there's one mll called scanner.mll
<sleepydog>
sounds promising
<quartz>
I'm assuming that lines 52 and 54 are where they implement it? https://bpa.st/MU6Q
xgqt has quit [Read error: Connection reset by peer]
<sleepydog>
the rule on line 120
<quartz>
Uhhh
<d_bot>
<NULL> Using `(==)` on ints, not a good idea
<sleepydog>
NULL: would that ever give an unexpected result? or does it just thwart certain optimizations?
Anarchos has joined #ocaml
<d_bot>
<NULL> It compares the underlying thing the variable holds (so it could be a pointer), but since it's an int it should behave as expected (since they are stored exactly as ints, just shifted)
xgqt has joined #ocaml
<d_bot>
<NULL> Also, it uses queues so not as "pure" as I'd do it
<quartz>
What do you guys use OCaml for?
<Anarchos>
quartz i develop a formal mathematical demonstration verifier
<quartz>
sleepydog: Can you tell me why line 105 implements python like indentation
<quartz>
Anarchos: Is that a project for your job or just a personal project?
<Anarchos>
quartz a personal one
<d_bot>
<mbacarella> I'm generally pretty intimidated when I hear what other people use ocaml for. Most of my career the answer is something like system monitoring or compliance archiving
<quartz>
Sorry to ask again, but I'm not sure how line 105 of this code implements a python like indentation for a compiler when it has FLOAT_LITERAL in the code: https://bpa.st/MU6Q
<d_bot>
<NULL> There's no indentation information related to a float literal, so why should there be INDENT or DEDENT there ?
<quartz>
yeah good point. I was just following up on what sleepydog suggested, that's all.
bartholin has quit [Ping timeout: 252 seconds]
<quartz>
So they actually implement python indentation in lines 52 and 54? it seems they wrote a simple recrusive function that adds DEDENT or INDENT to a queue?
<d_bot>
<NULL> As sleepdog said, the core of the implementation is at lines 120 and following
<quartz>
omg
<quartz>
Wow I need some sleep, I saw 105 for some reason
<quartz>
I've literally been up all night lol and this is what happens
<quartz>
sleepydog: Thanks for pointing that out
bartholin has joined #ocaml
quartz has quit [Quit: WeeChat 3.4]
rond_ has quit [Quit: Client closed]
rgrinberg has joined #ocaml
Anarchos has quit [Quit: Vision[]: i've been blurred!]
rgrinberg has quit [Ping timeout: 240 seconds]
bartholin has quit [Ping timeout: 260 seconds]
mro has joined #ocaml
mro has quit [Client Quit]
bartholin has joined #ocaml
waleee has quit [Ping timeout: 240 seconds]
gravicappa has quit [Ping timeout: 252 seconds]
waleee has joined #ocaml
rgrinberg has joined #ocaml
rgrinberg has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]