commit 8ecb783cf829596a031aad0d4ad5669520bf8295 Author: flashwave Date: Mon Sep 20 03:05:36 2021 +0200 importe diff --git a/.vs/GASi/v14/.suo b/.vs/GASi/v14/.suo new file mode 100644 index 0000000..bd8a7e7 Binary files /dev/null and b/.vs/GASi/v14/.suo differ diff --git a/.vs/GASi/v15/.suo b/.vs/GASi/v15/.suo new file mode 100644 index 0000000..f186f9b Binary files /dev/null and b/.vs/GASi/v15/.suo differ diff --git a/.vs/GASi/v15/Server/sqlite3/db.lock b/.vs/GASi/v15/Server/sqlite3/db.lock new file mode 100644 index 0000000..e69de29 diff --git a/.vs/GASi/v15/Server/sqlite3/storage.ide b/.vs/GASi/v15/Server/sqlite3/storage.ide new file mode 100644 index 0000000..802e988 Binary files /dev/null and b/.vs/GASi/v15/Server/sqlite3/storage.ide differ diff --git a/GASi.sln b/GASi.sln new file mode 100644 index 0000000..ce9c1c4 --- /dev/null +++ b/GASi.sln @@ -0,0 +1,22 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 14 +VisualStudioVersion = 14.0.25420.1 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GASi", "GASi\GASi.csproj", "{E0A2B15D-FBA2-43CB-9E13-843C6143E0F8}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {E0A2B15D-FBA2-43CB-9E13-843C6143E0F8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E0A2B15D-FBA2-43CB-9E13-843C6143E0F8}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E0A2B15D-FBA2-43CB-9E13-843C6143E0F8}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E0A2B15D-FBA2-43CB-9E13-843C6143E0F8}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/GASi/App.config b/GASi/App.config new file mode 100644 index 0000000..88fa402 --- /dev/null +++ b/GASi/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/GASi/GASi.csproj b/GASi/GASi.csproj new file mode 100644 index 0000000..c2d77c4 --- /dev/null +++ b/GASi/GASi.csproj @@ -0,0 +1,71 @@ + + + + + Debug + AnyCPU + {E0A2B15D-FBA2-43CB-9E13-843C6143E0F8} + Exe + Properties + GASi + GASi + v4.5.2 + 512 + true + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + COPY "$(ProjectDir)stdlib\" "$(TargetDir)" + + + \ No newline at end of file diff --git a/GASi/Lexer.cs b/GASi/Lexer.cs new file mode 100644 index 0000000..d34a5b2 --- /dev/null +++ b/GASi/Lexer.cs @@ -0,0 +1,213 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace GASi { + class Lexer { + private enum kTokenState { + UNSURE, ALPHA, NUMERIC, OPERATOR, PREPROCESSOR, RAW, STRING + } + + private static string[] Scopes = { "global", "static", "local" }; + private static string[] Types = { "string", "date", "bool", "float", "int", "void" }; + private static string[] Controls = { "if", "else", "elseif", + "switch", "case", "default", + "for", "while" }; + private static string[] Keywords = { "return", "ref", "break" }; + private static string[] Operators = { "+", "-", "*", "/", "%", + "==", "!=", ">", ">=", "<", "<=", "&&", "||", + "&", "|", "^", "~", + "++", "--" }; + private static string[] Assigners = { "=", "+=", "-=", "*=", "/=" }; + + private static string Significants = null; + + private static char Peek(int column, string line) { + return (column + 1 >= line.Length) ? '\0' : line[column + 1]; + } + + private static char Rewind(int column, string line) { + return (column - 1 < 0) ? '\0' : line[column - 1]; + } + + public static IEnumerable Interpret(string[] rawProgramLines) { + List tokenList = new List(); + Token current = new Token(); + kTokenState state = kTokenState.UNSURE; + var rawStartLine = -0xFF; + + for(var line = 0; line < rawProgramLines.Length; ++line) { + var rawProgramLine = rawProgramLines[line]; + bool firstCharFound = false; + var rawStartCol = -0xFF; + + for(var column = 0; column < rawProgramLine.Length; ++column) { + var glyph = rawProgramLine[column]; + var curWord = current.Value; + var tmpWord = current.Value + glyph; + bool rerunGlyph = false; + + if(state == kTokenState.UNSURE) { + // ignore tabs and spaces when nothing is being interpreted yet + if(glyph == 0x20 || glyph == 0x09) + continue; + + if(glyph == '/' && Peek(column, rawProgramLine) == '/') + break; + else if(glyph == '#' && !firstCharFound) + state = kTokenState.PREPROCESSOR; + else if(glyph == ':' && !firstCharFound && Peek(column, rawProgramLine) == ':') { + state = kTokenState.RAW; + rawStartCol = column; + rawStartLine = line; + } else if(glyph == '"') + state = kTokenState.STRING; + else if(IsAlpha(glyph)) + state = kTokenState.ALPHA; + else if(IsNumeric(glyph)) + state = kTokenState.NUMERIC; + else if(IsSignificant(glyph)) + state = kTokenState.OPERATOR; + else + throw Transpiler.Exception("Unexpected glyph " + glyph, line, column); + + firstCharFound = true; + } + + switch(state) { + case kTokenState.RAW: + if(glyph == ':' && Rewind(column, rawProgramLine) == ':' && rawStartCol != column - 1) + current.Type = Token.kType.RAW; + else if(column == 0 && line != rawStartLine) + current.Value += '\n'; + break; + case kTokenState.ALPHA: + if(!IsAlpha(glyph) && !IsNumeric(glyph)) { + if(Scopes.Contains(curWord.Trim())) + current.Type = Token.kType.SCOPE; + else if(Types.Contains(curWord.Trim())) + current.Type = Token.kType.TYPE; + else if(Controls.Contains(curWord.Trim())) + current.Type = Token.kType.CONTROL; + else if(Keywords.Contains(curWord.Trim())) + current.Type = Token.kType.KEYWORD; + else + current.Type = Token.kType.IDENTIFIER; + + rerunGlyph = true; + } + break; + case kTokenState.NUMERIC: + if(!IsNumeric(glyph) && !(glyph == '.' && !current.Value.Contains('.'))) { + current.Type = Token.kType.NUMBER; + rerunGlyph = true; + } + break; + case kTokenState.PREPROCESSOR: + if(!IsAlpha(glyph) && !(glyph == '#' && curWord == "")) { + current.Type = Token.kType.PREPROC; + rerunGlyph = true; + } + break; + case kTokenState.OPERATOR: + if("[]".Contains(glyph)) + current.Type = glyph == '[' ? Token.kType.LBRACKET : Token.kType.RBRACKET; + else if("()".Contains(glyph)) + current.Type = glyph == '(' ? Token.kType.LPAREN : Token.kType.RPAREN; + else if("{}".Contains(glyph)) + current.Type = glyph == '{' ? Token.kType.LBRACE : Token.kType.RBRACE; + else { + switch(glyph) { + case '.': + current.Type = Token.kType.PERIOD; + break; + case ',': + current.Type = Token.kType.COMMA; + break; + case ';': + current.Type = Token.kType.SEMICOL; + break; + default: + if(Operators.Contains(curWord) && !Operators.Contains(tmpWord) && !Assigners.Contains(tmpWord)) { + current.Type = Token.kType.OPERATOR; + rerunGlyph = true; + } else if(Assigners.Contains(curWord) && !Assigners.Contains(tmpWord) && !Operators.Contains(tmpWord)) { + current.Type = Token.kType.ASSIGNER; + rerunGlyph = true; + } + break; + } + } + break; + case kTokenState.STRING: + // TODO determine if you can escape double quotes in gas using \" + if(curWord != "") { + if((glyph == '"' && !curWord.EndsWith("\\")) || column == rawProgramLine.Length - 1) + current.Type = Token.kType.STRING; + } + break; + } + + if(!rerunGlyph) + current.Value += glyph; + else + --column; + + if(current.Type != Token.kType.UNDECIDED) { + current.Value = current.Value.Trim(); + tokenList.Add(current); + current = new Token(); + state = kTokenState.UNSURE; + } + } + } + + return tokenList; + } + + private static bool IsAlpha(char glyph) { + return (glyph >= 0x41 && glyph <= 0x5A) || (glyph >= 0x61 && glyph <= 0x7A); + } + + private static bool IsNumeric(char glyph) { + return glyph >= 0x30 && glyph <= 0x39; + } + + private static bool IsSignificant(char glyph) { + AssembleSignificantCharactersTable(); + return Significants.Contains(glyph); + } + + private static void AssembleSignificantCharactersTable() { + if(Significants != null) + return; + + Significants = "[]{}(),.;"; + List mergedList = Operators.ToList(); + mergedList.AddRange(Assigners.ToList()); + foreach(var op in mergedList) { + foreach(var glyph in op) { + if(!Significants.Contains(glyph)) + Significants += glyph; + } + } + } + + public class Token { + public kType Type { get; set; } = kType.UNDECIDED; + public string Value { get; set; } = ""; + + public enum kType { + UNDECIDED, + PREPROC, RAW, + SCOPE, TYPE, IDENTIFIER, + OPERATOR, ASSIGNER, CONTROL, KEYWORD, + LPAREN, RPAREN, LBRACKET, RBRACKET, LBRACE, RBRACE, + PERIOD, COMMA, SEMICOL, + NUMBER, STRING, BOOL + } + } + } +} diff --git a/GASi/Parser.cs b/GASi/Parser.cs new file mode 100644 index 0000000..92f11d7 --- /dev/null +++ b/GASi/Parser.cs @@ -0,0 +1,246 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using static GASi.Lexer; + +namespace GASi { + class Parser { + public enum kControl { + FUNC, IF, FOR, WHILE, SWITCH, CASE + } + + private ScopeTable Globals = new ScopeTable(); + private MethodTable Methods = new MethodTable(); + private Stack ControlStack = new Stack(); + + private MethodTable.Method CurrentMethod = null; + private List Tokens; + private int TokenIterator; + + private static Dictionary> Patterns = new Dictionary>() { + { "pre_inc", new List { + new Pattern(Token.kType.PREPROC, "#include"), + new Pattern(Token.kType.STRING) + } }, + + { "fndecl", new List { + new Pattern(Token.kType.TYPE), + new Pattern(Token.kType.IDENTIFIER), + new Pattern(Token.kType.LPAREN) + } }, + + { "fnparams", new List { + new Pattern(Token.kType.TYPE), + new Pattern(Token.kType.IDENTIFIER), + new Pattern(Token.kType.COMMA), + } }, + + { "ctrlstart", new List { + new Pattern(Token.kType.RPAREN), + new Pattern(Token.kType.LBRACE) + } } + }; + + public Parser(List Tokens) { + this.Tokens = Tokens; + } + + public List Parse() { + var ret = new List(); + + TokenIterator = 0; + while(TokenIterator < Tokens.Count) { + var expr = new Expression(); + var token = Tokens[TokenIterator]; + + if(CurrentMethod == null) { // if we're in the global scope + switch(token.Type) { + case Token.kType.PREPROC: // preprocessor definition + // TODO add more preproc defs + if(!CheckPattern(Patterns["pre_inc"])) + Transpiler.Exception("Invalid preprocessor directive '" + token.Value.Substring(1) + "'", 0, 0); + + expr.Tokens = Iterate(2); + expr.Type = Expression.kType.PREPROC; + break; + case Token.kType.TYPE: // function declaration + expr = ParseFunctionDeclaration(); + break; + default: + Transpiler.Exception("Unexpected token '" + token.Value + "' of type '" + token.Type.ToString() + "' in global scope", 0, 0); + break; + } + } else { // if we're in a local scope + + } + + ret.Add(expr); + } + + return null; + } + + public Expression ParseFunctionDeclaration() { + var expr = new Expression(); + + if(CheckPattern(Patterns["fndecl"])) { + expr.Tokens = Iterate(Patterns["fndecl"].Count); + var functionName = expr.Tokens[1].Value; + + expr.ControlName = functionName; + expr.ControlType = kControl.FUNC; + expr.Type = Expression.kType.CTRLSTART; + + var method = new MethodTable.Method() { + Name = functionName, + ReturnType = Conversion.StringToType(expr.Tokens[0].Value) + }; + + int argTokenCount; + if((argTokenCount = CheckPatternLoop(Patterns["fnparams"], Token.kType.RPAREN)) == -1) + Transpiler.Exception("Invalid token found in argument list of function '"+ functionName +"'", 0, 0); + + // Now that we know that it follows the pattern, we must check for early truncation. + // Note the standard form for an argument list: + // TOKENS: [TYPE IDENTIFIER COMMA]*(n-1) + [TYPE IDENTIFIER] + // Where n is the function's number of arguments. + // The last argument should not be followed by a comma, nor should be incomplete + // (that is to say, only a type identifier by itself), so we can check the + // length of the argument list passed and treat it as such: + // TOKEN COUNT = 3*(n-1) + 2 + // This follows from the token formula state above. + // If you add one to this token count, you end up with this: + // TOKEN COUNT = 3*(n-1) + 3 = 3n - 3 + 3 = 3n + // Which can then be confirmed using the remainder of dividing the argument list + // by three and determining if it is zero. This will only be true for a well- + // formed argument list. + if((argTokenCount + 1) % 3 != 0) + Transpiler.Exception("Malformed final argument in argument list of function '"+ functionName +"'", 0, 0); + + var args = Iterate(argTokenCount); + var arg = new MethodTable.Method.Argument(); + for(int i = 0; i < args.Count; ++i) { + var token = args[i]; + + switch(i%3) { + case 0: + arg = new MethodTable.Method.Argument { + Type = Conversion.StringToType(token.Value) + }; + + if(arg.Type == kType.VOID) + Transpiler.Exception("Function '" + functionName + "' cannot have arguments with a void type", 0, 0); + break; + case 1: + arg.Name = token.Value; + method.Arguments.Add(arg); + break; + } + } + + expr.Tokens.AddRange(args); + if(!CheckPattern(Patterns["ctrlstart"])) + Transpiler.Exception("Malformed tokens after argument list in function declaration '"+ functionName +"'", 0, 0); + + expr.Tokens.AddRange(Iterate(Patterns["ctrlstart"].Count)); + + Methods.AddMethod(method); + } else + Transpiler.Exception("Invalid token found during function declaration", 0, 0); + + return expr; + } + + private bool CheckPattern(List pattern) { + for(var i = TokenIterator; i < TokenIterator + pattern.Count; ++i) { + if(i >= Tokens.Count) + Transpiler.Exception("Unexpected EOF when checking for token pattern", 0, 0); + + var j = i - TokenIterator; + if(Tokens[i].Type != pattern[j].Type || (pattern[j].Value != null && Tokens[i].Value != pattern[j].Value)) + return false; + } + + return true; + } + + private int CheckPatternLoop(List pattern, Token.kType terminator) { + var i = TokenIterator; + for(; ; ++i) { + if(i >= Tokens.Count) + Transpiler.Exception("Unexpected EOF when checking for repeated token pattern", 0, 0); + + var j = (i - TokenIterator) % pattern.Count; + if(Tokens[i].Type == terminator) + break; + if(Tokens[i].Type != pattern[j].Type || (pattern[j].Value != null && Tokens[i].Value != pattern[j].Value)) + return -1; + } + + return i - TokenIterator; + } + + private List Extract(int length) { + if(TokenIterator + length > Tokens.Count) + Transpiler.Exception("Attempted to read expected tokens past EOF", 0, 0); + + return Tokens.GetRange(TokenIterator, length); + } + + private void Skip(int count) { + TokenIterator += count; + } + + private List Iterate(int count) { + var tmp = Extract(count); + Skip(count); + return tmp; + } + + private int CountUntilNext(Token.kType type, Token.kType? nester = null, bool allowNesting = true) { + int depth = 1, count = 0; + for(; depth > 0; ++count) { + if(TokenIterator + count >= Tokens.Count) + Transpiler.Exception("Closing token '"+ type.ToString() +"' for appropriate scope not found", 0, 0); + + var token = Tokens[TokenIterator + count]; + + if(token.Type == type) + --depth; + else if(token.Type == nester) { + if(allowNesting) + ++depth; + else + Transpiler.Exception("Invalid token of type '" + token.Type + "' found when nesting is not allowed", 0, 0); + } + + } + return count + 1; + } + + public class Pattern { + public Token.kType Type { get; set; } + public string Value { get; set; } + + public Pattern(Token.kType type, string value = null) { + Type = type; + Value = value; + } + } + + public class Expression { + public enum kType { + PREPROC, + CTRLSTART, BREAK, CTRLEND, + LVAL, ASSIGN, RVAL + } + + public kType Type { get; set; } + public kControl ControlType { get; set; } + public string ControlName { get; set; } + public List Tokens { get; set; } + } + } +} diff --git a/GASi/Properties/AssemblyInfo.cs b/GASi/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..4b61a5b --- /dev/null +++ b/GASi/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("GASi")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("GASi")] +[assembly: AssemblyCopyright("Copyright © 2017")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("e0a2b15d-fba2-43cb-9e13-843c6143e0f8")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/GASi/Stdlib.cs b/GASi/Stdlib.cs new file mode 100644 index 0000000..9114e17 --- /dev/null +++ b/GASi/Stdlib.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.IO; + +namespace GASi { + static class Stdlib { + private static MethodTable functions; + + public static void Initialize() { + + } + + public class StdMethod : MethodTable.Method { + + public string Translation { get; set; } + } + } +} diff --git a/GASi/SymbolTable.cs b/GASi/SymbolTable.cs new file mode 100644 index 0000000..2168ce6 --- /dev/null +++ b/GASi/SymbolTable.cs @@ -0,0 +1,77 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace GASi { + public enum kType { + STRING, INT, FLOAT, DATE, BOOL, VOID + } + + class Conversion { + public static kType StringToType(string str) { + try { + return (kType)Enum.Parse(typeof(kType), str, true); + } catch { + throw Transpiler.Exception("Could not determine type implied by keyword '"+ str +"'", 0, 0); + } + } + } + + class ScopeTable { + private List Variables = new List(); + + public void AddVariable(Variable var) { + if(!CheckVariableExists(var.Name)) + Variables.Add(var); + else + throw Transpiler.Exception("Variable already exists with name '" + var.Name + "' in this scope", 0, 0); + } + + public bool CheckVariableExists(string name) { + return Variables.FirstOrDefault(x => x.Name == name) != null; + } + + public Variable GetVariable(string name) { + return Variables.FirstOrDefault(x => x.Name == name); + } + + public class Variable { + public string Name { get; set; } + public kType Type { get; set; } + } + } + + class MethodTable { + private List Methods = new List(); + + public void AddMethod(Method method) { + // TODO determine if GAS allows function overloading + if(!CheckMethodExists(method.Name)) + Methods.Add(method); + else + throw Transpiler.Exception("Method already exists with name '" + method.Name + "'", 0, 0); + } + + public bool CheckMethodExists(string name) { + return Methods.FirstOrDefault(x => x.Name == name) != null; + } + + public Method GetMethod(string name) { + return Methods.FirstOrDefault(x => x.Name == name); + } + + public class Method { + public string Name { get; set; } + public kType ReturnType { get; set; } + public List Arguments { get; set; } + public ScopeTable Scope { get; set; } = new ScopeTable(); + + public class Argument { + public string Name { get; set; } + public kType Type { get; set; } + } + } + } +} diff --git a/GASi/Transpiler.cs b/GASi/Transpiler.cs new file mode 100644 index 0000000..6a76a40 --- /dev/null +++ b/GASi/Transpiler.cs @@ -0,0 +1,35 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.IO; + +// TODO: add foreach support at some point +// this will save enormous amounts of time when processing data + +namespace GASi { + class Transpiler { + static void Main(string[] args) { + var test = File.ReadAllLines("test.gi"); + var result = Lexer.Interpret(test); + FancyPrint(result); + + while(true) ; + } + + static void FancyPrint(IEnumerable tokens) { + var longestCount = 0; + foreach(var token in tokens) + longestCount = Math.Max(longestCount, token.Value.Length); + + foreach(var token in tokens) { + Console.WriteLine("{0, 20}{1}", "(" + token.Type.ToString() + ") | ", token.Value); + } + } + + public static Exception Exception(string text, int line, int column) { + return new Exception("ERROR: " + text + " (line: " + (line + 1) + ", column: " + (column + 1) + ")"); + } + } +} diff --git a/GASi/bin/Debug/GASi.exe b/GASi/bin/Debug/GASi.exe new file mode 100644 index 0000000..d6fcd4f Binary files /dev/null and b/GASi/bin/Debug/GASi.exe differ diff --git a/GASi/bin/Debug/GASi.exe.config b/GASi/bin/Debug/GASi.exe.config new file mode 100644 index 0000000..88fa402 --- /dev/null +++ b/GASi/bin/Debug/GASi.exe.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/GASi/bin/Debug/GASi.pdb b/GASi/bin/Debug/GASi.pdb new file mode 100644 index 0000000..f2605d3 Binary files /dev/null and b/GASi/bin/Debug/GASi.pdb differ diff --git a/GASi/bin/Debug/GASi.vshost.exe b/GASi/bin/Debug/GASi.vshost.exe new file mode 100644 index 0000000..681ab77 Binary files /dev/null and b/GASi/bin/Debug/GASi.vshost.exe differ diff --git a/GASi/bin/Debug/GASi.vshost.exe.config b/GASi/bin/Debug/GASi.vshost.exe.config new file mode 100644 index 0000000..88fa402 --- /dev/null +++ b/GASi/bin/Debug/GASi.vshost.exe.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/GASi/bin/Debug/GASi.vshost.exe.manifest b/GASi/bin/Debug/GASi.vshost.exe.manifest new file mode 100644 index 0000000..061c9ca --- /dev/null +++ b/GASi/bin/Debug/GASi.vshost.exe.manifest @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/GASi/bin/Debug/math.glib b/GASi/bin/Debug/math.glib new file mode 100644 index 0000000..ac9259f --- /dev/null +++ b/GASi/bin/Debug/math.glib @@ -0,0 +1,162 @@ +! gasi stdlib +! math function definitions +! {0}, {1}, {2}, etc. indicate function arguments +! {r} indicates the return value + +float abs float +Function.Instrinsic.Math.Abs({0}, {r}) +*** +float acos float +Function.Instrinsic.Math.Acos({0}, {r}) +*** +float acsc float +Function.Instrinsic.Math.ACoSec({0}, {r}) +*** +float acot float +Function.Intrinsic.Math.ACoTan({0}, {r}) +*** +float asec float +Function.Intrinsic.Math.Asec({0}, {r}) +*** +float asin float +Function.Intrinsic.Math.Asin({0}, {r}) +*** +float atan float +Function.Intrinsic.Math.Atan({0}, {r}) +*** +int upccheck string +Function.Intrinsic.Math.CalculateUPCcheckDigit({0}, {r}) +*** +float tofloat string +Function.Intrinsic.Math.ConvertToFloat({0}, {r}) +*** +int toint string +Function.Intrinsic.Math.ConvertToLong({0}, {r}) +*** +float cos float +Function.Intrinsic.Math.Cos({0}, {r}) +*** +float csc float +Function.Intrinsic.Math.CoSec({0}, {r}) +*** +float cot float +Function.Intrinsic.Math.CoTan({0}, {r}) +*** +string tofraction float +Function.Intrinsic.Math.DecimalToFraction({0}, {r}) +*** +string tofraction float float +Function.Intrinsic.Math.DecimalToFraction({0}, {1}, {r}) +*** +float degrees float +Function.Intrinsic.Math.DegToRad({0}, {r}) +*** +float radians float +Function.Intrinsic.Math.RadToDeg({0}, {r}) +*** +float exp float +Function.Intrinsic.Math.Exp({0}, {r}) +*** +int whole float +Function.Intrinsic.Math.Fix({0}, {r}) +*** +float acosh float +Function.Intrinsic.Math.HACos({0}, {r}) +*** +float acsch float +Function.Intrinsic.Math.HACoSec({0}, {r}) +*** +float acoth float +Function.Intrinsic.Math.HACoTan({0}, {r}) +*** +float asech float +Function.Intrinsic.Math.HASec({0}, {r}) +*** +float asinh float +Function.Intrinsic.Math.HASin({0}, {r}) +*** +float atanh float +Function.Intrinsic.Math.HATan({0}, {r}) +*** +float cosh float +Function.Intrinsic.Math.Hcos({0}, {r}) +*** +float csch float +Function.Intrinsic.Math.HCoSec({0}, {r}) +*** +float coth float +Function.Intrinsic.Math.HCoTan({0}, {r}) +*** +float sech float +Function.Intrinsic.Math.Hsec({0}, {r}) +*** +float sinh float +Function.Intrinsic.Math.Hsin({0}, {r}) +*** +float tanh float +Function.Intrinsic.Math.HTan({0}, {r}) +*** +int idiv float float +Function.Intrinsic.Math.Idiv({0}, {1}, {r}) +*** +float inv float +Function.Intrinsic.Math.Inv({0}, {r}) +*** +bool inrange float float float +Function.Intrinsic.Math.IsInRange({0}, {1}, {2}, {r}) +*** +bool isnum string +Function.Intrinsic.Math.IsNumeric({0}, {r}) +*** +float log float +Function.Intrinsic.Math.Log({0}, {r}) +*** +float logn float int +Function.Intrinsic.Math.LogN({0}, {1}, {r}) +*** +float polarx float float +Function.Intrinsic.Math.PolarToX({0}, {1}, {r}) +*** +float polary float float +Function.Intrinsic.Math.PolarToY({0}, {1}, {r}) +*** +float lendiag float float +Function.Intrinsic.Math.RectToRad({0}, {1}, {r}) +*** +float angdiag float float +Function.Intrinsic.Math.RectToTheta({0}, {1}, {r}) +*** +float rand +Function.Intrinsic.Math.Rnd({r}) +*** +float rand float +Function.Intrinsic.Math.Rnd({0}, {r}) +*** +float rand float float +Function.Intrinsic.Math.Rnd({0}, {1}, {r}) +*** +float round float float +Function.Intrinsic.Math.Round({0}, {1}, 0, {r}) +*** +float huround float float +Function.Intrinsic.Math.Round({0}, {1}, 1, {r}) +*** +float sec float +Function.Intrinsic.Math.Sec({0}, {r}) +*** +int sign float +Function.Intrinsic.Math.Sgn({0}, {r}) +*** +float sin float +Function.Intrinsic.Math.Sin({0}, {r}) +*** +float sqrt float +Function.Intrinsic.Math.Sqr({0}, {r}) +*** +float tan float +Function.Intrinsic.Math.Tan({0}, {r}) +*** +float pow float float +Function.Intrinsic.Math.XToY({0}, {1}, {r}) + +! TODO: add Function.Intrinsic.Math.UnitConversion aliases \ No newline at end of file diff --git a/GASi/bin/Debug/test.gi b/GASi/bin/Debug/test.gi new file mode 100644 index 0000000..43872b1 --- /dev/null +++ b/GASi/bin/Debug/test.gi @@ -0,0 +1,23 @@ +#include "test.gas" + +float add(float a, float b) { + return a + b; +} + +//this is a comment +void main() { + global float coolFloatDude = 20.30; + global int coolIntegerDude = 30; + + coolFloatDude = add(coolFloatDude, coolFloatDude); + + :: + Function.Intrinsic.Math.Log(coolFloatDude,coolFloatDude) + Function.Intrinsic.Math.Exp(coolFloatDude,coolFloatDude) + Really.Long.Trash.Statement(coolFloatDude,coolFloatDude) + :: + + if(coolFloatDude <= coolIntegerDude) { //comment after the line ends + Msgbox.Show("Hi"); + } +} \ No newline at end of file diff --git a/GASi/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache b/GASi/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache new file mode 100644 index 0000000..f802a8d Binary files /dev/null and b/GASi/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache differ diff --git a/GASi/obj/Debug/GASi.csproj.CoreCompileInputs.cache b/GASi/obj/Debug/GASi.csproj.CoreCompileInputs.cache new file mode 100644 index 0000000..6a63c4f --- /dev/null +++ b/GASi/obj/Debug/GASi.csproj.CoreCompileInputs.cache @@ -0,0 +1 @@ +6acd9c8c400fd21bde195fc004fe6c0d34033e41 diff --git a/GASi/obj/Debug/GASi.csproj.FileListAbsolute.txt b/GASi/obj/Debug/GASi.csproj.FileListAbsolute.txt new file mode 100644 index 0000000..99f2b96 --- /dev/null +++ b/GASi/obj/Debug/GASi.csproj.FileListAbsolute.txt @@ -0,0 +1,13 @@ +\\dc01\users\alec\my documents\visual studio 2015\Projects\GASi\GASi\bin\Debug\GASi.exe.config +\\dc01\users\alec\my documents\visual studio 2015\Projects\GASi\GASi\bin\Debug\GASi.exe +\\dc01\users\alec\my documents\visual studio 2015\Projects\GASi\GASi\bin\Debug\GASi.pdb +\\dc01\users\alec\my documents\visual studio 2015\Projects\GASi\GASi\obj\Debug\GASi.csprojResolveAssemblyReference.cache +\\dc01\users\alec\my documents\visual studio 2015\Projects\GASi\GASi\obj\Debug\GASi.exe +\\dc01\users\alec\my documents\visual studio 2015\Projects\GASi\GASi\obj\Debug\GASi.pdb +C:\Users\Julian\Desktop\GASi\GASi\bin\Debug\GASi.exe.config +C:\Users\Julian\Desktop\GASi\GASi\bin\Debug\GASi.exe +C:\Users\Julian\Desktop\GASi\GASi\bin\Debug\GASi.pdb +C:\Users\Julian\Desktop\GASi\GASi\obj\Debug\GASi.csprojResolveAssemblyReference.cache +C:\Users\Julian\Desktop\GASi\GASi\obj\Debug\GASi.csproj.CoreCompileInputs.cache +C:\Users\Julian\Desktop\GASi\GASi\obj\Debug\GASi.exe +C:\Users\Julian\Desktop\GASi\GASi\obj\Debug\GASi.pdb diff --git a/GASi/obj/Debug/GASi.csprojResolveAssemblyReference.cache b/GASi/obj/Debug/GASi.csprojResolveAssemblyReference.cache new file mode 100644 index 0000000..715f729 Binary files /dev/null and b/GASi/obj/Debug/GASi.csprojResolveAssemblyReference.cache differ diff --git a/GASi/obj/Debug/GASi.exe b/GASi/obj/Debug/GASi.exe new file mode 100644 index 0000000..d6fcd4f Binary files /dev/null and b/GASi/obj/Debug/GASi.exe differ diff --git a/GASi/obj/Debug/GASi.pdb b/GASi/obj/Debug/GASi.pdb new file mode 100644 index 0000000..f2605d3 Binary files /dev/null and b/GASi/obj/Debug/GASi.pdb differ diff --git a/GASi/obj/Debug/TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs b/GASi/obj/Debug/TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs new file mode 100644 index 0000000..e69de29 diff --git a/GASi/obj/Debug/TemporaryGeneratedFile_5937a670-0e60-4077-877b-f7221da3dda1.cs b/GASi/obj/Debug/TemporaryGeneratedFile_5937a670-0e60-4077-877b-f7221da3dda1.cs new file mode 100644 index 0000000..e69de29 diff --git a/GASi/obj/Debug/TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs b/GASi/obj/Debug/TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs new file mode 100644 index 0000000..e69de29 diff --git a/GASi/stdlib/math.glib b/GASi/stdlib/math.glib new file mode 100644 index 0000000..ac9259f --- /dev/null +++ b/GASi/stdlib/math.glib @@ -0,0 +1,162 @@ +! gasi stdlib +! math function definitions +! {0}, {1}, {2}, etc. indicate function arguments +! {r} indicates the return value + +float abs float +Function.Instrinsic.Math.Abs({0}, {r}) +*** +float acos float +Function.Instrinsic.Math.Acos({0}, {r}) +*** +float acsc float +Function.Instrinsic.Math.ACoSec({0}, {r}) +*** +float acot float +Function.Intrinsic.Math.ACoTan({0}, {r}) +*** +float asec float +Function.Intrinsic.Math.Asec({0}, {r}) +*** +float asin float +Function.Intrinsic.Math.Asin({0}, {r}) +*** +float atan float +Function.Intrinsic.Math.Atan({0}, {r}) +*** +int upccheck string +Function.Intrinsic.Math.CalculateUPCcheckDigit({0}, {r}) +*** +float tofloat string +Function.Intrinsic.Math.ConvertToFloat({0}, {r}) +*** +int toint string +Function.Intrinsic.Math.ConvertToLong({0}, {r}) +*** +float cos float +Function.Intrinsic.Math.Cos({0}, {r}) +*** +float csc float +Function.Intrinsic.Math.CoSec({0}, {r}) +*** +float cot float +Function.Intrinsic.Math.CoTan({0}, {r}) +*** +string tofraction float +Function.Intrinsic.Math.DecimalToFraction({0}, {r}) +*** +string tofraction float float +Function.Intrinsic.Math.DecimalToFraction({0}, {1}, {r}) +*** +float degrees float +Function.Intrinsic.Math.DegToRad({0}, {r}) +*** +float radians float +Function.Intrinsic.Math.RadToDeg({0}, {r}) +*** +float exp float +Function.Intrinsic.Math.Exp({0}, {r}) +*** +int whole float +Function.Intrinsic.Math.Fix({0}, {r}) +*** +float acosh float +Function.Intrinsic.Math.HACos({0}, {r}) +*** +float acsch float +Function.Intrinsic.Math.HACoSec({0}, {r}) +*** +float acoth float +Function.Intrinsic.Math.HACoTan({0}, {r}) +*** +float asech float +Function.Intrinsic.Math.HASec({0}, {r}) +*** +float asinh float +Function.Intrinsic.Math.HASin({0}, {r}) +*** +float atanh float +Function.Intrinsic.Math.HATan({0}, {r}) +*** +float cosh float +Function.Intrinsic.Math.Hcos({0}, {r}) +*** +float csch float +Function.Intrinsic.Math.HCoSec({0}, {r}) +*** +float coth float +Function.Intrinsic.Math.HCoTan({0}, {r}) +*** +float sech float +Function.Intrinsic.Math.Hsec({0}, {r}) +*** +float sinh float +Function.Intrinsic.Math.Hsin({0}, {r}) +*** +float tanh float +Function.Intrinsic.Math.HTan({0}, {r}) +*** +int idiv float float +Function.Intrinsic.Math.Idiv({0}, {1}, {r}) +*** +float inv float +Function.Intrinsic.Math.Inv({0}, {r}) +*** +bool inrange float float float +Function.Intrinsic.Math.IsInRange({0}, {1}, {2}, {r}) +*** +bool isnum string +Function.Intrinsic.Math.IsNumeric({0}, {r}) +*** +float log float +Function.Intrinsic.Math.Log({0}, {r}) +*** +float logn float int +Function.Intrinsic.Math.LogN({0}, {1}, {r}) +*** +float polarx float float +Function.Intrinsic.Math.PolarToX({0}, {1}, {r}) +*** +float polary float float +Function.Intrinsic.Math.PolarToY({0}, {1}, {r}) +*** +float lendiag float float +Function.Intrinsic.Math.RectToRad({0}, {1}, {r}) +*** +float angdiag float float +Function.Intrinsic.Math.RectToTheta({0}, {1}, {r}) +*** +float rand +Function.Intrinsic.Math.Rnd({r}) +*** +float rand float +Function.Intrinsic.Math.Rnd({0}, {r}) +*** +float rand float float +Function.Intrinsic.Math.Rnd({0}, {1}, {r}) +*** +float round float float +Function.Intrinsic.Math.Round({0}, {1}, 0, {r}) +*** +float huround float float +Function.Intrinsic.Math.Round({0}, {1}, 1, {r}) +*** +float sec float +Function.Intrinsic.Math.Sec({0}, {r}) +*** +int sign float +Function.Intrinsic.Math.Sgn({0}, {r}) +*** +float sin float +Function.Intrinsic.Math.Sin({0}, {r}) +*** +float sqrt float +Function.Intrinsic.Math.Sqr({0}, {r}) +*** +float tan float +Function.Intrinsic.Math.Tan({0}, {r}) +*** +float pow float float +Function.Intrinsic.Math.XToY({0}, {1}, {r}) + +! TODO: add Function.Intrinsic.Math.UnitConversion aliases \ No newline at end of file