On this page:
1.1 Conditions
1.2 RAWK vs AWK
8.17.0.6

1 Syntax🔗ℹ

The following describers RAWK language syntax, how to write conditions and differences between RAWK and AWK.

1.1 Conditions🔗ℹ

  condition = import-expression
  | begin-expression
  | end-expression
  | matchall-expression
  | match-expression
  | ...
     
  import-expression = (~seq IMPORT import-body)
     
  begin-expression = (~seq BEGIN expression-body)
     
  end-expression = (~seq END expression-body)
     
  matchall-expression = expression-body
     
  match-expression = (~seq symbol-regexp expression-body)
     
  import-body = (import-mod ...)
     
  expression-body = (body ...)

  • ~seq means that the inside identifiers appear as a sequence and they are not surrounded by parentheses,

  • import-name and import-statement are identifiers referring to a identifier imported from a module and the module the identifier should be imported from,

  • symbol-regexp is a symbol treated as a regexp, for example .* will become #rx".*",

  • body is any racket expression.

1.2 RAWK vs AWK🔗ℹ

  • condition actions (bodys) are pure Racket syntax

  • conditions are surrounded by "||" rather than "//",

    In RAWK:

    |a.*l| {

        (print "!")

    }

    In AWK:

    /a.*l/ {

        print "!";

    }

    "||" is also optional, it encapsulates the symbol-regexp similarly to how it can encapsulate symbols in Racket, so if there are no characters that are specially treated in the symbol-regexp, then "||" can be omitted,

  • there is no function statement, custom functions used inside condition bodys should be instead defined inside BEGIN pseudo-condition,

    BEGIN {

        (define (smile)

          (displayln ":-)"))

    }

    {

        (smile)

    }

  • IMPORT can be used to import Racket code defined elsewhere.