Skip to content

Commit

Permalink
Merge pull request #29 from nonetype/master
Browse files Browse the repository at this point in the history
Fix invisible contents
  • Loading branch information
ifratric authored Jan 8, 2021
2 parents 128250f + 8f342eb commit 8320455
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ Sometimes you might want to call custom Python code in your grammar. For example
<body> = <call function=createbody>
```

The python functions are defined between ‘!begin function <function_name>’ and ‘!end function’ commands. The functions can be called in two ways: using ‘beforeoutput’ attribute and using <call> symbol.
The python functions are defined between ‘!begin function <function_name>’ and ‘!end function’ commands. The functions can be called in two ways: using ‘beforeoutput’ attribute and using `<call>` symbol.

By specifying the ‘beforeoutput’ attribute in some symbol, the corresponding function will be called when this symbol is expanded, just before the result of the expansion is output to the sample. The expansion result will be passed to the function in the ret_val variable. The function is then free to modify ret_val, store it for later use or perform any other operations.

Expand All @@ -209,8 +209,8 @@ When using a special `<call>` symbol, the function (specified in a ‘function
Your python code has access to the following variables:

- `context` - a dictionary that is passed through the whole sample generation. You can use it to store values (such as storing the size in an example above) and retrieve them in the rules that fire subsequently.
- `attributes` - a dictionary corresponding to the symbol currently being processed. You can use it to pass parameters to your functions. For example if you used something like <call function=func foo=bar> to call your function attributes\[‘foo’\] will be set to ‘bar’.
- `ret_val` - The value that will be output as a result of the function call. It is initialized to an empty value when using <call> symbol to call a function, otherwise it will be initialized to the value generated by the symbol.
- `attributes` - a dictionary corresponding to the symbol currently being processed. You can use it to pass parameters to your functions. For example if you used something like `<call function=func foo=bar>` to call your function attributes\[‘foo’\] will be set to ‘bar’.
- `ret_val` - The value that will be output as a result of the function call. It is initialized to an empty value when using `<call>` symbol to call a function, otherwise it will be initialized to the value generated by the symbol.

##### Built-in symbols

Expand Down

0 comments on commit 8320455

Please sign in to comment.