1(* Prologue for the SML-TeX stuff *) 2 3(* The idea here is that I will have a file Library_reduce.sml and 4 another one Library_sml.sml that provide environment spectific 5 support. For instance the first thing here is the setting of 6 infix declarations for all the standard operators, since it is 7 easier to do that here within SML code than to hand-wire it into 8 the parser itself. 9 *) 10 11(* In the declarations here I am assuming that "=" and "*" have been 12 hard-wired into the parser. That is because they are used for purposes 13 other than as operators/constructors. The way I implement things is that 14 if a name, say "+" is declared as an infix as it is here, then the 15 lexer will turn a "+" sign in the input into a token with type :infix6 16 and with the further details (ie the value in yylval) showing it as 17 a "+". Then the grammar just has to cope with precedence info on the 18 abstract token types :infix0 to :infix9 (and the right-associating 19 variants. But this means that the parser can not distinguish one operator 20 with precedence n from another as far as raw syntax is concerned. But 21 the tokens "*" and "=" have to be recognized elsewhere in the grammar. 22 It I needed to support variable precedence for those I could arrange that 23 the lexer mapped * onto (say) one of :infix0* through :infix9* and then 24 in the syntax rule for types (as in ('a * 'b)) I could accept any one 25 of those 9 tokens, knowing that what I really had was still an asterisk. 26 I view that as too messy and specialised to worry about just now. 27 *) 28 29 30(* infix 7 *; Must be FIXED because also used in type descriptions *) 31infix 7 /; 32infix 7 %; 33infix 7 div; 34infix 7 mod; 35infix 6 +; 36infix 6 -; 37infixr 6 ^; 38infixr 5 ::; 39infixr 5 @; 40(* infix 4 =; Must be FIXED because also used after VAL and FUN (etc) *) 41infix 4 <; 42infix 4 >; 43infix 4 <=; 44infix 4 >=; 45infix 4 <>; 46infix 3 :=; 47infixr 3 o; 48 49(* end of Library_reduce.sml *) 50