Skip to content

Commit 56e84d3

Browse files
committed
Merge branch 'develop'
2 parents f3d6cf0 + 17af583 commit 56e84d3

26 files changed

+539
-47
lines changed

src/Viasfora.Core/Constants.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ public static class Constants {
2929
public const String Python = "Python";
3030
public const String R = "R";
3131
public const String Sql = "Sql";
32+
public const String USql = "U-SQL";
3233
public const String TypeScript = "TypeScript";
3334
public const String VB = "VB";
3435
}

src/Viasfora.Core/Guids.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ public static class Guids {
1414
public const String VBOptions = "52787c4e-2f7f-47de-b645-82779f648a04";
1515
public const String FSharpOptions = "4accae10-98db-4b60-9463-26a6ba9313da";
1616
public const String SqlOptions = "ea0d3217-2fed-4fa6-a47a-f88951a799fc";
17+
public const String USqlOptions = "ebacc073-f3ab-40c3-8ffa-869ac0e9b143";
1718
public const String TypeScriptOptions = "a7776058-9af1-476e-884a-d2a13ab3eaea";
1819
public const String PythonOptions = "e8fef725-07d8-469c-9e61-4c02a7de348e";
1920
public const String ROptions = "07df20ff-c086-47c0-8a4a-f3db50d7d8d6";

src/Viasfora.Languages/BraceScanners/SqlBraceScanner.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,6 @@ public String BraceList {
1313
get { return "()[]"; }
1414
}
1515

16-
public SqlBraceScanner() {
17-
}
18-
1916
public void Reset(int state) {
2017
this.status = stText;
2118
}
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
using System;
2+
using Winterdom.Viasfora.Rainbow;
3+
using Winterdom.Viasfora.Util;
4+
5+
namespace Winterdom.Viasfora.Languages.BraceScanners {
6+
public class USqlBraceScanner : IBraceScanner {
7+
const int stText = 0;
8+
const int stString = 1;
9+
const int stMultiLineComment = 4;
10+
private int status = stText;
11+
12+
public string BraceList {
13+
get { return "()[]{}"; }
14+
}
15+
16+
public void Reset(int state) {
17+
status = stText;
18+
}
19+
public bool Extract(ITextChars tc, ref CharPos pos) {
20+
pos = CharPos.Empty;
21+
while ( !tc.EndOfLine ) {
22+
switch ( status ) {
23+
case stString: ParseString(tc); break;
24+
case stMultiLineComment: ParseMultilineComment(tc); break;
25+
default:
26+
return ParseText(tc, ref pos);
27+
}
28+
}
29+
return false;
30+
}
31+
32+
private bool ParseText(ITextChars tc, ref CharPos pos) {
33+
while ( !tc.EndOfLine ) {
34+
if ( tc.Char() == '/' && tc.NChar() == '*' ) {
35+
tc.Skip(2);
36+
status = stMultiLineComment;
37+
ParseMultilineComment(tc);
38+
} else if ( tc.Char() == '/' && tc.NChar() == '/' ) {
39+
tc.SkipRemainder();
40+
} else if ( tc.Char() == '\'' ) {
41+
status = stString;
42+
tc.Next();
43+
ParseCharLiteral(tc);
44+
} else if ( tc.Char() == '"' ) {
45+
status = stString;
46+
tc.Next();
47+
ParseString(tc);
48+
} else if ( this.BraceList.IndexOf(tc.Char()) >= 0 ) {
49+
pos = new CharPos(tc.Char(), tc.AbsolutePosition);
50+
tc.Next();
51+
return true;
52+
} else {
53+
tc.Next();
54+
}
55+
}
56+
return false;
57+
}
58+
59+
private void ParseCharLiteral(ITextChars tc) {
60+
while ( !tc.EndOfLine ) {
61+
if ( tc.Char() == '\\' ) {
62+
// skip over escape sequences
63+
tc.Skip(2);
64+
} else if ( tc.Char() == '\'' ) {
65+
tc.Next();
66+
break;
67+
} else {
68+
tc.Next();
69+
}
70+
}
71+
this.status = stText;
72+
}
73+
74+
private void ParseMultilineComment(ITextChars tc) {
75+
while ( !tc.EndOfLine ) {
76+
if ( tc.Char() == '*' && tc.Char() == '/' ) {
77+
tc.Skip(2);
78+
status = stText;
79+
break;
80+
} else {
81+
tc.Next();
82+
}
83+
}
84+
}
85+
86+
private void ParseString(ITextChars tc) {
87+
while ( !tc.EndOfLine ) {
88+
if ( tc.Char() == '\"' ) {
89+
tc.Next();
90+
this.status = stText;
91+
break;
92+
} else {
93+
tc.Next();
94+
}
95+
}
96+
}
97+
}
98+
}

src/Viasfora.Languages/USql.cs

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
using System;
2+
using System.ComponentModel.Composition;
3+
using Winterdom.Viasfora.Contracts;
4+
using Winterdom.Viasfora.Languages.BraceScanners;
5+
using Winterdom.Viasfora.Languages.Sequences;
6+
using Winterdom.Viasfora.Rainbow;
7+
using Winterdom.Viasfora.Util;
8+
9+
namespace Winterdom.Viasfora.Languages {
10+
[Export(typeof(ILanguage))]
11+
public class USql : LanguageInfo {
12+
13+
static readonly String[] QUERY = {
14+
"select", "extract", "process", "reduce", "combine",
15+
"produce", "using", "output", "from"
16+
};
17+
static readonly String[] VISIBILITY = {
18+
"readonly"
19+
};
20+
21+
public override String KeyName {
22+
get { return Constants.USql; }
23+
}
24+
25+
protected override String[] ControlFlowDefaults {
26+
get { return EMPTY; }
27+
}
28+
29+
protected override String[] LinqDefaults {
30+
get { return QUERY; }
31+
}
32+
33+
protected override string[] VisibilityDefaults {
34+
get { return VISIBILITY; }
35+
}
36+
37+
protected override String[] SupportedContentTypes {
38+
get { return new String[] { "U-SQL" }; }
39+
}
40+
41+
protected override IBraceScanner NewBraceScanner() {
42+
return new USqlBraceScanner();
43+
}
44+
public override IStringScanner NewStringScanner(string text) {
45+
return new CSharpStringScanner(text);
46+
}
47+
48+
[ImportingConstructor]
49+
public USql(IVsfSettings settings) : base(settings) {
50+
}
51+
}
52+
}

src/Viasfora.Languages/Viasfora.Languages.csproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
<Compile Include="BraceScanners\PythonBraceScanner.cs" />
6161
<Compile Include="BraceScanners\RBraceScanner.cs" />
6262
<Compile Include="BraceScanners\SqlBraceScanner.cs" />
63+
<Compile Include="BraceScanners\USqlBraceScanner.cs" />
6364
<Compile Include="BraceScanners\VbBraceScanner.cs" />
6465
<Compile Include="CBasedLanguage.cs" />
6566
<Compile Include="CommentParsers\GenericCommentParser.cs" />
@@ -85,6 +86,7 @@
8586
<Compile Include="Sequences\RStringScanner.cs" />
8687
<Compile Include="Sql.cs" />
8788
<Compile Include="TypeScript.cs" />
89+
<Compile Include="USql.cs" />
8890
<Compile Include="VB.cs" />
8991
<Compile Include="XLang.cs" />
9092
</ItemGroup>
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
using System;
2+
3+
namespace Winterdom.Viasfora.Rainbow {
4+
public interface IBraceStacker {
5+
int Count(char brace);
6+
BracePos Push(CharPos brace);
7+
BracePos Pop(char brace);
8+
BracePos Peek(char brace);
9+
}
10+
}

src/Viasfora.Rainbow/IRainbowSettings.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ public interface IRainbowSettings : IUpdatableSettings {
77
long RainbowCtrlTimer { get; set; }
88
RainbowHighlightMode RainbowHighlightMode { get; set; }
99
bool RainbowToolTipsEnabled { get; set; }
10+
RainbowColoringMode RainbowColoringMode { get; set; }
1011
void Save();
1112
}
1213
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
using System;
2+
using System.Collections.Generic;
3+
4+
namespace Winterdom.Viasfora.Rainbow {
5+
public class PerBraceStacker : IBraceStacker {
6+
private String braceList;
7+
private Dictionary<char, Stack<BracePos>> stack;
8+
9+
public PerBraceStacker(String braceList) {
10+
this.braceList = braceList;
11+
this.stack = new Dictionary<char, Stack<BracePos>>();
12+
for ( int i=0; i < braceList.Length; i += 2 ) {
13+
var pairs = new Stack<BracePos>();
14+
this.stack[braceList[i]] = pairs;
15+
this.stack[braceList[i + 1]] = pairs;
16+
}
17+
}
18+
public int Count(char brace) {
19+
return stack[brace].Count;
20+
}
21+
22+
public BracePos Pop(char brace) {
23+
return stack[brace].Pop();
24+
}
25+
public BracePos Peek(char brace) {
26+
return stack[brace].Peek();
27+
}
28+
29+
public BracePos Push(CharPos brace) {
30+
var pairs = stack[brace.Char];
31+
var bp = brace.AsBrace(pairs.Count);
32+
pairs.Push(bp);
33+
return bp;
34+
}
35+
}
36+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
using System;
2+
3+
namespace Winterdom.Viasfora.Rainbow {
4+
public enum RainbowColoringMode {
5+
Unified = 0,
6+
PerBrace = 1
7+
}
8+
}

0 commit comments

Comments
 (0)