File Menu
File Menu. Open, save, or close an AWK program file.
Data Menu. Open, save or close a data file to be processed by AWK
Option Menu. Select the option to AWK. E.g. turn on/off AWK optimizer
Panels
The layout consists of four tabbed panels.
Panel 1 is where you type in or open up your AWK program.
- Source Editor.
- Help information.
- AWK Grammar
Panel 2 if where consist of two tabbed panels.
- Data Source.
- Console output.
Panel 3 is for Compiler or runtime panels
- Debug log. Dump of various compile time or runtime information.
- Token log. The Token log list the tokens found under the lexical scanning of the input source from the Panel-1 Source editor tab
- Code log. The code log list the AWK code instruction generated under the compile phase. It is high-level instruction that is interpreted and executed by the AWK run-time.
- Error log. Either compile-time or run-time errors
- Global var list.
- Local var list. E.g. parameters in the current function call.
- Watch log. Where you can add specific variables to a watch list. You just simply type in a variable name and press return and the variable is added to the Watch list. Each Watch list line will be prefixed with [x]. When you click on the prefix symbol [x] you delete the Watch variable on that line. A watch line consists of four elements.
- [x]. Prefix element
- the variable name
- The variable type. Either scalar or Array.
- The value of the variable.
Here is an example of a watch line.
[x] $1 scalar "Europe"
Panel 4 is for run-time execution.
- Stack. List the current stack contents
- Call Stack. List the current Function Call stack.
- Display Stack. In AWK, there is only two Display stack. Global display and local display. A function call adds a new local stack level to the Display stack.
- Label list. List the current register Labels while running the AWK program.
- Breakpoints. List the current set breakpoint. The list contains the user-defined breakpoint. But there is also a temporary breakpoint list that temporarily adds or deleted breakpoints while using the buttons: Step Over, Step into, Step Outo.
- Profiler. Display how many times each source line has been executed.
Buttons
Under the first Panel, there is one button. The compile button. As the name implies, it compiles the AWK source from the source editor and provides a line number list of the compiled source under the Source Line tab. The Debug log, Token log, Code log, Error log, and Global var list in Panel two, are populated with information from the compile stage
Below the 2nd panel are 6 buttons and a selection drop-down menu.
- Restart. Restart the current execution to a point right after the compile stage.
- Run. Run the program. If no breakpoint is set, the AWK will run to the end of execution or stop if it encounters a run-time error.
- Step Over. If the instruction is a function call. it stops at the instruction after the return of the function. If not a function call if acts like a single Step instruction
- Step Into. If the next instruction is a function call, it steps into the function and stops at the first instruction in the function. If not a function call, it acts like a single Step instruction.
- Step Outo. If within a function it resumes execution and stops at the instruction after the return of the function. If outside a function it resumes execution until the end of the program or a breakpoint is encountered.
- Single Step. As the name implies, it single step a single instruction.
- Add a Breakpoint menu. A menu is open allowing you to add/delete a breakpoint. A breakpoint can also be set in the Code log panel by just clicking on the leftmost code log. When doing so a B is added to the start of the code line where the breakpoint is set. If clicking again on the same line the B disappeared indicating that you have to delete a breakpoint at the instruction. You can also add a breakpoint at the source level by clicking on the Source below the SourceLine tab. When doing so the line starts with a capital B indicating a breakpoint is set at that location. Clicking on the same line again will delete the breakpoint at that source line. You can add an unlimited number of breakpoints.
AWK compatibility
The WebAWK followed the language as described in the book "The AWK Programming Language" from 1988 with the following exception:
- System. Is not supported since there is no Web browser equivalent.
- operator. Is not supported again due to the limitation of running in a web browser.
- close. Due to the limitation of a browser, the close pipe is not supported.
- getline < "filename". Is not supported. It seems that you can only read a file if used in connection with the HTML input="file"
AWK Gramma
Token symbols
~ ! # $ % ^ & * / ( ) - + = += -= *= /= %= ^= ? : !~ && || < <= == >= < != ++ -- [ ] " { } | >>
Reserved words
BEGIN, END, if, else, while, do, for, in, return, break, continue, delete, next, exit, print, printf, getline
Gramma
Reserved words in bold, production in italic and regular expression is enclosed between re and re
program | : | pattern actions |
| ; | |
pattern actions | : | pattern action |
| | | pattern actions pattern actions |
| ; | |
pattern action | : | function decl |
| | | BEGIN compound statement |
| | | END compound statement |
| | | compound statement |
| | | expression compound statement |
| | | expression , expression compound statement |
| ; | |
function decl | : | function id ( [ id list ] ) compound statement |
| ; | |
id list | : | id |
| | | id list , id |
| ; | |
statements | : | statement |
| | | statements ; statement |
| ; | |
statement | : | expression |
| | | compound statements |
| | | while ( expression ) statement |
| | | do statement while ( expression ) |
| | | if ( expression ) statement |
| | | if ( expression ) statement else statement |
| | | for ( expression ; expression ; expression ) statement |
| | | return [ expression ] |
| | | continue |
| | | break |
| | | delete [ subscript ] |
| | | next |
| | | exit [ expression ] |
| | | print |
| | | print expression list [ > | >> filename] ] |
| | | print ( expression list ) [ > | >> filename] ] |
| | | getline [ variable ] [ < filename ] |
| ; | |
compound statements | : | { statements } |
| ; | |
expression list | : | expression |
| | | expression list , expression |
| ; | |
expression | : | conditional exp |
| | | expression = expression |
| | | expression += expression |
| | | expression -= expression |
| | | expression *= expression |
| | | expression /= expression |
| | | expression %= expression |
| | | expression ^= expression |
| ; | |
conditional exp | : | logical or |
| | | logical or ? expression : conditional exp |
| ; | |
logical or | : | logical and |
| | | logical or || logical and |
| ; | |
logical and | : | in expression |
| | | logical and && in expression |
| ; | |
in expression | : | matching exp |
| | | in expression in matching exp |
| ; | |
matching exp | : | relational exp |
| | | matching exp ˜ relational exp |
| | | matching exp !˜ relational exp |
| ; | |
relational exp | : | concatenation exp |
| | | relational exp < concatenation exp |
| | | relational exp > concatenation exp |
| | | relational exp <= concatenation exp |
| | | relational exp >= concatenation exp |
| | | relational exp == concatenation exp |
| | | relational exp != concatenation exp |
| ; | |
concatenation exp | : | additive exp |
| | | concatenation exp additive exp |
| ; | |
additive exp | : | multiplicative exp |
| | | additive exp + multiplicative exp |
| | | additive exp - multiplicative exp |
| ; | |
multiplicative exp | : | unary expression |
| | | multiplicative exp * unary expression |
| | | multiplicative exp / unary expression |
| | | multiplicative exp % unary expression |
| ; | |
unary expression | : | power expression |
| | | + power expression |
| | | - power expression |
| | | ! power expression |
| | | ˜ power expression |
| | | multiplicative exp % unary expression |
| ; | |
power expression | : | prefix expression |
| | | power expression ^ power expression |
| ; | |
prefix expression | : | postfix expression |
| | | ++ postfix expression |
| | | -- postfix expression |
| ; | |
postfix expression | : | field expression |
| | | postfix expression ++ |
| | | postfix expression -- |
| | | postfix expression [ expression list ] |
| | | postfix expression ( expression list ) |
| ; | |
field expression | : | primary expression |
| | | $ primary expression |
| ; | |
primary expression | : | number |
| | | string |
| | | reg exp |
| | | id |
| | | ( expression ) |
| ; | |
id | : | re[_a-zA-Z]re |
| | | id re[_a-zA-Z0-9]re |
| ; | |
number | : | integer |
| | | float |
| ; | |
integer | : | re[0-9]re |
| ; | |
float | : | integer . re[0-9]*re exponent |
| | | . re[0-9]*re exponent |
| ; | |
exponent | : | |
| | | re[eE]re re[0-9]+re |
| | | re[eE]re re[+-]re re[0-9]+re |
| ; | |
string | : | " re[.]*re " |
| ; | |
reg exp | : | / re[^/]*re / |
| ; | |