diff --git a/Operand.cpp b/Operand.cpp index 54d7e35..b250e23 100644 --- a/Operand.cpp +++ b/Operand.cpp @@ -2,8 +2,10 @@ #include "Exception.h" #include #include +#include #include #include +#include namespace jet { @@ -116,7 +118,16 @@ namespace jet { } else throw coreutils::Exception("Expecting ) at end of INTEGER expression."); } else if(in.ifNextIgnoreCase("ROUND")) { - + if(!in.ifNext("(")) + throw coreutils::Exception("Expecting ( for ROUND parameters."); + Operand parm1(in, tag); + if(in.ifNext(")")) { + doubleValue = round(parm1.doubleValue); + isNumber = true; + string = std::format("{:.12f}", doubleValue); + string.removeTrailingZeros(); + } else + throw coreutils::Exception("Expecting ) at end of ROUND expression."); } else if(in.ifNextIgnoreCase("RANDOM")) { unsigned int seed = (unsigned int)clock(); doubleValue = (double) rand_r(&seed) / (RAND_MAX + 1.0); @@ -124,29 +135,144 @@ namespace jet { string = std::format("{:.12f}", doubleValue); string.removeTrailingZeros(); } else if(in.ifNextIgnoreCase("ABS")) { - + if(!in.ifNext("(")) + throw coreutils::Exception("Expecting ( for ABS parameters."); + Operand parm1(in, tag); + if(in.ifNext(")")) { + doubleValue = abs(parm1.doubleValue); + isNumber = true; + string = std::format("{:.12f}", doubleValue); + string.removeTrailingZeros(); + } else + throw coreutils::Exception("Expecting ) at end of ABS expression."); } else if(in.ifNextIgnoreCase("MAX")) { } else if(in.ifNextIgnoreCase("MIN")) { } else if(in.ifNextIgnoreCase("POW")) { - + if(!in.ifNext("(")) + throw coreutils::Exception("Expecting ( for POW parameters."); + Operand parm1(in, tag); + if(!in.ifNext(",")) + throw coreutils::Exception("Expecting , in POW expression."); + Operand parm2(in, tag); + if(in.ifNext(")")) { + doubleValue = pow(parm1.doubleValue, parm2.doubleValue); + isNumber = true; + string = std::format("{:.12f}", doubleValue); + string.removeTrailingZeros(); + } else + throw coreutils::Exception("Expecting ) at end of substring expression."); } else if(in.ifNextIgnoreCase("SIN")) { - + if(!in.ifNext("(")) + throw coreutils::Exception("Expecting ( for SIN parameters."); + Operand parm1(in, tag); + if(in.ifNext(")")) { + doubleValue = sin(parm1.doubleValue); + isNumber = true; + string = std::format("{:.12f}", doubleValue); + string.removeTrailingZeros(); + } else + throw coreutils::Exception("Expecting ) at end of SIN expression."); } else if(in.ifNextIgnoreCase("ASIN")) { - + if(!in.ifNext("(")) + throw coreutils::Exception("Expecting ( for ASIN parameters."); + Operand parm1(in, tag); + if(in.ifNext(")")) { + doubleValue = asin(parm1.doubleValue); + isNumber = true; + string = std::format("{:.12f}", doubleValue); + string.removeTrailingZeros(); + } else + throw coreutils::Exception("Expecting ) at end of ASIN expression."); } else if(in.ifNextIgnoreCase("COS")) { - + if(!in.ifNext("(")) + throw coreutils::Exception("Expecting ( for COS parameters."); + Operand parm1(in, tag); + if(in.ifNext(")")) { + doubleValue = cos(parm1.doubleValue); + isNumber = true; + string = std::format("{:.12f}", doubleValue); + string.removeTrailingZeros(); + } else + throw coreutils::Exception("Expecting ) at end of COS expression."); } else if(in.ifNextIgnoreCase("ACOS")) { - + if(!in.ifNext("(")) + throw coreutils::Exception("Expecting ( for ACOS parameters."); + Operand parm1(in, tag); + if(in.ifNext(")")) { + doubleValue = acos(parm1.doubleValue); + isNumber = true; + string = std::format("{:.12f}", doubleValue); + string.removeTrailingZeros(); + } else + throw coreutils::Exception("Expecting ) at end of ACOS expression."); } else if(in.ifNextIgnoreCase("ATAN")) { - + if(!in.ifNext("(")) + throw coreutils::Exception("Expecting ( for ATAN parameters."); + Operand parm1(in, tag); + if(in.ifNext(")")) { + doubleValue = atan(parm1.doubleValue); + isNumber = true; + string = std::format("{:.12f}", doubleValue); + string.removeTrailingZeros(); + } else + throw coreutils::Exception("Expecting ) at end of ATAN expression."); } else if(in.ifNextIgnoreCase("SQRT")) { - + if(!in.ifNext("(")) + throw coreutils::Exception("Expecting ( for SQRT parameters."); + Operand parm1(in, tag); + if(in.ifNext(")")) { + doubleValue = sqrt(parm1.doubleValue); + isNumber = true; + string = std::format("{:.12f}", doubleValue); + string.removeTrailingZeros(); + } else + throw coreutils::Exception("Expecting ) at end of SQRT expression."); + } else if(in.ifNextIgnoreCase("DEG")) { + if(!in.ifNext("(")) + throw coreutils::Exception("Expecting ( for DEG parameters."); + Operand parm1(in, tag); + if(in.ifNext(")")) { + doubleValue = parm1.doubleValue * 180 / 3.14159; + isNumber = true; + string = std::format("{:.12f}", doubleValue); + string.removeTrailingZeros(); + } else + throw coreutils::Exception("Expecting ) at end of DEG expression."); + } else if(in.ifNextIgnoreCase("RAD")) { + if(!in.ifNext("(")) + throw coreutils::Exception("Expecting ( for RAD parameters."); + Operand parm1(in, tag); + if(in.ifNext(")")) { + doubleValue = parm1.doubleValue * 3.14159 / 180; + isNumber = true; + string = std::format("{:.12f}", doubleValue); + string.removeTrailingZeros(); + } else + throw coreutils::Exception("Expecting ) at end of RAD expression."); } else if(in.ifNextIgnoreCase("TAN")) { - + if(!in.ifNext("(")) + throw coreutils::Exception("Expecting ( for TAN parameters."); + Operand parm1(in, tag); + if(in.ifNext(")")) { + doubleValue = tan(parm1.doubleValue); + isNumber = true; + string = std::format("{:.12f}", doubleValue); + string.removeTrailingZeros(); + } else + throw coreutils::Exception("Expecting ) at end of TAN expression."); } else if(in.ifNextIgnoreCase("TRUNC")) { - + if(!in.ifNext("(")) + throw coreutils::Exception("Expecting ( for TRUNC parameters."); + Operand parm1(in, tag); + if(in.ifNext(")")) { + doubleValue = trunc(parm1.doubleValue); + isNumber = true; + string = std::format("{:.12f}", doubleValue); + string.removeTrailingZeros(); + } else + throw coreutils::Exception("Expecting ) at end of TRUNC expression."); } else if(in.ifNextIgnoreCase("CEIL")) { } else if(in.ifNextIgnoreCase("FLOOR")) { diff --git a/TODO.txt b/TODO.txt index 9ee06f2..5b423b0 100644 --- a/TODO.txt +++ b/TODO.txt @@ -11,6 +11,5 @@ $[data(length)] possibly. BUG LIST -1) Call tag is acting wierd. Look at testcall.jet. -2) Fix the variable retriever to perform all variable translation +1) Fix the variable retriever to perform all variable translation before fetching value processing. diff --git a/docs/JetCore.aux b/docs/JetCore.aux new file mode 100644 index 0000000..4876431 --- /dev/null +++ b/docs/JetCore.aux @@ -0,0 +1,42 @@ +\relax +\@writefile{toc}{\contentsline {section}{\numberline {1}Global Variables}{4}{}\protected@file@percent } +\@writefile{toc}{\contentsline {section}{\numberline {2}Local Variables}{4}{}\protected@file@percent } +\@writefile{toc}{\contentsline {section}{\numberline {3}Keyword Variables}{4}{}\protected@file@percent } +\@writefile{toc}{\contentsline {section}{\numberline {4}Environment Variables}{4}{}\protected@file@percent } +\@writefile{toc}{\contentsline {section}{\numberline {5}CGI Variables}{4}{}\protected@file@percent } +\@writefile{toc}{\contentsline {section}{\numberline {6}Operators}{4}{}\protected@file@percent } +\@writefile{toc}{\contentsline {subsection}{\numberline {6.1}Arithmentic Operators}{5}{}\protected@file@percent } +\@writefile{toc}{\contentsline {subsection}{\numberline {6.2}Boolean Operators}{5}{}\protected@file@percent } +\@writefile{toc}{\contentsline {section}{\numberline {7}Function Reference}{5}{}\protected@file@percent } +\@writefile{toc}{\contentsline {subsection}{\numberline {7.1}concat}{5}{}\protected@file@percent } +\@writefile{toc}{\contentsline {subsection}{\numberline {7.2}integer}{5}{}\protected@file@percent } +\@writefile{toc}{\contentsline {subsection}{\numberline {7.3}left}{5}{}\protected@file@percent } +\@writefile{toc}{\contentsline {subsection}{\numberline {7.4}random}{5}{}\protected@file@percent } +\@writefile{toc}{\contentsline {subsection}{\numberline {7.5}round}{5}{}\protected@file@percent } +\@writefile{toc}{\contentsline {subsection}{\numberline {7.6}substring}{5}{}\protected@file@percent } +\@writefile{toc}{\contentsline {section}{\numberline {8}Session Control}{5}{}\protected@file@percent } +\@writefile{toc}{\contentsline {section}{\numberline {9}call}{6}{}\protected@file@percent } +\@writefile{toc}{\contentsline {section}{\numberline {10}comment}{6}{}\protected@file@percent } +\@writefile{toc}{\contentsline {section}{\numberline {11}cookie}{6}{}\protected@file@percent } +\@writefile{toc}{\contentsline {section}{\numberline {12}dump}{6}{}\protected@file@percent } +\@writefile{toc}{\contentsline {section}{\numberline {13}exclude}{7}{}\protected@file@percent } +\@writefile{toc}{\contentsline {section}{\numberline {14}expr}{7}{}\protected@file@percent } +\@writefile{toc}{\contentsline {section}{\numberline {15}for}{7}{}\protected@file@percent } +\@writefile{toc}{\contentsline {section}{\numberline {16}header}{7}{}\protected@file@percent } +\@writefile{toc}{\contentsline {section}{\numberline {17}if/else}{7}{}\protected@file@percent } +\@writefile{toc}{\contentsline {section}{\numberline {18}ifrow/else}{8}{}\protected@file@percent } +\@writefile{toc}{\contentsline {section}{\numberline {19}include}{8}{}\protected@file@percent } +\@writefile{toc}{\contentsline {section}{\numberline {20}jet}{8}{}\protected@file@percent } +\@writefile{toc}{\contentsline {section}{\numberline {21}mysql}{8}{}\protected@file@percent } +\@writefile{toc}{\contentsline {section}{\numberline {22}read}{8}{}\protected@file@percent } +\@writefile{toc}{\contentsline {section}{\numberline {23}set}{9}{}\protected@file@percent } +\@writefile{toc}{\contentsline {section}{\numberline {24}sql}{9}{}\protected@file@percent } +\@writefile{toc}{\contentsline {section}{\numberline {25}stream}{9}{}\protected@file@percent } +\@writefile{toc}{\contentsline {section}{\numberline {26}system}{9}{}\protected@file@percent } +\@writefile{toc}{\contentsline {section}{\numberline {27}tag}{9}{}\protected@file@percent } +\@writefile{toc}{\contentsline {section}{\numberline {28}until}{10}{}\protected@file@percent } +\@writefile{toc}{\contentsline {section}{\numberline {29}while}{10}{}\protected@file@percent } +\@writefile{toc}{\contentsline {section}{\numberline {30}whiledir}{10}{}\protected@file@percent } +\@writefile{toc}{\contentsline {section}{\numberline {31}whilerow}{10}{}\protected@file@percent } +\@writefile{toc}{\contentsline {section}{\numberline {32}write}{10}{}\protected@file@percent } +\gdef \@abspage@last{10} diff --git a/docs/JetCore.dvi b/docs/JetCore.dvi new file mode 100644 index 0000000..1288a5a Binary files /dev/null and b/docs/JetCore.dvi differ diff --git a/docs/JetCore.log b/docs/JetCore.log new file mode 100644 index 0000000..41d39c3 --- /dev/null +++ b/docs/JetCore.log @@ -0,0 +1,175 @@ +This is pdfTeX, Version 3.141592653-2.6-1.40.25 (TeX Live 2023/Debian) (preloaded format=latex 2024.11.17) 8 NOV 2025 16:58 +entering extended mode + restricted \write18 enabled. + %&-line parsing enabled. +**JetCore.tex +(./JetCore.tex +LaTeX2e <2023-11-01> patch level 1 +L3 programming layer <2024-01-22> +(/usr/share/texlive/texmf-dist/tex/latex/refman/refart.cls +Document Class: refart 2006/11/13 v2.0e LaTeX document class +\papermarginwidth=\skip48 +(/usr/share/texlive/texmf-dist/tex/latex/base/size10.clo +File: size10.clo 2023/05/17 v1.4n Standard LaTeX file (size option) +) +\leftmarginwidth=\dimen140 +\fullwidth=\dimen141 +\emptyfoottopmargin=\dimen142 +\emptyheadtopmargin=\dimen143 +\c@part=\count187 +\c@section=\count188 +\c@subsection=\count189 +\c@subsubsection=\count190 +\c@paragraph=\count191 +\c@subparagraph=\count192 +\c@figure=\count193 +\c@table=\count194 +\abovecaptionskip=\skip49 +\belowcaptionskip=\skip50 +\bibindent=\dimen144 +) +(/usr/share/texlive/texmf-dist/tex/latex/l3backend/l3backend-dvips.def +File: l3backend-dvips.def 2024-01-04 L3 backend support: dvips +\l__pdf_internal_box=\box51 +\g__pdf_backend_object_int=\count195 +\l__pdf_backend_content_box=\box52 +\l__pdf_backend_model_box=\box53 +\g__pdf_backend_annotation_int=\count196 +\g__pdf_backend_link_int=\count197 +\g__pdf_backend_link_sf_int=\count198 +) +(./JetCore.aux) +\openout1 = `JetCore.aux'. + +LaTeX Font Info: Checking defaults for OML/cmm/m/it on input line 7. +LaTeX Font Info: ... okay on input line 7. +LaTeX Font Info: Checking defaults for OMS/cmsy/m/n on input line 7. +LaTeX Font Info: ... okay on input line 7. +LaTeX Font Info: Checking defaults for OT1/cmr/m/n on input line 7. +LaTeX Font Info: ... okay on input line 7. +LaTeX Font Info: Checking defaults for T1/cmr/m/n on input line 7. +LaTeX Font Info: ... okay on input line 7. +LaTeX Font Info: Checking defaults for TS1/cmr/m/n on input line 7. +LaTeX Font Info: ... okay on input line 7. +LaTeX Font Info: Checking defaults for OMX/cmex/m/n on input line 7. +LaTeX Font Info: ... okay on input line 7. +LaTeX Font Info: Checking defaults for U/cmr/m/n on input line 7. +LaTeX Font Info: ... okay on input line 7. + (./JetCore.toc +LaTeX Font Info: External font `cmex10' loaded for size +(Font) <7> on input line 8. +LaTeX Font Info: External font `cmex10' loaded for size +(Font) <5> on input line 8. + [1 + +]) +\tf@toc=\write3 +\openout3 = `JetCore.toc'. + + +! Undefined control sequence. +l.13 \chaptermark + {Introduction} +? q +OK, entering \batchmode... + [2] +! Undefined control sequence. +l.23 \chaptermark + {Tags and Attributes} +The control sequence at the end of the top line +of your error message was never \def'ed. If you have +misspelled it (e.g., `\hobx'), type `I' and the correct +spelling (e.g., `I\hbox'). Otherwise just continue, +and I'll forget about whatever was undefined. + +! Undefined control sequence. +l.32 ...e from mysql may be performed using the \< + mysql\> tag +The control sequence at the end of the top line +of your error message was never \def'ed. If you have +misspelled it (e.g., `\hobx'), type `I' and the correct +spelling (e.g., `I\hbox'). Otherwise just continue, +and I'll forget about whatever was undefined. + +! Undefined control sequence. +l.33 in combination with the \< + ifrow\>, \ and \ tags. +The control sequence at the end of the top line +of your error message was never \def'ed. If you have +misspelled it (e.g., `\hobx'), type `I' and the correct +spelling (e.g., `I\hbox'). Otherwise just continue, +and I'll forget about whatever was undefined. + +! Undefined control sequence. +l.33 in combination with the \, \< + whilerow\> and \ tags. +The control sequence at the end of the top line +of your error message was never \def'ed. If you have +misspelled it (e.g., `\hobx'), type `I' and the correct +spelling (e.g., `I\hbox'). Otherwise just continue, +and I'll forget about whatever was undefined. + +! Undefined control sequence. +l.33 ...on with the \, \ and \< + sql\> tags. +The control sequence at the end of the top line +of your error message was never \def'ed. If you have +misspelled it (e.g., `\hobx'), type `I' and the correct +spelling (e.g., `I\hbox'). Otherwise just continue, +and I'll forget about whatever was undefined. + +! Undefined control sequence. +l.66 \chaptermark + {Variables and Variable Types} +The control sequence at the end of the top line +of your error message was never \def'ed. If you have +misspelled it (e.g., `\hobx'), type `I' and the correct +spelling (e.g., `I\hbox'). Otherwise just continue, +and I'll forget about whatever was undefined. + + [3] +! Undefined control sequence. +l.125 \chapter + {Expressions} +The control sequence at the end of the top line +of your error message was never \def'ed. If you have +misspelled it (e.g., `\hobx'), type `I' and the correct +spelling (e.g., `I\hbox'). Otherwise just continue, +and I'll forget about whatever was undefined. + + [4] +! Undefined control sequence. +l.172 \chapter + {Common Gateway Interface Features} +The control sequence at the end of the top line +of your error message was never \def'ed. If you have +misspelled it (e.g., `\hobx'), type `I' and the correct +spelling (e.g., `I\hbox'). Otherwise just continue, +and I'll forget about whatever was undefined. + + [5] +! Undefined control sequence. +l.218 \chapter + {Tag Reference} +The control sequence at the end of the top line +of your error message was never \def'ed. If you have +misspelled it (e.g., `\hobx'), type `I' and the correct +spelling (e.g., `I\hbox'). Otherwise just continue, +and I'll forget about whatever was undefined. + + [6] [7] [8] [9] [10] (./JetCore.aux) + *********** +LaTeX2e <2023-11-01> patch level 1 +L3 programming layer <2024-01-22> + *********** + ) +Here is how much of TeX's memory you used: + 500 strings out of 474223 + 9431 string characters out of 5748758 + 1931972 words of memory out of 5000000 + 22827 multiletter control sequences out of 15000+600000 + 560443 words of font info for 44 fonts, out of 8000000 for 9000 + 1141 hyphenation exceptions out of 8191 + 35i,6n,50p,160b,169s stack positions out of 10000i,1000n,20000p,200000b,200000s + +Output written on JetCore.dvi (10 pages, 21424 bytes). diff --git a/docs/JetCore.pdf b/docs/JetCore.pdf new file mode 100644 index 0000000..c852331 Binary files /dev/null and b/docs/JetCore.pdf differ diff --git a/docs/JetCore.txt b/docs/JetCore.tex similarity index 98% rename from docs/JetCore.txt rename to docs/JetCore.tex index 2ba16e3..1b74586 100644 --- a/docs/JetCore.txt +++ b/docs/JetCore.tex @@ -1,4 +1,4 @@ -\documentclass{book} +\documentclass{refart} \title{JET Extension Tags} \author{Bradford Matthew Arant Sr.} @@ -10,7 +10,7 @@ \tableofcontents -\chapter{Introduction} +\chaptermark{Introduction} JET will pass through the untagged areas to the output without any modifications. Data contained within the tags may modify their @@ -20,7 +20,7 @@ itself is not passed to the output and will not appear in the output. Skip Blank Lines options on containers will skip passing any blank lines or line containing only whitespace to the output. -\chapter{Tags and Attributes} +\chaptermark{Tags and Attributes} XML style tagging is used to insert functions and other behaviors into the script. As the document contents are output a tag may be inserted @@ -32,7 +32,7 @@ functionality for each tag. Outputting a database from mysql may be performed using the \ tag in combination with the \, \ and \ tags. -\section{User Defined Tags and Tag Liraries} +\sectionmark{User Defined Tags and Tag Libraries} You can define your own tag definitions and use them within your JET scripts. @@ -63,7 +63,7 @@ higher tag. -\chapter{Variables and Variable Types} +\chaptermark{Variables and Variable Types} Variables are used to contain dynamic content values and can be sourced from several locations and limited in scope depending on use. diff --git a/docs/JetCore.toc b/docs/JetCore.toc new file mode 100644 index 0000000..495a803 --- /dev/null +++ b/docs/JetCore.toc @@ -0,0 +1,40 @@ +\contentsline {section}{\numberline {1}Global Variables}{4}{}% +\contentsline {section}{\numberline {2}Local Variables}{4}{}% +\contentsline {section}{\numberline {3}Keyword Variables}{4}{}% +\contentsline {section}{\numberline {4}Environment Variables}{4}{}% +\contentsline {section}{\numberline {5}CGI Variables}{4}{}% +\contentsline {section}{\numberline {6}Operators}{4}{}% +\contentsline {subsection}{\numberline {6.1}Arithmentic Operators}{5}{}% +\contentsline {subsection}{\numberline {6.2}Boolean Operators}{5}{}% +\contentsline {section}{\numberline {7}Function Reference}{5}{}% +\contentsline {subsection}{\numberline {7.1}concat}{5}{}% +\contentsline {subsection}{\numberline {7.2}integer}{5}{}% +\contentsline {subsection}{\numberline {7.3}left}{5}{}% +\contentsline {subsection}{\numberline {7.4}random}{5}{}% +\contentsline {subsection}{\numberline {7.5}round}{5}{}% +\contentsline {subsection}{\numberline {7.6}substring}{5}{}% +\contentsline {section}{\numberline {8}Session Control}{5}{}% +\contentsline {section}{\numberline {9}call}{6}{}% +\contentsline {section}{\numberline {10}comment}{6}{}% +\contentsline {section}{\numberline {11}cookie}{6}{}% +\contentsline {section}{\numberline {12}dump}{6}{}% +\contentsline {section}{\numberline {13}exclude}{7}{}% +\contentsline {section}{\numberline {14}expr}{7}{}% +\contentsline {section}{\numberline {15}for}{7}{}% +\contentsline {section}{\numberline {16}header}{7}{}% +\contentsline {section}{\numberline {17}if/else}{7}{}% +\contentsline {section}{\numberline {18}ifrow/else}{8}{}% +\contentsline {section}{\numberline {19}include}{8}{}% +\contentsline {section}{\numberline {20}jet}{8}{}% +\contentsline {section}{\numberline {21}mysql}{8}{}% +\contentsline {section}{\numberline {22}read}{8}{}% +\contentsline {section}{\numberline {23}set}{9}{}% +\contentsline {section}{\numberline {24}sql}{9}{}% +\contentsline {section}{\numberline {25}stream}{9}{}% +\contentsline {section}{\numberline {26}system}{9}{}% +\contentsline {section}{\numberline {27}tag}{9}{}% +\contentsline {section}{\numberline {28}until}{10}{}% +\contentsline {section}{\numberline {29}while}{10}{}% +\contentsline {section}{\numberline {30}whiledir}{10}{}% +\contentsline {section}{\numberline {31}whilerow}{10}{}% +\contentsline {section}{\numberline {32}write}{10}{}% diff --git a/tests/testmath.jet b/tests/testmath.jet new file mode 100755 index 0000000..f0af3d2 --- /dev/null +++ b/tests/testmath.jet @@ -0,0 +1,23 @@ +#!../jet-2.0 + + +$[value1] + +$[value2] + +$[value3] + +$[value4] + +$[value5] + +$[value6] + +$[value6] + +$[value7] + +$[value8] + +$[value9] +