Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source
Source file pretoken.ml
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182(**************************************************************************)(* Copyright (C) 2017-2023 Yann Régis-Gianas, Nicolas Jeannerod, *)(* Ralf Treinen. *)(* *)(* This is free software: you can redistribute it and/or modify it *)(* under the terms of the GNU General Public License, version 3. *)(* *)(* Additional terms apply, due to the reproduction of portions of *)(* the POSIX standard. Please refer to the file COPYING for details. *)(**************************************************************************)openParsertypet=|PreWordofstring*CST.word_cst|IoNumberofstring|OperatorofParser.token|EOF|NEWLINEletstring_of_pretoken=function|PreWord(s,_)->Printf.sprintf"PREWORD(%s)"s|IoNumbers->Printf.sprintf"IONUM(%s)"s|Operatort->Printf.sprintf"OPERATOR(%s)"(Token.string_of_tokent)|EOF->"EOF"|NEWLINE->"NEWLINE"letoperators=Hashtbl.(lett=create17inList.iter(fun(sym,tok)->addtsymtok)["&&",AND_IF;"||",OR_IF;";;",DSEMI;"<&",LESSAND;">&",GREATAND;"<>",LESSGREAT;">>",DGREAT;">|",CLOBBER;"|",Pipe;"(",Lparen;")",Rparen;"<",LESS;">",GREAT;";",Semicolon;"&",Uppersand];t)letoptoken_of_strings=tryOperator(Hashtbl.findoperatorss)withNot_found->Printf.eprintf"Internal error: `%s' is not a valid operator token.\n"s;assertfalseletpreword_of_operator=function|AND_IF->"&&"|OR_IF->"||"|DSEMI->";;"|LESSAND->"<&"|GREATAND->">&"|LESSGREAT->"<>"|DGREAT->">>"|CLOBBER->">|"|Pipe->"|"|Lparen->"("|Rparen->")"|LESS->"<"|DLESS_->"<<"|GREAT->">"|Semicolon->";"|Uppersand->"&"|_->assertfalse(* By definition of operators. *)letpreword_of_pretoken=function|IoNumbers->PreWord(s,[WordLiterals])|Operatoro->lets=preword_of_operatoroinPreWord(s,[WordLiterals])|NEWLINE->PreWord("\n",[WordLiteral"\n"])|p->p