<Algebr`>
I have an exectuable defined in _oasis that depends on C code. It the makefile generated by _oasis compiles the C code correctly using the -CCopts I gave but it doesn't use those -CCopts for the final executable. I need it to include them
<Algebr`>
I found it, its NativeOpt field.
keen___________8 has joined #ocaml
keen___________7 has quit [Ping timeout: 240 seconds]
tmtwd has quit [Ping timeout: 250 seconds]
sigjuice has quit [K-Lined]
sigjuice has joined #ocaml
Algebr` has quit [Remote host closed the connection]
tmtwd has joined #ocaml
struktured has quit [Ping timeout: 268 seconds]
ygrek has joined #ocaml
Algebr has joined #ocaml
<Algebr>
Ugh, the caml_alloc macro is biting me. Its replacing other code that uses alloc a whole bunch. What can I do
<Algebr>
ah, had to do #define CAML_NAME_SPACE
Fleurety has quit [Ping timeout: 240 seconds]
jpdeplaix1 has joined #ocaml
jpdeplaix has quit [Ping timeout: 240 seconds]
sgnb``` has joined #ocaml
Fleurety has joined #ocaml
sgnb`` has quit [Ping timeout: 240 seconds]
tokik_ has joined #ocaml
tokik has quit [Ping timeout: 240 seconds]
_whitelogger has joined #ocaml
ygrek has quit [Ping timeout: 260 seconds]
bendiken has quit [Ping timeout: 250 seconds]
ygrek has joined #ocaml
Algebr has quit [Remote host closed the connection]
MrScout has quit [Remote host closed the connection]
mcclurmc has joined #ocaml
browncodes has quit [Remote host closed the connection]
tmtwd has quit [Ping timeout: 246 seconds]
tennix has joined #ocaml
tmtwd has joined #ocaml
ygrek_ has joined #ocaml
ygrek has quit [Ping timeout: 268 seconds]
tmtwd has quit [Ping timeout: 246 seconds]
darkf has joined #ocaml
ygrek_ has quit [Ping timeout: 264 seconds]
tmtwd has joined #ocaml
samrat has joined #ocaml
mcclurmc has quit [Remote host closed the connection]
mcclurmc has joined #ocaml
samrat has quit [Ping timeout: 272 seconds]
samrat has joined #ocaml
MercurialAlchemi has joined #ocaml
tmtwd has quit [Ping timeout: 260 seconds]
ygrek has joined #ocaml
browncodes has joined #ocaml
samrat has quit [Ping timeout: 264 seconds]
MercurialAlchemi has quit [Ping timeout: 265 seconds]
BitPuffin|osx has quit [Ping timeout: 256 seconds]
psy_ has quit [Ping timeout: 246 seconds]
tmtwd has joined #ocaml
tmtwd has quit [Ping timeout: 246 seconds]
psy_ has joined #ocaml
ggole has joined #ocaml
Simn has joined #ocaml
BhavyaM has joined #ocaml
mea-culpa has joined #ocaml
ely-se has joined #ocaml
ousado_ has joined #ocaml
ousado has quit [Ping timeout: 255 seconds]
tibor has joined #ocaml
ggole has quit [Ping timeout: 252 seconds]
grouzen has joined #ocaml
thomasga has joined #ocaml
<tibor>
Hi
<tibor>
If I have st = I of int F of float;; How can I typecast type an int into st ?
<adrien>
let x = 42 in I x
<adrien>
?
<tibor>
thank you
mea-culpa has quit [Ping timeout: 240 seconds]
<adrien>
:)
thomasga has quit [Quit: Leaving.]
orbitz has quit [Remote host closed the connection]
ggole has joined #ocaml
mort___ has joined #ocaml
jpdeplaix1 is now known as jpdeplaix
orbitz has joined #ocaml
psy_ has quit [Ping timeout: 246 seconds]
zpe has joined #ocaml
kushal has joined #ocaml
ygrek has quit [Ping timeout: 255 seconds]
mort___ has quit [Quit: Leaving.]
mort___ has joined #ocaml
ousado_ is now known as ousado
ousado has quit [Changing host]
ousado has joined #ocaml
Haudegen has quit [Ping timeout: 244 seconds]
thomasga has joined #ocaml
mcc has quit [Quit: Connection closed for inactivity]
moei has quit [Read error: Connection reset by peer]
Haudegen has joined #ocaml
moei has joined #ocaml
thomasga has quit [Quit: Leaving.]
zpe has quit [Read error: Connection reset by peer]
ollehar has joined #ocaml
Kakadu has joined #ocaml
mort___ has quit [Quit: Leaving.]
ely-se has quit [Quit: leaving]
ely-se has joined #ocaml
browncodes has quit [Remote host closed the connection]
grouzen has quit [Ping timeout: 240 seconds]
larhat has joined #ocaml
ely-se has quit [Quit: leaving]
larhat has quit [Client Quit]
Sorella has quit [Quit: Connection closed for inactivity]
jtfmumm has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
psy has joined #ocaml
martintrojer has joined #ocaml
jtfmumm has joined #ocaml
ceryo has joined #ocaml
sh0t has joined #ocaml
AlexRussia has quit [Ping timeout: 244 seconds]
SomeDamnBody has joined #ocaml
<SomeDamnBody>
So, I'm using Async_extra's tcp module
<SomeDamnBody>
and I have a C++ program that I want to communicate with my ocaml server
<SomeDamnBody>
in ocaml, I have the server listening with a callback able to read from a reader on a known port. The server receives a request on that known port from any client, does some work, and then writes a response out over a writer
<SomeDamnBody>
The problem I have is I'm connecting from the C++ side, I have a socket that I use connect with to send to the server, but how do I recceive from the server on the C++ side when the ocaml side calls write on the writer?
sh0t has quit [Remote host closed the connection]
ceryo has joined #ocaml
AlexRussia has joined #ocaml
bendiken has joined #ocaml
psy has quit [Disconnected by services]
ceryo has quit [Read error: Connection reset by peer]
psy_ has joined #ocaml
ceryo has joined #ocaml
tennix has quit [Ping timeout: 246 seconds]
zozozo has quit [Quit: WeeChat 1.2]
zozozo has joined #ocaml
grouzen has quit [Ping timeout: 244 seconds]
demonimin has quit [Ping timeout: 240 seconds]
tennix has joined #ocaml
pyon has quit [Quit: Dammit, f...ix you, Emacs.]
samrat has quit [Ping timeout: 244 seconds]
pyon has joined #ocaml
pyon has quit [Remote host closed the connection]
pyon has joined #ocaml
AlexRussia has quit [Ping timeout: 250 seconds]
<flux>
somedamnbody, sounds like a completely c++ question.. :-)
<flux>
but no worries, competent ocamler knows it as well!
<flux>
how are you trying to send and receive?
tennix has quit [Ping timeout: 250 seconds]
zpe has joined #ocaml
AlexRussia has joined #ocaml
<tane>
flux, yeah, as C++ is going ugly functional :)
<SomeDamnBody>
Well, on C++ side I'm using network socket, with is just really zmq
<tane>
problably easier to first establish whether the ocaml server actually sends anything with a small python script or similar
<tane>
(or telnet even)
<flux>
somedamnbody, well I don't know zmq, but I understand it has some function for reading from the scoket.. ?
<SomeDamnBody>
tane, I'm able to unit test the ocaml side with some short code that clearly shows the ocaml side is sending
<tane>
alright, that's good
<SomeDamnBody>
well, that's just the same problem really-
<flux>
a shocking revelation: socat doesn't support ZMQ :-o
<SomeDamnBody>
in C++, sockets or zeromq on up, when you create a socket that one socket is really either a reader or a writer as I understand it
<SomeDamnBody>
socat - ? I'm using Async_extra's Tcp module
<flux>
socat is a command line tool for dealing with different kind of sockets
<flux>
zmq support would be fine
<SomeDamnBody>
ok, so maybe just better to recode the ocaml part in zmq
<SomeDamnBody>
?
<flux>
I thought you were using zmq already?
<SomeDamnBody>
yeah, but only on C++ side
<flux>
oh...
<tane>
what about zmq_recv?
<SomeDamnBody>
I know, it's a zombie
<flux>
isn't zmq an all-or-nothing deal?
<tane>
and where does it state what you said about either being reader or writer?
<SomeDamnBody>
well, zmq's socket models are REQ/REP, PUSH/PULL or some other model
zpe has quit [Ping timeout: 250 seconds]
<flux>
somedamnbody, so you're not using async-zmq?
<SomeDamnBody>
REQ sockets use some kind of framing...
<SomeDamnBody>
no, I'm using async_extra's Tcp module
samrat has joined #ocaml
<flux>
well, that seems so counterproductive to me.. :)
<SomeDamnBody>
yeah I know
<SomeDamnBody>
it wasn't my choice to pick Async on ocaml and ZMQ on C/++
<flux>
you're not writing an alternative ocaml zmq implementation?
<SomeDamnBody>
I was "ordered" into it by an ignorant manager
<flux>
somedamnbody, you can just use async-zmq
<tane>
even this is for python, it shows how zmq can send and recv on the same socket
<flux>
and then you're using async on ocaml and zmq on c++
<flux>
I doubt he meant you to write the code with tcp sockets?-o
<SomeDamnBody>
no he did
<SomeDamnBody>
we are dealing with an ignorant manager here
<flux>
well, educate him
<flux>
I mean, what's the point of ZMQ if you do that..
<SomeDamnBody>
I tried. He's stubborn
<SomeDamnBody>
I should be the one making technical decisions because I'm in the dirt and thick of it
<SomeDamnBody>
he should only say "what"
<SomeDamnBody>
should be done. Anyway, hopefully I can make it work with Async-zmq
<flux>
good luck! may your sanity prevail!
<tane>
(btw, the zmq c++ wrapper is a real masterpiece of bad naming)
<flux>
somedamnbody, btw, is zmq itself any good?-o
<SomeDamnBody>
yes, I like zmq a lot
<flux>
I seem to recall there was some replacement/fork for zmq
<SomeDamnBody>
it's very well supported and well documented
<flux>
which attempts to address some shortcomings of zmq
<flux>
I don't remember its name, though..
<flux>
ah, nanomsg
<SomeDamnBody>
tane, I know about the bad C++ wrapper, but honestly, I don't have the time to change the periphery of my tools. I want to write a czmq ocaml wrapper with ctypes
jtfmumm has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
<SomeDamnBody>
flux, no, I'm not writing alternative ocaml zmq implementation. Just writing a basic RPC between ocaml function and C++ in ocaml
<tane>
yeah, interested in whether people actually use _t for their own types i've scanned the top 20 C projects on github, and yeah, a lot do. But for c++ as a classname, that's new :D
johnf has quit [Read error: Connection reset by peer]
<maurer>
So, I'm calling caml_acquire_runtime_system() in some external code, with a print statement immediately after (long before the release) and two threads seem to be successfully acquiring the runtime system at the same time
<maurer>
Is there something I might have missed that would allow two threads to call caml_acquire_runtime_system and both succeed without a release?
<maurer>
Hrm, actually, I just checked the return codes on caml_register_thread(), and they're returning false, so maybe that has something to do with it?
<tane>
maurer, did you create that thread?
<tane>
(the two additional threadS)
ygrek has joined #ocaml
<maurer>
tane: I called caml_register_thread, I'm now working on checking the error code to know if it succeeded
<maurer>
*caml_c_register_thread
<tane>
alright, that would've been my next question :)
yomimono has joined #ocaml
nullcatxxx_ has joined #ocaml
<tane>
the question remains, why they fail
Guest38 has joined #ocaml
nullcatxxx_ has quit [Client Quit]
nullcatxxx_ has joined #ocaml
MrScout has joined #ocaml
<vbmithr>
yo
<vbmithr>
Does anyone has an issue compiling opam ?
<nullcatxxx_>
?
<vbmithr>
sorry it's vague :)
<vbmithr>
I need to investigate
nullcatxxx_ has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
ollehar has quit [Ping timeout: 240 seconds]
<vbmithr>
found the issue
ncthom91 has joined #ocaml
<mrvn>
zmq has one major issue: You don't get told when a connection dies.
ncthom91 has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<tibor>
if I have a type: "type a = {b:int;c:string option};; type d = | A of a | G of g;;" and I would like to write a pattern mach to have a varaible to point to the structure and an other variable to point to a field example: "match d with |A {newa with a.c = x} when Option.is_some x -> ..." How can I do this?
zpe has quit [Ping timeout: 256 seconds]
<maurer>
tane: caml_c_register_thread is returning 0 for me on both thread registration attempts
<zozozo>
tibor: match .. with | A { b; c } as a -> ...
<tibor>
thank you zozozo
<maurer>
tane: I've already called caml_startup, which is the only other initialization I know I need to do before calling caml_c_register_thread
<tane>
maurer, so the main entry point to the whole application is on the c-side?
johnf has joined #ocaml
<zozozo>
tibor: you can even go further and do something like match d with A { b; c = Some string; } as a -> ...
<zozozo>
which should be faster than using a side condition with 'when'
<maurer>
tane: yes
<tibor>
thanks :)
<tane>
maurer, i guess you called caml_startup with some non-null value?
<maurer>
I fed it:
<maurer>
static char* argv[] = { NULL };
ryanartecona has quit [Quit: ryanartecona]
<maurer>
Without using thread registration/locking the C-side works correctly
<tane>
so calling into ocaml from the startup thread works fine, mh
<maurer>
Correct
<maurer>
So, I actually have two programs here - the actual program, which does some other stuff via threads before trying to access the library, has caml_c_thread_register() fail all the time
<maurer>
The testcase I have, which is a much shorter file, has caml_c_thread_register() succeed, but _unregister() fails
ceryo has joined #ocaml
tennix has joined #ocaml
struktured has quit [Ping timeout: 256 seconds]
raichoo has quit [Ping timeout: 256 seconds]
<tane>
maurer, is that "testcase" code pastable?
tennix has quit [Ping timeout: 246 seconds]
<maurer>
Sure
<maurer>
I think I may have figured out why caml_c_thread_register() is failing in the other code, but I'll get back to that (it looks like OCaml may think it owns TLS)
<maurer>
Hrm, no, it looks like it may be using tls right, I no longer have a theory
tennix has joined #ocaml
<tibor>
if I have a type: "type a = {b:int;c:string option};; type d = | A of a | G of g;;" and I would like to write a pattern mach to have a variable to point to the structure and an other variable to point to a field example: "match d with |A {c = Some x} as newa -> a {c = (Some x(*this is not relevant*))}" Why newa is type G?
raichoo has joined #ocaml
tennix has quit [Ping timeout: 260 seconds]
<tibor>
if I have a type: "type a = {b:int;c:string option};; type d = | A of a | G of g;;" and I would like to write a pattern mach to have a variable to point to the structure and an other variable to point to a field example: "match d with |A {c = Some x} as newa -> a { newa with c = (Some x(*this is not relevant*))}" Why newa is type G?
<tibor>
if I have a type: "type a = {b:int;c:string option};; type d = | A of a | G of g;;" and I would like to write a pattern mach to have a variable to point to the structure and an other variable to point to a field example: "match d with |A {c = Some x} as newa -> a { newa with c = (Some x(*this is not relevant*))}" Why newa is type d?
jtfmumm has joined #ocaml
_obad_ has joined #ocaml
ncthom91 has joined #ocaml
<maurer>
tane: Do I perhaps need to call caml_thread_initialize?
<zozozo>
tibor: in your first example, your pattern is not complete, it should be : match d with A {c = Some x; _ } -> ...
<tane>
maurer, calling into caml from the first initialized thread then, to enable the other two to register? may work, i don't know :)
<tane>
seems strange though
<zozozo>
tibor: could you paste a complete self contained code and error somewhere ? it would be easier to read
whirm has quit [Quit: WeeChat 1.3]
<maurer>
tane: I have a theory again
<maurer>
tane: I think caml_thread_initialize is not being called
<tane>
oh ok, well, i'm curious if that'll work
<maurer>
tane: This would result in a failure upon trying to deallocate the thread (thus why unregister is failing), and would mean then that the thread tls key is uninitialized
<tibor>
zozozo: I have a very complicated code, 200 k lines and it would be very hard to send you the interesting part
<maurer>
tane: this would also explain why my other program has caml_c_thread_register failing, because it uses TLS, and so the "0" key is already in use
<maurer>
So when it goes to check if the thread is allocated, it sees that it is
<tane>
yes, ok
<tibor>
Error: This expression has type IF.struc_sess_formula = Iformula.struc_sess_formula but an expression was expected of type IF.sess_formula_transmit = Iformula.sess_formula_transmit
<tane>
still, this would render using ocaml from a threaded c-context rather impractical
<tane>
anyway, i hope that's it
<tane>
can't get bap to even install here, as of missing device space..
<maurer>
Yeah, sorry, I know it's kind of a big project
<zozozo>
tibor: hm... so, your first example should be (from what I can understand): match d with | A of ({ c = Some x; _ } as newa) -> A { newa with c = Some x } | G _ -> ...
<tibor>
where struc_sess_formula = d and sess_formula_transmit = a
<tibor>
yes
<zozozo>
tibor: anyway, when you match a record, either specify all the fields, or omit some using _
<zozozo>
because in the code you showed the '{c = Some x}' part of the match only matches a record type with one field which is an '_a option, while your type a has two fields, so that explains why there are some errors
<tibor>
zozozo: yes, I fixed the maching problem but the error is still the same
<maurer>
tane: So, I tried adding Thread.yield () to the OCaml library side, and this causes caml_c_register_thread() to return false, but that may be because caml_startup is now registering it, so it looks like it does something
jeffmo has joined #ocaml
Kakadu has quit [Quit: Page closed]
<zozozo>
tibor: also, at the end, you should do 'A { newa with ...', and not 'a { newa with ..', since the constructor is 'A' not 'a'
<maurer>
OK, so it turns out you need to:
<tibor>
Thank you, this was the problem
<maurer>
1.) Call at least one function from the thread module
<tibor>
zozozo : Thank you, this was the problem
nullcatxxx_ has joined #ocaml
<maurer>
2.) once you call caml_startup, your current thread has been registered and you hold the lock
<maurer>
3.) Before you unregister your thread, you must release the lock
<zozozo>
ah, and lastly, parenthesis rules for the 'as' constructs are sometimes surprising, so do not hesitate to add a lot of parenthesis in a match with it
ryanartecona has joined #ocaml
<tibor>
zozozo: thank you
<zozozo>
tibor: i.e 'match d with | A {..} as a' is understood as 'match d with | (A {..}) as a'
<zozozo>
so you need to add some parenthesis if you want to bind the record and note the sum type
<tibor>
zozozo : very interesting, thank you for your help and I'm sorry for my simple questions
<zozozo>
tibor: glad I could help
<tane>
maurer, yeah, i thought about that too, so it works now?
<tane>
like, what does `caml_startup` actually do regarding the starting thread..
<tane>
i hope you save that knowledge somewhere in the your repository :)
<maurer>
(you can replace bap_ with caml_ and get the same idea. The functions have separate symbol names to support multiple wrapped ocaml libs in the same program)
<tane>
yeah
<tane>
alright then, this was an interesting hunt :)
<tane>
i'll prepare myself for future undertakings by moving some files around.. hehe
zpe has joined #ocaml
nullcatxxx_ has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
zpe has quit [Ping timeout: 264 seconds]
Algebr has joined #ocaml
johnf has quit [Read error: Connection reset by peer]
MercurialAlchemi has quit [Ping timeout: 272 seconds]
_andre has joined #ocaml
zpe has joined #ocaml
_andre has quit [Quit: leaving]
zpe has quit [Ping timeout: 260 seconds]
bendiken has quit []
bendiken has joined #ocaml
Guest38 has quit [Read error: Connection reset by peer]
Guest38 has joined #ocaml
kushal has quit [Ping timeout: 268 seconds]
yomimono has quit [Ping timeout: 252 seconds]
struktured has quit [Ping timeout: 244 seconds]
johnf has joined #ocaml
MrScout has quit [Remote host closed the connection]
ryanartecona has quit [Quit: ryanartecona]
MrScout has joined #ocaml
Wickoo has joined #ocaml
<Wickoo>
Hi everyone! earlier today I asked a question on stackoverflow about the way campl4/5 deal with operator precedence, but haven't got an answer. Can anyone here take a look? http://stackoverflow.com/questions/32312521/how-does-camlp5-former-camlp4-parse-expressions. What I'm looking at is how this approach is implement. Any links to publications, etc is highly appreciated.
MrScout has quit [Remote host closed the connection]
MrScout has joined #ocaml
Haudegen has quit [Ping timeout: 250 seconds]
zpe has joined #ocaml
zpe has quit [Ping timeout: 246 seconds]
Haudegen has joined #ocaml
jwatzman|work has quit [Quit: jwatzman|work]
MrScout has quit [Remote host closed the connection]
<Wickoo>
If anyone can help me understand the internals of campl4 parsing technique (specifically, for precedence) let me know.
<mrvn>
Why do you want to learn something (mostly) obsolete?
raichoo has quit [Ping timeout: 264 seconds]
tane has quit [Quit: Verlassend]
<Wickoo>
@mrvn you mean obsolete "as a topic" or camlp4? I'm doing research on parsing algorithms (well, I know it's not the hottest PL topic out there, but the scope is also a bit different) Anyway, a reviewer pointed out that camlp4 is good and can parse full OCaml, and I cannot figure it out how it works (with respect to operator precedence)
<mrvn>
Wickoo: camlp4 is mostly obsoleted by ppx.
<Wickoo>
mrvn: ok, I've never heard of ppx. Thanks for pointing it out. Does it also have the same parsing capabilities as camlp4?
<mrvn>
I'm not sure how camlp4/4 does it specifically but generally a recursive descent parser has rules like: expr-add: expr-mul | expr-mul "+" expr-add, expr-mul: expr-simple | expr-simple "*" expr-mul, expr-simple: int | "(" expr-add ")"
<mrvn>
Wickoo: ppx is called from inside ocamlc/ocamlop with an already parsed tree. it doesn't parse at all.
jtfmumm has joined #ocaml
<Wickoo>
mrvn: that's exactly my question. When I look at a camlp4 grammar it has left recursions and there is a declarative way to define operator precedence:
<Wickoo>
mrvn: for example: expr: [ "add" LEFTA [ x = expr; "+"; y = expr -> x + y | x = expr; "-"; y = expr -> x - y ] | "mult" RIGHTA [ x = expr; "*"; y = expr -> x * y | x = expr; "/"; y = expr -> x / y ] | "simple" NONA [ x = INT -> int_of_string x | "("; e = expr; ")" -> e ] ] ;
<mrvn>
Wickoo: did you write that?
<Wickoo>
mrvn: there is left recursion and there is precedence, and I cannot figure it out how exactly it works. There are some vague descriptions on some blog posts, but I was looking for more details. Does the translation pass an argument as a precedence level? or rewrites the grammar under the hood to make it like your grammar?
<mrvn>
Wickoo: "(You'll need a string_of_int to use this grammar with the earlier framework.) The idea with levels is that parsing begins at the topmost level; if no rule applies in the current level, then the next level down is tried. Furthermore, when making a self-call, call at the current level (or the following level; see below) rather than at the top. This gives a way to implement operator precedence: order the operators to
<mrvn>
Wickoo: so it transforms it interally on the fly.
<Wickoo>
mrvn: is there a way I can see the transformed version or the code for the transformation? (I basically don't know OCaml, but I guess I can get through it if someone show me where to look) What I'm really interested is the algorithm it uses to transform/or the way it passes arguments, etc
jtfmumm has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
<mrvn>
Wickoo: it sounds like it doesn't transform. It just keeps track of the current level.
<mrvn>
Wickoo: it's all explained verry well in that article.
tennix has joined #ocaml
<Wickoo>
mrvn: I think the explanation is very high-level, I really want to see the actual code that it is being executed. In particular how it manages LEFTA, RIGHTA values and how it avoids going to infinite loops. It also says that it will try the next level if the current level fails. Does it backtrack?
<mrvn>
Wickoo: LEFTA, RIGHTA just change what level the recursion needs to match.
<mrvn>
No idea how it avoids the looping in RIGHTA
tennix has quit [Ping timeout: 244 seconds]
<mrvn>
It must have some way that a self call tries without recursion and falls back to recursion when it can't.
rand000 has joined #ocaml
<Wickoo>
mrvn: I see the basic idea, but devil is in the details. Would be nice if I could see the magic behind it. Any ide where to look for the magic?
<mrvn>
the source
enquora has joined #ocaml
<Wickoo>
mrvn: good that I don't have to look at the binary version :-) ok, I'll try to dig into the source file. Was hoping this is documented somewhere
<Wickoo>
mrvn: thanks for the help
<mrvn>
Wickoo: How do you define a RIGHTA manually so it doesn't loop?
grouzen has quit [Ping timeout: 250 seconds]
<mrvn>
without any magic parser that knows associativity
<Wickoo>
marv: say you have E ::= E '+' E | 'a'. if you want a right associative version, you need to restrict the left E, something like this: E ::= E1 '+' E | 'a', E1 ::= 'a'. Well, there is a right-recursion, which is a loop, but right recursion is not a problem for top-down parsing
<mrvn>
Wickoo: That isn't right recursive anymore
<Wickoo>
marv: why? E ::= E1 '+' E is not right recursive?
<mrvn>
Wickoo: its left associative.
zpe has joined #ocaml
<Wickoo>
marv: E ::= E1 + E | 'a'; E1 ::= 'a'. Try parsing a+a+a: you will get E => E1 + E => a + E => a + E1 + E => a + a + a
<Wickoo>
marv: isn't it right associative to you?
<mrvn>
Ends up with 'a' + ('a' + ('a' + 'a'))
<mrvn>
not (('a' + 'a') + 'a') + 'a'
<Wickoo>
marv: which is right associative? the left one would be (('a' + 'a') + 'a') + 'a'. If you want the other one, you need the following grammar: E ::= E + E1 | 'a'; E1 ::= 'a'
<mrvn>
That one loops
<Wickoo>
marv: which is left-recursive and cannot be easily dealt-with in recursive descent parsing
<mrvn>
Wickoo: RIGHTA causes such a left-recursion
mort___ has quit [Ping timeout: 244 seconds]
<mrvn>
Wickoo: I'm wondering if you can solve that at all without some magic in the parser.
zpe has quit [Ping timeout: 246 seconds]
<Wickoo>
mrvn: for left associativity you need left recursion (otherwise you need to rewrite the trees) so, I think a simple answer is no, you need a mechanism
<mrvn>
Wickoo: well. have fun finding out what that magic is in camlp4.
<mrvn>
Wickoo: I wrote myself a grammar driven LALR(1) parser.
<Wickoo>
marv: but I still don't understand why you say for RIGHTA you need that, I think for LEFTA we need left recursion. LEFTA should yield ((a+a)+a) and RIGHTA, (a+(a+a)).
<Wickoo>
marv: yeah, I was hoping someone could show me a document and relieve me from the pain of looking into OCaml :-)
<mrvn>
Wickoo: your example has * and / as RIGHTA. The / is the one that causes the loop.
<mrvn>
Wickoo: maybe your example had it backward.
<Wickoo>
mrvn: OK, so it's the example, I thought you mean in general.
<mrvn>
Wickoo: "If the next token is a binary operator and the precedence of that operator is greater or equal to p" is the magic bit. I guess in camlp4 that translates into the lookahead matching a rule in the current level.
<mrvn>
(or greater)
<Wickoo>
mrvn: where did you find this text?
<mrvn>
Wickoo: your url
<Wickoo>
mrvn: aha, the last one. Yeah, I suspect it should be something similar, but would be good if I can confirm it. now looking into source codes :-) lost in OCaml
Denommus has quit [Quit: going home]
<mrvn>
Wickoo: a lookahead with the right grammar eliminates all the guesses and backtracking and leads to always picking the right recursion to call.
<mrvn>
just in the case of a left recursion you make the decision that you should have recursed at the end of the rule.
<Wickoo>
mrvn: in this url, left recursion is explicitly rewritten, but in campl4 it is dealt with dynamically as far as I can say
<mrvn>
Something like: { parse next level, again: parse "/", parse next level, $0 = action; if (lookahead == "/") goto again; }
<mrvn>
The endless recursion is turned into a finite iteration.
ollehar has joined #ocaml
ollehar has quit [Remote host closed the connection]
<mrvn>
Wickoo: have you understood the shunting yard algorithm?
<Wickoo>
marv: yeah, I know how it works, but does camlp4 work according to that? I mean translating all these info into a table and then running it?
<mrvn>
Wickoo: as said, no idea about camlp4 internas.
mort___ has joined #ocaml
<mrvn>
only way to know what camlp4 does is to read the source.
<Wickoo>
mrvn: ok, I thought maybe you discovered it works like that.
<Wickoo>
mrvn: yeah, I wish I have spent some time learning OCaml instead of spending studying its syntax
<Wickoo>
mrvn: would have been handy in times like this
mort___ has quit [Client Quit]
<Wickoo>
mrvn: I'm basically a Java programmer, and recently some Scala, but no way close to ML, Haskell stuff. Hurts my brain
<mrvn>
Wickoo: learning ocaml is worth it for its own sake.
<Wickoo>
mrvn: that's definitely true!
<mrvn>
and not knowing any functional language will make reading ocaml hard
mort___ has joined #ocaml
nullcatxxx_ has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
Kakadu has quit [Remote host closed the connection]
nullcatxxx_ has joined #ocaml
ryanartecona has quit [Quit: ryanartecona]
rand000 has quit [Quit: leaving]
Guest38 has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
mort___ has quit [Quit: Leaving.]
Wickoo has quit [Ping timeout: 246 seconds]
deavid has quit [Ping timeout: 250 seconds]
deavid has joined #ocaml
zpe has joined #ocaml
zpe has quit [Ping timeout: 264 seconds]
madroach has quit [Ping timeout: 264 seconds]
swgillespie has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
madroach has joined #ocaml
nullcatxxx_ has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
Simn has quit [Read error: Connection reset by peer]
Wickoo has joined #ocaml
JuggleTux has quit [Ping timeout: 244 seconds]
johnf has quit [Read error: Connection reset by peer]