Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source
Source file reason_parser_explain.ml
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134(* See the comments in menhir_error_processor.ml *)moduleParser=Reason_parsermoduleInterp=Parser.MenhirInterpretermoduleRaw=Reason_parser_explain_rawletidentlike_keywords=letreverse_table=lazy(lettable=Hashtbl.create7inletflip_addkv=Hashtbl.addtablevkinHashtbl.iterflip_addReason_declarative_lexer.keyword_table;table)infunction|Parser.SIG->Some"sig"|Parser.MODULE->Some"module"|Parser.BEGIN->Some"begin"|Parser.END->Some"end"|Parser.OBJECT->Some"object"|Parser.SWITCH->Some"switch"|Parser.TO->Some"to"|Parser.THEN->Some"then"|Parser.TYPE->Some"type"|token->matchHashtbl.find(Lazy.forcereverse_table)tokenwith|name->Somename|exceptionNot_found->Noneletkeyword_confused_with_identstatetoken=matchidentlike_keywordstokenwith|SomenamewhenRaw.transitions_on_lidentstate||Raw.transitions_on_uidentstate->(name^" is a reserved keyword, it cannot be used as an identifier. Try `"^name^"_` or `_"^name^"` instead")|_->raiseNot_foundletuppercased_instead_of_lowercasedstatetoken=matchtokenwith|Parser.UIDENTnamewhenRaw.transitions_on_lidentstate->letname=String.uncapitalize_asciinameinifHashtbl.memReason_declarative_lexer.keyword_tablenamethen"variables and labels should be lowercased"elsePrintf.sprintf"variables and labels should be lowercased. Try `%s'"name|_->raiseNot_foundletsemicolon_might_be_missingstate_token=(*let state = Interp.current_state_number env in*)ifRaw.transitions_on_semistatethen"syntax error, consider adding a `;' before"elseraiseNot_foundlettoken_specific_message=function|Parser.UNDERSCORE->"underscore is not a valid identifier. Use _ only in pattern matching and partial function application"|_->raiseNot_foundletunclosed_parenthesisis_opening_symbolclosing_symbolcheck_functionenv=letstate=Interp.current_state_numberenvinifcheck_functionstatethenletrecfind_opening_location=function|None->None|Someenv->letfound=matchInterp.topenvwith|Some(Interp.Element(state,_,startp,endp))when(is_opening_symbol(Interp.X(Interp.incoming_symbolstate)))->Some(startp,endp)|Some(Interp.Element(state,_,_,_))when(Interp.X(Interp.incoming_symbolstate)=closing_symbol)->raiseNot_found|_->Noneinmatchfoundwith|Some_->found|_->find_opening_location(Interp.popenv)intryfind_opening_location(Someenv)withNot_found->NoneelseNoneletcheck_unclosedenv=letcheck(message,opening_symbols,closing_symbol,check_function)=matchunclosed_parenthesis(funx->List.memxopening_symbols)closing_symbolcheck_functionenvwith|None->None|Some(loc_start,_)->Some(Format.asprintf"Unclosed %S (opened line %d, column %d)"messageloc_start.pos_lnum(loc_start.pos_cnum-loc_start.pos_bol))inletreccheck_list=function|[]->raiseNot_found|x::xs->matchcheckxwith|None->check_listxs|Someresult->resultincheck_list[("(",Interp.[X(TT_LPAREN)],Interp.X(TT_RPAREN),Raw.transitions_on_rparen);("{",Interp.[X(TT_LBRACE);X(TT_LBRACELESS)],Interp.X(TT_RBRACE),Raw.transitions_on_rbrace);("[",Interp.[X(TT_LBRACKET);X(TT_LBRACKETAT);X(TT_LBRACKETBAR);X(TT_LBRACKETGREATER);X(TT_LBRACKETLESS);X(TT_LBRACKETPERCENT);X(TT_LBRACKETPERCENTPERCENT);],Interp.X(TT_RBRACKET),Raw.transitions_on_rbracket);]letmessageenv(token,_,_)=letstate=Interp.current_state_numberenvin(* Identify a keyword used as an identifier *)trykeyword_confused_with_identstatetokenwithNot_found->trycheck_unclosedenvwithNot_found->(* Identify an uppercased identifier in a lowercase place *)tryuppercased_instead_of_lowercasedstatetokenwithNot_found->trysemicolon_might_be_missingstatetokenwithNot_found->trytoken_specific_messagetokenwithNot_found->(* Is there a message for this specific state ? *)(* TODO: we don't know what to say *)"Syntax error"