Merge pull request #28 from Servostar/main

Branch update
This commit is contained in:
SirTalksalot75 2024-04-22 15:59:40 +02:00 committed by GitHub
commit 67efb13fe4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 134 additions and 7 deletions

View File

@ -1,6 +1,6 @@
FROM servostar/gemstone:sdk-0.1.0-alma-9.3 FROM servostar/gemstone:sdk-0.2.0-alpine-3.19.1
LABEL authors="servostar" LABEL authors="servostar"
LABEL version="0.1.0" LABEL version="0.2.0"
LABEL description="docker image for setting up the build pipeline on SDK" LABEL description="docker image for setting up the build pipeline on SDK"
LABEL website="https://github.com/Servostar/gemstone" LABEL website="https://github.com/Servostar/gemstone"

View File

@ -1,13 +1,13 @@
FROM almalinux:9.3 FROM alpine:3.19.1
LABEL authors="servostar" LABEL authors="servostar"
LABEL version="0.1.0" LABEL version="0.2.0"
LABEL description="base image for building the gemstone programming language compiler" LABEL description="base image for building the gemstone programming language compiler"
LABEL website="https://github.com/Servostar/gemstone" LABEL website="https://github.com/Servostar/gemstone"
# install dependencies # install dependencies
RUN yum install cmake gcc flex byacc -y RUN apk add build-base gcc make cmake bison flex
# create user for build # create user for build
RUN adduser lorang RUN adduser --disabled-password lorang
WORKDIR /home/lorang WORKDIR /home/lorang
USER lorang USER lorang

View File

@ -1,6 +1,7 @@
%option noyywrap %option noyywrap
%{ %{
#include <yacc/parser.tab.h> #include <yacc/parser.tab.h>
#include <sys/log.h>
int yyLineNumber = 1; int yyLineNumber = 1;
int yylex(); int yylex();
@ -12,5 +13,71 @@
%option noinput %option noinput
%% %%
"\n" yyLineNumber++;
":" {DEBUG("\"%s\" tokenized with \':\'", yytext); return(':');};
"=" {DEBUG("\"%s\" tokenized with \'=\'", yytext); return('=');};
"+" {DEBUG("\"%s\" tokenized with \'+\'", yytext); return('+');};
"-" {DEBUG("\"%s\" tokenized with \'-\'", yytext); return('-');};
"*" {DEBUG("\"%s\" tokenized with \'*\'", yytext); return('*');};
"/" {DEBUG("\"%s\" tokenized with \'/\'", yytext); return('/');};
"," {DEBUG("\"%s\" tokenized with \',\'", yytext); return(',');};
";" {DEBUG("\"%s\" tokenized with \';\'", yytext); return(';');};
"." {DEBUG("\"%s\" tokenized with \'.\'", yytext); return('.');};
"#" {DEBUG("\"%s\" tokenized with \'#\'", yytext); return('#');};
"(" {DEBUG("\"%s\" tokenized with \'(\'", yytext); return('(');};
")" {DEBUG("\"%s\" tokenized with \')\'", yytext); return(')');};
"[" {DEBUG("\"%s\" tokenized with \'[\'", yytext); return('[');};
"]" {DEBUG("\"%s\" tokenized with \']\'", yytext); return(']');};
"{" {DEBUG("\"%s\" tokenized with \'{\'", yytext); return('{');};
"}" {DEBUG("\"%s\" tokenized with \'}\'", yytext); return('}');};
">" {DEBUG("\"%s\" tokenized with \'>\'", yytext); return('>');};
"<" {DEBUG("\"%s\" tokenized with \'<\'", yytext); return('<');};
"int" {DEBUG("\"%s\" tokenized with \'<KeyInt'", yytext); return(KeyInt);};
"float" {DEBUG("\"%s\" tokenized with \'KeyFloat\'", yytext); return(KeyFloat);};
"as" {DEBUG("\"%s\" tokenized with \'<KeyAs'", yytext); return (KeyAs);};
"short" {DEBUG("\"%s\" tokenized with \'KeyShort\'", yytext); return(KeyShort);};
"long" {DEBUG("\"%s\" tokenized with \'KeyLong\'", yytext); return(KeyLong);};
"half" {DEBUG("\"%s\" tokenized with \'KeyHalf\'", yytext); return(KeyHalf);};
"double" {DEBUG("\"%s\" tokenized with \'KeyDouble\'", yytext); return(KeyDouble);};
"signed" {DEBUG("\"%s\" tokenized with \'KeySigned\'", yytext); return(KeySigned);};
"unsigned" {DEBUG("\"%s\" tokenized with \'KeyUnsigned\'", yytext); return(KeyUnsigned);};
"ref" {DEBUG("\"%s\" tokenized with \'KeyRef\'", yytext); return(KeyRef);};
"type" {DEBUG("\"%s\" tokenized with \'KeyType\'", yytext); return(KeyType);};
"local" {DEBUG("\"%s\" tokenized with \'KeyLocal\'", yytext); return(KeyLocal);};
"global" {DEBUG("\"%s\" tokenized with \'KeyGlobal\'", yytext); return(KeyGlobal);};
"static" {DEBUG("\"%s\" tokenized with \'KeyStatic\'", yytext); return(KeyStatic);};
"if" {DEBUG("\"%s\" tokenized with \'KeyIf\'", yytext); return(KeyIf);};
"else" {DEBUG("\"%s\" tokenized with \'KeyElse\'", yytext); return(KeyElse);};
"while" {DEBUG("\"%s\" tokenized with \'KeyWhile\'", yytext); return(KeyWhile);};
"in" {DEBUG("\"%s\" tokenized with \'KeyIn\'", yytext); return(KeyIn);};
"out" {DEBUG("\"%s\" tokenized with \'KeyOut\'", yytext); return(KeyOut);};
"fun" {DEBUG("\"%s\" tokenized with \'KeyFun\'", yytext); return(KeyFun);};
"==" {DEBUG("\"%s\" tokenized with \'OpEquals\'", yytext); return(OpEquals);};
"&&" {DEBUG("\"%s\" tokenized with \'OpAnd\'", yytext); return(OpAnd);};
"||" {DEBUG("\"%s\" tokenized with \'OpOr\'", yytext); return(OpOr);};
"!!" {DEBUG("\"%s\" tokenized with \'OpNot\'", yytext); return(OpNot);};
"^^" {DEBUG("\"%s\" tokenized with \'OpXor\'", yytext); return(OpXor);};
"&" {DEBUG("\"%s\" tokenized with \'OpBitand\'", yytext); return(OpBitand);};
"|" {DEBUG("\"%s\" tokenized with \'OpBitor\'", yytext); return(OpBitor);};
"!" {DEBUG("\"%s\" tokenized with \'OpBitnot\'", yytext); return(OpBitnot);};
"^" {DEBUG("\"%s\" tokenized with \'OpBitxor\'", yytext); return(OpBitxor);};
"import" {DEBUG("\"%s\" tokenized with \'KeyImport\'", yytext); return(KeyImport);};
"silent" {DEBUG("\"%s\" tokenized with \'KeySilent\'", yytext); return(KeySilent);};
"box" {DEBUG("\"%s\" tokenized with \'KeyBox\'", yytext); return(KeyBox);};
"typeof" {DEBUG("\"%s\" tokenized with \'FunTypeof\'", yytext); return(FunTypeof);};
"sizeof" {DEBUG("\"%s\" tokenized with \'FunSizeof\'", yytext); return(FunSizeof);};
"filename" {DEBUG("\"%s\" tokenized with \'FunFilename\'", yytext); return(FunFilename);};
"funname" {DEBUG("\"%s\" tokenized with \'FunFunname\'", yytext); return(FunFunname);};
"lineno" {DEBUG("\"%s\" tokenized with \'FunLineno\'", yytext); return(FunLineno);};
"extsupport" {DEBUG("\"%s\" tokenized with \'FunExtsupport\'", yytext); return(FunExtsupport);};
[0-9]+ {DEBUG("\"%s\" tokenized with \'ValInt\'", yytext); yylval.string = strdup(yytext); return(ValInt); };
[0-9]*\.[0-9]+ {DEBUG("\"%s\" tokenized with \'ValFloat\'", yytext); yylval.string = strdup(yytext); return(ValFloat);};
[a-zA-Z_0-9]+ {DEBUG("\"%s\" tokenized with \'Ident\'", yytext); yylval.string = strdup(yytext); return(Ident); };
\"([^\"\n])*\" {DEBUG("\"%s\" tokenized with \'ValStr\'", yytext); yylval.string = strdup(yytext); return(ValStr);};
\"\"\"([^\"\n]|\\\n)*\"\"\" {DEBUG("\"%s\" tokenized with \'ValMultistr\'", yytext); yylval.string = strdup(yytext); return(ValMultistr);};
.; .;
%% %%

