Skip to content

Commit cfde7a1

Browse files
committed
Merge branch 'master' of https://github.com/c272/algo
2 parents 3c6a813 + 63f5286 commit cfde7a1

File tree

4 files changed

+44
-6
lines changed

4 files changed

+44
-6
lines changed

.travis.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,10 @@
11
language: csharp
2-
solution: Algo.sln
2+
solution: Algo.sln
3+
4+
deploy:
5+
provider: releases
6+
api_key: $gh_oauth
7+
file: "algo"
8+
skip_cleanup: true
9+
on:
10+
tags: true

Algo/ALEC/ALEC.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,7 @@ public static void PrintCompileHeader()
414414
\ \_\ \_\ \ \_____\ \ \_____\ \ \_____\
415415
\/_/\/_/ \/_____/ \/_____/ \/_____/
416416
");
417-
Console.WriteLine("ALEC (Algo Executable Language Compiler) v" + MAJOR_VER + "." + MINOR_VER + "." + verInfo[2] + ", build " + verInfo[3]);
417+
Console.WriteLine("ALEC (Algo Language Executable Compiler) v" + MAJOR_VER + "." + MINOR_VER + "." + verInfo[2] + ", build " + verInfo[3]);
418418
Console.WriteLine("Framework: .NET Framework ENV " + Environment.Version);
419419
Console.WriteLine("Operating System: " + Environment.OSVersion);
420420
if (Environment.Is64BitProcess)
@@ -470,4 +470,4 @@ public enum ALECEvent
470470
Notice,
471471
Success
472472
}
473-
}
473+
}

Algo/Standard Library/Algo Scripts/string.ag

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//The "string" standard library provided by Algo.
1+
//The "string" standard library provided by Algo.
22
//v0.0.4, revision 0.
33

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

28+
//Returns a boolean of whether a string starts with a substring.
29+
external startsWith <- std_string.startsWith;
30+
2831
//Returns a boolean of whether a string represents an integer.
2932
external isInteger <- std_string.isInteger;
3033

@@ -42,4 +45,4 @@ library string
4245
library regex
4346
{
4447
external match <- std_string.regex_match;
45-
}
48+
}

Algo/Standard Library/Libraries/AlgoStd_String.cs

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using Antlr4.Runtime;
1+
using Antlr4.Runtime;
22
using ExtendedNumerics;
33
using System;
44
using System.Collections.Generic;
@@ -61,6 +61,14 @@ public class AlgoStd_String : IFunctionPlugin
6161
Function = StringEndsWith
6262
},
6363

64+
//StartsWith
65+
new AlgoPluginFunction()
66+
{
67+
Name = "startsWith",
68+
ParameterCount = 2,
69+
Function = StringStartsWith
70+
},
71+
6472
//IsInteger
6573
new AlgoPluginFunction()
6674
{
@@ -377,6 +385,25 @@ public static AlgoValue StringEndsWith(ParserRuleContext context, params AlgoVal
377385
};
378386
}
379387

388+
//Returns whether a string value starts with a specific substring.
389+
public static AlgoValue StringStartsWith(ParserRuleContext context, params AlgoValue[] args)
390+
{
391+
//Arguments are strings?
392+
if (args[0].Type != AlgoValueType.String || args[1].Type != AlgoValueType.String)
393+
{
394+
Error.Fatal(context, "Source and substring must both be of type String.");
395+
return null;
396+
}
397+
398+
string source = (string)args[0].Value;
399+
string start = (string)args[1].Value;
400+
return new AlgoValue()
401+
{
402+
Type = AlgoValueType.Boolean,
403+
Value = source.StartsWith(start)
404+
};
405+
}
406+
380407
//Check if a string is a valid integer.
381408
public static AlgoValue IsInteger(ParserRuleContext context, params AlgoValue[] args)
382409
{

0 commit comments

Comments
 (0)