Skip to content

Commit

Permalink
made line separator configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
GeorgRottensteiner committed Jun 3, 2019
1 parent 87d30f4 commit 897b939
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 102 deletions.
103 changes: 2 additions & 101 deletions C64Models/Parser/ASMFileParser.cs
Expand Up @@ -3360,10 +3360,6 @@ private string GetLoopGUID( List<Types.ScopeInfo> Scopes )

public List<Types.TokenInfo> PrepareLineTokens( string Line )
{
if ( Line.Contains( "(SCREEN)" ) )
{
Debug.Log( "aha" );
}
List<Types.TokenInfo> lineTokenInfos = ParseTokenInfo( Line, 0, Line.Length );
if ( HasError() )
{
Expand Down Expand Up @@ -9075,101 +9071,6 @@ private ParseLineResult PORepeat( List<TokenInfo> lineTokenInfos, int lineIndex,

//Debug.Log( "New total " + Lines.Length + " lines" );
return ParseLineResult.CALL_CONTINUE;

/*
ScopeInfo scope = new ScopeInfo( ScopeInfo.ScopeType.REPEAT );
scope.Active = true;
scope.StartIndex = lineIndex;
Scopes.Add( scope );
OnScopeAdded( scope );*/

// repeat next line x times


/*
bool doesContainSeparator = false;
int numSeparators = 0;
for ( int tokenIndex = 0; tokenIndex < lineTokenInfos.Count; ++tokenIndex )
{
var token = lineTokenInfos[tokenIndex];
if ( ( token.Type == C64Studio.Types.TokenInfo.TokenType.SEPARATOR )
&& ( token.Content == "," ) )
{
doesContainSeparator = true;
++numSeparators;
}
}
if ( doesContainSeparator )
{
string[] newLines = new string[numSeparators + 1];
int partStartIndex = 0;
int partIndex = 0;
for ( int tokenIndex = 0; tokenIndex < lineTokenInfos.Count; ++tokenIndex )
{
var token = lineTokenInfos[tokenIndex];
if ( ( token.Type == C64Studio.Types.TokenInfo.TokenType.SEPARATOR )
&& ( token.Content == ":" ) )
{
newLines[partIndex] = TokensToExpression( lineTokenInfos, partStartIndex, tokenIndex - partStartIndex );
partStartIndex = tokenIndex + 1;
++partIndex;
}
}
if ( partStartIndex < lineTokenInfos.Count )
{
newLines[partIndex] = TokensToExpression( lineTokenInfos, partStartIndex, lineTokenInfos.Count - partStartIndex );
}
// if any part was null, set to empty
for ( int i = 0; i < newLines.Length; ++i )
{
if ( newLines[i] == null )
{
newLines[i] = "";
}
}
Types.ASM.SourceInfo sourceInfo = new Types.ASM.SourceInfo();
sourceInfo.Filename = ParentFilename;
sourceInfo.FullPath = ParentFilename;
sourceInfo.GlobalStartLine = lineIndex;
sourceInfo.LineCount = newLines.Length;
sourceInfo.FilenameParent = ParentFilename;
string dummyFile = "";
int localFileIndex = -1;
ASMFileInfo.FindTrueLineSource( lineIndex, out dummyFile, out localFileIndex );
sourceInfo.LocalStartLine = localFileIndex;
SourceInfoLog( "-include at global index " + lineIndex );
SourceInfoLog( "-has " + sourceInfo.LineCount + " lines" );
InsertSourceInfo( sourceInfo, true, true );
string[] result = new string[Lines.Length + sourceInfo.LineCount];
System.Array.Copy( Lines, 0, result, 0, lineIndex + 1 );
System.Array.Copy( newLines, 0, result, lineIndex + 1, newLines.Length );
// this keeps the !source line in the final code, makes working with source infos easier though
System.Array.Copy( Lines, lineIndex + 1, result, lineIndex + newLines.Length + 1, Lines.Length - lineIndex - 1 );
// replace !source with empty line (otherwise source infos would have one line more!)
//result[lineIndex + newLines.Length] = "";
result[lineIndex] = "";
Lines = result;
ASMFileInfo.LineInfo.Remove( lineIndex );
--lineIndex;
return ParseLineResult.CALL_CONTINUE;
}*/
//return ParseLineResult.OK;
}


Expand Down Expand Up @@ -9272,7 +9173,7 @@ private ParseLineResult HandleLineSeparators( ref int lineIndex, List<TokenInfo>
var token = lineTokenInfos[tokenIndex];

if ( ( token.Type == C64Studio.Types.TokenInfo.TokenType.SEPARATOR )
&& ( token.Content == ":" ) )
&& ( m_AssemblerSettings.LineSeparatorChars.Contains( token.Content ) ) )
{
doesContainSeparator = true;
++numSeparators;
Expand All @@ -9289,7 +9190,7 @@ private ParseLineResult HandleLineSeparators( ref int lineIndex, List<TokenInfo>
var token = lineTokenInfos[tokenIndex];

if ( ( token.Type == C64Studio.Types.TokenInfo.TokenType.SEPARATOR )
&& ( token.Content == ":" ) )
&& ( m_AssemblerSettings.LineSeparatorChars.Contains( token.Content ) ) )
{
newLines[partIndex] = TokensToExpression( lineTokenInfos, partStartIndex, tokenIndex - partStartIndex );
partStartIndex = tokenIndex + 1;
Expand Down
14 changes: 13 additions & 1 deletion C64Models/Parser/AssemblerSettings.cs
Expand Up @@ -13,6 +13,7 @@ public class AssemblerSettings
public string AllowedSingleTokens;
public string OpenBracketChars = "";
public string CloseBracketChars = "";
public string LineSeparatorChars = "";
public GR.Collections.Map<string, Types.MacroInfo> Macros = new GR.Collections.Map<string, Types.MacroInfo>();
public string MacroPrefix = "";
public string LabelPostfix = "";
Expand Down Expand Up @@ -110,6 +111,8 @@ public void SetAssemblerType( Types.AssemblerType Type )
OpenBracketChars = "(" + INTERNAL_OPENING_BRACE;
CloseBracketChars = ")" + INTERNAL_CLOSING_BRACE;

LineSeparatorChars = ":";

AllowedTokenStartChars[Types.TokenInfo.TokenType.LABEL_LOCAL] = ".";
AllowedTokenChars[Types.TokenInfo.TokenType.LABEL_LOCAL] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_äöüÄÖÜß.";
AllowedTokenStartChars[Types.TokenInfo.TokenType.LABEL_CHEAP_LOCAL] = "@";
Expand Down Expand Up @@ -281,7 +284,7 @@ public void SetAssemblerType( Types.AssemblerType Type )
OpenBracketChars = "([" + INTERNAL_OPENING_BRACE;
CloseBracketChars = ")]" + INTERNAL_CLOSING_BRACE;

AllowedTokenStartChars[Types.TokenInfo.TokenType.LABEL_LOCAL] = "!";
AllowedTokenStartChars[Types.TokenInfo.TokenType.LABEL_LOCAL] = "!:";
AllowedTokenChars[Types.TokenInfo.TokenType.LABEL_LOCAL] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_äöüÄÖÜß!";

// we misuse cheap labels as macro parameters
Expand Down Expand Up @@ -343,6 +346,15 @@ public void SetAssemblerType( Types.AssemblerType Type )
AddMacro( "SKIP", Types.MacroInfo.MacroType.IGNORE );
AddMacro( "INFO", Types.MacroInfo.MacroType.IGNORE );
AddMacro( "RUN", Types.MacroInfo.MacroType.IGNORE );

AddMacro( "EXEC", Types.MacroInfo.MacroType.IGNORE );
AddMacro( "START", Types.MacroInfo.MacroType.IGNORE );

AddMacro( "DSECT", Types.MacroInfo.MacroType.IGNORE );
AddMacro( "DEND", Types.MacroInfo.MacroType.IGNORE );

AddMacro( "MSW", Types.MacroInfo.MacroType.IGNORE );

AddMacro( "END", Types.MacroInfo.MacroType.END_OF_FILE );
AddMacro( "REPEAT", Types.MacroInfo.MacroType.REPEAT );

Expand Down
Binary file added OtherAssemblersDoc/P.D.S._Manual_Z80.pdf
Binary file not shown.

0 comments on commit 897b939

Please sign in to comment.