-
Notifications
You must be signed in to change notification settings - Fork 91
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
26 changed files
with
539 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
using System; | ||
using Winterdom.Viasfora.Rainbow; | ||
using Winterdom.Viasfora.Util; | ||
|
||
namespace Winterdom.Viasfora.Languages.BraceScanners { | ||
public class USqlBraceScanner : IBraceScanner { | ||
const int stText = 0; | ||
const int stString = 1; | ||
const int stMultiLineComment = 4; | ||
private int status = stText; | ||
|
||
public string BraceList { | ||
get { return "()[]{}"; } | ||
} | ||
|
||
public void Reset(int state) { | ||
status = stText; | ||
} | ||
public bool Extract(ITextChars tc, ref CharPos pos) { | ||
pos = CharPos.Empty; | ||
while ( !tc.EndOfLine ) { | ||
switch ( status ) { | ||
case stString: ParseString(tc); break; | ||
case stMultiLineComment: ParseMultilineComment(tc); break; | ||
default: | ||
return ParseText(tc, ref pos); | ||
} | ||
} | ||
return false; | ||
} | ||
|
||
private bool ParseText(ITextChars tc, ref CharPos pos) { | ||
while ( !tc.EndOfLine ) { | ||
if ( tc.Char() == '/' && tc.NChar() == '*' ) { | ||
tc.Skip(2); | ||
status = stMultiLineComment; | ||
ParseMultilineComment(tc); | ||
} else if ( tc.Char() == '/' && tc.NChar() == '/' ) { | ||
tc.SkipRemainder(); | ||
} else if ( tc.Char() == '\'' ) { | ||
status = stString; | ||
tc.Next(); | ||
ParseCharLiteral(tc); | ||
} else if ( tc.Char() == '"' ) { | ||
status = stString; | ||
tc.Next(); | ||
ParseString(tc); | ||
} else if ( this.BraceList.IndexOf(tc.Char()) >= 0 ) { | ||
pos = new CharPos(tc.Char(), tc.AbsolutePosition); | ||
tc.Next(); | ||
return true; | ||
} else { | ||
tc.Next(); | ||
} | ||
} | ||
return false; | ||
} | ||
|
||
private void ParseCharLiteral(ITextChars tc) { | ||
while ( !tc.EndOfLine ) { | ||
if ( tc.Char() == '\\' ) { | ||
// skip over escape sequences | ||
tc.Skip(2); | ||
} else if ( tc.Char() == '\'' ) { | ||
tc.Next(); | ||
break; | ||
} else { | ||
tc.Next(); | ||
} | ||
} | ||
this.status = stText; | ||
} | ||
|
||
private void ParseMultilineComment(ITextChars tc) { | ||
while ( !tc.EndOfLine ) { | ||
if ( tc.Char() == '*' && tc.Char() == '/' ) { | ||
tc.Skip(2); | ||
status = stText; | ||
break; | ||
} else { | ||
tc.Next(); | ||
} | ||
} | ||
} | ||
|
||
private void ParseString(ITextChars tc) { | ||
while ( !tc.EndOfLine ) { | ||
if ( tc.Char() == '\"' ) { | ||
tc.Next(); | ||
this.status = stText; | ||
break; | ||
} else { | ||
tc.Next(); | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
using System; | ||
using System.ComponentModel.Composition; | ||
using Winterdom.Viasfora.Contracts; | ||
using Winterdom.Viasfora.Languages.BraceScanners; | ||
using Winterdom.Viasfora.Languages.Sequences; | ||
using Winterdom.Viasfora.Rainbow; | ||
using Winterdom.Viasfora.Util; | ||
|
||
namespace Winterdom.Viasfora.Languages { | ||
[Export(typeof(ILanguage))] | ||
public class USql : LanguageInfo { | ||
|
||
static readonly String[] QUERY = { | ||
"select", "extract", "process", "reduce", "combine", | ||
"produce", "using", "output", "from" | ||
}; | ||
static readonly String[] VISIBILITY = { | ||
"readonly" | ||
}; | ||
|
||
public override String KeyName { | ||
get { return Constants.USql; } | ||
} | ||
|
||
protected override String[] ControlFlowDefaults { | ||
get { return EMPTY; } | ||
} | ||
|
||
protected override String[] LinqDefaults { | ||
get { return QUERY; } | ||
} | ||
|
||
protected override string[] VisibilityDefaults { | ||
get { return VISIBILITY; } | ||
} | ||
|
||
protected override String[] SupportedContentTypes { | ||
get { return new String[] { "U-SQL" }; } | ||
} | ||
|
||
protected override IBraceScanner NewBraceScanner() { | ||
return new USqlBraceScanner(); | ||
} | ||
public override IStringScanner NewStringScanner(string text) { | ||
return new CSharpStringScanner(text); | ||
} | ||
|
||
[ImportingConstructor] | ||
public USql(IVsfSettings settings) : base(settings) { | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
using System; | ||
|
||
namespace Winterdom.Viasfora.Rainbow { | ||
public interface IBraceStacker { | ||
int Count(char brace); | ||
BracePos Push(CharPos brace); | ||
BracePos Pop(char brace); | ||
BracePos Peek(char brace); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
|
||
namespace Winterdom.Viasfora.Rainbow { | ||
public class PerBraceStacker : IBraceStacker { | ||
private String braceList; | ||
private Dictionary<char, Stack<BracePos>> stack; | ||
|
||
public PerBraceStacker(String braceList) { | ||
this.braceList = braceList; | ||
this.stack = new Dictionary<char, Stack<BracePos>>(); | ||
for ( int i=0; i < braceList.Length; i += 2 ) { | ||
var pairs = new Stack<BracePos>(); | ||
this.stack[braceList[i]] = pairs; | ||
this.stack[braceList[i + 1]] = pairs; | ||
} | ||
} | ||
public int Count(char brace) { | ||
return stack[brace].Count; | ||
} | ||
|
||
public BracePos Pop(char brace) { | ||
return stack[brace].Pop(); | ||
} | ||
public BracePos Peek(char brace) { | ||
return stack[brace].Peek(); | ||
} | ||
|
||
public BracePos Push(CharPos brace) { | ||
var pairs = stack[brace.Char]; | ||
var bp = brace.AsBrace(pairs.Count); | ||
pairs.Push(bp); | ||
return bp; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
using System; | ||
|
||
namespace Winterdom.Viasfora.Rainbow { | ||
public enum RainbowColoringMode { | ||
Unified = 0, | ||
PerBrace = 1 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.