Banana changed the topic of #ocaml to: OCaml 3.08.1 available! | Archive of Caml Weekly News: http://sardes.inrialpes.fr/~aschmitt/cwn/ | A tutorial: http://merjis.com/richj/computers/ocaml/tutorial/ | A free book: http://cristal.inria.fr/~remy/cours/appsem/ | Mailing List: http://caml.inria.fr/bin/wilma/caml-list/ | Cookbook: http://pleac.sourceforge.net/
<vincenz> re
GreyLensman has joined #ocaml
<vincenz> is there unicode support for ocaml?
solarwind has quit [Read error: 110 (Connection timed out)]
<Demitar> vincenz, yes. (Depends on exactly what you want of course.)
<vincenz> I'm trying to build a lexer that recognizes utf
<vincenz> also
<vincenz> for lexer
<vincenz> if I have letter = ['a'-'z']
<vincenz> let digit = ['0'-'9']
<vincenz> how do I combine these two?
<vincenz> nm, got it
zigong_ has joined #ocaml
<vincenz> Demitar: do you know how to use the ocamllexer well?
<Demitar> vincenz, yes and no. :)
<Demitar> vincenz, what you want is wlex or ulex.
<vincenz> thnx
<vincenz> are they any good?
<Demitar> Haven't used them. What are you lexing btw?
GreyLensman has quit ["Leaving"]
<vincenz> question about parser
<vincenz> if you have a rule in BNF
<vincenz> a:
<vincenz> b {.b} c
<vincenz> is there an easy way to do this?
<Demitar> What do {} mean in bnf?
* vincenz mutters at the specs
<vincenz> how stupid
<Nutssh> Define your notation with {}
<Demitar> And take into account that I should be sleeping... :)
<vincenz> bnf {} means zero or more of
<vincenz> aka
<vincenz> 'a' {'b'}
<vincenz> is: a, ab, abb, abbb
<vincenz> ..
<vincenz> in bnf
<vincenz> man the java specs are dumb
<Demitar> It's a regexp in ocamllex.
<vincenz> Demitar: nono...this was an example
<vincenz> I'm doing syntax now
<Demitar> Thus 'b'*
<vincenz> I was merely explaining {}
<vincenz> I'm doing syntax
<vincenz> aka parser
<vincenz> lexer is done
<Demitar> Ah. :)
<vincenz> how stupid
<vincenz> qualified_identifier:
<vincenz> identifier {DOT identifier}
<vincenz> then later
<Demitar> Well recursiveness is the key in the parser.
<vincenz> type:
<Nutssh> Thats pretty easy. SPlit it into two nonterminals B ::= b B | b A ::= A B C | A C
<vincenz> identifier {DOT identifier} brackets_opt
* vincenz palmslaps
<vincenz> just put qualified_identifier then!
<vincenz> man they just have a really fucked up bnf
<vincenz> check this
<vincenz> expression1:
<vincenz> expression2 [expression1rest]
<vincenz> where [] means optional
<vincenz> expression1rest:
<vincenz> [? expression : expression1]
<vincenz> call about redundant []
<vincenz> s/call/talk
<Demitar> Good to hear java isn't merely evil as a language but even the specs are evil. ;-)
<vincenz> ack, even more crap
<vincenz> I'm never quite sure whether I should turn b: {a } into
<vincenz> b:
<vincenz> b_recurse
<vincenz> with b_recurse either
<vincenz> b_recurse:
<vincenz> | a
<vincenz> | b_recurse a
<vincenz> or | a b_recurse
<vincenz> hmm left to right most likely dictates the second
* vincenz does qualified_identifiers right to left and the rest left to right
* vincenz mutters
<vincenz> their bnf doesn't even take care of operator-precende
<vincenz> precedence
<vincenz> oh well, I'll backpatch it later
<Nutssh> Keep it simple and systematic. ANytime you see {x} turn that into X ::= x X | epsilon .
<vincenz> yeah I know
<vincenz> but not for qids
<Nutssh> Err, you're using ocamlyacc, thats an LALR, left recursive isn't a problem.
<Nutssh> qid == ??
<vincenz> qualified identifier
<vincenz> ala
<vincenz> X.Y.C
<vincenz> I'd rather have (C (Y (X)))
<vincenz> the rest I'm doing x X
<vincenz> sadly their bnf doesn't take care of operator overloading :/
<vincenz> ack
<vincenz> I mean operator precedence
<Nutssh> What is this for? Can you reuse another java parser and avoid the whole hangup?
<vincenz> fun
<Nutssh> Why not play with CIL and analyze and manipulate C code? CIL can gobble the linux kernel!
<vincenz> I've looked at cil
<vincenz> sadly I need to parse c++
* vincenz mutters
<vincenz> and there's nothing good out there
lus|wazz has joined #ocaml
<Nutssh> C++ grammar is AFAIK insane. Maybe try to write an extension to CIL for C++? :)
<vincenz> no
<vincenz> a) impossible
<vincenz> b) useleess
<vincenz> you need SGLR or GLR to parse C++
<vincenz> only two opensource systems do it (actually 3)
<vincenz> elsa from same guy as cil
<vincenz> and transformers or codeboost that work on stratego
<vincenz> sadly elsa doesn't cover certain things and has an AST-format that's too flattened
<vincenz> transformers gives you perfect input to output but does no semantic analysis at all (except to disambiguate the syntax)
<vincenz> codeboost does some semantic analysis, but sadly no template instantiation so I'll have to do that by hand
<vincenz> :/
<vincenz> if you consider that it took microsoft 2 years to get it right
<vincenz> as for the uselessness, cil flattens too much
<Nutssh> I don't know how hard it is to parse C++.
<vincenz> Nutssh: consider that the syntax has ambiguities
<vincenz> transformers uses stratego which allows trees with ambiguous leaves
lus|wazz has quit [Client Quit]
* Nutssh nods. Whats wrong with flattening?
<vincenz> and then does some post processing (pruning) to select the right leaves
* Nutssh nods.
<vincenz> Nutssh: I need to do source to source transformations that leave the code as much as possible as i
<vincenz> one example
<vincenz> elsa and cil turn
<vincenz> a[i]
<vincenz> into
<vincenz> (*((a) + (i)))
<vincenz> well elsa adds the extra parens, cil does that better
<Nutssh> Whats wrong with that other than the lost type information? (which doesn't matter for C)
lus|wazz has joined #ocaml
<vincenz> the fact that after me come other optimisation steps, not done by me
<vincenz> that are specific for arrays
<vincenz> (loop-unrolling, data-morphing, etc)
<Nutssh> [] is a syntatic abbreviation---are you sure that modern compilers give it a semantic meaning in optimization passes?
<vincenz> preferably I can get the exact input (well without whitespace,indent and comments) in the output if I don't do any actual transformations
<vincenz> Nutssh: compilers don't, tools made in my research group do
<vincenz> most loop and data transformations work on regular arrays
<vincenz> and thus scan for array accesses
<vincenz> though I doubt they can do much with c++
<vincenz> they only handle c
<vincenz> but my advisor forces me to do C++
<vincenz> :/
<vincenz> (I'm the very first step in our metaflow so I need to be as general as possible)
<Nutssh> Ah. Alter unparser to rewrite: *a+b into a[b]?
<vincenz> yeah I know
<vincenz> I'm still not sure whether to go for elsa or codeboost
<vincenz> I'll have to look into codeboost first
<vincenz> but afaik elsa doesn't handle templates
<vincenz> stratego is a nice framework though
<vincenz> language-independent tranformation framework
<vincenz> you write transformation rules for any ast
<vincenz> as well as strategies to use those rules
<Nutssh> I'm not familiar to compilers to that depth. :)
<vincenz> it's not quite a compiler
<vincenz> basically a tranformation framewor
<vincenz> though theoretically you could transform and transform until you have assembly
<vincenz> though stratego is not that efficient
* Nutssh nods.
<vincenz> nice thing is that you can easily make many small programs
<vincenz> and then just do
<vincenz> inputfile | transformation1 | transformation2| prettyprint
<Nutssh> Neat, but must be sluggish.
<vincenz> well nothing forces you to do it, you could always bundle transfos
<Nutssh> The.. I forget the compiler framework that rice uses works the same way.
<vincenz> but in case you 're testing things
<vincenz> it's a shame that there's so little out there for c++
<vincenz> another thing which I haven't figured out yet
<vincenz> is how to output only the code from the .cpp file
<vincenz> without all the crap from the headers
<vincenz> make that .cpp files
* vincenz feels a bit lost :/
<vincenz> if only I could do a simple lang like java or so
<vincenz> no preprocessor crap, no unparseable language
<Nutssh> What does a google for C++ parsers give you? Or can you use G++ as a front end?
<vincenz> Nutssh: no g++ flattens too much
<vincenz> google for c++ parsers gives you many parsers (for instance xml) written in c++
<vincenz> hmm
* vincenz tries clusty
<vincenz> I might try this question here, as c++ is a big channel full of newbies
<vincenz> do you know whom to contact about changes to the c++-standard?
<Nutssh> Can you undo the flattening? Do downstream tools care *that* much?
<vincenz> Nutssh: yes
<vincenz> many of these tools are exploratory tools
<vincenz> me printing unreadable code isn't going to help the developers much
vezenchio has quit [Read error: 110 (Connection timed out)]
<Nutssh> Try googling for 'c++ parsing' I found, eg, TENDRA.
<vincenz> thx
<vincenz> btw what do you do again?
<Nutssh> Computer security, but I like to play a formal languages guy in my spare time.
<Nutssh> Buy a parsing front end. Maybe kai as a C++ --> C translater?
<Demitar> vincenz, you want to change the c++-standard? :)
<vincenz> yeah
<vincenz> I placed a post on comp.std.c++
<vincenz> there's somtehing that imho is lacking
pango has quit [tolkien.freenode.net irc.freenode.net]
Godeke has quit [tolkien.freenode.net irc.freenode.net]
Smerdyakov has quit [tolkien.freenode.net irc.freenode.net]
skylan has quit [tolkien.freenode.net irc.freenode.net]
judge has quit [tolkien.freenode.net irc.freenode.net]
Demitar has quit [tolkien.freenode.net irc.freenode.net]
mattam has quit [tolkien.freenode.net irc.freenode.net]
zigong_ has quit [tolkien.freenode.net irc.freenode.net]
cmeme has quit [tolkien.freenode.net irc.freenode.net]
mrvn has quit [tolkien.freenode.net irc.freenode.net]
async has quit [tolkien.freenode.net irc.freenode.net]
pharx has quit [tolkien.freenode.net irc.freenode.net]
zigong_ has joined #ocaml
Smerdyakov has joined #ocaml
pango has joined #ocaml
cmeme has joined #ocaml
mrvn has joined #ocaml
async has joined #ocaml
skylan has joined #ocaml
Godeke has joined #ocaml
judge has joined #ocaml
Demitar has joined #ocaml
mattam has joined #ocaml
pharx has joined #ocaml
pango has quit [tolkien.freenode.net irc.freenode.net]
Godeke has quit [tolkien.freenode.net irc.freenode.net]
Smerdyakov has quit [tolkien.freenode.net irc.freenode.net]
mattam has quit [tolkien.freenode.net irc.freenode.net]
skylan has quit [tolkien.freenode.net irc.freenode.net]
Demitar has quit [tolkien.freenode.net irc.freenode.net]
judge has quit [tolkien.freenode.net irc.freenode.net]
async has quit [tolkien.freenode.net irc.freenode.net]
mrvn has quit [tolkien.freenode.net irc.freenode.net]
cmeme has quit [tolkien.freenode.net irc.freenode.net]
zigong_ has quit [tolkien.freenode.net irc.freenode.net]
pharx has quit [tolkien.freenode.net irc.freenode.net]
lus|wazz has quit [Read error: 110 (Connection timed out)]
zigong_ has joined #ocaml
Smerdyakov has joined #ocaml
pango has joined #ocaml
cmeme has joined #ocaml
mrvn has joined #ocaml
async has joined #ocaml
skylan has joined #ocaml
Godeke has joined #ocaml
judge has joined #ocaml
Demitar has joined #ocaml
mattam has joined #ocaml
pharx has joined #ocaml
vezenchio has joined #ocaml
mrsolo has joined #ocaml
mrsolo has quit [Client Quit]
mrsolo has joined #ocaml
Ulianov has joined #ocaml
Ulianov has quit []
mlh has joined #ocaml
mrsolo_ has joined #ocaml
cmeme has quit ["Client terminated by server"]
cmeme has joined #ocaml
mrsolo has quit [Read error: 110 (Connection timed out)]
zigong has joined #ocaml
zigong_ has quit [Read error: 110 (Connection timed out)]
mrvn_ has joined #ocaml
mrvn has quit [Read error: 110 (Connection timed out)]
skyrace has joined #ocaml
skyrace has left #ocaml []
mlh has quit [Client Quit]
srv has joined #ocaml
srv_ has quit [Read error: 232 (Connection reset by peer)]
zigong has quit [Read error: 110 (Connection timed out)]
zigong has joined #ocaml
menace has joined #ocaml
_fab has quit [Remote closed the connection]
menace has left #ocaml []
goooomba has quit [Read error: 104 (Connection reset by peer)]
Maldoror has quit [Read error: 54 (Connection reset by peer)]
Maldoror has joined #ocaml
_fab has joined #ocaml
Submarine has joined #ocaml
<Submarine> sheesh
<Submarine> 45129.11user 8.11system 12:32:34 <-- minor heap size = 32k (default)
<Submarine> 33468.41user 12.11system 9:18:26 <-- minor heap size = 1000k
<Submarine> 26% off - enormous
_fab has quit []
budjet has joined #ocaml
vezenchio has quit ["Deadpool still votes for Perot. Every time. Just in case."]
budjet has quit [Remote closed the connection]
Submarine has quit ["Leaving"]
zigong has quit [Remote closed the connection]
Maldoror has quit ["Leaving"]
_fab has joined #ocaml
GreyLensman has joined #ocaml
cjohnson has quit [Read error: 238 (Connection timed out)]
pango has quit [Nick collision from services.]
pango has joined #ocaml
ianxek has joined #ocaml
<drz> what do I call to print an arbitrary value, like the debugger does?
terpstra has joined #ocaml
<terpstra> good evening!
<terpstra> I was wondering if anyone knows how to make ocaml swallow multiple module definitions. I want the most recent definite to override older one; similar to rebinding with let
<Demitar> terpstra, and your problem is?
<terpstra> Demitar, ... it doesn't seem to be possible.
<terpstra> 'module A = ....; module A = ....;'
<Demitar> drz, check the mailing list. It has been discussed back and forth recently.
<terpstra> -> 'Multiple definition of the module name Multiplication.'
<terpstra> or A in the above example
<terpstra> I want to do this inside a signature; I am trying to add aditional restrictions on a nested module
<terpstra> module type Ring = sig ...lots of stuff... module Multiplication : Monoid end
<Demitar> Why not use module Foo = (struct ... end : sig end) ?
<terpstra> module type Field = sig include Ring ... more stuff ... module Multiplication : Group end
<Smerdyakov> Clearly it makes no sense to define a module twice inside a signature.
<terpstra> I want to say that in a Field, the nested module Multiplication must also be a Group
<terpstra> Smerdyakov, I think in the above example it does make sense
<Demitar> Something like a class implementing multiple interfaces?
<terpstra> no
<Smerdyakov> You are shadowing a definition from an old signature, not defining it twice.
<terpstra> Smerdyakov, the 'include' redefines it, so when i define it again -- it amounts to the same error as defining it twice
<terpstra> Demitar, it's not multiple inheritence -- what i want it to restrict the interface further by requiring a stricter signature on a nested module
<Demitar> Why not define the least common denominator and then include that?
<terpstra> Demitar, that's what i do at the moment
<terpstra> however, i wanted to know if there's a way to clean this up
<Smerdyakov> terpstra, oh, I see the problem.
<terpstra> if you know abstract algebra, you'll recognize that there is an increasing tower of types
<terpstra> each adding more definitions and more restrictions
<Smerdyakov> terpstra, perhaps you can modify the signature you include, using 'where type' or whatever the OCaml version of that is.
<terpstra> for each layer, right now i have to introduce the new definitions (without the modules) in one branch of module types
<terpstra> Smerdyakov, there is 'where type = type-expr' and 'where module = module-expr' according to the grammar
<terpstra> neither do what i need -- they are for saying these two types or modules must be equal
<terpstra> they don't allow you to restrict the signature further
<Smerdyakov> 'where type'
<Smerdyakov> restricts signatures.
<Smerdyakov> Perhaps not in the way you need, but that's what it does.
<terpstra> Smerdyakov, as i understand where type t = x, that says that in the signature, type t must _exactly_ equal x
<Smerdyakov> Right, which makes for a more restrictive signature.
<terpstra> Smerdyakov, and where module y = x means again, exact equality
<terpstra> Smerdyakov, If there was a 'where module y : somesig' -- that would work
<terpstra> but i don't see it in ocaml's grammar =)
<terpstra> another way of acheiving the same thing would be if ocaml let me rebind modules, the way you can rebind variables
<terpstra> ... it seems inconsistent that ocaml can't do this
<Demitar> I'm sure caml-list can answer your question if nothing else. :)
Hipo has quit [Read error: 232 (Connection reset by peer)]
Hipo has joined #ocaml
<terpstra> Demitar, what is the address of caml-list?
<terpstra> inria.fr
<terpstra> ok - thanks =)
vezenchio has joined #ocaml
kinners has joined #ocaml