I originally used BASH with the 'ack' program to generate the Keywords.txt and Prototypes.txt files for Jade.
Problem was that 'ack' is a 3rd party program which isn't typically installed on Linux/macOS machines (I don't even know if there's a version for Windows, to be honest).
I rewrote the script using Python, but while it typically comes pre-installed on Linux/macOS, it definitely is not pre-installed on Windows.
Rather than require the installation on OS's that don't have Python installed, I decided to re-write the generate-keywords using Jade itself.
Here is what it looks like, feedback is encouraged!!!
#include "jade.h"
/*
* generate-keywords
*
* Jade program to generate Jade Keywords.txt and Prototypes.txt files
*
* Copyright 2018, Armando I. Rivera
*
* License: MIT
*
* Compile with: g++ -std=c++11 -O2 -s generate-keywords.cc -o generate-keywords
*/
SUB jadeKeywordProto(STRING srcFile,STRING query, STRARRAY& sarray) BEGIN
REGQUERY term(query);
STRING src(LOADFILE$(srcFile));
std::sregex_token_iterator it(src.begin(), src.end(), term,2);
WHILE ( it != std::sregex_token_iterator() ) BEGIN
IF ( NOT it->str().empty() && it->str() != " " ) THEN
sarray.push_back(it->str());
ENDIF
it++;
WEND
END
MAIN
STRARRAY KEYWORDS,PROTOTYPES;
jadeKeywordProto("runtime.inc", "(FUNCTION|SUB) (.+\\)) BEGIN", PROTOTYPES);
jadeKeywordProto("header.inc", "(#define\\s+|typedef .+ )(\\w+\\$|\\w+)", KEYWORDS);
jadeKeywordProto("runtime.inc", "(FUNCTION .+ |SUB|SUB )(\\w+|\\w+\\$) \\(.+ BEGIN", KEYWORDS);
OUTFILE keyFile("KEYWORDS.txt");
FOR (VAR item IN KEYWORDS) BEGIN
keyFile << item << std::endl;
END
OUTFILE protoFile("PROTOTYPES.txt");
FOR (VAR item IN PROTOTYPES) BEGIN
protoFile << item << std::endl;
END
ENDMAIN
Keep in mind that this is C++; I didn't use DIM, etc because it's redundant with my Jade implementation, and just clutters things up.
AIR.