Numerical Methods at work

Disclaimer:
Permission to use, copy, and distribute this software, and It’s documentation for any non-commercial purpose is hereby granted without fee, provided: THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL Henrik Vestermark, BE LIABLE FOR ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

WebAWK:Image of news icon

A JavaScript-based implementation of the famous AWK application. However, it is more than an AWK implementation. It also includes a complete IDE for AWK, making debugging and bug fixing fast and easy. Have fun. Please report any issues back to me using the Rate page form below.

AWK Interpreter ver. 1.1
Status: Waiting for Source
Source: No Source loaded
  • Source Editor
  • Help
  • AWK Gramma

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 actionspattern actions
;
pattern action:function decl
|BEGINcompound statement
|ENDcompound statement
|compound statement
|expression compound statement
|expression ,  expression compound statement
;
function decl:functionid( [ id list ] )compound statement
;
id list:id
|id list,id
;
statements:statement
|statements;statement
;
statement:expression
|compound statements
|while(expression)statement
|dostatementwhile(expression)
|if(expression)statement
|if(expression)statementelsestatement
|for(expression;expression;expression)statement
|return [ expression ]
|continue
|break
|delete [ subscript ]
|next
|exit [ expression ]
|print
|printexpression 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 expressioninmatching exp
;
matching exp:relational exp
|matching exp˜relational exp
|matching exprelational 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 expadditive 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
|idre[_a-zA-Z0-9]re
;
number:integer
|float
;
integer:re[0-9]re
;
float:integer.re[0-9]*reexponent
|.re[0-9]*reexponent
;
exponent:
|re[eE]rere[0-9]+re
|re[eE]rere[+-]rere[0-9]+re
;
string:"re[.]*re"
;
reg exp:/re[^/]*re/
;
Data: No Data Source loaded
  • Data Source
  • Console
  • o1
  • o2
  • o3


  • Debug Log
  • Token Log
  • Code Log
  • Error Log
  • Var List
  • Local Vars
  • Watch
  • Stack
  • Call Stack
  • Display Stack
  • Labels
  • Break Points
  • Profiler

Rate this page

Click on the stars below to rate this page

Low
a Star
a Star
a Star
a Star
a Star
High


Corrections:
3-Aug-2021Vs 1.1Several bugs have been fixed
15-Nov-2020Vs 1.0Initial release