Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/c272/algo
Browse files Browse the repository at this point in the history
  • Loading branch information
c272 committed Sep 4, 2019
2 parents 3c6a813 + 63f5286 commit cfde7a1
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 6 deletions.
10 changes: 9 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,10 @@
language: csharp
solution: Algo.sln
solution: Algo.sln

deploy:
provider: releases
api_key: $gh_oauth
file: "algo"
skip_cleanup: true
on:
tags: true
4 changes: 2 additions & 2 deletions Algo/ALEC/ALEC.cs
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ public static void PrintCompileHeader()
\ \_\ \_\ \ \_____\ \ \_____\ \ \_____\
\/_/\/_/ \/_____/ \/_____/ \/_____/
");
Console.WriteLine("ALEC (Algo Executable Language Compiler) v" + MAJOR_VER + "." + MINOR_VER + "." + verInfo[2] + ", build " + verInfo[3]);
Console.WriteLine("ALEC (Algo Language Executable Compiler) v" + MAJOR_VER + "." + MINOR_VER + "." + verInfo[2] + ", build " + verInfo[3]);
Console.WriteLine("Framework: .NET Framework ENV " + Environment.Version);
Console.WriteLine("Operating System: " + Environment.OSVersion);
if (Environment.Is64BitProcess)
Expand Down Expand Up @@ -470,4 +470,4 @@ public enum ALECEvent
Notice,
Success
}
}
}
7 changes: 5 additions & 2 deletions Algo/Standard Library/Algo Scripts/string.ag
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//The "string" standard library provided by Algo.
//The "string" standard library provided by Algo.
//v0.0.4, revision 0.

library string
Expand All @@ -25,6 +25,9 @@ library string
//Returns a boolean of whether a string ends with a substring.
external endsWith <- std_string.endsWith;

//Returns a boolean of whether a string starts with a substring.
external startsWith <- std_string.startsWith;

//Returns a boolean of whether a string represents an integer.
external isInteger <- std_string.isInteger;

Expand All @@ -42,4 +45,4 @@ library string
library regex
{
external match <- std_string.regex_match;
}
}
29 changes: 28 additions & 1 deletion Algo/Standard Library/Libraries/AlgoStd_String.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Antlr4.Runtime;
using Antlr4.Runtime;
using ExtendedNumerics;
using System;
using System.Collections.Generic;
Expand Down Expand Up @@ -61,6 +61,14 @@ public class AlgoStd_String : IFunctionPlugin
Function = StringEndsWith
},

//StartsWith
new AlgoPluginFunction()
{
Name = "startsWith",
ParameterCount = 2,
Function = StringStartsWith
},

//IsInteger
new AlgoPluginFunction()
{
Expand Down Expand Up @@ -377,6 +385,25 @@ public static AlgoValue StringEndsWith(ParserRuleContext context, params AlgoVal
};
}

//Returns whether a string value starts with a specific substring.
public static AlgoValue StringStartsWith(ParserRuleContext context, params AlgoValue[] args)
{
//Arguments are strings?
if (args[0].Type != AlgoValueType.String || args[1].Type != AlgoValueType.String)
{
Error.Fatal(context, "Source and substring must both be of type String.");
return null;
}

string source = (string)args[0].Value;
string start = (string)args[1].Value;
return new AlgoValue()
{
Type = AlgoValueType.Boolean,
Value = source.StartsWith(start)
};
}

//Check if a string is a valid integer.
public static AlgoValue IsInteger(ParserRuleContext context, params AlgoValue[] args)
{
Expand Down

0 comments on commit cfde7a1

Please sign in to comment.