ada

Convert unbounded string to integer Ada

允我心安 提交于 2019-12-11 06:08:16
问题 My question is rather simple, as Google has let me down. How do I convert an unbounded string to an integer? If the string was bounded, I could do this: I : Integer := Integer'Value("613"); However, my string is unbounded, and Ada throws this error: expected type "Standard.String" found private type "Ada.Strings.Unbounded.Unbounded_String" Is what I want to do possible? 回答1: You just have to do the intermediate conversion: I : Integer := Integer'Value (To_String (T)); Here is a full test

How to transform integer to float and vice-versa in Ada?

寵の児 提交于 2019-12-11 05:34:24
问题 Is there some kind of implemented function that would allow to transform an integer to float and vice versa? I managed to write a short function that transforms an integer to float: function Transform(First: Integer) return Float is A: Integer := First; B: Float := 0.0; begin For_Loop: for I in Integer range 1 .. A loop B := B + 1.0; end loop For_Loop; return B; end Transform; But I don't know how to go from Float to Integer . 回答1: Ada can do explicit type conversions with Ada.Text_IO; use

Ada constant array of string literals

扶醉桌前 提交于 2019-12-11 05:17:10
问题 I have a large array in C that I wish to move into my ada project. That array is used to store filenames for assets which will later be loaded. It looks something like: const char *filenames[NUMBER_OF_FILES] = { /* file[0] */ "res/0.file", /* ... */ /* file[n] */ "res/some_more/complicated/file.name" }; I want to move this into an ada package body, but can't find a decent way to do it. Obviously my first attempt was: filenames : constant array (File_Index) of String := ( index_0 => "res/0

String handling in Ada

偶尔善良 提交于 2019-12-11 03:04:32
问题 I'm trying to define an array of Strings in Ada to store Strings of variable size. The problem I have is that I must pre-define the size of my Strings which I don't know at compile time, and with the Unbounded_Strings the String_Split.Create wouldn't work, as it requires Standard.String. Below is my code, where I need to be able to parse Strings of variable size, and not just the fixed length 4. Thanks in advance. type StrArray is array(1..7) of String(1..4); function Split(Line : String;Sep

Stack Overflow when Pyparsing Ada 2005 Scoped Identifiers using Reference Manual Grammar

依然范特西╮ 提交于 2019-12-11 02:37:20
问题 I'm currently implementing an Ada 2005 parser using Pyparsing and the reference manual grammar rules. We need this in order to analyze and transform parts of our aging Ada-codebase to C/C++. Most things work. However, one little annoying problem remains: The grammar rule name when parsing scoped identifiers (rule selected_component ) such as the expression "Global_Types.Integer2" fails because it is part of a left-associative grammar rule cycle. I believe this rule is incorrectly written: the

Ada : operator is not directly visible

 ̄綄美尐妖づ 提交于 2019-12-11 02:23:17
问题 I'm using GNAT GPS studio IDE in order to train a bit in Ada. I'm having an issue with package visibility. First I specify a package in a file called "DScale.ads" containing a type: package DScale is type DMajor is (D, E, F_Sharp, G, A, B, C_Sharp); end DScale; Then I specify in a different file ("Noteworthy.ads") a package that defines a procedure that will use the DMajor type of the DScale package: with Ada.Text_IO; with DScale; package NoteWorthy is procedure Note; end NoteWorthy; Finally

Cannot find -lgfortran though gfortran is installed [duplicate]

心已入冬 提交于 2019-12-11 02:21:35
问题 This question already has answers here : Closed 7 years ago . Possible Duplicate: lgfortran not found I must admit that my question can be considered to be very similar to lgfortran not found, but as I am a newbie in Linux I need more help and I couldn't find what I am looking for in the above post. I have a fresh linux mint Debian edition installed and I am trying to make a lapack binding for Ada to work. If I check for gfortran, I get: gfortran-4.6 -v Using built-in specs. COLLECT_GCC

Ada beginner Stack program

淺唱寂寞╮ 提交于 2019-12-11 02:14:42
问题 Basically, I have 2 files ( .adb and .ads). I am totally new to Ada and also how to compile 2 files. The program is of a basic stack implementation. I got this compile error when I compiled the .adb file. $ gcc -c test_adt_stack.adb abstract_char_stack.ads:22:01: end of file expected, file can have only one compilation unit The 2 files I have are: abstract_char_stack.ads ----------------------------------------------------------- package Abstract_Char_Stack is type Stack_Type is private;

Use of Pragmas in Ada

落花浮王杯 提交于 2019-12-11 01:48:52
问题 Can anyone supply me with simple working examples which illustrate the use of pragmas in Ada 2005 ? I understand that pragmas are used to priorities processes, just that I have not come across working examples ! Much appreciated ! 回答1: A search of comp.lang.ada for recent discussions about priorities has several interesting examples. This one seems particularly apropos to your question. Addendum: Two other exemplary sources are the Rationale for Ada 95 and Rationale for Ada 2005 回答2: An Ada

Can't make Ada work with Xcode 3.2

北城以北 提交于 2019-12-11 01:37:05
问题 I've been looking around the web for an hour and I'm just giving up to ask it here... I've got to work under Ada. I managed to make gnat work as a command line to compile my files. But I want to be able to have proper projects in Xcode. My problem is that I've found some templates on the to make ada default templates, I've copy pasted them a bit everywhere (/library/developer/ application support etc) but they never appear in the list when I want to create a project. My other problem is that