Stability Increases! Ver: 1.3!

Still work to be done though
This commit is contained in:
Ryan 2017-09-01 23:29:25 -04:00
parent e5d5f884ad
commit b4cca046a3
32 changed files with 537 additions and 25537 deletions

View File

@ -7,6 +7,7 @@ TODO:
- [x] Improve audio support (Simple) - [x] Improve audio support (Simple)
- [x] Add simple threading (Alright) - [x] Add simple threading (Alright)
- [ ] Fix Bugs! (Death) - [ ] Fix Bugs! (Death)
- [ ] multiple returns for functions
Maybe: Maybe:
- [ ] Add While/for loops (With labels this can easily be done. So it isn't really needed, I may add it in the future though!) - [ ] Add While/for loops (With labels this can easily be done. So it isn't really needed, I may add it in the future though!)
@ -31,7 +32,6 @@ DISABLE forseelabels
ENABLE debugging ENABLE debugging
-- When enabled a lot of mess will show up on your console... This isn't really useful to you as much as it is for me... If you ever have a weird error enable debugging and post everything into an issue so I can look at what causes an error -- When enabled a lot of mess will show up on your console... This isn't really useful to you as much as it is for me... If you ever have a weird error enable debugging and post everything into an issue so I can look at what causes an error
-- This language is still a major WIP! -- This language is still a major WIP!
-- Create a block named START -- Create a block named START
[START]{ [START]{
"This is a pause statement" "This is a pause statement"
@ -114,5 +114,77 @@ We also have a bunch of other built in functions to make coding eaiser!
- void=writeAt(string msg,x,y) -- writes at a certain position - void=writeAt(string msg,x,y) -- writes at a certain position
- bool=isDown(key) -- returns true if a key is pressed See Keys - bool=isDown(key) -- returns true if a key is pressed See Keys
TODO: Finish the readme... Here is a RPS(rock paper scissors) Example!
```lua
VERSION 1.2 -- This will not work on older versions!
ENTRY RPS -- Set entry point to RPS
[RPS]{
write("Name: ")
name=getInput()
clear() -- clear the console
if name=="" then SKIP(-4)|SKIP(0) -- This stuff makes empty inputs invalid! If nothing was entered prompt again!
"Lets play! Press Enter when your ready" -- a pause statement... Well kinda atleast on CONSOLE mode...
list=["r","p","s"] -- create a list
list2=["rock","paper","scissors"] -- creats another list
list3=[] -- create an empty table
list3["r"]="rock" -- set the index of the table
list3["p"]="paper"
list3["s"]="scissors"
::gameloop::
cpus_mov=random(0,3)
cpus_move=list[cpus_mov]
write("Enter 'r' 'p' or 's': ")
player_move=getInput()
print("You played: $player_move$ the CPU played: $cpus_move$")
if player_move!="r" and player_move!="p" and player_move!="s" then GOTO("gameloop")|SKIP(0)
a=list2[cpus_mov]
b=list3[player_move]
if player_move==cpus_move then JUMP("TIE")|SKIP(0)
if cpus_move=="r" and player_move=="s" then JUMP("CPUWIN")|SKIP(0)
if cpus_move=="p" and player_move=="r" then JUMP("CPUWIN")|SKIP(0)
if cpus_move=="s" and player_move=="p" then JUMP("CPUWIN")|SKIP(0)
b=list2[cpus_mov]
a=list3[player_move]
if player_move=="r" and cpus_move=="s" then JUMP("PlayerWIN")|SKIP(0)
if player_move=="p" and cpus_move=="r" then JUMP("PlayerWIN")|SKIP(0)
if player_move=="s" and cpus_move=="p" then JUMP("PlayerWIN")|SKIP(0)
::choice::
write("That was a fun game! Do you want to play again? (y/n): ")
cho=getInput()
if cho=="y" then GOTO("gameloop")|SKIP(0)
if cho=="n" then JUMP("GOODBYE")|GOTO("choice")
}
[CPUWIN]{ -- I am using these blocks like hybrid functions... instead of going back to their called location they go back to a location that I define
"I won $name$, you lose! You know $a$ beats $b$"
GOTO("choice")
}
[PlayerWIN]{
"$name$ you won wow! I guess my $b$ was no match for your $a$"
GOTO("choice")
}
[TIE]{
"No one won..."
GOTO("choice")
}
[GOODBYE]{
"Thanks for playing!"
QUIT()
}
```
Version 1.1 - 1.2 Were all about bug fixes
- Logic if `condition then func1()|func2()` has been fixed!
- Parentheses in both logic and math expressions now adhere to the order of opperations and(*) before or(+)
- Fixed minor bugs with tables!
Version 1.3 addressed error handling
- Error handling now displays the file that contains the error, the line number, the actual line's text and the error message!
- new method: error(msg) Throws an error
- new header: THREAD filename -- runs a file in a seperate thread. This helps when you are dealing with lots of threads!
TODO: Version 1.4
- Fix error handling in a thread... While errors are handles correctly on the main thread multithreaded errors seem to not be handled correctly!
-
Idea:
new block made to catch thread errors and stop thread related errors from exiting the app

Binary file not shown.

File diff suppressed because it is too large Load Diff

View File

@ -1,19 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<EmbedderSignAssembly Condition="$(EmbedderSignAssembly) == '' Or $(EmbedderSignAssembly) == '*Undefined*'">$(SignAssembly)</EmbedderSignAssembly>
<IntermediateDir>$(ProjectDir)$(IntermediateOutputPath)</IntermediateDir>
<EmbedderPath Condition="$(EmbedderPath) == '' Or $(EmbedderPath) == '*Undefined*'">$(MSBuildThisFileDirectory)..\</EmbedderPath>
</PropertyGroup>
<UsingTask TaskName="ResourceEmbedder.MsBuild.SatelliteAssemblyEmbedderTask" AssemblyFile="$(EmbedderPath)ResourceEmbedder.MsBuild.dll" />
<UsingTask TaskName="ResourceEmbedder.MsBuild.SatelliteAssemblyCleanupTask" AssemblyFile="$(EmbedderPath)ResourceEmbedder.MsBuild.dll" />
<!-- We want to run as soon as the satellite assemblies are generated -->
<Target AfterTargets="GenerateSatelliteAssemblies" Name="EmbedderTarget" DependsOnTargets="$(EmbedderDependsOnTargets)">
<ResourceEmbedder.MsBuild.SatelliteAssemblyEmbedderTask AssemblyPath="@(IntermediateAssembly)" ProjectDirectory="$(ProjectDir)" TargetPath="$(TargetPath)" SignAssembly="$(EmbedderSignAssembly)" References="@(ReferencePath)" DebugSymbols="$(DebugSymbols)" DebugType="$(DebugType)" />
</Target>
<!--Cleanup after generating -->
<Target AfterTargets="AfterBuild" Name="CleanupTarget" DependsOnTargets="$(EmbedderDependsOnTargets)">
<ResourceEmbedder.MsBuild.SatelliteAssemblyCleanupTask AssemblyPath="@(IntermediateAssembly)" ProjectDirectory="$(ProjectDir)" TargetPath="$(TargetPath)" SignAssembly="$(EmbedderSignAssembly)" />
</Target>
</Project>

View File

@ -1,4 +0,0 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<dllmap dll="vulkan-1" target="vulkan.so" />
</configuration>

View File

@ -1,4 +0,0 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<dllmap dll="vulkan-1" target="vulkan.so" />
</configuration>

View File

@ -1,4 +0,0 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<dllmap dll="vulkan-1" target="vulkan.so" />
</configuration>

View File

@ -1,4 +0,0 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<dllmap dll="vulkan-1" target="vulkan.so" />
</configuration>

View File

@ -7,10 +7,10 @@
* To change this template use Tools | Options | Coding | Edit Standard Headers. * To change this template use Tools | Options | Coding | Edit Standard Headers.
*/ */
using System; using System;
using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.Runtime.InteropServices; using System.IO;
using parseManagerCS; using parseManagerCS;
using System.Windows.Input;
namespace parseManagerCS namespace parseManagerCS
{ {
class Program class Program
@ -18,12 +18,47 @@ namespace parseManagerCS
[STAThread] [STAThread]
public static void Main(string[] args) public static void Main(string[] args)
{ {
if (args.Length == 0) { args=new string[]{"choiceTest.txt"};
Console.Write("Please Include a file path!"); string file;
Console.ReadLine(); string print = "";
Environment.Exit(0); List<char> temp = new List<char>();
parseManager PM;
var cpath = Process.GetCurrentProcess().MainModule.FileName;
int counter = 0;
if (args.Length == 0) { // if we don't have args, let's check for an appended script!
using (FileStream fs = new FileStream(cpath, FileMode.Open, FileAccess.Read)) {
long offset;
int nextByte;
for (offset = 1; offset <= fs.Length; offset++) {
fs.Seek(-offset, SeekOrigin.End);
nextByte = fs.ReadByte();
if (nextByte == 0) {
break;
}
counter++;
}
if (counter == 0 && args.Length == 0) {
Console.WriteLine("No appended code and no file path given!\nPress Emter!");
Console.ReadLine();
Environment.Exit(0);
} else {
fs.Close();
using (var reader = new StreamReader(cpath))
{
reader.BaseStream.Seek(-counter, SeekOrigin.End);
string line;
while ((line = reader.ReadLine()) != null) {
print+=line+"\n";
}
}
}
}
PM = new parseManager(print, true);
} else { // we have args so lets load it!
file = args[0];
PM = new parseManager(file);
} }
parseManager PM = new parseManager(args[0]); GLOBALS.SetMainPM(PM);
nextType next = PM.Next(); nextType next = PM.Next();
string type; string type;
while (next.GetCMDType() != "EOF") { while (next.GetCMDType() != "EOF") {
@ -37,3 +72,14 @@ namespace parseManagerCS
} }
} }
} }
/*
- New Block structure!
NOTE: If you have an error within the catch block you will not be a happy coder!
```lua
-- This Blcok will catch any errors that take place! This may cause an un recoverable error however!
[BLOCKNAME:event("catch",err)]{
}
```
*/

View File

@ -0,0 +1 @@
ILRepack.exe /target:exe /targetplatform:"v4,C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.x" /out:MergedFile.exe parsemanagertester.exe NAudio.dll

View File

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

View File

@ -0,0 +1,84 @@
VERSION 1.2
THREAD testthread.txt
[PLAYGAME]{
print("Welcome to my game!")
PAUSE("ENJOY!")
QUIT()
}
[COUNTER]{
::cloop::
sleep(1000)
secs_played=secs_played+1
if secs_played==60 then GOTO("secs")|SKIP(0)
if mins_played==60 then GOTO("mins")|GOTO("cloop")
::secs::
secs_played=0
mins_played=mins_played+1
GOTO("cloop")
::mins::
mins_played=0
hours_played=hours_played+1
GOTO("cloop")
}
[START]{
secs_played=0
mins_played=0
hours_played=0
newThread("COUNTER")
bgm_song=loadSong("Audio/Collapse.mp3")
snd_select=loadSong("Audio/select.mp3")
playSong(bgm_song)
setFancyForm("left")
LOAD()
write("Name: ")
name=getInput()
clear()
if name=="" then SKIP(-4)|SKIP(0)
"So your name is $name$, thats cool!"
pos=1
sleep(200)
SAVE()
::loop::
clear()
SAVE()
setFG(Color_Blue)
fancy(" What to do $name$? Time plsyed $hours_played$:$mins_played$:$secs_played$,/l, Play Game, View Stats, View Credits, Quit Game")
keyUP=isDown("{UP}")
keyDOWN=isDown("{DOWN}")
keyENTER=isDown("{ENTER}")
if keyUP==true then setVarPlay("pos",pos-1)|SKIP(0)
if keyDOWN==true then setVarPlay("pos",pos+1)|SKIP(0)
if keyENTER==true then GOTO("choicemade")|SKIP(0)
writeAt("->",1,pos+2)
sleep(50)
GOTO("loop")
::choicemade::
playSong(snd_select)
sleep(200)
if pos==1 then JUMP("PLAYGAME")|SKIP(0)
if pos==2 then print("You Pressed Stats")|SKIP(0)
if pos==3 then print("You Pressed Credits")|SKIP(0)
if pos==4 then QUIT()|SKIP(0)
PAUSE("Tests done (Press Enter!)")
QUIT()
}
[PAUSE:function(msg)]{
write(msg)
::loop::
keyENTER=isDown("{ENTER}")
if keyENTER==true then SKIP(0)|GOTO("loop")
print(" ")
}
[setVarPlay:function(var,val)]{
setVar(var,val)
if pos<1 then GOTO("toolittle")|SKIP(0)
if pos>4 then GOTO("toomuch")|SKIP(0)
beep()
GOTO("end")
::toolittle::
setVar("pos",1)
GOTO("end")
::toomuch::
setVar("pos",4)
::end::
}

View File

@ -41,9 +41,9 @@ LOAD game/play.dat
keyUP=isDown("{UP}") keyUP=isDown("{UP}")
keyDOWN=isDown("{DOWN}") keyDOWN=isDown("{DOWN}")
keyENTER=isDown("{ENTER}") keyENTER=isDown("{ENTER}")
if keyUP==true then setVarPlay("pos",pos-1)|SKIP(0) if keyUP==true then setVarPlay("pos",pos-1)|SKIP(0) -- tests
if keyDOWN==true then setVarPlay("pos",pos+1)|SKIP(0) if keyDOWN==true then setVarPlay("pos",pos+1)|SKIP(0) -- more tests
if keyENTER==true then GOTO("choicemade")|SKIP(0) if keyENTER==true then GOTO("choicemade")|SKIP(0) -- hehehe
writeAt("->",1,pos+2) writeAt("->",1,pos+2)
sleep(50) sleep(50)
GOTO("loop") GOTO("loop")

View File

@ -0,0 +1,53 @@
ENTRY RPS
[RPS]{
write("Name: ")
name=getInput()
clear()
if name=="" then SKIP(-4)|SKIP(0) -- This stuff makes empty inputs invalid!
"Lets play! Press Enter when your ready"
list=["r","p","s"]
list2=["rock","paper","scissors"]
list3=[]
list3["r"]="rock"
list3["p"]="paper"
list3["s"]="scissors"
::gameloop::
cpus_mov=random(0,3)
cpus_move=list[cpus_mov]
write("Enter 'r' 'p' or 's': ")
player_move=getInput()
print("You played: $player_move$ the CPU played: $cpus_move$")
if player_move!="r" and player_move!="p" and player_move!="s" then GOTO("gameloop")|SKIP(0)
a=list2[cpus_mov]
b=list3[player_move]
if player_move==cpus_move then JUMP("TIE")|SKIP(0)
if cpus_move=="r" and player_move=="s" then JUMP("CPUWIN")|SKIP(0)
if cpus_move=="p" and player_move=="r" then JUMP("CPUWIN")|SKIP(0)
if cpus_move=="s" and player_move=="p" then JUMP("CPUWIN")|SKIP(0)
b=list2[cpus_mov]
a=list3[player_move]
if player_move=="r" and cpus_move=="s" then JUMP("PlayerWIN")|SKIP(0)
if player_move=="p" and cpus_move=="r" then JUMP("PlayerWIN")|SKIP(0)
if player_move=="s" and cpus_move=="p" then JUMP("PlayerWIN")|SKIP(0)
::choice::
write("That was a fun game! Do you want to play again? (y/n): ")
cho=getInput()
if cho=="y" then GOTO("gameloop")|SKIP(0)
if cho=="n" then JUMP("GOODBYE")|GOTO("choice")
}
[CPUWIN]{
"I won $name$, you lose! You know $a$ beats $b$"
GOTO("choice")
}
[PlayerWIN]{
"$name$ you won wow! I guess my $b$ was no match for your $a$"
GOTO("choice")
}
[TIE]{
"No one won..."
GOTO("choice")
}
[GOODBYE]{
"Thanks for playing!"
QUIT()
}

Binary file not shown.

View File

@ -1,61 +1,8 @@
ENTRY TESTSTART [START]{
[TESTSTART]{ test = 3
song=loadSong("test.flac") "Version: $VERSION$"
setFG(Color_Blue) num = 3 + test
"Hello (Press Enter)" "Enter is safe! $num$"
-- print("PLAY SONG (1)") num = five + 3
-- print("MESSAGE (2)") "Here!"
-- print("An Adventure (3)")
-- print("QUIT (4)")
fancy("left","PLAY SONG (1),MESSAGE (2),An Adventure (3),QUIT (4)")
::choice::
write("Choose: ")
choice=getInput()
if choice=="1" then JUMP("SONG")|SKIP(0)
if choice=="2" then JUMP("YO")|SKIP(0)
if choice=="4" then QUIT()|SKIP(0)
if choice=="3" then SKIP(2)|SKIP(0)
GOTO("choice")
"We are here now! Time for some fun..."
::name::
write("Please enter your name: ")
name=getInput()
ClearLine()
setCC()
if name=="" then GOTO("name")|SKIP(0)
print("So your name is $name$ huh...")
"I won't judge haha"
"Anyway let's get controls for that song"
print("Stop (s)")
print("Play (t)")
print("Pause (a)")
print("Resume (r)")
print("Quit (q)")
::control::
write("Choose: ")
choice=getInput()
if choice=="s" then STOP(song)|SKIP(0)
if choice=="t" then JUMP("PLAYS")|SKIP(0)
if choice=="a" then pauseSong(song)|SKIP(0)
if choice=="r" then resumeSong(song)|SKIP(0)
if choice=="q" then QUIT()|SKIP(0)
GOTO("control")
}
[ClearLine:function()]{
whiteOut()
setCC()
}
[PLAYS]{
pauseSong(song)
song=loadSong("test.flac")
playSong(song)
GOTO("control")
}
[SONG]{
playSong(song)
GOTO("choice")
}
[YO]{
"How are you doing?"
GOTO("choice")
} }

View File

@ -0,0 +1,10 @@
ENTRY SCREEN_FIX
[SCREEN_FIX]{
::checker::
x=getConsoleWidth()
y=getConsoleHeight()
sleep(1000)
if x==100 and y==50 then GOTO("checker")|SKIP(0)
setWindowSize(100,50)
GOTO("checker")
}

View File

@ -1 +1 @@
ILRepack.exe /target:exe /targetplatform:"v4,C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.x" /out:MergedFile.exe parsemanagertester.exe NAudio.dll ILRepack.exe /target:exe /targetplatform:"v4,C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.x" /out:MergedFile.exe parsemanagertester.exe NAudio.dll Vulkan.dll Vulkan.Windows.dll

View File

@ -6,5 +6,3 @@ C:\Users\Ryan\Documents\SharpDevelop Projects\parseManager\parseManager\obj\Debu
C:\Users\Ryan\Documents\SharpDevelop Projects\parseManager\parseManager\obj\Debug\parseManagerTester.pdb C:\Users\Ryan\Documents\SharpDevelop Projects\parseManager\parseManager\obj\Debug\parseManagerTester.pdb
C:\Users\Ryan\Documents\SharpDevelop Projects\parseManager\parseManager\bin\Debug\NAudio.dll C:\Users\Ryan\Documents\SharpDevelop Projects\parseManager\parseManager\bin\Debug\NAudio.dll
C:\Users\Ryan\Documents\SharpDevelop Projects\parseManager\parseManager\bin\Debug\NAudio.xml C:\Users\Ryan\Documents\SharpDevelop Projects\parseManager\parseManager\bin\Debug\NAudio.xml
C:\Users\Ryan\Documents\SharpDevelop Projects\parseManager\parseManager\bin\Debug\Vulkan.dll
C:\Users\Ryan\Documents\SharpDevelop Projects\parseManager\parseManager\bin\Debug\Vulkan.Windows.dll

View File

@ -3,6 +3,4 @@ C:\Users\Ryan\Documents\SharpDevelop Projects\parseManager\parseManager\bin\Rele
C:\Users\Ryan\Documents\SharpDevelop Projects\parseManager\parseManager\obj\Release\parseManagerTester.csprojResolveAssemblyReference.cache C:\Users\Ryan\Documents\SharpDevelop Projects\parseManager\parseManager\obj\Release\parseManagerTester.csprojResolveAssemblyReference.cache
C:\Users\Ryan\Documents\SharpDevelop Projects\parseManager\parseManager\obj\Release\parseManagerTester.exe C:\Users\Ryan\Documents\SharpDevelop Projects\parseManager\parseManager\obj\Release\parseManagerTester.exe
C:\Users\Ryan\Documents\SharpDevelop Projects\parseManager\parseManager\bin\Release\NAudio.dll C:\Users\Ryan\Documents\SharpDevelop Projects\parseManager\parseManager\bin\Release\NAudio.dll
C:\Users\Ryan\Documents\SharpDevelop Projects\parseManager\parseManager\bin\Release\Vulkan.dll
C:\Users\Ryan\Documents\SharpDevelop Projects\parseManager\parseManager\bin\Release\Vulkan.Windows.dll
C:\Users\Ryan\Documents\SharpDevelop Projects\parseManager\parseManager\bin\Release\NAudio.xml C:\Users\Ryan\Documents\SharpDevelop Projects\parseManager\parseManager\bin\Release\NAudio.xml

View File

@ -1,8 +1,5 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<packages> <packages>
<package id="CSCore" version="1.2.1.1" targetFramework="net40" />
<package id="MediaToolkit" version="1.1.0.1" targetFramework="net40" /> <package id="MediaToolkit" version="1.1.0.1" targetFramework="net40" />
<package id="NAudio" version="1.8.2" targetFramework="net40" /> <package id="NAudio" version="1.8.2" targetFramework="net40" />
<package id="Resource.Embedder" version="1.2.4" targetFramework="net40" developmentDependency="true" />
<package id="VulkanSharp" version="0.1.8" targetFramework="net452" />
</packages> </packages>

View File

@ -4,6 +4,7 @@
* Time: 11:54 AM * Time: 11:54 AM
*/ */
using System; using System;
using System.Data;
using System.Diagnostics; using System.Diagnostics;
using System.IO; using System.IO;
using System.Collections.Generic; using System.Collections.Generic;
@ -18,11 +19,11 @@ using parseManagerCS;
namespace parseManagerCS namespace parseManagerCS
{ {
/// The parseManager is an Advance Config Script /// The parseManager is an Advance Config Script
/// It allows the user to run code while also definine variables /// It allows the user to run code while also defining variables
/// This also has very flexible flow control meaning you can use it for chat logic and such /// This also has very flexible flow control meaning you can use it for chat logic and such
public class parseManager public class parseManager
{ {
public string _VERSION = "1.0"; public string _VERSION = "1.3.0";
standardDefine _invoke = new standardDefine(); standardDefine _invoke = new standardDefine();
string _filepath; string _filepath;
bool _active = true; bool _active = true;
@ -61,15 +62,18 @@ namespace parseManagerCS
_mainENV["Color_Red"] = ConsoleColor.Red; _mainENV["Color_Red"] = ConsoleColor.Red;
_mainENV["Color_White"] = ConsoleColor.White; _mainENV["Color_White"] = ConsoleColor.White;
_mainENV["Color_Yellow"] = ConsoleColor.Yellow; _mainENV["Color_Yellow"] = ConsoleColor.Yellow;
_mainENV["VERSION"] = _VERSION;
} }
public void _SetDENV(ENV env) public void _SetDENV(ENV env)
{ {
_mainENV = env; _mainENV = env;
} }
public void makeThread(){ public void makeThread()
isThread=true; {
isThread = true;
} }
public bool isAThread(){ public bool isAThread()
{
return isThread; return isThread;
} }
public parseManager(string filepath) public parseManager(string filepath)
@ -139,6 +143,7 @@ namespace parseManagerCS
_flags.Add("debugging", false); _flags.Add("debugging", false);
_flags.Add("topdown", true); _flags.Add("topdown", true);
_flags.Add("casesensitive", true); _flags.Add("casesensitive", true);
_flags.Add("strictsyntax",false);
} }
public ENV Pop() public ENV Pop()
{ {
@ -157,7 +162,8 @@ namespace parseManagerCS
if (_flags["debugging"]) if (_flags["debugging"])
Console.WriteLine("DEBUGGING: " + msg); Console.WriteLine("DEBUGGING: " + msg);
} }
void _Parse(string data)
void _Parse(string data, string hFile)
{ {
foreach (Match m in Regex.Matches(data, @"LOAD ([a-zA-Z0-9_\./]+)")) { foreach (Match m in Regex.Matches(data, @"LOAD ([a-zA-Z0-9_\./]+)")) {
Parse(m.Groups[1].ToString()); Parse(m.Groups[1].ToString());
@ -172,13 +178,13 @@ namespace parseManagerCS
_entry = m.Groups[1].ToString(); _entry = m.Groups[1].ToString();
} }
foreach (Match m in Regex.Matches(data, @"VERSION ([a-zA-Z0-9_\./]+)")) { foreach (Match m in Regex.Matches(data, @"VERSION ([a-zA-Z0-9_\./]+)")) {
if (Version.Parse(m.Groups[1].ToString()) != Version.Parse(_VERSION)) { if (Version.Parse(m.Groups[1].ToString()) > Version.Parse(_VERSION)) {
PushError("Attempt to run a code created for a different version of the interperter/compiler!"); PushError("Attempt to run a code created for a greater version of the interperter/compiler! Script's Version: "+Version.Parse(m.Groups[1].ToString())+" Interperter's Version: "+Version.Parse(_VERSION));
} }
} }
// foreach (Match m in Regex.Matches(data, @"USING ([a-zA-Z0-9_\./]+)")) { foreach (Match m in Regex.Matches(data, @"THREAD ([a-zA-Z0-9_\./]+)")) {
// m.Groups[1].ToString(); def._newThread(this, m.Groups[1].ToString());
// } }
data = data + "\n"; data = data + "\n";
var match = Regex.Matches(data, "\\[(.+)\\][\r\n]*?\\{([^\0]+?)\\}\r?\n"); var match = Regex.Matches(data, "\\[(.+)\\][\r\n]*?\\{([^\0]+?)\\}\r?\n");
var count = 0; var count = 0;
@ -193,6 +199,7 @@ namespace parseManagerCS
_chunks[Blck] = new chunk(Blck, Cont); _chunks[Blck] = new chunk(Blck, Cont);
} }
count++; count++;
_chunks[Blck].SetHostFile(hFile);
if (_lastChunk != null) if (_lastChunk != null)
_lastChunk.SetNextChunk(_chunks[Blck]); _lastChunk.SetNextChunk(_chunks[Blck]);
_lastChunk = _chunks[Blck]; _lastChunk = _chunks[Blck];
@ -202,29 +209,29 @@ namespace parseManagerCS
{ {
try { try {
StreamReader sr = File.OpenText(_filepath); StreamReader sr = File.OpenText(_filepath);
_Parse(sr.ReadToEnd()); _Parse(sr.ReadToEnd(), _filepath);
sr.Close(); sr.Close();
} catch (FileNotFoundException) { } catch (FileNotFoundException) {
Console.WriteLine("File '" + _filepath + "' does not exist! Loading failled!"); PushError("File '" + _filepath + "' does not exist!");
} }
} }
void Parse(string code, bool c) void Parse(string code, bool c)
{ {
_Parse(code); _Parse(code, "Internally Parsed Code!");
} }
void Parse(string filename) void Parse(string filename)
{ {
try { try {
StreamReader sr = File.OpenText(filename); StreamReader sr = File.OpenText(filename);
_Parse(sr.ReadToEnd()); _Parse(sr.ReadToEnd(), filename);
sr.Close(); sr.Close();
} catch (FileNotFoundException) { } catch (FileNotFoundException) {
Console.WriteLine("Load '" + filename + "' File not found. Loading failled!"); PushError("Could not load '" + _filepath + "' it does not exist!");
} }
} }
public void ParseCode(string code) public void ParseCode(string code)
{ {
_Parse(code); _Parse(code, "Internally Parsed Code!");
} }
public chunk[] GetChunks() public chunk[] GetChunks()
{ {
@ -245,6 +252,16 @@ namespace parseManagerCS
{ {
_active = false; _active = false;
} }
public bool GetLogic(parseManager PM, string log)
{
var test2 = PM.Logic(log);
var te = evaluater.Evaluate(PM, test2);
if (te > 0) {
return true;
} else {
return false;
}
}
public bool isRegisteredFunction(string method, out chunk o) public bool isRegisteredFunction(string method, out chunk o)
{ {
if (_chunks.TryGetValue(method, out o)) { if (_chunks.TryGetValue(method, out o)) {
@ -255,7 +272,7 @@ namespace parseManagerCS
} }
return false; return false;
} }
public object InvokeI(string method, object[] argsV, chunk c,bool rets) public object InvokeI(string method, object[] argsV, chunk c, bool rets)
{ {
var ccP = _currentChunk.GetPos(); var ccP = _currentChunk.GetPos();
var ccN = _currentChunk.GetName(); var ccN = _currentChunk.GetName();
@ -277,7 +294,7 @@ namespace parseManagerCS
} }
_defualtENV = fEnv; _defualtENV = fEnv;
def.JUMP(this, method); def.JUMP(this, method);
if(rets){ if (rets) {
return fEnv; // TODO Handle returns return fEnv; // TODO Handle returns
} else { } else {
return null; return null;
@ -293,7 +310,13 @@ namespace parseManagerCS
_defineMethod = _defineType.GetMethod(method); _defineMethod = _defineType.GetMethod(method);
return _defineMethod.Invoke(_defineClassObject, tackBArgs(this, args)); return _defineMethod.Invoke(_defineClassObject, tackBArgs(this, args));
} catch (Exception e) { } catch (Exception e) {
PushError("Invalid method: " + method + "\n\n" + e); var tests = e.ToString();
if (tests.Contains("Null")) {
PushError("Invalid method: " + method + " (Method does not exist! Check your spelling!)");
} else if (tests.Contains("ArgumentException")) {
PushError("Invalid method: " + method + " (Check your arguments! Ensure the types are correct!)");
}
PushError("Invalid method: " + method + " (Unknown Error! It just doesn't work!)\n\n" + e);
return null; return null;
} }
} }
@ -309,7 +332,13 @@ namespace parseManagerCS
_defineMethod.Invoke(_defineClassObject, tackBArgs(this, args)); _defineMethod.Invoke(_defineClassObject, tackBArgs(this, args));
return 0; return 0;
} catch (Exception e) { } catch (Exception e) {
PushError("Invalid method: " + method + "\n\n" + e); var tests = e.ToString();
if (tests.Contains("Null")) {
PushError("Invalid method: " + method + " (Method does not exist! Check your spelling!)");
} else if (tests.Contains("ArgumentException")) {
PushError("Invalid method: " + method + " (Check your arguments! Ensure the types are correct!)");
}
PushError("Invalid method: " + method + " (Unknown Error! It just doesn't work!)\n\n" + e);
return -1; return -1;
} }
} }
@ -330,7 +359,7 @@ namespace parseManagerCS
_currentChunk = cchunk; _currentChunk = cchunk;
_currentChunk.ResetPos(); _currentChunk.ResetPos();
} else { } else {
PushError("Attempt to JUMP to a non existing block!"); PushError("Attempt to JUMP to a non existing block: \""+BLOCK+"\"");
} }
} }
public ENV GetENV() public ENV GetENV()
@ -368,9 +397,32 @@ namespace parseManagerCS
} }
public void PushError(string err) public void PushError(string err)
{ {
Console.WriteLine(err + "\nPress Enter!"); if (_currentChunk==null){
Console.WriteLine(err+"\nPress Enter");
Console.ReadLine();
Environment.Exit(0);
}
var line = _currentChunk.GetCurrentLine();
var file = _currentChunk.GetHostFile();
var sr = File.OpenText(file);
var code = sr.ReadToEnd();
var haschunk = false;
var chunk = _currentChunk.GetName();
code = Regex.Replace(code, @"^\t+", "", RegexOptions.Multiline);
var lines = code.Split(new [] { "\r\n", "\n" }, StringSplitOptions.None);
var pos = 0;
for (int i = 0; i < lines.Length; i++) {
if (!haschunk && lines[i].StartsWith("[" + chunk)) {
haschunk = true;
}
if (lines[i].StartsWith(line) && haschunk) {
pos = i + 1;
break;
}
}
Console.WriteLine(string.Format("Error in File: {0} on Line: {1}\nLIQ: {2}\n\nERROR: {3}\nPress Enter!", file, pos, line, err));
Console.ReadLine(); Console.ReadLine();
def.EXIT(this); Environment.Exit(0);
} }
public nextType Next(string BLOCK) public nextType Next(string BLOCK)
{ {
@ -408,57 +460,18 @@ namespace parseManagerCS
var type = cCMD.GetCMDType(); var type = cCMD.GetCMDType();
stuff = cCMD.GetArgs(); stuff = cCMD.GetArgs();
if (type == "LOGIC") {//{conds,andors,_funcif,_resultif,_funcelse,_resultelse} if (type == "LOGIC") {//{conds,andors,_funcif,_resultif,_funcelse,_resultelse}
var conds = (string[])stuff[0]; var conds = (string)stuff[0];
var andors = (string[])stuff[1]; var funcif = (string)stuff[1];
var funcif = (string)stuff[2]; var argsif = (string[])stuff[2];
var argsif = (string[])stuff[3]; var funcelse = (string)stuff[3];
var funcelse = (string)stuff[4]; var argselse = (string[])stuff[4];
var argselse = (string[])stuff[5]; var truth = GetLogic(this, conds);
var objs = new object[conds.Length]; // contain the actual values of what is in the env if (truth) {
var truths = new bool[conds.Length / 3];
var c = 0;
for (int i = 0; i < conds.Length; i += 3) {
var condA = (object)ResolveVar(new []{ conds[i] })[0];
var e = conds[i + 1];
var condB = (object)ResolveVar(new []{ conds[i + 2] })[0];
if (e == "==") {
truths[c] = condA.ToString() == condB.ToString();
} else if (e == ">=") {
truths[c] = (double)condA >= (double)condB;
} else if (e == "<=") {
truths[c] = (double)condA <= (double)condB;
} else if (e == "!=" || e == "~=") {
truths[c] = condA.ToString() != condB.ToString();
} else if (e == ">") {
truths[c] = (double)condA > (double)condB;
} else if (e == "<") {
truths[c] = (double)condA < (double)condB;
} else {
PushError("Invalid conditional test! " + e + " is not valid!");
}
c++;
}
var truth = truths[0];
if (truths.Length == 1 && truth) {
InvokeNR(funcif, ResolveVar(argsif)); InvokeNR(funcif, ResolveVar(argsif));
} else if (truths.Length == 1) {
InvokeNR(funcelse, ResolveVar(argselse));
} else { } else {
for (int i = 1; i < andors.Length; i++) { InvokeNR(funcelse, ResolveVar(argselse));
if (andors[i - 1] == "a") {
truth = truth && truths[i];
} else if (andors[i - 1] == "o") {
truth = truth || truths[i];
} else {
PushError("Invalid conditional test! " + andors[i - 1] + " is not valid!");
}
}
if (truth) {
InvokeNR(funcif, ResolveVar(argsif));
} else {
InvokeNR(funcelse, ResolveVar(argselse));
}
} }
tempReturn.SetCMDType("conditional"); tempReturn.SetCMDType("conditional");
tempReturn.SetText("test turned out to be: " + truth); tempReturn.SetText("test turned out to be: " + truth);
return tempReturn; return tempReturn;
@ -508,6 +521,11 @@ namespace parseManagerCS
tempReturn.SetCMDType("assignment"); tempReturn.SetCMDType("assignment");
tempReturn.SetText(_currentChunk.GetLine()); tempReturn.SetText(_currentChunk.GetLine());
return tempReturn; return tempReturn;
} else {
var b = GetFlag("strictsyntax");
if (b){
PushError("INVALID SYNTAX!");
}
} }
return tempReturn; return tempReturn;
} }
@ -566,8 +584,16 @@ namespace parseManagerCS
bool boo; bool boo;
double ex; double ex;
for (int i = 0; i < len; i++) { for (int i = 0; i < len; i++) {
if (v[i] == "true") {
args[i] = true;
continue;
}
if (v[i] == "false") {
args[i] = false;
continue;
}
if (!v[i].StartsWith("[") && !v[i].StartsWith("\"")) if (!v[i].StartsWith("[") && !v[i].StartsWith("\""))
ex = evaluater.Evaluate(v[i]); ex = evaluater.Evaluate(this, v[i]);
else else
ex = double.NaN; ex = double.NaN;
if (v[i].Length == 0 && len == 1) { if (v[i].Length == 0 && len == 1) {
@ -625,6 +651,54 @@ namespace parseManagerCS
} }
return args; return args;
} }
public int resolveLogic(bool b)
{
if (b) {
return 1;
} else {
return 0;
}
}
public bool resolveLogic(int b)
{
if (b == 1) {
return true;
} else {
return true;
}
}
public string Logic(string log)
{
log = Regex.Replace(log, "and", "*");
log = Regex.Replace(log, "or", "+");
foreach (Match m in Regex.Matches(log,@"\(?\s*(\S+?)\s*([=!><]+)\s*(\S+)\s*\)?")) {
var a = m.Groups[1].Value;
var b = m.Groups[2].Value;
var c = m.Groups[3].Value;
a = Regex.Replace(a, @"\(", "");
c = Regex.Replace(c, @"\)", "");
if (b == "==") {
debug("==");
log = Regex.Replace(log, a + "\\s*" + b + "\\s*" + c, resolveLogic(ResolveVar(new []{ a })[0].ToString() == ResolveVar(new []{ c })[0].ToString()).ToString());
} else if (b == ">=") {
debug(">=");
log = Regex.Replace(log, a + "\\s*" + b + "\\s*" + c, resolveLogic(double.Parse(ResolveVar(new []{ a })[0].ToString()) >= double.Parse(ResolveVar(new []{ c })[0].ToString())).ToString());
} else if (b == "<=") {
debug("<=");
log = Regex.Replace(log, a + "\\s*" + b + "\\s*" + c, resolveLogic(double.Parse(ResolveVar(new []{ a })[0].ToString()) <= double.Parse(ResolveVar(new []{ c })[0].ToString())).ToString());
} else if (b == ">") {
debug(">");
log = Regex.Replace(log, a + "\\s*" + b + "\\s*" + c, resolveLogic(double.Parse(ResolveVar(new []{ a })[0].ToString()) > double.Parse(ResolveVar(new []{ c })[0].ToString())).ToString());
} else if (b == "<") {
debug("<");
log = Regex.Replace(log, a + "\\s*" + b + "\\s*" + c, resolveLogic(double.Parse(ResolveVar(new []{ a })[0].ToString()) < double.Parse(ResolveVar(new []{ c })[0].ToString())).ToString());
} else if (b == "!=") {
debug("!=");
log = Regex.Replace(log, a + "\\s*" + b + "\\s*" + c, resolveLogic(ResolveVar(new []{ a })[0].ToString() != ResolveVar(new []{ c })[0].ToString()).ToString());
}
}
return log;
}
public bool isVar(string val, out object v) public bool isVar(string val, out object v)
{ {
debug("TESTING: " + val); debug("TESTING: " + val);
@ -673,6 +747,7 @@ namespace parseManagerCS
string[] _lines; string[] _lines;
string[] args; string[] args;
bool isFunc; bool isFunc;
string _hostfile;
Dictionary<string, int> _labels = new Dictionary<string, int>(); Dictionary<string, int> _labels = new Dictionary<string, int>();
List<CMD> _compiledlines = new List<CMD>(); List<CMD> _compiledlines = new List<CMD>();
int _pos = 0; int _pos = 0;
@ -697,14 +772,22 @@ namespace parseManagerCS
_type = "CODEBLOCK"; _type = "CODEBLOCK";
_clean(cont); _clean(cont);
} }
public void SetHostFile(string file)
{
_hostfile = file;
}
public string GetHostFile()
{
return _hostfile;
}
void _clean(string cont) void _clean(string cont)
{ {
var m = Regex.Match(_type, @"([a-zA-Z0-9_]+)"); var m = Regex.Match(_type, @"([a-zA-Z0-9_]+)");
_pureType = m.Groups[1].ToString(); _pureType = m.Groups[1].ToString();
var tCont = Regex.Replace(cont, @"\-\-\[\[[\S\s]+\]\]", "", RegexOptions.Multiline); var tCont = Regex.Replace(cont, @"\-\-\[\[[\S\s]+\]\]", "", RegexOptions.Multiline);
tCont = Regex.Replace(tCont, @"\t", "", RegexOptions.Multiline); tCont = Regex.Replace(tCont, @"^\t+", "", RegexOptions.Multiline);
tCont = Regex.Replace(tCont, @"^\-\-.+\r\n", "", RegexOptions.Multiline); tCont = Regex.Replace(tCont, @"\-\-.+\r\n", "\r\n", RegexOptions.Multiline);
tCont = Regex.Replace(tCont, @"^\-\-.+\n", "", RegexOptions.Multiline); tCont = Regex.Replace(tCont, @"\-\-.+\n", "\n", RegexOptions.Multiline);
tCont = Regex.Replace(tCont, @"\n\n", "", RegexOptions.Multiline); tCont = Regex.Replace(tCont, @"\n\n", "", RegexOptions.Multiline);
tCont = Regex.Replace(tCont, @"\r\n\r\n", "", RegexOptions.Multiline); tCont = Regex.Replace(tCont, @"\r\n\r\n", "", RegexOptions.Multiline);
tCont = Regex.Replace(tCont, @"\-\-\[\[[\S\s]+\]\]", "", RegexOptions.Multiline); tCont = Regex.Replace(tCont, @"\-\-\[\[[\S\s]+\]\]", "", RegexOptions.Multiline);
@ -719,12 +802,11 @@ namespace parseManagerCS
temp = _lines[i]; temp = _lines[i];
var pureLine = Regex.Match(temp, "^\"(.+)\""); var pureLine = Regex.Match(temp, "^\"(.+)\"");
var FuncTest = Regex.Match(temp, @"([a-zA-Z0-9_]+)\s?\((.*)\)"); var FuncTest = Regex.Match(temp, @"([a-zA-Z0-9_]+)\s?\((.*)\)");
var assignment = Regex.Match(temp, "^([a-zA-Z0-9_,\\[\\]\"]+)=([a-zA-Z\\|&\\^\\+\\-\\*/%0-9_\",\\[\\]]+)"); var assignment = Regex.Match(temp, "^([a-zA-Z0-9_,\\[\\]\"]+)\\s*=([a-zA-Z\\s\\|&\\^\\+\\-\\*/%0-9_\",\\[\\]]*)");
var FuncWReturn = Regex.Match(temp, "([\\[\\]\"a-zA-Z0-9_,]+)\\s?=\\s?([a-zA-Z0-9_]+)\\s?\\((.*)\\)"); var FuncWReturn = Regex.Match(temp, "([\\[\\]\"a-zA-Z0-9_,]+)\\s?=\\s?([a-zA-Z0-9_]+)\\s?\\((.*)\\)");
var FuncWOReturn = Regex.Match(temp, @"^([a-zA-Z0-9_]+)\s?\((.*)\)"); var FuncWOReturn = Regex.Match(temp, @"^([a-zA-Z0-9_]+)\s?\((.*)\)");
var label = Regex.Match(temp, "::(.*)::"); var label = Regex.Match(temp, "::(.*)::");
var logic = Regex.Match(temp, @"if\s*(.+)\s*then\s*(.+?\))\s*\|\s*(.+?\))"); var logic = Regex.Match(temp, @"if\s*(.+)\s*then\s*(.+?\))\s*\|\s*(.+?\))");
if (logic.ToString() != "") { if (logic.ToString() != "") {
var condition = logic.Groups[1].ToString(); var condition = logic.Groups[1].ToString();
var tempif = logic.Groups[2].ToString(); var tempif = logic.Groups[2].ToString();
@ -764,8 +846,7 @@ namespace parseManagerCS
conds[p++] = s1b2; conds[p++] = s1b2;
conds[p++] = s1c2; conds[p++] = s1c2;
_compiledlines.Add(new CMD("LOGIC", new object[] { _compiledlines.Add(new CMD("LOGIC", new object[] {
conds, condition,
andors,
_funcif, _funcif,
_resultif, _resultif,
_funcelse, _funcelse,
@ -858,6 +939,19 @@ namespace parseManagerCS
} }
return temp; return temp;
} }
public string GetCurrentLine()
{
string temp="";
if (_pos == 0) {
temp = _lines[_pos+2];
} else {
temp = _lines[_pos - 1];
}
if (_pos - 1 == _lines.Length) {
return null;
}
return temp;
}
public CMD GetCLine() public CMD GetCLine()
{ {
if (_pos < _compiledlines.Count) { if (_pos < _compiledlines.Count) {
@ -888,104 +982,34 @@ namespace parseManagerCS
} }
public static class evaluater public static class evaluater
{ {
static double helper(ENV env, parseManager PM, string o, object _v, object _r) public static double Evaluate(parseManager PM, string str)
{ {
double v = 0; string oldstr = str;
double r = 0; object temp;
if (_v.GetType().ToString() == "System.String") { double temp2;
object temp; foreach (Match m in Regex.Matches(str, "([a-zA-Z0-9_]+)")) {
if (env.TryGetValue((string)_v, out temp)) { if (!double.TryParse(m.Groups[0].Value, out temp2)) {
v = (double)temp; temp2 = double.NaN;
} else if (double.TryParse((string)_v, out v)) {
// We good!
} else {
PM.PushError("Attempt to do arithmetic on a null value: " + _v);
} }
} else { if (PM.isVar(m.Groups[0].Value, out temp)) {
v = (double)_v; if (temp.GetType().ToString().Contains("Double")) {
} str = str.Replace(m.Groups[0].Value, ((double)temp).ToString());
if (_r.GetType().ToString() == "System.String") { } else {
object temp; return double.NaN;
if (env.TryGetValue((string)_r, out temp)) {
r = (double)temp;
} else if (double.TryParse((string)_r, out r)) {
// We good!
} else {
PM.PushError("Attempt to do arithmetic on a null value: " + _r);
}
} else {
v = (double)_v;
}
// Constructs?
if (o == "+") {
return r + v;
} else if (o == "-") {
return r - v;
} else if (o == "/") {
return r / v;
} else if (o == "*") {
return r * v;
} else if (o == "^") {
return Math.Pow(r, v);
} else if (o == "%") {
return r % v;
}
return 0;
}
public static double Evaluate(string cmd)
{
return Evaluate(cmd, 0);
}
public static double Evaluate(string cmd, double v)
{
double test;
if (cmd.Length == 0) {
return double.NaN;
}
if (double.TryParse(cmd, out test)) {
return test;
}
var loop = false;
if (cmd.Substring(0, 1) == "-") {
cmd = "0" + cmd;
}
var PM = GLOBALS.GetPM();
var env = PM.GetENV();
var count = 0;
var para = Regex.Match(cmd, @"(\(.+\))");
if (para.ToString() != "") {
return Evaluate(para.Groups[1].Value.Substring(1, para.Groups[1].Value.Length - 2));
}
foreach (Match m in Regex.Matches(cmd,@"(.*)([/%\+\^\-\*])(.*)")) {
loop = true;
count++;
var l = m.Groups[1].Value;
var o = m.Groups[2].Value;
var r = m.Groups[3].Value;
if (Regex.Match(l, @"([/%\+\^\-\*])").ToString() != "") {
v = Evaluate(l, v);
v = helper(env, PM, o, r, v);
} else if (count == 1) {
v = helper(env, PM, o, r, l);
}
}
if (!loop) {
object t;
if (env != null)
if (env.TryGetValue(cmd, out t)) {
double te;
if (t.GetType().ToString().Contains("Double"))
return (double)t;
if (t.GetType().ToString().Contains("String"))
if (double.TryParse((string)t, out te)) {
return te;
} }
return double.NaN; } else if (!double.IsNaN(temp2)) {
str = str.Replace(m.Groups[0].Value, temp2.ToString());
} else { } else {
t = double.NaN; // It couldn't be done :'( PM.PushError("Variable \""+m.Groups[0].Value+"\" does not exist: ");
} }
} }
return v; // TODO grab current ENV and does the calculation double result;
try {
result = Convert.ToDouble(new DataTable().Compute(str, null));
} catch {
result = double.NaN;
}
return result;
} }
} }
[Serializable] [Serializable]
@ -1142,6 +1166,7 @@ namespace parseManagerCS
{ {
static standardDefine _define = new standardDefine(); static standardDefine _define = new standardDefine();
static parseManager _current; static parseManager _current;
static parseManager _main;
static readonly ENV _env = new ENV(); static readonly ENV _env = new ENV();
static List<string> _numvars = new List<string>(); static List<string> _numvars = new List<string>();
static List<parseManager> _Threads = new List<parseManager>(); static List<parseManager> _Threads = new List<parseManager>();
@ -1188,10 +1213,17 @@ namespace parseManagerCS
{ {
_current = o; _current = o;
} }
public static void SetMainPM(parseManager o)
{
_main = o;
}
public static parseManager GetPM() public static parseManager GetPM()
{ {
return _current; return _current;
} }
public static parseManager GetMainPM(){
return _main;
}
public static bool GetFlag(string flag) public static bool GetFlag(string flag)
{ {
var PM = GetPM(); var PM = GetPM();
@ -1301,10 +1333,29 @@ public class standardDefine
next = PM.Next(); next = PM.Next();
} }
} }
public void _newThread(parseManager PM, string filename)
{
var thread = new Thread(() => _THREAD(PM,filename));
thread.Start();
}
public void _THREAD(parseManager _PM, string filename)
{
parseManager PM = new parseManager(filename);
GLOBALS.AddThread(PM);
PM.makeThread();
PM._SetDENV(_PM.GetDENV());
PM.SetENV(_PM.GetENV());
nextType next = PM.Next();
string type;
while (next.GetCMDType() != "EOF") {
type = next.GetCMDType();
next = PM.Next();
}
}
public void SAVE(parseManager PM) public void SAVE(parseManager PM)
{ {
if(PM.isAThread()){ if (PM.isAThread()) {
PM.PushError("Cannot Call SAVE() in a thread!"); GLOBALS.GetMainPM().PushError("Cannot Call SAVE() in a thread!");
} }
var env = PM.GetDENV(); var env = PM.GetDENV();
var c = PM.GetCurrentChunk(); var c = PM.GetCurrentChunk();
@ -1315,8 +1366,8 @@ public class standardDefine
} }
public bool LOAD(parseManager PM) public bool LOAD(parseManager PM)
{ {
if(PM.isAThread()){ if (PM.isAThread()) {
PM.PushError("Cannot Call LOAD() in a thread!"); GLOBALS.GetMainPM().PushError("Cannot Call LOAD() in a thread!");
} }
try { try {
ENV env = GLOBALS.ReadFromBinaryFile("savedata.dat"); ENV env = GLOBALS.ReadFromBinaryFile("savedata.dat");
@ -1412,7 +1463,7 @@ public class standardDefine
} }
} }
} }
PM.PushError("Unable to GOTO a non existing label: " + label + "!"); PM.PushError("Unable to GOTO a non existing label: \"" + label + "\"");
return 0; return 0;
} }
public double len(parseManager PM, object o) public double len(parseManager PM, object o)
@ -1478,7 +1529,7 @@ public class standardDefine
} }
public double CALC(parseManager PM, string ex) public double CALC(parseManager PM, string ex)
{ {
return evaluater.Evaluate(ex); return evaluater.Evaluate(PM, ex);
} }
public void pause(parseManager PM) public void pause(parseManager PM)
{ {
@ -1579,9 +1630,18 @@ public class standardDefine
Console.Write(s); Console.Write(s);
} catch (ArgumentOutOfRangeException e) { } catch (ArgumentOutOfRangeException e) {
Console.Clear(); Console.Clear();
Console.WriteLine(e.Message); PM.PushError(e.Message);
} }
} }
public void setWindowSize(parseManager PM, double x,double y){
Console.SetWindowSize((int)x,(int)y);
}
public double getConsoleWidth(parseManager PM){
return Console.WindowWidth;
}
public double getConsoleHeight(parseManager PM){
return Console.WindowHeight;
}
public bool isDown(parseManager PM, string key) public bool isDown(parseManager PM, string key)
{ {
if (!ApplicationIsActivated()) { if (!ApplicationIsActivated()) {
@ -1680,6 +1740,10 @@ public class standardDefine
} }
return Keyboard.IsKeyDown(kk); return Keyboard.IsKeyDown(kk);
} }
public void error(parseManager PM, string msg)
{
PM.PushError(msg);
}
public string isPressing(parseManager PM) public string isPressing(parseManager PM)
{ {
return Console.ReadKey(true).Key.ToString(); return Console.ReadKey(true).Key.ToString();

View File

@ -56,12 +56,6 @@
<Reference Include="System.Xml.Linq"> <Reference Include="System.Xml.Linq">
<RequiredTargetFramework>3.5</RequiredTargetFramework> <RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference> </Reference>
<Reference Include="Vulkan">
<HintPath>..\packages\VulkanSharp.0.1.8\lib\net452\Vulkan.dll</HintPath>
</Reference>
<Reference Include="Vulkan.Windows">
<HintPath>..\packages\VulkanSharp.0.1.8\lib\net452\Vulkan.Windows.dll</HintPath>
</Reference>
<Reference Include="WindowsBase"> <Reference Include="WindowsBase">
<RequiredTargetFramework>3.0</RequiredTargetFramework> <RequiredTargetFramework>3.0</RequiredTargetFramework>
</Reference> </Reference>
@ -77,5 +71,4 @@
<None Include="packages.config" /> <None Include="packages.config" />
</ItemGroup> </ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="..\packages\Resource.Embedder.1.2.4\build\Resource.Embedder.targets" Condition="Exists('..\packages\Resource.Embedder.1.2.4\build\Resource.Embedder.targets')" />
</Project> </Project>