-
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.
Merge pull request #289 from tomasr/develop
v4.3 release merge
- Loading branch information
Showing
29 changed files
with
465 additions
and
117 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
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,81 @@ | ||
using System; | ||
using Winterdom.Viasfora.Rainbow; | ||
using Winterdom.Viasfora.Util; | ||
|
||
namespace Winterdom.Viasfora.Languages.BraceScanners { | ||
public class MplBraceScanner : IBraceScanner { | ||
private enum State { | ||
Text, MultiLineString | ||
} | ||
|
||
private State status = State.Text; | ||
|
||
public String BraceList => "(){}[]:;"; | ||
|
||
public MplBraceScanner() { | ||
} | ||
|
||
public void Reset(int state) { | ||
this.status = (int)State.Text; | ||
} | ||
|
||
public bool Extract(ITextChars tc, ref CharPos pos) { | ||
while ( !tc.AtEnd ) { | ||
switch ( this.status ) { | ||
case State.MultiLineString: String(tc); break; | ||
default: | ||
return Parse(tc, ref pos); | ||
} | ||
} | ||
return false; | ||
} | ||
|
||
private bool Parse(ITextChars tc, ref CharPos pos) { | ||
while ( !tc.AtEnd ) { | ||
// Comment. | ||
if ( tc.Char() == '#' ) { | ||
tc.SkipRemainder(); | ||
} | ||
|
||
// String. | ||
else if ( tc.Char() == '"' ) { | ||
tc.Next(); | ||
|
||
this.status = State.MultiLineString; | ||
this.String(tc); | ||
|
||
continue; | ||
} | ||
|
||
// Braces. | ||
else if ( this.BraceList.IndexOf(tc.Char()) >= 0 ) { | ||
pos = new CharPos(tc.Char(), tc.AbsolutePosition); | ||
tc.Next(); | ||
return true; | ||
} | ||
|
||
// Code. | ||
tc.Next(); | ||
} | ||
return false; | ||
} | ||
|
||
private void String(ITextChars tc) { | ||
while ( !tc.AtEnd ) { | ||
// End of a String. | ||
if ( tc.Char() == '"' ) { | ||
tc.Next(); | ||
this.status = State.Text; | ||
return; | ||
} | ||
|
||
// Start of an Escape Sequence. | ||
if ( tc.Char() == '\\' ) | ||
tc.Next(); | ||
|
||
// Content of a String, or an Escaped Character. | ||
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
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,7 @@ | ||
using System; | ||
|
||
namespace Winterdom.Viasfora.Languages { | ||
public interface ILanguageWithStrings : ILanguage { | ||
bool IsStringClassification(String classificationType); | ||
} | ||
} |
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,53 @@ | ||
using System; | ||
using System.ComponentModel.Composition; | ||
using Winterdom.Viasfora.Languages.BraceScanners; | ||
using Winterdom.Viasfora.Languages.Sequences; | ||
using Winterdom.Viasfora.Rainbow; | ||
using Winterdom.Viasfora.Settings; | ||
using Winterdom.Viasfora.Util; | ||
|
||
namespace Winterdom.Viasfora.Languages { | ||
[Export(typeof(ILanguage))] | ||
public class Mpl : LanguageInfo, ILanguageWithStrings { | ||
public const String ContentType = "MPL"; | ||
|
||
public override StringComparer Comparer => StringComparer.Ordinal; | ||
protected override String[] SupportedContentTypes | ||
=> new String[] { ContentType }; | ||
|
||
public ILanguageSettings Settings { get; private set; } | ||
|
||
[ImportingConstructor] | ||
public Mpl(ITypedSettingsStore store) { | ||
this.Settings = new MplSettings(store); | ||
} | ||
|
||
protected override IBraceScanner NewBraceScanner() | ||
=> new MplBraceScanner(); | ||
|
||
public override IStringScanner NewStringScanner(String classificationName, String text) { | ||
return new MplStringScanner(text); | ||
} | ||
|
||
public override bool IsKeywordClassification(String classificationType) { | ||
var comp = StringComparer.OrdinalIgnoreCase; | ||
return comp.Equals(classificationType, "MplBuiltin"); | ||
} | ||
public bool IsStringClassification(String classificationType) { | ||
var comp = StringComparer.OrdinalIgnoreCase; | ||
return comp.Equals(classificationType, "MplText"); | ||
} | ||
} | ||
|
||
class MplSettings : LanguageSettings { | ||
protected override String[] ControlFlowDefaults => new String[] { | ||
"call", "loop", "if", "ucall", "uif" | ||
}; | ||
protected override String[] LinqDefaults => EMPTY; | ||
protected override String[] VisibilityDefaults => EMPTY; | ||
|
||
public MplSettings(ITypedSettingsStore store) | ||
: base(Langs.Mpl, store) { | ||
} | ||
} | ||
} |
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,34 @@ | ||
using System; | ||
using Winterdom.Viasfora.Util; | ||
|
||
namespace Winterdom.Viasfora.Languages.Sequences { | ||
public class MplStringScanner : IStringScanner { | ||
protected ITextChars text; | ||
public MplStringScanner(String text) { | ||
this.text = new StringChars(text, 0, text.Length - 1); | ||
} | ||
public StringPart? Next() { | ||
while ( !this.text.AtEnd ) { | ||
if ( this.text.Char() == '\\' ) { | ||
return ParseEscapeSequence(this.text); | ||
} | ||
this.text.Next(); | ||
} | ||
return null; | ||
} | ||
|
||
private StringPart? ParseEscapeSequence(ITextChars text) { | ||
// text.Char() == \ | ||
int start = text.Position; | ||
text.Next(); | ||
|
||
char f = text.Char(); | ||
text.Next(); | ||
if ( f == '\\' || f == '\"' ) { | ||
var span = new TextSpan(start, 2); | ||
return new StringPart(span, StringPartType.EscapeSequence); | ||
} | ||
return null; | ||
} | ||
} | ||
} |
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.