A tool to gather statistics on common grammatical constructs, to hopefully produce helpful error messages & to rank syntactic completion
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

154 lines
4.4 KiB

let string_of_token : Raw_parser.token -> _ = function
| AMPERAMPER -> "AMPERAMPER"
| AMPERSAND -> "AMPERSAND"
| AND -> "AND"
| ANDOP -> "ANDOP"
| AS -> "AS"
| ASSERT -> "ASSERT"
| BACKQUOTE -> "BACKQUOTE"
| BANG -> "BANG"
| BAR -> "BAR"
| BARBAR -> "BARBAR"
| BARRBRACKET -> "BARRBRACKET"
| BEGIN -> "BEGIN"
| CHAR -> "CHAR"
| CLASS -> "CLASS"
| COLON -> "COLON"
| COLONCOLON -> "COLONCOLON"
| COLONEQUAL -> "COLONEQUAL"
| COLONGREATER -> "COLONGREATER"
| COMMA -> "COMMA"
| COMMENT -> "COMMENT"
| CONSTRAINT -> "CONSTRAINT"
| DO -> "DO"
| DOCSTRING -> "DOCSTRING"
| DONE -> "DONE"
| DOT -> "DOT"
| DOTDOT -> "DOTDOT"
| DOTOP -> "DOTOP"
| DOWNTO -> "DOWNTO"
| ELSE -> "ELSE"
| END -> "END"
| EOF -> "EOF"
| EOL -> "EOL"
| EQUAL -> "EQUAL"
| EXCEPTION -> "EXCEPTION"
| EXTERNAL -> "EXTERNAL"
| FALSE -> "FALSE"
| FLOAT -> "FLOAT"
| FOR -> "FOR"
| FUN -> "FUN"
| FUNCTION -> "FUNCTION"
| FUNCTOR -> "FUNCTOR"
| GREATER -> "GREATER"
| GREATERRBRACE-> "GREATERRBRACE"
| GREATERRBRACKET -> "GREATERRBRACKET"
| HASH -> "HASH"
| HASHOP -> "HASHOP"
| IF -> "IF"
| IN -> "IN"
| INCLUDE -> "INCLUDE"
| INFIXOP0 -> "INFIXOP0"
| INFIXOP1 -> "INFIXOP1"
| INFIXOP2 -> "INFIXOP2"
| INFIXOP3 -> "INFIXOP3"
| INFIXOP4 -> "INFIXOP4"
| INHERIT -> "INHERIT"
| INITIALIZER -> "INITIALIZER"
| INT -> "INT"
| LABEL -> "LABEL"
| LAZY -> "LAZY"
| LBRACE -> "LBRACE"
| LBRACELESS -> "LBRACELESS"
| LBRACKET -> "LBRACKET"
| LBRACKETAT -> "LBRACKETAT"
| LBRACKETATAT -> "LBRACKETATAT"
| LBRACKETATATAT -> "LBRACKETATATAT"
| LBRACKETBAR -> "LBRACKETBAR"
| LBRACKETGREATER -> "LBRACKETGREATER"
| LBRACKETLESS -> "LBRACKETLESS"
| LBRACKETPERCENT -> "LBRACKETPERCENT"
| LBRACKETPERCENTPERCENT -> "LBRACKETPERCENTPERCENTERCENT"
| LESS -> "LESS"
| LESSMINUS -> "LESSMINUS"
| LET -> "LET"
| LETOP -> "LETOP"
| LIDENT -> "LIDENT"
| LPAREN -> "LPAREN"
| MATCH -> "MATCH"
| METHOD -> "METHOD"
| MINUS -> "MINUS"
| MINUSDOT -> "MINUSDOT"
| MINUSGREATER -> "MINUSGREATER"
| MODULE -> "MODULE"
| MUTABLE -> "MUTABLE"
| NEW -> "NEW"
| NONREC -> "NONREC"
| OBJECT -> "OBJECT"
| OF -> "OF"
| OPEN -> "OPEN"
| OPTLABEL -> "OPTLABEL"
| OR -> "OR"
| PERCENT -> "PERCENT"
| PLUS -> "PLUS"
| PLUSDOT -> "PLUSDOT"
| PLUSEQ -> "PLUSEQ"
| PREFIXOP -> "PREFIXOP"
| PRIVATE -> "PRIVATE"
| QUESTION -> "QUESTION"
| QUOTE -> "QUOTE"
| RBRACE -> "RBRACE"
| RBRACKET -> "RBRACKET"
| REC -> "REC"
| RPAREN -> "RPAREN"
| SEMI -> "SEMI"
| SEMISEMI -> "SEMISEMI"
| SIG -> "SIG"
| STAR -> "STAR"
| STRING -> "STRING"
| STRUCT -> "STRUCT"
| THEN -> "THEN"
| TILDE -> "TILDE"
| TO -> "TO"
| TRUE -> "TRUE"
| TRY -> "TRY"
| TYPE -> "TYPE"
| UIDENT -> "UIDENT"
| UNDERSCORE -> "UNDERSCORE"
| VAL -> "VAL"
| VIRTUAL -> "VIRTUAL"
| WHEN -> "WHEN"
| WHILE -> "WHILE"
| WITH -> "WITH"
let () =
for i = 1 to Array.length Sys.argv - 1 do
let name = Sys.argv.(i) in
let ic = open_in name in
try
let lexbuf = Lexing.from_channel ic in
let rec aux () =
match Raw_lexer.token lexbuf with
| Raw_parser.EOF -> ()
| tok ->
print_char ' ';
print_string (string_of_token tok);
aux ()
in
let is_intf = name.[String.length name - 1] = 'i' in
if is_intf then
print_string "interface:"
else
print_string "implementation:";
aux ();
print_newline ();
close_in ic
with exn ->
begin match exn with
| Raw_lexer.Error (err, loc) ->
Raw_lexer.print_error loc err;
| exn -> prerr_endline (Printexc.to_string exn)
end;
close_in ic
done