Skip to content

Commit 0fae436

Browse files
committed
Initial commit
1 parent 00d883a commit 0fae436

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+9313
-36
lines changed

.gitignore

Lines changed: 65 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,76 @@
1-
# Windows image file caches
2-
Thumbs.db
3-
ehthumbs.db
1+
# =============== #
2+
# Unity generated #
3+
# =============== #
4+
Temp/
5+
Library/
6+
Build/
47

5-
# Folder config file
6-
Desktop.ini
8+
# ===================================== #
9+
# Visual Studio / MonoDevelop generated #
10+
# ===================================== #
11+
ExportedObj/
12+
obj/
13+
TestResults
14+
*.svd
15+
*.userprefs
16+
/*.csproj
17+
*.pidb
18+
*.suo
19+
/*.sln
20+
*.user
21+
*.unityproj
22+
*.booproj
23+
*.dll
24+
*.pdb
725

8-
# Recycle Bin used on file shares
9-
$RECYCLE.BIN/
26+
# ============= #
27+
# Excel generated #
28+
# ============= #
1029

11-
# Windows Installer files
12-
*.cab
13-
*.msi
14-
*.msm
15-
*.msp
30+
~$*
1631

17-
# Windows shortcuts
18-
*.lnk
32+
# ============= #
33+
# Emacs-related #
34+
# ============= #
1935

20-
# =========================
21-
# Operating System Files
22-
# =========================
36+
*~
37+
\#*\#
38+
.\#*
39+
\#*\#.meta
40+
Assets/TAGS
41+
Assets/TAGS.meta
2342

24-
# OSX
25-
# =========================
2643

44+
# ============ #
45+
# OS generated #
46+
# ============ #
2747
.DS_Store
28-
.AppleDouble
29-
.LSOverride
30-
31-
# Thumbnails
48+
.DS_Store?
3249
._*
33-
34-
# Files that might appear in the root of a volume
35-
.DocumentRevisions-V100
36-
.fseventsd
3750
.Spotlight-V100
38-
.TemporaryItems
3951
.Trashes
40-
.VolumeIcon.icns
41-
42-
# Directories potentially created on remote AFP share
43-
.AppleDB
44-
.AppleDesktop
45-
Network Trash Folder
46-
Temporary Items
47-
.apdisk
52+
ehthumbs.db
53+
Thumbs.db
54+
55+
# ===== #
56+
# Other #
57+
# ===== #
58+
.dropbox
59+
UnityVS/
60+
UnityVS.meta
61+
UnityVS.*.sln.DotSettings
62+
63+
#Un-ignore these specific files
64+
#!Library/*.asset
65+
#!Library/AssetImportState
66+
#!Library/AssetVersioning.db
67+
#!Library/BuildPlayer.prefs
68+
#!Library/ScriptMapper
69+
#!Library/assetservercachev3
70+
#!Library/expandedItems
71+
#!Library/guidmapper
72+
#!Library/unity default resources
73+
#!Library/unity editor resources
74+
#!Library/metadata/
75+
*.stackdump
76+
TAGS

BotL/BotL.csproj

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
4+
<PropertyGroup>
5+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
6+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
7+
<ProjectGuid>{09D1AE55-B600-44FC-9FEA-455EC969465C}</ProjectGuid>
8+
<OutputType>Library</OutputType>
9+
<AppDesignerFolder>Properties</AppDesignerFolder>
10+
<RootNamespace>BotL</RootNamespace>
11+
<AssemblyName>BotL</AssemblyName>
12+
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
13+
<FileAlignment>512</FileAlignment>
14+
<TargetFrameworkProfile />
15+
</PropertyGroup>
16+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
17+
<DebugSymbols>true</DebugSymbols>
18+
<DebugType>full</DebugType>
19+
<Optimize>false</Optimize>
20+
<OutputPath>bin\Debug\</OutputPath>
21+
<DefineConstants>DEBUG;TRACE</DefineConstants>
22+
<ErrorReport>prompt</ErrorReport>
23+
<WarningLevel>4</WarningLevel>
24+
</PropertyGroup>
25+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
26+
<DebugType>pdbonly</DebugType>
27+
<Optimize>true</Optimize>
28+
<OutputPath>bin\Release\</OutputPath>
29+
<DefineConstants>TRACE</DefineConstants>
30+
<ErrorReport>prompt</ErrorReport>
31+
<WarningLevel>4</WarningLevel>
32+
</PropertyGroup>
33+
<ItemGroup>
34+
<Reference Include="System" />
35+
<Reference Include="System.Core" />
36+
<Reference Include="System.Data" />
37+
<Reference Include="UnityEngine">
38+
<HintPath>..\..\UnityProlog\Prolog\bin\Release\UnityEngine.dll</HintPath>
39+
</Reference>
40+
</ItemGroup>
41+
<ItemGroup>
42+
<Compile Include="Call.cs" />
43+
<Compile Include="CallStatus.cs" />
44+
<Compile Include="ChoicePoint.cs" />
45+
<Compile Include="Compiler\BindingEnvironment.cs" />
46+
<Compile Include="Compiler\CodeBuilder.cs" />
47+
<Compile Include="Compiler\Compiler.cs" />
48+
<Compile Include="Compiler\Functions.cs" />
49+
<Compile Include="Compiler\Macros.cs" />
50+
<Compile Include="Compiler\StackReference.cs" />
51+
<Compile Include="Compiler\Structs.cs" />
52+
<Compile Include="Compiler\SyntaxError.cs" />
53+
<Compile Include="Compiler\Transform.cs" />
54+
<Compile Include="Compiler\Variable.cs" />
55+
<Compile Include="Compiler\VariableInfo.cs" />
56+
<Compile Include="Compiler\VariableType.cs" />
57+
<Compile Include="Engine.cs" />
58+
<Compile Include="Environment.cs" />
59+
<Compile Include="Compiler\FOpcode.cs" />
60+
<Compile Include="FunctionalExpression.cs" />
61+
<Compile Include="GlobalVariable.cs" />
62+
<Compile Include="InstantiationException.cs" />
63+
<Compile Include="KB.cs" />
64+
<Compile Include="Compiler\Opcode.cs" />
65+
<Compile Include="Compiler\OpcodeConstantType.cs" />
66+
<Compile Include="NamedEntities.cs" />
67+
<Compile Include="Parser\CSVParser.cs" />
68+
<Compile Include="Parser\ExpressionParser.cs" />
69+
<Compile Include="Parser\PositionTrackingTextReader.cs" />
70+
<Compile Include="Parser\Tokenizer.cs" />
71+
<Compile Include="Predicate.cs" />
72+
<Compile Include="PredicateIndicator.cs" />
73+
<Compile Include="Compiler\CompiledClause.cs" />
74+
<Compile Include="Compiler\Primops.cs" />
75+
<Compile Include="Repl.cs" />
76+
<Compile Include="Symbol.cs" />
77+
<Compile Include="Table.cs" />
78+
<Compile Include="TaggedValue.cs" />
79+
<Compile Include="Properties\AssemblyInfo.cs" />
80+
<Compile Include="TaggedValueType.cs" />
81+
<Compile Include="TypeUtils.cs" />
82+
<Compile Include="Unity\BotLConsole.cs" />
83+
<Compile Include="Unity\Console.cs" />
84+
<Compile Include="Unity\ExtensionMethods.cs" />
85+
<Compile Include="Unity\UnityUtilities.cs" />
86+
</ItemGroup>
87+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
88+
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
89+
Other similar extension points exist, see Microsoft.Common.targets.
90+
<Target Name="BeforeBuild">
91+
</Target>
92+
<Target Name="AfterBuild">
93+
</Target>
94+
-->
95+
</Project>

BotL/Call.cs

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
#region Copyright
2+
// --------------------------------------------------------------------------------------------------------------------
3+
// <copyright file="Call.cs" company="Ian Horswill">
4+
// Copyright (C) 2017 Ian Horswill
5+
//
6+
// Permission is hereby granted, free of charge, to any person obtaining a copy of
7+
// this software and associated documentation files (the "Software"), to deal in the
8+
// Software without restriction, including without limitation the rights to use, copy,
9+
// modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
10+
// and to permit persons to whom the Software is furnished to do so, subject to the
11+
// following conditions:
12+
//
13+
// The above copyright notice and this permission notice shall be included in all
14+
// copies or substantial portions of the Software.
15+
//
16+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
17+
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
18+
// PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
19+
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20+
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
21+
// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22+
// </copyright>
23+
// --------------------------------------------------------------------------------------------------------------------
24+
#endregion
25+
using System;
26+
using BotL.Parser;
27+
28+
namespace BotL
29+
{
30+
public class Call
31+
{
32+
public Call(Symbol f, params object[] args)
33+
{
34+
Functor = f;
35+
Arguments = args;
36+
}
37+
38+
public Call(string s, params object[] args) : this(Symbol.Intern(s), args) { }
39+
40+
public readonly Symbol Functor;
41+
public readonly object[] Arguments;
42+
43+
public int Arity => Arguments.Length;
44+
45+
public override string ToString()
46+
{
47+
return ExpressionParser.WriteExpressionToString(this);
48+
}
49+
50+
public static bool IsFunctor(object o, Symbol functor, int arity)
51+
{
52+
Call c = o as Call;
53+
return c != null && c.Functor == functor && c.Arity == arity;
54+
}
55+
56+
internal bool IsFunctor(Symbol functor, int arity)
57+
{
58+
return Functor == functor && Arity == arity;
59+
}
60+
61+
internal static object AddArgument(object term, object arg)
62+
{
63+
var c = term as Call;
64+
if (c == null)
65+
return new Call((Symbol) term, arg);
66+
return c.AddArgument(arg);
67+
}
68+
69+
internal Call AddArgument(object t)
70+
{
71+
var extendedArgs = new object[Arity + 1];
72+
Array.Copy(Arguments, extendedArgs, Arguments.Length);
73+
extendedArgs[extendedArgs.Length - 1] = t;
74+
return new Call(Functor, extendedArgs);
75+
}
76+
}
77+
}

BotL/CallStatus.cs

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#region Copyright
2+
// --------------------------------------------------------------------------------------------------------------------
3+
// <copyright file="CallStatus.cs" company="Ian Horswill">
4+
// Copyright (C) 2017 Ian Horswill
5+
//
6+
// Permission is hereby granted, free of charge, to any person obtaining a copy of
7+
// this software and associated documentation files (the "Software"), to deal in the
8+
// Software without restriction, including without limitation the rights to use, copy,
9+
// modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
10+
// and to permit persons to whom the Software is furnished to do so, subject to the
11+
// following conditions:
12+
//
13+
// The above copyright notice and this permission notice shall be included in all
14+
// copies or substantial portions of the Software.
15+
//
16+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
17+
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
18+
// PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
19+
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20+
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
21+
// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22+
// </copyright>
23+
// --------------------------------------------------------------------------------------------------------------------
24+
#endregion
25+
namespace BotL
26+
{
27+
/// <summary>
28+
/// Describes the result of a call to a Primop.
29+
/// </summary>
30+
public enum CallStatus
31+
{
32+
/// <summary>
33+
/// Call failed; can't be restarted
34+
/// </summary>
35+
Fail,
36+
/// <summary>
37+
/// Call succeeded, but can't be restarted. Don't add a choicepoint to the stack
38+
/// </summary>
39+
DeterministicSuccess,
40+
/// <summary>
41+
/// Call succeeded and can be restarted. Add a choicepoint.
42+
/// </summary>
43+
NonDeterministicSuccess,
44+
/// <summary>
45+
/// Only used by internal call/2 primop: reset headPredicate to be argBase and continue with call.
46+
/// </summary>
47+
CallIndirect
48+
}
49+
}

BotL/ChoicePoint.cs

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
#region Copyright
2+
// --------------------------------------------------------------------------------------------------------------------
3+
// <copyright file="ChoicePoint.cs" company="Ian Horswill">
4+
// Copyright (C) 2017 Ian Horswill
5+
//
6+
// Permission is hereby granted, free of charge, to any person obtaining a copy of
7+
// this software and associated documentation files (the "Software"), to deal in the
8+
// Software without restriction, including without limitation the rights to use, copy,
9+
// modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
10+
// and to permit persons to whom the Software is furnished to do so, subject to the
11+
// following conditions:
12+
//
13+
// The above copyright notice and this permission notice shall be included in all
14+
// copies or substantial portions of the Software.
15+
//
16+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
17+
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
18+
// PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
19+
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20+
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
21+
// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22+
// </copyright>
23+
// --------------------------------------------------------------------------------------------------------------------
24+
#endregion
25+
26+
namespace BotL
27+
{
28+
internal struct ChoicePoint
29+
{
30+
public readonly ushort CallingFrame;
31+
public readonly ushort CallingPC;
32+
public readonly Predicate Callee;
33+
public ushort NextClause;
34+
public readonly ushort DataStackTop;
35+
public readonly ushort TrailTop;
36+
37+
public readonly ushort SavedETop;
38+
39+
public ChoicePoint(ushort callingFrame, ushort callingPc, Predicate callee, ushort nextClause, ushort dTop, ushort trailTop, ushort savedETop)
40+
{
41+
CallingFrame = callingFrame;
42+
CallingPC = callingPc;
43+
Callee = callee;
44+
NextClause = nextClause;
45+
DataStackTop = dTop;
46+
TrailTop = trailTop;
47+
SavedETop = savedETop;
48+
//Debug.Assert(callingFrame==0 || Engine.EnvironmentStack[callingFrame].CompiledClause.Code[callingPc-2]==(byte)Opcode.CGoal, "Invalid calling PC address in choicepoint");
49+
}
50+
51+
public override string ToString()
52+
{
53+
return $"{CallingFrame}:{Engine.EnvironmentStack[CallingFrame].Predicate}=>{Callee}";
54+
}
55+
}
56+
}

0 commit comments

Comments
 (0)