{ open Lexing open Irc_parser open Irc_types } let letter = [^' '] let digit = ['0'-'9'] rule param = parse | ':'((letter|' ')* as s) { STRING s } | (letter+) as s { STRING s } | [' ']+ { param lexbuf } | eof { EOL } and command = parse | (digit digit digit) as num { COMMAND (Numeric (int_of_string num)) } | "JOIN" { COMMAND JOIN } | "PART" { COMMAND PART } | "MODE" { COMMAND MODE } | "TOPIC" { COMMAND TOPIC } | "NAMES" { COMMAND NAMES } | "LIST" { COMMAND LIST } | "INVITE" { COMMAND INVITE } | "KICK" { COMMAND KICK } | "PRIVMSG" { COMMAND PRIVMSG } | "NOTICE" { COMMAND NOTICE } | "QUIT" { COMMAND QUIT } | "PING" { COMMAND PING } | [' ']* { param lexbuf } (* this means we won't get a command, and parsing will fail *) | eof { EOL } (* this will raise a parsing error *) and message = parse | ':'((letter+) as s) { STRING s } | [' ']* { command lexbuf } | eof { EOL } (* and this will also raise a parsing error *)