Arithmetic evaluation/Ada: Difference between revisions

m
Fixing syntax highlighting tags
(Copy from main task page)
 
m (Fixing syntax highlighting tags)
 
(One intermediate revision by one other user not shown)
Line 6:
 
The implementation provides an advanced error handling and skipping blanks and Ada comments (these are taken from the library).
<langsyntaxhighlight lang="ada">
with Ada.Unchecked_Deallocation;
with Parsers.String_Source; use Parsers.String_Source;
Line 98:
);
end Parsers.Simple;
</syntaxhighlight>
</lang>
Here is the implementation of the package.
<langsyntaxhighlight lang="ada">
with Ada.Characters.Handling; use Ada.Characters.Handling;
with Ada.Exceptions; use Ada.Exceptions;
Line 269:
 
end Parsers.Simple;
</syntaxhighlight>
</lang>
The next is a little test. It reads a line from the keyboard and then evaluates it. The program stops when the input is empty:
<langsyntaxhighlight lang="ada">
with Ada.Exceptions; use Ada.Exceptions;
with Ada.Text_IO; use Ada.Text_IO;
Line 312:
end loop;
end Test_Simple_Parser;
</syntaxhighlight>
</lang>
Sample exchange. When the expression is evaluated its range in the source string is indicated. Upon errors, the location of is shown as well:
<pre>
2

edits