Skip to content

Commit

Permalink
v3.5.8
Browse files Browse the repository at this point in the history
  • Loading branch information
Randy Hollines committed Jan 23, 2017
1 parent 23f8ffa commit 0ff91ed
Show file tree
Hide file tree
Showing 10 changed files with 304 additions and 241 deletions.
Binary file modified docs/api.zip
Binary file not shown.
Binary file modified docs/readme.docx
Binary file not shown.
23 changes: 15 additions & 8 deletions docs/readme.htm
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,8 @@ <h1><span style='font-size:24.0pt;line-height:107%;font-family:"Agency FB",sans-
<h2><span style='font-size:12.0pt;line-height:107%'>Release notes</span></h2>

<p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:
normal;text-autospace:none'><span style='font-family:"Calibri",sans-serif'>Bug
fixes and minor enhancements.</span></p>
normal;text-autospace:none'><span style='font-family:"Calibri",sans-serif'>Organized
the distribution and made minor bug fixes.</span></p>

<p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:
normal;text-autospace:none'><span style='font-family:"Calibri",sans-serif'>&nbsp;</span></p>
Expand All @@ -180,18 +180,25 @@ <h2><span style='font-size:12.0pt;line-height:107%'>Release notes</span></h2>
<p class=MsoListParagraphCxSpFirst style='margin-bottom:0in;margin-bottom:.0001pt;
text-indent:-.25in;line-height:normal;text-autospace:none'><span
style='font-family:"Calibri",sans-serif'>1.<span style='font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span></span><span style='font-family:"Calibri",sans-serif'>Revamped the code
</span></span><span style='font-family:"Calibri",sans-serif'>Revamped code
examples (new)</span></p>

<p class=MsoListParagraphCxSpMiddle style='margin-bottom:0in;margin-bottom:
.0001pt;text-indent:-.25in;line-height:normal;text-autospace:none'><span
style='font-family:"Calibri",sans-serif'>2.<span style='font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span></span><span style='font-family:"Calibri",sans-serif'>Simplified the layout
of files and directories (new)</span></p>
</span></span><span style='font-family:"Calibri",sans-serif'>Simplified the
layout of files and directories (new)</span></p>

<p class=MsoListParagraphCxSpMiddle style='margin-bottom:0in;margin-bottom:
.0001pt;text-indent:-.25in;line-height:normal;text-autospace:none'><span
style='font-family:"Calibri",sans-serif'>3.<span style='font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span></span><span style='font-family:"Calibri",sans-serif'>Modified
&quot;FileReader-&gt;ReadString()&quot; to handle different platform newline
differences (bug/minor)</span></p>

<p class=MsoListParagraphCxSpLast style='margin-bottom:0in;margin-bottom:.0001pt;
text-indent:-.25in;line-height:normal;text-autospace:none'><span
style='font-family:"Calibri",sans-serif'>3.<span style='font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
style='font-family:"Calibri",sans-serif'>4.<span style='font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span></span><span style='font-family:"Calibri",sans-serif'>Fixed a compiler
contextual check for certain types of method calls (bug/minor)</span></p>

Expand Down Expand Up @@ -325,8 +332,8 @@ <h2><span style='font-size:12.0pt;line-height:107%'>Compiling and executing

<p class=MsoNormal style='margin-top:0in;margin-right:0in;margin-bottom:0in;
margin-left:.5in;margin-bottom:.0001pt;text-indent:-.25in;line-height:normal;
text-autospace:none'><span style='font-family:"Calibri",sans-serif'>2.    obr xml.obe
</span></p>
text-autospace:none'><span style='font-family:"Calibri",sans-serif'>2.    obr
xml.obe </span></p>

