Skip to content

Commit

Permalink
Implemented parser
Browse files Browse the repository at this point in the history
- Implemented parser without handling of syntactic errors.
- Updated documentation;
  • Loading branch information
davidsonbrsilva committed Apr 15, 2018
1 parent 417e660 commit eaaeb03
Show file tree
Hide file tree
Showing 36 changed files with 1,562 additions and 173 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ the_bigger: (x, y)
}
}
write the_bigger(5, 6.5) // Saída: 6.5
write the_bigger(5, 6.5); // Saída: 6.5
```

Expand All @@ -214,7 +214,7 @@ is_prime: (x)
for (i: 0; i < x; i++)
{
if (x % i == 0)
if (x % i = 0)
{
count++;
Expand All @@ -228,8 +228,8 @@ is_prime: (x)
return true;
}
write is_prime(4) Saída: false
write is_prime(7) Saída: true
write is_prime(4); // Saída: false
write is_prime(7); // Saída: true
```

Expand Down
5 changes: 4 additions & 1 deletion compiler/Compiler/Compiler.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,15 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Exception\TokenNotFoundException.cs" />
<Compile Include="Exception\SyntaxErrorException.cs" />
<Compile Include="Exception\InvalidTokenException.cs" />
<Compile Include="Attributes\LexemeAttribute.cs" />
<Compile Include="Enum\TokenCode.cs" />
<Compile Include="LexicalAnalyzer.cs" />
<Compile Include="Parser.cs" />
<Compile Include="Parser.Util.cs" />
<Compile Include="Parser.Declarations.cs" />
<Compile Include="Parser.Verifications.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Structure\Token.cs" />
Expand Down
46 changes: 21 additions & 25 deletions compiler/Compiler/Enum/TokenCode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ public enum TokenCode
/// </summary>
[Lexeme("break")] Break,
/// <summary>
/// Addition operator.
/// Plus operator.
/// </summary>
[Lexeme("+")] Addition,
[Lexeme("+")] Plus,
/// <summary>
/// Subtraction operator.
/// Minus operator.
/// </summary>
[Lexeme("-")] Subtraction,
[Lexeme("-")] Minus,
/// <summary>
/// Multiplication operator.
/// </summary>
Expand Down Expand Up @@ -67,21 +67,21 @@ public enum TokenCode
/// </summary>
[Lexeme("for")] For,
/// <summary>
/// Code for opening bracket symbol.
/// Code for left bracket symbol.
/// </summary>
[Lexeme("{")] OpeningBracket,
[Lexeme("{")] LeftBracket,
/// <summary>
/// Code for closing bracket symbol.
/// Code for right bracket symbol.
/// </summary>
[Lexeme("}")] ClosingBracket,
[Lexeme("}")] RightBracket,
/// <summary>
/// Code for opening parenthesis symbol.
/// Code for left parenthesis symbol.
/// </summary>
[Lexeme("(")] OpeningParenthesis,
[Lexeme("(")] LeftParenthesis,
/// <summary>
/// Code for closing parenthesis symbol.
/// Code for right parenthesis symbol.
/// </summary>
[Lexeme(")")] ClosingParenthesis,
[Lexeme(")")] RightParenthesis,
/// <summary>
/// Equal operator.
/// </summary>
Expand All @@ -91,17 +91,17 @@ public enum TokenCode
/// </summary>
[Lexeme("<=")] LessOrEqual,
/// <summary>
/// Higher or equal operator.
/// Greater or equal operator.
/// </summary>
[Lexeme(">=")] HigherOrEqual,
[Lexeme(">=")] GreaterOrEqual,
/// <summary>
/// Less operator.
/// </summary>
[Lexeme("<")] Less,
/// <summary>
/// Higher operator.
/// Greater operator.
/// </summary>
[Lexeme(">")] Higher,
[Lexeme(">")] Greater,
/// <summary>
/// Different operator.
/// </summary>
Expand Down Expand Up @@ -129,35 +129,31 @@ public enum TokenCode
/// <summary>
/// Numerical value.
/// </summary>
[Lexeme("")] Number,
[Lexeme("<number>")] Number,
/// <summary>
/// Textual value.
/// </summary>
[Lexeme("")] Text,
[Lexeme("<text>")] Text,
/// <summary>
/// Parameters separator.
/// </summary>
[Lexeme(",")] Colon,
[Lexeme(",")] Comma,
/// <summary>
/// End of line separator.
/// </summary>
[Lexeme(";")] Semicolon,
/// <summary>
/// Invalid token.
/// </summary>
[Lexeme("")] Invalid,
/// <summary>
/// Attribuition operator.
/// </summary>
[Lexeme(":")] Attribuition,
[Lexeme(":")] Colon,
/// <summary>
/// Code for identification lexeme.
/// </summary>
[Lexeme("null")] Null,
/// <summary>
/// Code for identification lexeme.
/// </summary>
[Lexeme("")] Id
[Lexeme("<identifier>")] Id
}

public static class TokenCodeExtensions
Expand Down
4 changes: 2 additions & 2 deletions compiler/Compiler/Exception/InvalidTokenException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
[System.Serializable]
public class InvalidTokenException : System.Exception
{
public InvalidTokenException() : base() { }
public InvalidTokenException(string message) : base(message) { }
public InvalidTokenException() { }
public InvalidTokenException(string message) { }
public InvalidTokenException(string message, System.Exception inner) : base(message, inner) { }
}
}
10 changes: 10 additions & 0 deletions compiler/Compiler/Exception/TokenNotFoundException.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
namespace AquaScript.Compiler
{
[System.Serializable]
public class TokenNotFoundException : System.Exception
{
public TokenNotFoundException() { }
public TokenNotFoundException(string message) { }
public TokenNotFoundException(string message, System.Exception inner) : base(message, inner) { }
}
}
Loading

1 comment on commit eaaeb03

@davidsonbrsilva
Copy link
Owner Author

@davidsonbrsilva davidsonbrsilva commented on eaaeb03 Apr 15, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Close #1

Please sign in to comment.