Skip to content

Commit

Permalink
normalize line endings for test & masters as git interferes otherwise.
Browse files Browse the repository at this point in the history
  • Loading branch information
erikeidt committed Mar 8, 2019
1 parent e9dc404 commit 2194e01
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 4 deletions.
18 changes: 18 additions & 0 deletions src/1. Token Scanner/Token Scanner Library/ScanIt.cs
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,9 @@ public void Advance ()

public bool IsEOF ()
{
if ( _identifierPushedBack.HasValue )
return false;

Trim ();
return _curr.AtEOF ();
}
Expand All @@ -216,6 +219,9 @@ public bool WhiteSpace ()

private bool Trim ()
{
if ( _identifierPushedBack.HasValue )
return false;

var ans = false;
for ( ; ; )
{
Expand Down Expand Up @@ -569,6 +575,9 @@ public ByteString GetStringLiteral ()

public bool IfTokenNoAdvance ( char what )
{
if ( _identifierPushedBack.HasValue )
return false;

Trim ();
if ( _curr.Value != what )
return false;
Expand All @@ -589,6 +598,9 @@ public bool IfTokenNoAdvance ( char what )
/// </returns>
public bool IfToken ( char what )
{
if ( _identifierPushedBack.HasValue )
return false;

Trim ();
if ( _curr.Value != what )
return false;
Expand All @@ -610,6 +622,9 @@ public bool IfToken ( char what )
/// </returns>
public bool IfCharacter ( char what ) //
{
if ( _identifierPushedBack.HasValue )
return false;

if ( _curr.Value != what )
return false;
Advance ();
Expand All @@ -625,6 +640,9 @@ public bool IfCharacter ( char what ) //
public void ExpectToken ( char what )
{
Trim ();
if ( _identifierPushedBack.HasValue )
Error ( "Expected character: '" + what + "' instead of identifier" );

if ( _curr.Value != what ) {
var val = unchecked((char) _curr.Value);
Error ( "Expected character: '" + what + "' instead of: '" + val + "'" );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public StringTreeNode ( UnicodeUtf8.ByteString stringLiteral )

public override void PrettyPrintHeader ( string prolog = "" )
{
WriteLine ( string.Format ( "string: \"{0}\"", Value ), prolog );
WriteLine ( string.Format ( "string: \"{0}\"", Value.ToString().Replace("\n", "\r\n" ) ), prolog );
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/3. Expression Parser/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ void Test ( int testNum, string exprToParse, int terminatingChar = -1 )
var testName = string.Format ( "results-test-{0}.txt", testNum );
using ( var tw = File.CreateText ( _testDir + testName ) ) {
string tc = terminatingChar >= 0 ? ((char) terminatingChar).ToString () : "";
tw.WriteLine ( "------ Test: {0} ------\t{1}\t{2}", testNum, tc, exprToParse );
tw.WriteLine ( "------ Test: {0} ------\t{1}\t{2}", testNum, tc, exprToParse.Replace ("\n", "\r\n") );
tw.WriteLine ();
var utf8Stream = CodePointStream.FromString ( exprToParse );
var scanner = new ScanIt ( utf8Stream, testName, tw );
Expand Down
2 changes: 1 addition & 1 deletion src/4. Statement Parser/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ void Test ( int testNum, string exprToParse, int terminatingChar = -1 )
var testName = string.Format ( "results-test-{0}.txt", testNum );
using ( var tw = File.CreateText ( _testDir + testName ) ) {
string tc = terminatingChar >= 0 ? ((char) terminatingChar).ToString () : "";
tw.WriteLine ( "------ Test: {0} ------\t{1}\t{2}", testNum, tc, exprToParse );
tw.WriteLine ( "------ Test: {0} ------\t{1}\t{2}", testNum, tc, exprToParse.Replace("\n", "\r\n" ) );
tw.WriteLine ();
var utf8Stream = CodePointStream.FromString ( exprToParse );
var scanner = new ScanIt ( utf8Stream, testName, tw );
Expand Down
2 changes: 1 addition & 1 deletion src/6. Code Generator/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ void Test ( int testNum, string exprToParse, int terminatingChar = -1 )
var testName = string.Format ( "results-test-{0}.txt", testNum );
using ( var tw = File.CreateText ( _testDir + testName ) ) {
string tc = terminatingChar >= 0 ? ((char) terminatingChar).ToString () : "";
tw.WriteLine ( "------ Test: {0} ------\t{1}\t{2}", testNum, tc, exprToParse );
tw.WriteLine ( "------ Test: {0} ------\t{1}\t{2}", testNum, tc, exprToParse.Replace("\n", "\r\n" ) );
tw.WriteLine ();
var utf8Stream = CodePointStream.FromString ( exprToParse );
var scanner = new ScanIt ( utf8Stream, testName, tw );
Expand Down

0 comments on commit 2194e01

Please sign in to comment.