Show HN: Cppawk

What is cppawk?

cppawk is a miniature shell script that is historical bask in awk. It invokes
the C preprocessor (GNU cpp) on the Awk code and calls see.

cppawk understands the basic Awk alternatives bask in -F and -v, and additionally
realize total cpp alternatives bask in -I and -Dmacro=price.

There could be a man web page with the total critical parts.

To illustrate, if we elaborate a file known as awkloop.h which has these contents

#elaborate awkloop(file)  for (; getline 
#elaborate nextrec        continue
#elaborate rule(cond)     if (cond)

Then this invent of code is conceivable:

#embody "awkloop.h"

contrivance vital()
  awkloop ("/proc/mounts") {
    rule ($3 != "ext4") { nextrec }
    rule ($2 == "/") { print $1 }


Now we beget implemented a facsimile of an Awk input scanning loop interior a contrivance
with moderately syntactic sugar.


  • Why no longer?

  • You perceive Awk. You perceive C preprocessing interior out. Now use two issues
    that you know, collectively, in glaring techniques.

  • Awks varied than GNU Awk beget downhearted reinforce for making a program out of
    quite a lot of recordsdata. No assemble meta-programming, or conditional alternative
    of code.

  • Totally different minor advantages: Awk has no feedback varied than from a #
    character to the tip of the line. You procure /... */ feedback
    with cppawk, and additionally #if 0#endif for immediate
    disabling code.

But GNU Awk has @embody?

  • GNU Awk’s @embody is no longer essentially a beefy preprocessor. There are no longer any conditional
    expressions, and no macros.

  • It is some distance best implemented in GNU Awk.

  • It provides no capacity to buy the total included output.

  • The capacity @embody searches for recordsdata is pass to cpp. GNU Awk’s
    embody search is driven by the AWKPATH variable which brings in the total
    disadvantages shared by shared by PATH-bask in variables. In distinction cpp
    implements the acquainted habits that an #embody "..." directive is
    resolved relative to the listing of the file which comprises that
    #embody directive. No configuration is required for a program to search out
    all of its included gadgets.

I use awk on embedded techniques with out a cpp!

Although packaged that implies, cppawk doesn’t beget to be historical as an interpreter
which preprocesses and runs the code. Preprocessed code will seemingly be captured with
the --prepro-best risk, and then transferred to a target system for
execution with its Awk.

Tip: it’ll be a edifying conception to tweak cppawk in say that it doesn’t elaborate the
__gawk__ symbol, in case your target system’s Awk is no longer essentially GNU Awk.

Read More

Related Articles

Valve has just validated 3000 Games For The Steam Deck

Willy Jetman: Astromonkey’s RevengeSteam Deck Verified2022-05-21Store Page The Princess, the Stray Cat, and Matters of the HeartSteam Deck Verified2022-05-21Store Page YngletSteam Deck Verified2022-05-21Store Page Citizens of SpaceSteam Deck Playable2022-05-21Store Page VirtuaVerseSteam Deck Playable2022-05-21Store Page Shank 2Steam Deck Verified2022-05-21Store Page Chromosome EvilSteam Deck Playable2022-05-21Store Page New Super Lucky’s TaleSteam Deck Playable2022-05-21Store Page DeleveledSteam Deck Verified2022-05-21Store Page…

What’s recent in Emacs 28.1?

By Mickey Petersen It’s that time again: there’s a new major version of Emacs and, with it, a treasure trove of new features and changes.Notable features include the formal inclusion of native compilation, a technique that will greatly speed up your Emacs experience.A critical issue surrounding the use of ligatures also fixed; without it, you…

System Design Primer: Learn how to design large-scale systems

English ∙ 日本語 ∙ 简体中文 ∙ 繁體中文 | العَرَبِيَّة‎ ∙ বাংলা ∙ Português do Brasil ∙ Deutsch ∙ ελληνικά ∙ עברית ∙ Italiano ∙ 한국어 ∙ فارسی ∙ Polski ∙ русский язык ∙ Español ∙ ภาษาไทย ∙ Türkçe ∙ tiếng Việt ∙ Français | Add Translation Help translate this guide! Motivation Learn how to design…

x86 Is an Octal Machine

# source: From: (Mark Hopkins) Newsgroups: alt.lang.asm Subject: A Summary of the 80486 Opcodes and Instructions (1) The 80×86 is an Octal Machine This is a follow-up and revision of an article posted in alt.lang.asm on 7-5-92 concerning the 80×86 instruction encoding. The only proper way to understand 80×86 coding is to realize that…

Fish 3.4.0 Released

Notable improvements and fixes fish’s command substitution syntax has been extended: $(cmd) now has the same meaning as (cmd) but it can be used inside double quotes, to prevent line splitting of the results (#159): foo (bar | string collect) # can now be written as foo “$(bar)” # and foo (bar) # can now…