<p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:
normal;text-autospace:none'><span style='font-family:"Calibri",sans-serif'>&nbsp;</span></p>
Expand Down
20 changes: 15 additions & 5 deletions src/compiler/prgms/tiny/compiler/emitter.obs
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,10 @@ class Emitter {
leaving {
out->Close();
};

Strings(out);
Statements(@statements);



each(i : @instructions) {
instruction := @instructions->Get(i)->As(Instruction);
select(instruction->GetType()) {
Expand Down Expand Up @@ -146,7 +144,6 @@ class Emitter {
}

label ParseNode->Type->IF: {
start := @code_index;
if(<>Expression(node->GetLeft())) {
return false;
};
Expand All @@ -156,7 +153,20 @@ class Emitter {
if(<>Statements(node->GetStatements())) {
return false;
};
cond_jmp->SetValue(@code_index);

if(node->GetRight() = Nil) {
cond_jmp->SetValue(@code_index);
};

if(node->GetRight() <> Nil) {
cond_jmp->SetValue(@code_index + 1);
cond_jmp := Instruction->New(Instruction->Type->JP);
@instructions->AddBack(cond_jmp);
if(<>Statements(node->GetRight()->GetStatements())) {
return false;
};
cond_jmp->SetValue(@code_index + 1);
};
}

label ParseNode->Type->WHILE: {
Expand Down
46 changes: 38 additions & 8 deletions src/compiler/prgms/tiny/compiler/parser.obs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class Parser {
};

if(<>Match(Token->Type->ASGN)) {
"*** Expected '=' ***"->ErrorLine();
"*** Expected '=' or statement ***"->ErrorLine();
return Nil;
};
NextToken();
Expand Down Expand Up @@ -100,10 +100,39 @@ class Parser {
label Token->Type->IF: {
node := ParseNode->New(ParseNode->Type->IF);
NextToken();

if(<>ConditionalStatement(node)) {
return Nil;
};

if(Match(Token->Type->ELSE)) {
NextToken();

if(<>Match(Token->Type->OCBRACE)) {
"*** Expected '{' ***"->ErrorLine();
return Nil;
};
NextToken();

statements := Vector->New();
while(GetToken()->GetType() <> Token->Type->EOS & GetToken()->GetType() <> Token->Type->CCBRACE) {
statement := Statement();
if(statement = Nil) {
return Nil;
};
statements->AddBack(statement);
};

if(<>Match(Token->Type->CCBRACE)) {
"*** Expected '}' ***"->ErrorLine();
return Nil;
};
NextToken();

right := ParseNode->New(ParseNode->Type->IF);
right->SetStatements(statements);
node->SetRight(right);
};
}

label Token->Type->PRINT: {
Expand Down Expand Up @@ -204,7 +233,7 @@ class Parser {
return false;
};
NextToken();

left := Expression();
if(left = Nil) {
return false;
Expand Down Expand Up @@ -237,8 +266,8 @@ class Parser {
return false;
};
NextToken();
node->SetStatements(statements);

node->SetStatements(statements);
return true;
}

Expand Down Expand Up @@ -320,12 +349,12 @@ class Parser {
}
else if(Match(Token->Type->EQL)) {
NextToken();

right := Expression();
if(right = Nil) {
return Nil;
};

return ParseNode->New(ParseNode->Type->EQL, left, right);
}
else if(Match(Token->Type->NEQL)) {
Expand Down Expand Up @@ -456,7 +485,8 @@ class Parser {
}

other: {
"*** Invalid expression ***"->ErrorLine();
code := GetToken()->GetType()->As(Int);
"*** Invalid expression: {$code} ***"->ErrorLine();
return Nil;
}
};
Expand Down
3 changes: 2 additions & 1 deletion src/compiler/prgms/tiny/compiler/scanner.obs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class Scanner {
reserved := StringMap->New();
reserved->Insert("while", Token->New(Token->Type->WHILE, "while"));
reserved->Insert("if", Token->New(Token->Type->IF, "if"));
reserved->Insert("else", Token->New(Token->Type->ELSE, "else")); # TODO
reserved->Insert("else", Token->New(Token->Type->ELSE, "else"));
reserved->Insert("print", Token->New(Token->Type->PRINT, "print"));
reserved->Insert("put", Token->New(Token->Type->PUT, "put"));

Expand Down Expand Up @@ -197,6 +197,7 @@ class Scanner {

other: {
System.IO.Console->Print("*** Invalid token: char='")->Print(line->Get(i))->PrintLine("' ***");
System.Runtime->Exit(1);
}
};
i += 1;
Expand Down
10 changes: 10 additions & 0 deletions src/compiler/prgms/tiny/programs/test.t
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
a = 3;
b = a - -3;
print(b, "\n");

if(b == 6) {
put "foo\n";
b = b * 100;
}
else {
put "bar\n";
b = b + 13;
}
print( "done = ", b , "\n");
2 changes: 2 additions & 0 deletions src/compiler/prgms/tiny/readme.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
version of a "tiny" language
rc: http://rosettacode.org/wiki/Compiler/syntax_analyzer
2 changes: 1 addition & 1 deletion src/compiler/prgms/tiny/vm/interpreter.obs
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ class Interpreter {
@strings := String->New[string_count];
for(i := 0; i < string_count; i += 1;) {
string := "";
line := reader->ReadString()->Trim();
line := reader->ReadString();
each(j : line) {
c := line->Get(j);
if(c = '\\' & j + 1 < line->Size()) {
Expand Down
Loading

0 comments on commit 0ff91ed

Please sign in to comment.