ada

Implementing an abstract function with access types in Ada

邮差的信 提交于 2019-12-10 23:59:05
问题 I have a package called Statements with an abstract type called Statement and an abstract function called execute(). In another package I have a type CompoundStatement which is a type Statement and it implements the execute() function. I have a function called createStatement(). It's purpose is to evaluate a token of type Unbounded_String and determine what keyword it contains. Then based on this keyword it will generate an access type based on this keyword. So far so good. But what I can't

ada split() method

孤街浪徒 提交于 2019-12-10 22:22:43
问题 I am trying to write an Ada equivalent to the split() method in Java or C++. I am to intake a string and an integer and output two seperate string values. For example: split of "hello" and 2 would return: "The first part is he and the second part is llo" The code I have is as follows: -- split.adb splits an input string about a specified position. -- -- Input: Astring, a string, -- Pos, an integer. -- Precondition: pos is in Astring'Range. -- Output: The substrings Astring(Astring'First..Pos)

Threads and semaphores in Ada95

自闭症网瘾萝莉.ら 提交于 2019-12-10 20:34:46
问题 How can I use threads in Ada95? What functions can I use to create, destroy, stop and start them? How can I use semaphores in this language? 回答1: Ada's terminology for a thread is a "task". Ada doesn't have semaphores (as such) built directly into the language, but Googling for something like "Ada semaphore" should turn up a fair number of hits. AdaPower.com, in particular, has quite a bit about concurrent programming in Ada (and, for that matter, almost all kinds of programming in Ada). 回答2:

Ada with Netbeans

安稳与你 提交于 2019-12-10 20:04:56
问题 I downloaded the Netbeans plugin for programming with Ada. However, I dunno how to link the Eclipse to the Ada platform library. What should link to the IDE ? lib,etc,bin ? I dunno what what to do. Any help is appreciated. 回答1: After installing the Ada plugin modules in NetBeans, use File > New Project to create a new Ada project. In the New Ada Application dialog, click Manage to select your installed Ada compiler. 回答2: I don't know about Netbeans or Eclipse, but this might be applicable?

Installation issue with AWS for Ada

≡放荡痞女 提交于 2019-12-10 17:51:55
问题 I installed Ada and AWS on a Macbook for the first time tonight. Everything seemed successful with the installation, but I'm getting the feeling that AWS didn't install to the right directory. GNAT is in /usr/local/gnat. The AWS makefile.conf said, AWS will be installed under $(prefix). Update this variable to point to the install directory. By default, it is set to the current GNAT root directory to have AWS project files automatically available. So I didn't change the target. But when I try

Extracting record from big endian data

空扰寡人 提交于 2019-12-10 17:35:48
问题 I have the following code for network protocol implementation. As the protocol is big endian, I wanted to use the Bit_Order attribute and High_Order_First value but it seems I made a mistake. With Ada.Unchecked_Conversion; with Ada.Text_IO; use Ada.Text_IO; with System; use System; procedure Bit_Extraction is type Byte is range 0 .. (2**8)-1 with Size => 8; type Command is (Read_Coils, Read_Discrete_Inputs ) with Size => 7; for Command use (Read_Coils => 1, Read_Discrete_Inputs => 4); type

Ada Generic Averaging Function

早过忘川 提交于 2019-12-10 17:28:17
问题 I have a function which averages a certain numeric value from an array of records. This value is either a natural or an enumerated type delta. I have it summing up the values correctly but my question is this: how do I get the length of an array into a generic type, so that it can divide both integers and delta type numbers? 回答1: On your array-of-records use the 'Length attribute; this has the advantage of always working even if your bounds are somewhat odd, like -18..3, or an enumeration,

How [“03C0”] match <Ada Reference Manual>'s grammar in Annex P?

时间秒杀一切 提交于 2019-12-10 17:26:30
问题 I'm writing a tool to parse Ada source file with the grammar provided in 2005 Annex P. With following piece of code, I know ["03C0"] stands for "greek letter Pi", but is it a legal variable name? 01 package Ada.Numerics is 02 Pi : constant := 3.14159_26535_89793_23846_26433_83279_50288_41971_69399_37511; 03 ["03C0"] : constant := Pi; 04 e : constant := 2.71828_18284_59045_23536_02874_71352_66249_77572_47093_69996; 05 end Ada.Numerics; When using the grammar to parse line 03, I currently come

Regular Expressions in Ada?

喜夏-厌秋 提交于 2019-12-10 16:58:00
问题 I'm very new to Ada, and I'm trying to do some simple work with some text. All I want to do is read in a file, and strip out anything that isn't a letter, space, or new line. so removing all the punctuation and numbers. In other languages I would just create a simple [^a-zA-Z] regular expression, look at each character and delete it if it fit the RegEx, but I can't seem to find any documentation on RegEx's in Ada. So, are there RegEx's in Ada? If not, what's the best way for me to go about

Ada/Eclipse Integration

隐身守侯 提交于 2019-12-10 16:45:56
问题 Are there any freely available Ada plugins eclipse. Eclipse is my main IDE and I occasionally need to read and modify some Ada, having it all in the one IDE would be ideal. 回答1: For Eclipse, AdaCore distributes and maintains the GNATBench plug-in, though I've never personally used it. I believe it is not GNAT specific, so it may still be of value even if you're using a different compiler--but I could be wrong on that :-) If you're using the GNAT Ada compilation system, you've got a fully Ada