User loginNavigation |
a logic of precedences. SuggestionsHi, I'm new to programming language theory but like I suppose Anyways I'm asking about an idea I have for my pet programming language. It is a precedence based logic. With it the programmer can Now, suppose we have the basic infix aritmetic 'operators' +, -, *, and div + a b / a + b, +:int->int->int. We can declare their precedence with: precedences { aritmetic := {+ - * div}, + = -, * = /, * > + } or the more cute 'ladder syntax': precedences { aritmetic := (* div) (+ -) }
I have developed a 'logic of precedences' that can deal with When a program or library grows you can still declare precedences without ! n / n !. precedences { ! > aritmetic }
I know that the emblematic languages like ocaml or haskell don't provide What do you think about this idea of declaring precedences with a 'logic system'? The language will have types like disjoint sets (a la ocaml's but with With types declared as lexems, aplication modes of functions and precedence system % control structures for if-then-else lexemas iftest := { iftest(bool) } lexemas elsesol x := { thensol(x) elsesol } % declarations (not required but useful to see ugly types) if / if : bool -> iftest bool. then ifcont thenexp / ifcont then thenexp, then : iftest -> x -> elsesol x. else thencont elseexp / thencont else elseexp, else : elsesol x -> x -> x. % this declaration puts 'if' 'then' 'else' operators to a 'ifexp' class % (classes of precedence are useful to handle DSLs or operators related % as a whole). It reads as: "'if' has more precedence than 'then', and 'then' % has more precedence than 'else'; all of then put on a class 'ifexp' whose % precedence level is greater than the rest of functions, including default % aplication level". It also raises the invariant that no other declaration % can mess with their relation nor merge between the 'ifexp' owned levels % so from this point of view the DSL is unaltered. fixed_precedences { ifexp := if then else, ifexp > all, } % if-then-else implementation (requires lazy evaluation, naturally) if b = iftest(b). then ifcont exp = ifcont con iftest(true) -> thensol(exp) con iftest(false) -> elsesol. else branch elseexp = branch con thensol(x) -> x con elsesol -> elseexp. By fbraunin at 2011-04-06 02:30 | LtU Forum | previous forum topic | next forum topic | other blogs | 4928 reads
|
Browse archives
Active forum topics |
Recent comments
22 weeks 6 days ago
22 weeks 6 days ago
22 weeks 6 days ago
45 weeks 17 hours ago
49 weeks 2 days ago
50 weeks 6 days ago
50 weeks 6 days ago
1 year 1 week ago
1 year 6 weeks ago
1 year 6 weeks ago