vrtc / pjass (public) (License: BSD) (since 2023-08-03) (hash sha1)
pjass is a free Jass scripting language parser. This repository is a fork of lep/pjass. The goal is to add Debian packaging. As of the time of this writing, it works for current stable, that is Debian 12 (bookworm).

/token.l (22ec4a6f71e40e38ca426fc3db474636a1990061) (6387 bytes) (mode 100644) (type blob)

/* Jass2 parser for bison/yacc */
/* by Rudi Cilibrasi */
/* Sun Jun  8 00:51:53 CEST 2003 */
/* thanks to Jeff Pang for the handy documentation that this was based */
/* on at http://jass.sourceforge.net */
/* Released under the BSD license */

%{
/* need this for the call to atof() below */
#undef yywrap
int yywrap()
{
	return 1;
}

#include "grammar.tab.h" 
#include "misc.h"

%}

COMMENTSTART [/][/]
NEWLINE  (\r*\n)|\r*
OCTDIGIT [0-7]
DIGIT    [0-9]
HEXDIGIT [0-9a-fA-F]
ID       [a-zA-Z]([a-zA-Z0-9_]*[a-zA-Z0-9])?
SPACE    [ \t]
TABS     [\x01-\x09\x0B\x0C\x0E-\x1F]
STRINGSTART ["]
RAWCODESTART [']

%%

{COMMENTSTART} {
    int c;
    for(c = input(); !(c == '\n' || c == EOF); c = input()) ;
    lineno++;
    islinebreak = 1;
    isconstant = 0;
    return NEWLINE;
}

{RAWCODESTART} {
    int prevChar = 0;
    int curChar = input();
    int special = 0;
    int count = 0;
    for(;;){
        if (prevChar == '\r' && curChar != '\r') {
            lineno++;
        }
        if(curChar == EOF){
            break;
        }else if (prevChar == '\\'){
            if(count != 1){
                yyerrorline(3, lineno, "Escaped chars are only allowed if they are the only char in the rawcode.");
            }else{
                if (curChar != 'b' && curChar != 't' && curChar != 'r' && curChar != 'n' &&  curChar != 'f' && curChar != '\'' && curChar != '\\')
                    yyerrorline(3, lineno, "Invalid escape character sequence");
                curChar = 0;
                special = 1;
            }
        }else if (curChar == '\''){
            if(count != 4 && count - special != 1){
                yyerrorline(3, lineno, "Rawcodes must be 1 or 4 characters.");
            }
            break;
        }
        count++;
        prevChar = curChar;
        curChar = input();
    }
    return UNITTYPEINT;
}

{STRINGSTART} {  int prevChar = 0;
                 int curChar = input();
                 islinebreak = 0;
                 for (;;) {
                   if (prevChar == '\r' && curChar != '\r') {
                     lineno++; isconstant = 0;
                   }
                   if (curChar == EOF)
                     break;
                   else if (prevChar == '\\') {
                     if (curChar != 'b' && curChar != 't' && curChar != 'r' && curChar != 'n' &&  curChar != 'f' && curChar != '\"' && curChar != '\\')
                       yyerrorline(3, lineno, "Invalid escape character sequence");
                     curChar = 0;
                   } else if (curChar == '\"') {
                     break;
                   }
                   prevChar = curChar;
                   curChar = input();
                 }
                 return STRINGLIT;
              }

{NEWLINE} lineno++; islinebreak=1; isconstant=0; return NEWLINE;

{DIGIT}*"."{DIGIT}*  return REALLIT;
"0"({OCTDIGIT}*("8"|"9"){OCTDIGIT}*)+ yyerrorline(3, lineno, "Invalid digit in octal integer notation"); return INTLIT;
({DIGIT}+)|(("0x"|"$"){HEXDIGIT}+) return INTLIT;

"if" if (!islinebreak) yyerrorline(3, lineno, "Missing linebreak before if"); islinebreak=0; return IF;
"not" return NOT;
"then" return THEN;
"type" if (!islinebreak) { char ebuf[1024]; sprintf(ebuf, "Missing linebreak before type declaration"); yyerrorline(3, lineno, ebuf); } islinebreak=0; return TYPE;
"extends" return EXTENDS;
"handle" islinebreak=0; return HANDLE;
"globals" if (!islinebreak) { char ebuf[1024]; sprintf(ebuf, "Missing linebreak before globals block"); yyerrorline(3, lineno, ebuf); } islinebreak=0; inblock=1; return GLOBALS;
"endglobals" islinebreak=0; inblock=0; return ENDGLOBALS;
"constant" isconstant = islinebreak; islinebreak=0; return CONSTANT;
"native" if (!islinebreak && !isconstant) { char ebuf[1024]; sprintf(ebuf, "Missing linebreak before native declaration"); yyerrorline(3, lineno, ebuf); } islinebreak=0; return NATIVE;
"takes" return TAKES;
"returns" return RETURNS;
"function" if (!islinebreak && !isconstant && !inblock) { char ebuf[1024]; sprintf(ebuf, "Missing linebreak before function declaration"); yyerrorline(3, lineno, ebuf); } islinebreak=0; return FUNCTION;
"endfunction" islinebreak=0; return ENDFUNCTION;
"local" if (!islinebreak) { char ebuf[1024]; sprintf(ebuf, "Missing linebreak before local declaration"); yyerrorline(3, lineno, ebuf); } islinebreak=0; return LOCAL;
"array" return ARRAY;
"set" if (!islinebreak) yyerrorline(3, lineno, "Missing linebreak before assignment"); islinebreak=0; return SET;
"call" if (!islinebreak) yyerrorline(3, lineno, "Missing linebreak before function call"); islinebreak=0; return CALL;
"else" if (!islinebreak) yyerrorline(3, lineno, "Missing linebreak before else"); islinebreak=0; return ELSE;
"elseif" if (!islinebreak) yyerrorline(3, lineno, "Missing linebreak before elseif"); islinebreak=0; return ELSEIF;
"endif" if (!islinebreak) yyerrorline(3, lineno, "Missing linebreak before endif"); islinebreak=0; return ENDIF;
"loop" if (!islinebreak) yyerrorline(3, lineno, "Missing linebreak before loop"); islinebreak=0; return LOOP;
"exitwhen" if (!islinebreak) yyerrorline(3, lineno, "Missing linebreak before exitwhen"); islinebreak=0; return EXITWHEN;
"return" if (!islinebreak) yyerrorline(3, lineno, "Missing linebreak before return"); islinebreak=0; return RETURN;
"debug" return DEBUG;
"endloop" if (!islinebreak) yyerrorline(3, lineno, "Missing linebreak before endloop"); islinebreak=0; return ENDLOOP;
"null" return TNULL;
"true" return TTRUE;
"false" return TFALSE;
"code" islinebreak=0; return CODE;
"string" islinebreak=0; return STRING;
"integer" islinebreak=0; return INTEGER;
"real" islinebreak=0; return REAL;
"boolean" islinebreak=0; return BOOLEAN;
"nothing" return NOTHING;
"and" return AND;
"or" return OR;
"," return COMMA;
"=" return EQUALS;
"*" return TIMES;
"/" return DIV;
"+" return PLUS;
"-" return MINUS;
"(" return LPAREN;
")" return RPAREN;
"[" return LBRACKET;
"]" return RBRACKET;
"<" return LESS;
">" return GREATER;
"==" return EQCOMP;
"<=" return LEQ;
">=" return GEQ;
"!=" return NEQ;

{ID}        islinebreak=0; return ID;


"<"|">"|"!"|"["|"]"|"("|")"|"+"|"-"|"*"|"/"|"."  return TNULL;

[ \t]+          /* eat up whitespace */
[\x01-\x09\x0B\x0C\x0E-\x1F]+    /* eat up tabs */

.            if (1) { char ebuf[1024]; sprintf(ebuf, "Unrecognized character %s (ASCII %d)", yytext, yytext[0] ); yyerrorline(3, lineno, ebuf); }

%%



Mode Type Size Ref File
100644 blob 730 d833c0c2ee6b5aa377f4f30d3e678d0fcac569ee Makefile
100644 blob 439 04f5f4c52ea3055fd29ddd78ff091326ee1b4177 Makefile.Whatever
100644 blob 564 2da1e0352a6d6e6f5a956f60424e1ee391131e98 Makefile.cygwin
100644 blob 26021 6b3bbeb49255a1bf6c841c38be4a77e340e60dc6 grammar.y
100644 blob 19641 0dfd52afe6720b9b117559d08e1751cb856d9f44 misc.c
100644 blob 3369 9603d7a0f63502ef428407ef7df18764f1322c4c misc.h
100644 blob 1302 13d65e05aca85cddd2f539b14d98cfbf1c622752 notes.txt
100644 blob 744 c8efdbf329d07cba0543a81c2aa696108bb97080 pjass.res
100644 blob 764 270df8583e78c80f366a8ab431fab673d89446d5 readme.txt
100644 blob 6387 22ec4a6f71e40e38ca426fc3db474636a1990061 token.l
Hints:
Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"

Clone this repository using HTTP(S):
git clone https://rocketgit.com/user/vrtc/pjass

Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@ssh.rocketgit.com/user/vrtc/pjass

Clone this repository using git:
git clone git://git.rocketgit.com/user/vrtc/pjass

You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a merge request:
... clone the repository ...
... make some changes and some commits ...
git push origin main