module Fonte module Parsers grammar Action include Word include Player include Address include Property include Rcon rule action log_started_action / log_ended_action / cvar_start_action / cvar_end_action / cvar_set_action / map_loading_action / map_started_action / server_name_action / connection_action / validation_action / enter_game_action / disconnection_action / kick_action / kick_and_ban_action / suicide_action / join_team_action / role_selection_action / name_change_action / kill_action / injure_action / triggered_player_action_against_player / triggered_player_action / triggered_team_action / triggered_world_action / chat_action / team_chat_action / private_chat_action / server_chat_action / team_alliance_action / score_report / weapon_selection_action / weapon_pickup_action / rcon_command / steamauth_failure_action / spawn_action end rule log_started_action "Log file started" properties:action_properties? { def value "log start" end } end rule log_ended_action "Log file closed" { def value "log end" end } end rule cvar_start_action [Ss] "erver cvars start" { def value "cvar start" end } end rule cvar_end_action [Ss] "erver cvars end" { def value "cvar end" end } end rule cvar_set_action (cvar_set_complete_syntax / cvar_set_colon_sytax) { def value "cvar set" end def to_hash { key.value => val.value } end } end rule cvar_set_complete_syntax ([Ss] "erver cvar" SPACE)? key:quoted_word SPACE "=" SPACE val:quoted_word end rule cvar_set_colon_sytax "server_cvar:" SPACE key:quoted_word SPACE val:quoted_word end rule map_loading_action "Loading map" SPACE name:map_name { def value "map load" end } end rule map_started_action "Started map" SPACE name:map_name SPACE "(" crc:map_crc ")" { def value "map start" end } end rule map_name quoted_word end rule map_crc "CRC" SPACE quoted_word end rule server_name_action "Server name is" SPACE name:quoted_word { def value "server name" end } end rule server_chat_action "Server say" SPACE message:quoted_word { def value "server chat" end } end rule connection_action QUOTE player QUOTE SPACE "connected, address" SPACE QUOTE ip QUOTE { def value "connection" end } end rule validation_action QUOTE player QUOTE SPACE "STEAM USERID validated" { def value "validation" end } end rule enter_game_action QUOTE player QUOTE SPACE "entered the game" { def value "enter" end } end rule disconnection_action QUOTE player QUOTE SPACE "disconnected" properties:action_properties? { def value "disconnection" end } end rule kick_action QUOTE player QUOTE SPACE "was kicked by" SPACE '"Console"' properties:action_properties? { def value "kick" end } end rule kick_and_ban_action QUOTE player QUOTE SPACE "was kicked and banned by" SPACE '"Console"' properties:action_properties? { def value "kickban" end } end rule suicide_action QUOTE player QUOTE SPACE "committed suicide with" SPACE QUOTE weapon QUOTE properties:action_properties? { def value "suicide" end } end rule join_team_action QUOTE player QUOTE SPACE "joined team" SPACE QUOTE team QUOTE { def value "join" end } end rule role_selection_action QUOTE player QUOTE SPACE "changed role to" SPACE QUOTE role QUOTE { def value "role selection" end } end rule name_change_action QUOTE player QUOTE SPACE "changed name to" SPACE new_name:quoted_word { def value "name change" end } end rule kill_action source_kill_action / l4d2_kill_action end rule source_kill_action QUOTE attacker:player QUOTE SPACE "killed" SPACE QUOTE victim:player QUOTE SPACE "with" SPACE QUOTE weapon QUOTE properties:action_properties? { def value "kill" end } end # TODO: move this to separated grammar rule l4d2_kill_action "(DEATH)" source_kill_action { def value "kill" end def attacker source_kill_action.attacker end def victim source_kill_action.victim end def weapon source_kill_action.weapon end def properties source_kill_action.properties end } end rule injure_action QUOTE attacker:player QUOTE SPACE "attacked" SPACE QUOTE victim:player QUOTE SPACE "with" SPACE QUOTE weapon QUOTE properties:action_properties? { def value "injure" end } end rule triggered_player_action_against_player QUOTE attacker:player QUOTE SPACE "triggered" SPACE action:quoted_word SPACE "against" SPACE QUOTE victim:player QUOTE (SPACE "with" SPACE QUOTE weapon QUOTE)? properties:action_properties? { def value action.value end } end rule triggered_player_action QUOTE player QUOTE SPACE "triggered" SPACE action:quoted_word properties:action_properties? { def value action.value end } end rule triggered_team_action "Team" SPACE QUOTE team QUOTE SPACE "triggered" SPACE action:quoted_word properties:action_properties? { def value action.value end } end rule triggered_world_action "World triggered" SPACE action:quoted_word reason:triggered_world_action_reason? properties:action_properties? { def value action.value end } end rule triggered_world_action_reason SPACE "reason" SPACE reason:quoted_word { def value reason.value end } end rule chat_action QUOTE player QUOTE SPACE "say" SPACE message:quoted_word { def value "chat" end } end rule team_chat_action QUOTE player QUOTE SPACE "say_team" SPACE message:quoted_word { def value "team chat" end } end rule private_chat_action QUOTE player QUOTE SPACE "tell" SPACE QUOTE target:player QUOTE SPACE "message" SPACE message:quoted_word { def value "private chat" end } end rule team_alliance_action "Team" SPACE QUOTE team QUOTE SPACE "formed alliance with team" SPACE QUOTE allied_team:team QUOTE { def value "alliance" end } end rule score_report "Team" SPACE QUOTE team QUOTE SPACE score_type SPACE QUOTE points:integer QUOTE SPACE "with" SPACE QUOTE players_count:integer QUOTE SPACE "players" { def value score_type.value end } end rule score_type ("current score" / "final score" / "scored") { def value case text_value when "scored" "team score" else text_value end end } end rule weapon_selection_action QUOTE player QUOTE SPACE "selected weapon" SPACE QUOTE weapon QUOTE { def value "weapon selection" end } end rule weapon_pickup_action QUOTE player QUOTE SPACE "acquired weapon" SPACE QUOTE weapon QUOTE { def value "weapon pickup" end } end rule steamauth_failure_action "STEAMAUTH: Client" SPACE client:steamauth_client SPACE "received failure code" SPACE code:integer { def value "authentication failure" end } end rule spawn_action QUOTE player QUOTE SPACE "spawned" { def value "spawn" end } end rule steamauth_client (!SPACE .)+ { def value text_value end } end rule role word end rule weapon word end rule action_properties SPACE properties { def value properties.value end } end end end end