Updated?
This commit is contained in:
commit
6e143c09e6
82
Keywords.txt
82
Keywords.txt
@ -1,82 +0,0 @@
|
|||||||
ADDR
|
|
||||||
AND
|
|
||||||
AS
|
|
||||||
BEGIN
|
|
||||||
BOOL
|
|
||||||
BREAK
|
|
||||||
BYREF
|
|
||||||
CASE
|
|
||||||
CASE_ELSE
|
|
||||||
CHAR
|
|
||||||
CLASS
|
|
||||||
CLASS
|
|
||||||
CONSTANT
|
|
||||||
CONSTRUCTOR
|
|
||||||
DECLARE
|
|
||||||
DECR
|
|
||||||
DIM
|
|
||||||
DO
|
|
||||||
ELSE
|
|
||||||
ENC$
|
|
||||||
END
|
|
||||||
ENDCASE
|
|
||||||
ENDCLASS
|
|
||||||
ENDCONSTRUCTOR
|
|
||||||
ENDENUM
|
|
||||||
ENDFUNCTION
|
|
||||||
ENDIF
|
|
||||||
ENDMAIN
|
|
||||||
ENDSELECT
|
|
||||||
ENDSUB
|
|
||||||
ENUM
|
|
||||||
EXIT
|
|
||||||
FALSE
|
|
||||||
FOR
|
|
||||||
FORMAT$
|
|
||||||
FUNCTION
|
|
||||||
IF
|
|
||||||
INCR
|
|
||||||
INSTR
|
|
||||||
INT
|
|
||||||
INTEGER
|
|
||||||
LCASE$
|
|
||||||
LEFT$
|
|
||||||
LEN(
|
|
||||||
LOADFILE$
|
|
||||||
LPCHAR
|
|
||||||
LTRIM$
|
|
||||||
MAIN
|
|
||||||
MAP
|
|
||||||
MCASE$
|
|
||||||
MID$
|
|
||||||
NEXT
|
|
||||||
NOT
|
|
||||||
OR
|
|
||||||
PRINT
|
|
||||||
PTR
|
|
||||||
REPLACE$
|
|
||||||
RETURN
|
|
||||||
REVERSE$
|
|
||||||
RIGHT$
|
|
||||||
RTRIM$
|
|
||||||
SAVEFILE
|
|
||||||
SELECT
|
|
||||||
SHORT
|
|
||||||
SPLIT
|
|
||||||
SPLITPATH$
|
|
||||||
STEP
|
|
||||||
STR$
|
|
||||||
STRARRAY
|
|
||||||
SUB
|
|
||||||
THEN
|
|
||||||
TO
|
|
||||||
TRIM$
|
|
||||||
TRUE
|
|
||||||
TYPE
|
|
||||||
UCASE$
|
|
||||||
UINT
|
|
||||||
VAL
|
|
||||||
VECTOR
|
|
||||||
WEND
|
|
||||||
WHILE
|
|
||||||
_TO_
|
|
@ -1,20 +0,0 @@
|
|||||||
ENC$ (CSTRING A, INT L, INT R)
|
|
||||||
FORMAT$ (CONSTANT CSTRING fmt, ...)
|
|
||||||
INSTR (CSTRING s,CSTRING match, size_t offset)
|
|
||||||
LCASE$ (CSTRING str)
|
|
||||||
LEFT$ (CSTRING s, INT length)
|
|
||||||
LOADFILE$ (CSTRING N)
|
|
||||||
LTRIM$ (CSTRING s)
|
|
||||||
MCASE$ (CSTRING S)
|
|
||||||
MID$ (CSTRING s, INT start, INT length)
|
|
||||||
PRINT (CSTRING A="")
|
|
||||||
REPLACE$ (CSTRING subject, CONSTANT CSTRING& search, CONSTANT CSTRING& replace)
|
|
||||||
REVERSE$ (CSTRING src)
|
|
||||||
RIGHT$ (CSTRING s, INT length)
|
|
||||||
RTRIM$ (CSTRING s)
|
|
||||||
SAVEFILE (CSTRING src, CSTRING fname)
|
|
||||||
SPLIT (CONSTANT CSTRING input, CONSTANT CSTRING separators, BOOL remove_empty)
|
|
||||||
SPLITPATH$ (CSTRING FPATH, INT mask)
|
|
||||||
TRIM$ (CSTRING s)
|
|
||||||
UCASE$ (CSTRING str)
|
|
||||||
VAL (CSTRING str)
|
|
63
curl.inc
Normal file
63
curl.inc
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
|
||||||
|
#ifdef USE_CURL
|
||||||
|
#include <curl/curl.h>
|
||||||
|
|
||||||
|
typedef int (*JADE_PROGRESS_CALLBACK)(void*,double,double,double,double);
|
||||||
|
typedef int (*JADE_WRITE_CALLBACK)(void*,long,long,void*);
|
||||||
|
|
||||||
|
void downloadFile(CSTRING url, CSTRING downloadFileName, void *progress_callback);
|
||||||
|
void downloadPage(CSTRING url, CSTRING buffer, void *write_callback);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int jade_curl_progress_callback(void* clientp, double dltotal, double dlnow, double ultotal, double ulnow ) {
|
||||||
|
printf("Downloaded %d of %d bytes\r",(int)dlnow,(int)dltotal);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int jade_curl_write_data_callback (void* content, long size, long nmemb, void* stream) {
|
||||||
|
((std::string*)stream)->append((char*)content, size * nmemb);
|
||||||
|
return size * nmemb;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string downloadPage(CSTRING url,JADE_WRITE_CALLBACK write_callback = jade_curl_write_data_callback) {
|
||||||
|
void* handle;
|
||||||
|
int success;
|
||||||
|
std::string buffer$;
|
||||||
|
|
||||||
|
handle = curl_easy_init();
|
||||||
|
curl_easy_setopt(handle, CURLOPT_URL, url.c_str());
|
||||||
|
curl_easy_setopt(handle, CURLOPT_FOLLOWLOCATION,1);
|
||||||
|
curl_easy_setopt(handle, CURLOPT_WRITEFUNCTION, write_callback);
|
||||||
|
curl_easy_setopt(handle, CURLOPT_WRITEDATA, &buffer$);
|
||||||
|
|
||||||
|
|
||||||
|
success = curl_easy_perform(handle);
|
||||||
|
|
||||||
|
curl_easy_cleanup(handle);
|
||||||
|
|
||||||
|
return buffer$;
|
||||||
|
}
|
||||||
|
void downloadFile(CSTRING url, CSTRING downloadFileName, JADE_PROGRESS_CALLBACK progress_callback=jade_curl_progress_callback) {
|
||||||
|
void* handle;
|
||||||
|
int success;
|
||||||
|
FILE *fp;
|
||||||
|
|
||||||
|
handle = curl_easy_init();
|
||||||
|
if ((fp = fopen(downloadFileName.c_str(), "wb+"))) {
|
||||||
|
curl_easy_setopt(handle, CURLOPT_URL, url.c_str());
|
||||||
|
curl_easy_setopt(handle, CURLOPT_FOLLOWLOCATION,1);
|
||||||
|
curl_easy_setopt(handle, CURLOPT_WRITEDATA, fp);
|
||||||
|
curl_easy_setopt(handle, CURLOPT_NOPROGRESS,0);
|
||||||
|
curl_easy_setopt(handle, CURLOPT_PROGRESSDATA,downloadFileName.c_str());
|
||||||
|
curl_easy_setopt(handle, CURLOPT_PROGRESSFUNCTION,progress_callback);
|
||||||
|
|
||||||
|
success = curl_easy_perform(handle);
|
||||||
|
fclose(fp);
|
||||||
|
}
|
||||||
|
curl_easy_cleanup(handle);
|
||||||
|
printf("\n\nDownload of '%s' Complete.\n\n", downloadFileName.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
14
header.inc
14
header.inc
@ -24,6 +24,7 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
#include <regex>
|
||||||
|
|
||||||
/* DEFINES */
|
/* DEFINES */
|
||||||
#define MAIN int main (int argc, char** argv) {
|
#define MAIN int main (int argc, char** argv) {
|
||||||
@ -33,6 +34,7 @@
|
|||||||
#define ENDFUNCTION }
|
#define ENDFUNCTION }
|
||||||
#define DIM
|
#define DIM
|
||||||
#define AS
|
#define AS
|
||||||
|
#define DEF
|
||||||
#define SUB void
|
#define SUB void
|
||||||
#define ENDSUB }
|
#define ENDSUB }
|
||||||
#define BEGIN {
|
#define BEGIN {
|
||||||
@ -59,17 +61,20 @@
|
|||||||
#define _TO_ ...
|
#define _TO_ ...
|
||||||
#define ENDCASE break;
|
#define ENDCASE break;
|
||||||
#define CASE_ELSE default
|
#define CASE_ELSE default
|
||||||
|
#define CLS printf("\33[2J\33[H")
|
||||||
#define ENDSELECT }
|
#define ENDSELECT }
|
||||||
#define WHILE while
|
#define WHILE while
|
||||||
#define WEND }
|
#define WEND }
|
||||||
#define RETURN return
|
#define RETURN return
|
||||||
#define CONSTANT const
|
#define CONSTANT const
|
||||||
#define STR$( x ) dynamic_cast< std::ostringstream & >( ( std::ostringstream() << std::dec << x ) ).str()
|
// #define STR$( x ) dynamic_cast< std::ostringstream & >( ( std::ostringstream() << std::dec << x ) ).str()
|
||||||
|
#define STR$(x) std::to_string(x)
|
||||||
#define BOOL bool
|
#define BOOL bool
|
||||||
#define INT int
|
#define INT int
|
||||||
#define INTEGER int
|
#define INTEGER int
|
||||||
#define UINT unsigned int
|
#define UINT unsigned int
|
||||||
#define VECTOR std::vector
|
#define VECTOR std::vector
|
||||||
|
#define ARRAY std::vector
|
||||||
#define MAP std::map
|
#define MAP std::map
|
||||||
#define CHAR char
|
#define CHAR char
|
||||||
#define ENUM enum {
|
#define ENUM enum {
|
||||||
@ -86,7 +91,10 @@
|
|||||||
#define NEXT }
|
#define NEXT }
|
||||||
#define STRARRAY VECTOR<CSTRING>
|
#define STRARRAY VECTOR<CSTRING>
|
||||||
#define LEN(x) x.size()
|
#define LEN(x) x.size()
|
||||||
|
#define REGQUERY std::regex
|
||||||
|
#define REGMATCH std::smatch
|
||||||
|
#define PRINTNL printf("\n")
|
||||||
|
#define NL std::endl
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -107,3 +115,5 @@ typedef std::string CSTRING;
|
|||||||
char LF [2]= {10,0}; // Line Feed
|
char LF [2]= {10,0}; // Line Feed
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
7
jade.h
7
jade.h
@ -1,3 +1,10 @@
|
|||||||
#include "header.inc"
|
#include "header.inc"
|
||||||
#include "runtime.inc"
|
#include "runtime.inc"
|
||||||
|
|
||||||
|
#ifdef USE_CURL
|
||||||
|
#include "curl.inc"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
template <class PRN>
|
||||||
|
|
||||||
|
22
runtime.inc
22
runtime.inc
@ -18,6 +18,18 @@ DECLARE FUNCTION CSTRING FORMAT$ (CONSTANT CSTRING fmt, ...);
|
|||||||
DECLARE FUNCTION VECTOR<CSTRING> SPLIT (CONSTANT CSTRING input, CONSTANT CSTRING separators, BOOL remove_empty = TRUE);
|
DECLARE FUNCTION VECTOR<CSTRING> SPLIT (CONSTANT CSTRING input, CONSTANT CSTRING separators, BOOL remove_empty = TRUE);
|
||||||
DECLARE SUB PRINT (CSTRING);
|
DECLARE SUB PRINT (CSTRING);
|
||||||
DECLARE SUB SAVEFILE(CSTRING src, CSTRING fname);
|
DECLARE SUB SAVEFILE(CSTRING src, CSTRING fname);
|
||||||
|
DECLARE FUNCTION CSTRING REGEX (CSTRING src, CSTRING query);
|
||||||
|
|
||||||
|
FUNCTION CSTRING REGEX (CSTRING src, CSTRING query) {
|
||||||
|
CSTRING result;
|
||||||
|
REGMATCH match;
|
||||||
|
REGQUERY term(query);
|
||||||
|
if (regex_search(src, match, term,std::regex_constants::match_any) == true){
|
||||||
|
std::cout << match.size() << std::endl;
|
||||||
|
result = match[1];
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
ENDFUNCTION
|
||||||
|
|
||||||
FUNCTION VECTOR<CSTRING> SPLIT (CONSTANT CSTRING input, CONSTANT CSTRING separators, BOOL remove_empty) BEGIN
|
FUNCTION VECTOR<CSTRING> SPLIT (CONSTANT CSTRING input, CONSTANT CSTRING separators, BOOL remove_empty) BEGIN
|
||||||
DIM VECTOR<CSTRING> lst;
|
DIM VECTOR<CSTRING> lst;
|
||||||
@ -127,7 +139,7 @@ ENDFUNCTION
|
|||||||
FUNCTION CSTRING MCASE$ (CSTRING S) BEGIN
|
FUNCTION CSTRING MCASE$ (CSTRING S) BEGIN
|
||||||
DIM AS CSTRING tmpStr(S);
|
DIM AS CSTRING tmpStr(S);
|
||||||
DIM AS bool capFlag = FALSE;
|
DIM AS bool capFlag = FALSE;
|
||||||
DIM AS register size_t i;
|
DIM AS size_t i;
|
||||||
|
|
||||||
|
|
||||||
std::transform(tmpStr.begin(),tmpStr.end(),tmpStr.begin(),::tolower);
|
std::transform(tmpStr.begin(),tmpStr.end(),tmpStr.begin(),::tolower);
|
||||||
@ -242,3 +254,11 @@ ENDFUNCTION
|
|||||||
FUNCTION INT VAL (CSTRING str) BEGIN
|
FUNCTION INT VAL (CSTRING str) BEGIN
|
||||||
RETURN atoi(str.c_str());
|
RETURN atoi(str.c_str());
|
||||||
ENDFUNCTION
|
ENDFUNCTION
|
||||||
|
|
||||||
|
FUNCTION CSTRING GRAB$(CONSTANT CSTRING &src, CONSTANT CSTRING &start, CONSTANT CSTRING &stop) {
|
||||||
|
DIM AS size_t begin = src.find(start);
|
||||||
|
DIM AS size_t end = (begin + start.length());
|
||||||
|
DIM AS size_t term = src.find(stop);
|
||||||
|
|
||||||
|
return src.substr(end, (term - end));
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user