mirror of
https://github.com/zeek/zeek.git
synced 2025-10-10 10:38:20 +00:00

Avoid the issue outlined in #2289 where the @if or @else is taken as the statement of an `if`, `for` or `while` by rejecting such constructs. Effectively this means the following scripts are now rejected: # Print's "cond true" with Zeek 5.0 even though the `if ( F )` # should be in effect. if ( F ) @if ( T ) print "cond true"; @else print "cond false"; @endif or # Print's "hello" once with Zeek 5.0 local v = vector( 1, 2, 3 ); for ( i in v ) @if ( T ) print("hello") @endif To make above work as intended, additional braces can be used. if ( T ) { @if ( cond ) print "cond true"; @else print "cond false"; @endif } for ( i in v ) { @if ( T ) print("hello") @endif }
53 lines
1.3 KiB
C++
53 lines
1.3 KiB
C++
// See the file "COPYING" in the main distribution directory for copyright.
|
|
|
|
#pragma once
|
|
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
#include "zeek/ZeekList.h"
|
|
|
|
// These are required by the lexer in scan.l and are intentionally not namespaced.
|
|
extern int yyparse();
|
|
extern int yydebug;
|
|
extern int zeeklex();
|
|
extern char last_tok[128];
|
|
|
|
extern void add_essential_input_file(const char* file);
|
|
extern void add_input_file(const char* file);
|
|
extern void add_input_file_at_front(const char* file);
|
|
|
|
// Adds the substrings (using the given delimiter) in a string to the
|
|
// given namelist.
|
|
extern void add_to_name_list(char* s, char delim, zeek::name_list& nl);
|
|
|
|
extern void begin_RE();
|
|
|
|
extern void do_atif(zeek::detail::Expr* expr);
|
|
extern void do_atifdef(const char* id);
|
|
extern void do_atifndef(const char* id);
|
|
extern void do_atelse();
|
|
extern void do_atendif();
|
|
extern void reject_directive(zeek::detail::Stmt* s);
|
|
extern void do_doc_token_start();
|
|
extern void do_doc_token_stop();
|
|
|
|
extern int line_number;
|
|
extern const char* filename;
|
|
|
|
namespace zeek::detail
|
|
{
|
|
|
|
class Stmt;
|
|
|
|
extern int zeek_argc;
|
|
extern char** zeek_argv;
|
|
extern const char* prog;
|
|
|
|
extern std::vector<std::string> zeek_script_prefixes; // -p flag
|
|
extern const char* command_line_policy; // -e flag
|
|
extern std::vector<std::string> params;
|
|
|
|
extern Stmt* stmts; // global statements
|
|
|
|
} // namespace zeek::detail
|