companion_cube changed the topic of #ocaml to: Discussion about the OCaml programming language | http://www.ocaml.org | OCaml 5.2.0 released: https://ocaml.org/releases/5.2.0 | Try OCaml in your browser: https://try.ocamlpro.com | Public channel logs at https://libera.irclog.whitequark.org/ocaml/
tomku has quit [Ping timeout: 260 seconds]
waleee has quit [Ping timeout: 260 seconds]
Tuplanolla has quit [Quit: Leaving.]
tomku has joined #ocaml
germ has quit [Quit: ZNC 1.8.2+deb2build5 - https://znc.in]
germ has joined #ocaml
szkl has quit [Quit: Connection closed for inactivity]
YuGiOhJCJ has joined #ocaml
dh` has quit [Changing host]
dh` has joined #ocaml
mbuf has joined #ocaml
YuGiOhJCJ has quit [Remote host closed the connection]
YuGiOhJCJ has joined #ocaml
bartholin has joined #ocaml
Inline has joined #ocaml
Serpent7776 has joined #ocaml
Tuplanolla has joined #ocaml
sroso has joined #ocaml
YuGiOhJCJ has quit [Quit: YuGiOhJCJ]
Inline has quit [Ping timeout: 276 seconds]
sroso has quit [Quit: Leaving :)]
TCZ has joined #ocaml
bartholin has quit [Quit: Leaving]
waleee has joined #ocaml
torretto_ has quit [Remote host closed the connection]
torretto has joined #ocaml
TCZ has quit []
Anarchos has joined #ocaml
Inline has joined #ocaml
bartholin has joined #ocaml
<Anarchos> how can i see rules used by a grammar on a specific entry ? I have an error and i don't understand which rules are used
<dh`> by entry you mean... state?
<Anarchos> dh` on a specific text
<dh`> ah
<dh`> there is unfortunately no particularly good way to do that other than staring at the grammar and the example file
<dh`> first question is: are you actually getting the expected tokens from the lexer? if not that can cause very weird things to happen
<dh`> you probably have some idea of which rule/rules ought to apply, but it's not working, right?
<Anarchos> right
<dh`> can you pastebin the grammar? will be easier to discuss concretely
<dh`> (also, have you fixed all the conflicts?)
<Anarchos> dh` yes conflicts are fixed
<dh`> thanks
<Anarchos> i get «:1:64: syntax error near := X:=XFatal error: exception Stdlib.Parsing.Parse_error» on a line «var N := 8»
<dh`> right, I guess we also need the failing input
gareppa has joined #ocaml
<dh`> ok, so it got past var n := 8
<dh`> so it's reasonable to suspect that it doesn't like the expression
<dh`> (printing the column can make this sort of thing clearer)
<Anarchos> 64 is near the := and the 8
<dh`> my first guess would be that the precedence declarations have altered the meaning of the grammar in an unexpected way
<dh`> well, hold on, it said on line 8
<dh`> line 1 is a comment
<Anarchos> not hte line 8, but the '8' character
<dh`> oh, that's the text. oops
* dh` kan reed
<dh`> first obvious thing is to fix the lexer so you get the right line number out :-)
<dh`> my guess would be you aren't incrementing the line number on newline
germ- has joined #ocaml
germ has quit [Read error: Connection reset by peer]
<dh`> so the first thing I see is that you have a COLON_EQ token but the rules for vardec use COLON EQ
<Anarchos> the 1 is not the line, it is the first character position
<dh`> with reasonable assumptions about the lexer, that will prevent := from matching COLON EQ because it'll come through as COLON_EQ
<Anarchos> that is the problem ! I didn't see it thanks
<dh`> re lines, the default expectation for positions is "file:line:column: message"
<Anarchos> i never know if the smartest tokens are COLON_EQ for ':=' or COLON EQ
<dh`> if you make them separate tokens, it'll accept "var x : = 3" and you probably don't want that
<dh`> at least given normal treatment of whitespace in the lexer
<dh`> so the basic principle is anything you want to be a lexical unit where whitespace/comments/whatnot can't appear in the middle should be its own token
<dh`> so in a C grammar you have PLUS, PLUSEQ, PLUSPLUS, MINUS, MINUSEQ, MINUSMINUS, etc.
<dh`> also my recommendation is: use names of glyphs for tokens and names of semantic operations in the downstream parse tree/ast
<dh`> so STAR for *, MUL or MULT downstream
gareppa has quit [Quit: WeeChat 4.1.1]
<dh`> also, split up that 200-character %token line :-)
<dh`> (my suggestion would be: one %token line or group of lines for punctuation, separate one for reserved words; sometimes also makes sense to split the grouping punctuation out)
<dh`> also I continue to recommend writing out the expression grammar and not using associativity declarations, but that's up to you
<dh`> and, it looks like the parser won't accept this: for i := 0 to N do x[i] := i
<dh`> and if you fix that, make sure that this: for i := 0 to N do x[i] := i + 1
<dh`> groups the + correctly
<Anarchos> dh` i have 52 test cases . I will do my best
<dh`> also, do you mean to have both expseq and exp_seq?
<dh`> and it looks like the distinction between the parens and sequencing rules is unnecessary
<dh`> er, parentheses
<dh`> that is: "parentheses" and "sequencing" are allowed in the exact same places. The first is a single expression in parens; the second is at least two separated by a semicolon
<dh`> this can be replaced with a single version that accepts one or more
<dh`> which then eliminates most of the distinction between expseq and exp_seq
<Anarchos> dh` ok
mbuf has quit [Quit: Leaving]
germ- has quit [Ping timeout: 260 seconds]
germ has joined #ocaml
Anarchos has quit [Quit: Vision[]: i've been blurred!]
Inline has quit [Ping timeout: 244 seconds]
Inline has joined #ocaml
Serpent7776 has quit [Ping timeout: 255 seconds]
Inline has quit [Ping timeout: 272 seconds]
noddy has quit [Quit: WeeChat 4.3.3]
noddy has joined #ocaml
bartholin has quit [Quit: Leaving]
chrisz has quit [Ping timeout: 244 seconds]
chrisz has joined #ocaml
gentauro has quit [Read error: Connection reset by peer]
gentauro has joined #ocaml
dylanj has quit [Ping timeout: 246 seconds]
dylanj has joined #ocaml