This commit is contained in:
flash 2021-09-20 03:05:36 +02:00
commit 8ecb783cf8
31 changed files with 1111 additions and 0 deletions

BIN
.vs/GASi/v14/.suo Normal file

Binary file not shown.

BIN
.vs/GASi/v15/.suo Normal file

Binary file not shown.

View file

Binary file not shown.

22
GASi.sln Normal file
View file

@ -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

6
GASi/App.config Normal file
View file

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
</startup>
</configuration>

71
GASi/GASi.csproj Normal file
View file

@ -0,0 +1,71 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{E0A2B15D-FBA2-43CB-9E13-843C6143E0F8}</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>GASi</RootNamespace>
<AssemblyName>GASi</AssemblyName>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Lexer.cs" />
<Compile Include="Stdlib.cs" />
<Compile Include="Parser.cs" />
<Compile Include="SymbolTable.cs" />
<Compile Include="Transpiler.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<ItemGroup />
<ItemGroup>
<None Include="stdlib\math.glib" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PostBuildEvent>COPY "$(ProjectDir)stdlib\" "$(TargetDir)"</PostBuildEvent>
</PropertyGroup>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

213
GASi/Lexer.cs Normal file
View file

@ -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<Token> Interpret(string[] rawProgramLines) {
List<Token> tokenList = new List<Token>();
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<string> 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
}
}
}
}

246
GASi/Parser.cs Normal file
View file

@ -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<kControl> ControlStack = new Stack<kControl>();
private MethodTable.Method CurrentMethod = null;
private List<Token> Tokens;
private int TokenIterator;
private static Dictionary<string, List<Pattern>> Patterns = new Dictionary<string, List<Pattern>>() {
{ "pre_inc", new List<Pattern> {
new Pattern(Token.kType.PREPROC, "#include"),
new Pattern(Token.kType.STRING)
} },
{ "fndecl", new List<Pattern> {
new Pattern(Token.kType.TYPE),
new Pattern(Token.kType.IDENTIFIER),
new Pattern(Token.kType.LPAREN)
} },
{ "fnparams", new List<Pattern> {
new Pattern(Token.kType.TYPE),
new Pattern(Token.kType.IDENTIFIER),
new Pattern(Token.kType.COMMA),
} },
{ "ctrlstart", new List<Pattern> {
new Pattern(Token.kType.RPAREN),
new Pattern(Token.kType.LBRACE)
} }
};
public Parser(List<Token> Tokens) {
this.Tokens = Tokens;
}
public List<Expression> Parse() {
var ret = new List<Expression>();
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> 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> 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<Token> 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<Token> 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<Token> Tokens { get; set; }
}
}
}

View file

@ -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")]

21
GASi/Stdlib.cs Normal file
View file

@ -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; }
}
}
}

77
GASi/SymbolTable.cs Normal file
View file

@ -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<Variable> Variables = new List<Variable>();
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<Method> Methods = new List<Method>();
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<Argument> Arguments { get; set; }
public ScopeTable Scope { get; set; } = new ScopeTable();
public class Argument {
public string Name { get; set; }
public kType Type { get; set; }
}
}
}
}

35
GASi/Transpiler.cs Normal file
View file

@ -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<Lexer.Token> 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) + ")");
}
}
}

BIN
GASi/bin/Debug/GASi.exe Normal file

Binary file not shown.

View file

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
</startup>
</configuration>

BIN
GASi/bin/Debug/GASi.pdb Normal file

Binary file not shown.

Binary file not shown.

View file

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
</startup>
</configuration>

View file

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity version="1.0.0.0" name="MyApplication.app"/>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
<security>
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
<requestedExecutionLevel level="asInvoker" uiAccess="false"/>
</requestedPrivileges>
</security>
</trustInfo>
</assembly>

162
GASi/bin/Debug/math.glib Normal file
View file

@ -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

23
GASi/bin/Debug/test.gi Normal file
View file

@ -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");
}
}

View file

@ -0,0 +1 @@
6acd9c8c400fd21bde195fc004fe6c0d34033e41

View file

@ -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

BIN
GASi/obj/Debug/GASi.exe Normal file

Binary file not shown.

BIN
GASi/obj/Debug/GASi.pdb Normal file

Binary file not shown.

162
GASi/stdlib/math.glib Normal file
View file

@ -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