View File

@ -2,7 +2,7 @@
#define _SYS_ERR_H_ #define _SYS_ERR_H_
#include <stdio.h> #include <stdio.h>
#include <sys/cdefs.h> #include <string.h>
#define LOG_DEFAULT_STREAM stderr #define LOG_DEFAULT_STREAM stderr
@ -20,6 +20,16 @@
#define LOG_STRING_INFORMATION "Information" #define LOG_STRING_INFORMATION "Information"
#define LOG_STRING_DEBUG "Debug" #define LOG_STRING_DEBUG "Debug"
// define __FILE_NAME__ macro if not defined
// generally not defined by GCC < 11.3 and MSVC
#ifndef __FILE_NAME__
#if defined(_WIN32) || defined(_WIN64) || defined(_MSC_VER)
#define __FILE_NAME__ (strrstr(__FILE__, "\\") ? strrstr(__FILE__, "\\") + 1 : __FILE__)
#else
#define __FILE_NAME__ (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__)
#endif
#endif
/** /**
* @brief Panic is used in cases where the process is in an unrecoverable state. * @brief Panic is used in cases where the process is in an unrecoverable state.
* This macro will print debug information to stderr and call abort() to * This macro will print debug information to stderr and call abort() to

View File

@ -1,4 +1,5 @@
%{ %{
#include <sys/log.h>
extern int yylineno; extern int yylineno;
int yyerror(char*); int yyerror(char*);
@ -6,10 +7,59 @@
extern int yylex(); extern int yylex();
%} %}
%union {
char *string;
}
%token KeyInt
%token KeyFloat
%token KeyAs
%token <string> ValInt
%token <string> Ident
%token <string> ValFloat
%token <string> ValStr
%token <string> ValMultistr
%token KeyShort
%token KeyLong
%token KeyHalf
%token KeyDouble
%token KeySigned
%token KeyUnsigned
%token KeyRef
%token KeyType
%token KeyLocal
%token KeyGlobal
%token KeyStatic
%token KeyIf
%token KeyElse
%token KeyWhile
%token KeyIn
%token KeyOut
%token KeyFun
%token OpEquals
%token OpAnd
%token OpOr
%token OpNot
%token OpXor
%token OpBitand
%token OpBitor
%token OpBitnot
%token OpBitxor
%token KeyImport
%token KeySilent
%token KeyBox
%token FunTypeof
%token FunSizeof
%token FunFilename
%token FunFunname
%token FunLineno
%token FunExtsupport
%% %%
program: ; program: ;
%% %%
int yyerror(char *s) { int yyerror(char *s) {
ERROR("%s", s);
return 0; return 0;
} }