SmallCC / src /

(* This help to manage param *)

type 'a value = None | Some of 'a

exception NoValue
exception NotImplemented of string

let getValue v = match v with
    Some a  -> a
  | None    -> raise NoValue

(* Begin of the visitor class*)

class visitor =

(************************* Accept method for overriding **************************)

    (* Complet this accept *)
  method acceptFunctionDefinition decspe dec dec_list cs =
    if (decspe <> None) then ();
    if (dec_list <> None) then ();

  method acceptTranslationUnit tu ed =
    if (tu <> None) then this#visitTranslationUnit (getValue tu);
    this#visitExternalDeclaration (getValue ed)

(************************ Visite method *******************************)

  method visitFunctionDefinition ast = match ast with
  	  Ast.FUN_spec_dec_list(decspe, dec, dec_list, cs)
      -> this#acceptFunctionDefinition (Some decspe) (Some dec) (Some dec_list) (Some cs)
	  | Ast.FUN_spec_dec(decspe, dec, cs)
      -> this#acceptFunctionDefinition (Some decspe) (Some dec) None (Some cs)
	  | Ast.FUN_dec_list(dec, dec_list, cs)
      -> this#acceptFunctionDefinition None (Some dec) (Some dec_list) (Some cs)
	  | Ast.FUN_dec(dec, cs)
      -> this#acceptFunctionDefinition None (Some dec) None (Some cs)

    (* Here i visite directly, but why not? *)
  method visitExternalDeclaration ast = match ast with
	    Ast.ED_fun_def(fd)  -> this#visitFunctionDefinition fd
	  | Ast.ED_dec(dec)     -> raise (NotImplemented "ED_dec")

  method visitTranslationUnit ast = match ast with
	    Ast.TU_dec(ed)      -> this#acceptTranslationUnit None (Some ed) 
	  | Ast.TU_tans(tu, ed) -> this#acceptTranslationUnit (Some tu) (Some ed)
	  | Ast.None            -> ()
(*************** Some buttyfull method to help ***********************)
(********************** Beurk By Kokarez *****************************)

  method getFuncName ast =
    let dd = match ast with
      Ast.DECL_direct(dd) -> dd | _ -> raise (NotImplemented "GetFuncName") in
      let rec rec_name ast = match ast with
          Ast.DIDE_id(s) -> s
        | Ast.DIDE_param_list(d, _) -> rec_name d
        | _ -> raise (NotImplemented "GetFuncName")
            rec_name dd

Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.