[Bro-Dev] [JIRA] (BIT-1237) Bro script declaration ordering

Jon Siwek (JIRA) jira at bro-tracker.atlassian.net
Wed Aug 27 14:58:08 PDT 2014


    [ https://bro-tracker.atlassian.net/browse/BIT-1237?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17802#comment-17802 ] 

Jon Siwek commented on BIT-1237:
--------------------------------

Thanks.  It is a bit of a quirk of the parser -- it expects no statement to precede a declaration (at the global scope).  In this case, the function definition and redef are types of declarations while locals are considered statements.  For now, maybe a habit to pick up in order to avoid the situation is only using locals inside functions/events.

> Bro script declaration ordering
> -------------------------------
>
>                 Key: BIT-1237
>                 URL: https://bro-tracker.atlassian.net/browse/BIT-1237
>             Project: Bro Issue Tracker
>          Issue Type: Problem
>          Components: Bro
>    Affects Versions: 2.3
>         Environment: Bro con training VM
>            Reporter: Peter Kaloroumakis
>            Priority: Trivial
>              Labels: BroScript
>
> During one of the scripting exercises I noticed odd behavior with items declared in the global scope:
> ############################# error.bro
> not working:
> ------------------------------------------------
> local test_var = "test_var";
> function test_1()
>     {
>     print "test_1";
>     }
> print test_var;
> test_1();
> >>> Output:
> error in ./test.bro, line 3: syntax error, at or near "test_1"
> ############################# working.bro
> working:
> ------------------------------------------------
> function test_1()
>     {
>     print "test_1";
>     }
> local test_var = "test_var";
> print test_var;
> test_1();
> >>> Output:
> test_var
> test_1
> #############################
> To declare a function, bro 2.3 forced me to do it at the top of the file. On the exercise with the redef of the grid ftp size variable I noticed the same issue with redef, it required me to put the redef at the very top of the file. 
> Robin asked me to open a ticket and mentioned this was low priority.



--
This message was sent by Atlassian JIRA
(v6.4-OD-04-006#64001)


More information about the bro-dev mailing list