-
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
28 changed files
with
265 additions
and
31 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 |
---|---|---|
@@ -1,9 +1,7 @@ | ||
using System; | ||
using Microsoft.VisualStudio.Text.Editor; | ||
|
||
namespace Winterdom.Viasfora.Tags | ||
{ | ||
public class OutliningGlyphTag : IGlyphTag | ||
{ | ||
} | ||
namespace Winterdom.Viasfora.Tags { | ||
public class OutliningGlyphTag : IGlyphTag { | ||
} | ||
} |
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
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
76 changes: 76 additions & 0 deletions
76
src/Viasfora.Languages/BraceScanners/FortranBraceScanner.cs
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,76 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using Winterdom.Viasfora.Rainbow; | ||
using Winterdom.Viasfora.Util; | ||
|
||
namespace Winterdom.Viasfora.Languages.BraceScanners { | ||
public class FortranBraceScanner : IBraceScanner { | ||
const int stText = 0; | ||
const int stStringSingle = 1; | ||
const int stStringDouble = 2; | ||
private int status = stText; | ||
|
||
public string BraceList => "()"; | ||
|
||
public void Reset(int state) { | ||
this.status = stText; | ||
} | ||
|
||
public bool Extract(ITextChars tc, ref CharPos pos) { | ||
while ( !tc.EndOfLine ) { | ||
switch ( this.status ) { | ||
case stStringSingle: ParseStringSingle(tc); break; | ||
case stStringDouble: ParseStringDouble(tc); break; | ||
default: | ||
return ParseText(tc, ref pos); | ||
} | ||
} | ||
return false; | ||
} | ||
|
||
private bool ParseText(ITextChars tc, ref CharPos pos) { | ||
while ( !tc.EndOfLine ) { | ||
if ( tc.Char() == '!' ) { | ||
// single line comment | ||
tc.SkipRemainder(); | ||
} else if ( tc.Char() == '\'' ) { | ||
this.status = stStringSingle; | ||
tc.Next(); | ||
ParseStringSingle(tc); | ||
} else if ( tc.Char() == '"' ) { | ||
this.status = stStringDouble; | ||
tc.Next(); | ||
ParseStringDouble(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 ParseStringSingle(ITextChars tc) => ParseString(tc, '\''); | ||
private void ParseStringDouble(ITextChars tc) => ParseString(tc, '"'); | ||
|
||
private void ParseString(ITextChars tc, char quote) { | ||
while ( !tc.EndOfLine ) { | ||
if ( tc.Char() == quote && tc.NChar() == quote ) { | ||
// double quote, meaning a single literal quote, skip | ||
tc.Skip(2); | ||
} else if ( tc.Char() == quote ) { | ||
tc.Next(); | ||
break; | ||
} else { | ||
tc.Next(); | ||
} | ||
} | ||
this.status = stText; | ||
} | ||
} | ||
} |
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,39 @@ | ||
using System; | ||
using System.ComponentModel.Composition; | ||
using Winterdom.Viasfora.Contracts; | ||
using Winterdom.Viasfora.Languages.BraceScanners; | ||
using Winterdom.Viasfora.Rainbow; | ||
using Winterdom.Viasfora.Settings; | ||
|
||
namespace Winterdom.Viasfora.Languages { | ||
[Export(typeof(ILanguage))] | ||
public class Fortran : LanguageInfo, ILanguage { | ||
public const String ContentType = "Fortran"; | ||
protected override String[] SupportedContentTypes | ||
=> new String[] { ContentType }; | ||
public ILanguageSettings Settings { get; private set; } | ||
|
||
[ImportingConstructor] | ||
public Fortran(ITypedSettingsStore store) { | ||
this.Settings = new FortranSettings(store); | ||
} | ||
|
||
protected override IBraceScanner NewBraceScanner() | ||
=> new FortranBraceScanner(); | ||
} | ||
|
||
class FortranSettings : LanguageSettings { | ||
protected override String[] ControlFlowDefaults => new String[] { | ||
"if", "then", "end if", "endif", "else", "call", "return", | ||
"do", "end do", "enddo", "while", "select", "end select" | ||
}; | ||
protected override String[] LinqDefaults => EMPTY; | ||
protected override String[] VisibilityDefaults => new String[] { | ||
"public", "private" | ||
}; | ||
|
||
public FortranSettings(ITypedSettingsStore store) | ||
: base (Constants.Fortran, 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
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,9 @@ | ||
using System; | ||
using System.Windows.Input; | ||
|
||
namespace Winterdom.Viasfora.Rainbow { | ||
public enum RainbowHighlightKey { | ||
LeftCtrl = (int)Key.LeftCtrl, | ||
RightCtrl = (int)Key.RightCtrl | ||
} | ||
} |
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,47 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.ComponentModel; | ||
using System.Drawing.Design; | ||
using System.Linq; | ||
using System.Runtime.InteropServices; | ||
using Microsoft.VisualStudio.Shell; | ||
using Winterdom.Viasfora.Contracts; | ||
|
||
namespace Winterdom.Viasfora.Options { | ||
[Guid(Guids.FortranOptions)] | ||
public class FortranOptionsPage : DialogPage { | ||
private ILanguage language = SettingsContext.GetLanguage(Constants.Fortran); | ||
|
||
public override void SaveSettingsToStorage() { | ||
base.SaveSettingsToStorage(); | ||
language.Settings.ControlFlow = ControlFlowKeywords.ToArray(); | ||
language.Settings.Visibility = VisibilityKeywords.ToArray(); | ||
language.Settings.Enabled = Enabled; | ||
language.Settings.Save(); | ||
} | ||
public override void LoadSettingsFromStorage() { | ||
base.LoadSettingsFromStorage(); | ||
ControlFlowKeywords = language.Settings.ControlFlow.ToList(); | ||
VisibilityKeywords = language.Settings.Visibility.ToList(); | ||
Enabled = language.Settings.Enabled; | ||
} | ||
|
||
[LocDisplayName("Enabled")] | ||
[Description("Enabled or disables all Viasfora features for this language")] | ||
public bool Enabled { get; set; } | ||
|
||
[LocDisplayName("Control Flow")] | ||
[Description("Control Flow keywords to highlight")] | ||
[Category("Fortran")] | ||
[Editor(Constants.STRING_COLLECTION_EDITOR, typeof(UITypeEditor))] | ||
[TypeConverter(typeof(Design.StringListConverter))] | ||
public List<String> ControlFlowKeywords { get; set; } | ||
|
||
[LocDisplayName("Visibility")] | ||
[Description("Visibility keywords to highlight")] | ||
[Category("Fortran")] | ||
[Editor(Constants.STRING_COLLECTION_EDITOR, typeof(UITypeEditor))] | ||
[TypeConverter(typeof(Design.StringListConverter))] | ||
public List<String> VisibilityKeywords { get; set; } | ||
} | ||
} |
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.