اسم المحلل اللغوي: علامات عامة مثبتة مع برنامج Homebrew
سطر الأوامر الذي استخدمته لتشغيل ctags:
$ ctags --options=NONE src/carte/tasche/carte_p-tasche_p.ads
محتوى ملف الإدخال:
-- <strong i="10">@summary</strong>
-- Implémentation par une tâche.
-- <strong i="11">@description</strong>
-- Implémentation par une tache de la classe synchronisé.
-- <strong i="12">@group</strong> Version tâche
package Carte_P.Tasche_P
with
Pure => False,
Preelaborate => False,
Elaborate_Body => True,
Spark_Mode => Off
is
---------------------------------------------------------------------------
task type Tasche_T is new Carte_T with
-- Implémentation par une tâche de l'interface Carte_T.
-----------------------------------
overriding
entry Coucou;
-- Implémentation par un accept.
-----------------------------------
-- overriding
-- entry Inutile;
-- Implémentation par un accept.
-- <strong i="13">@param</strong> This
-- La carte.
end Tasche_T;
---------------------------------------------------------------------------
overriding
procedure Inutile
(This : in out Tasche_T);
-- Implémentation par une procédure.
-- <strong i="14">@param</strong> This
-- La carte.
end Carte_P.Tasche_P;
ناتج العلامات الذي لست راضيًا عنه:
!_TAG_FILE_FORMAT 2 /extended format; --format=1 will not append ;" to lines/
!_TAG_FILE_SORTED 1 /0=unsorted, 1=sorted, 2=foldcase/
!_TAG_OUTPUT_FILESEP slash /slash or backslash/
!_TAG_OUTPUT_MODE u-ctags /u-ctags or e-ctags/
!_TAG_PROGRAM_AUTHOR Universal Ctags Team //
!_TAG_PROGRAM_NAME Universal Ctags /Derived from Exuberant Ctags/
!_TAG_PROGRAM_URL https://ctags.io/ /official site/
!_TAG_PROGRAM_VERSION 0.0.0 /e216bb4/
(This src/carte/tasche/carte_p-tasche_p.ads /^ (This : in out Tasche_T);$/;" v packspec:Carte_P.Tasche_P
Carte_P.Tasche_P src/carte/tasche/carte_p-tasche_p.ads /^package Carte_P.Tasche_P$/;" P
Inutile src/carte/tasche/carte_p-tasche_p.ads /^ procedure Inutile$/;" v packspec:Carte_P.Tasche_P
Tasche_T src/carte/tasche/carte_p-tasche_p.ads /^ task type Tasche_T is new Carte_T with$/;" K packspec:Carte_P.Tasche_P
overriding src/carte/tasche/carte_p-tasche_p.ads /^ overriding$/;" v packspec:Carte_P.Tasche_P
procedure src/carte/tasche/carte_p-tasche_p.ads /^ procedure Inutile$/;" v packspec:Carte_P.Tasche_P
overriding
، procedure
ليست اسم متغير ، هناك كلمات رئيسية.
Inutile
هو اسم برنامج فرعي.
(This
وسيطة للبرنامج الفرعي.
دخول Coucou
توقيع غير مرئي
إخراج العلامات الذي تتوقعه:
!_TAG_FILE_FORMAT 2 /extended format; --format=1 will not append ;" to lines/
!_TAG_FILE_SORTED 1 /0=unsorted, 1=sorted, 2=foldcase/
!_TAG_OUTPUT_FILESEP slash /slash or backslash/
!_TAG_OUTPUT_MODE u-ctags /u-ctags or e-ctags/
!_TAG_PROGRAM_AUTHOR Universal Ctags Team //
!_TAG_PROGRAM_NAME Universal Ctags /Derived from Exuberant Ctags/
!_TAG_PROGRAM_URL https://ctags.io/ /official site/
!_TAG_PROGRAM_VERSION 0.0.0 /e216bb4/
Carte_P.Tasche_P src/carte/tasche/carte_p-tasche_p.ads /^package Carte_P.Tasche_P$/;" P
Inutile src/carte/tasche/carte_p-tasche_p.ads /^ procedure Inutile$/;" R packspec:Carte_P.Tasche_P
Tasche_T src/carte/tasche/carte_p-tasche_p.ads /^ task type Tasche_T is new Carte_T with$/;" K packspec:Carte_P.Tasche_P
Coucou src/carte/tasche/carte_p-tasche_p.ads e task:Tasche_T
الهيئة المقابلة:
سطر الأوامر الذي استخدمته لتشغيل ctags:
$ ctags --options=NONE src/carte/tasche/carte_p-tasche_p.adb
محتوى ملف الإدخال:
with Ada.Text_IO;
package body Carte_P.Tasche_P
with Spark_Mode => Off
is
---------------------------------------------------------------------------
task body Tasche_T is
-- Les déclarations qui vont bien.
begin
accept Coucou do
null;
end Coucou;
Ada.Text_IO.Put_Line (Item => "Wesh gros je suis une tâche");
-- accept Inutile do
-- null;
-- end Inutile;
abort Tasche_T;
end Tasche_T;
---------------------------------------------------------------------------
---------------------------------------------------------------------------
overriding
procedure Inutile
(This : in out Tasche_T)
is
begin
null;
end Inutile;
---------------------------------------------------------------------------
end Carte_P.Tasche_P;
ناتج العلامات الذي لست راضيًا عنه:
!_TAG_FILE_FORMAT 2 /extended format; --format=1 will not append ;" to lines/
!_TAG_FILE_SORTED 1 /0=unsorted, 1=sorted, 2=foldcase/
!_TAG_OUTPUT_FILESEP slash /slash or backslash/
!_TAG_OUTPUT_MODE u-ctags /u-ctags or e-ctags/
!_TAG_PROGRAM_AUTHOR Universal Ctags Team //
!_TAG_PROGRAM_NAME Universal Ctags /Derived from Exuberant Ctags/
!_TAG_PROGRAM_URL https://ctags.io/ /official site/
!_TAG_PROGRAM_VERSION 0.0.0 /e216bb4/
(This src/carte/tasche/carte_p-tasche_p.adb /^ (This : in out Tasche_T)$/;" v package:Carte_P.Tasche_P file:
Carte_P.Tasche_P src/carte/tasche/carte_p-tasche_p.adb /^package body Carte_P.Tasche_P$/;" p
Coucou src/carte/tasche/carte_p-tasche_p.adb /^ accept Coucou do$/;" e task:Tasche_T file:
Inutile src/carte/tasche/carte_p-tasche_p.adb /^ procedure Inutile$/;" v package:Carte_P.Tasche_P file:
Tasche_T src/carte/tasche/carte_p-tasche_p.adb /^ task body Tasche_T is$/;" k package:Carte_P.Tasche_P file:
overriding src/carte/tasche/carte_p-tasche_p.adb /^ overriding$/;" v package:Carte_P.Tasche_P file:
procedure src/carte/tasche/carte_p-tasche_p.adb /^ procedure Inutile$/;" v package:Carte_P.Tasche_P file:
إخراج العلامات الذي تتوقعه:
!_TAG_FILE_FORMAT 2 /extended format; --format=1 will not append ;" to lines/
!_TAG_FILE_SORTED 1 /0=unsorted, 1=sorted, 2=foldcase/
!_TAG_OUTPUT_FILESEP slash /slash or backslash/
!_TAG_OUTPUT_MODE u-ctags /u-ctags or e-ctags/
!_TAG_PROGRAM_AUTHOR Universal Ctags Team //
!_TAG_PROGRAM_NAME Universal Ctags /Derived from Exuberant Ctags/
!_TAG_PROGRAM_URL https://ctags.io/ /official site/
!_TAG_PROGRAM_VERSION 0.0.0 /e216bb4/
Carte_P.Tasche_P src/carte/tasche/carte_p-tasche_p.adb /^package body Carte_P.Tasche_P$/;" p
Coucou src/carte/tasche/carte_p-tasche_p.adb /^ accept Coucou do$/;" e task:Tasche_T file:
Inutile src/carte/tasche/carte_p-tasche_p.adb /^ procedure Inutile$/;" r package:Carte_P.Tasche_P file:
Tasche_T src/carte/tasche/carte_p-tasche_p.adb /^ task body Tasche_T is$/;" k package:Carte_P.Tasche_P file:
إصدار ctags:
$ ctags --version
Universal Ctags 0.0.0(e216bb4), Copyright (C) 2015 Universal Ctags Team
Universal Ctags is derived from Exuberant Ctags.
Exuberant Ctags 5.8, Copyright (C) 1996-2009 Darren Hiebert
Compiled: Dec 18 2019, 11:28:07
URL: https://ctags.io/
Optional compiled features: +wildcards, +regex, +iconv, +option-directory, +xpath, +case-insensitive-filenames, +packcc
كيف تحصل على ثنائي ctags:
البيرة مع الإعدادات الافتراضية.
شكرا لك. لقد قدمت رمزًا لتخطي "التجاوز" و "عدم التجاوز". انظر # 2383.
ومع ذلك ، لا يزال المحلل اللغوي Ada غير قادر على التقاط "Coucou" في المثال الأول للإدخال.
هذا صحيح حتى عندما أحذف مؤشر "التجاوز" من الإدخال.
أنا لا أعرف آدا. لذلك أنا بحاجة لمساعدتكم.
يبدو أن التفاف الكتل Coucou هو واجهة موضحة في https://en.wikibooks.org/wiki/Ada_Programming/Tasking#Interfaces . هل انا صائب؟
نعم ، هذا صحيح ، وهذا أيضًا كيف نحدد المهام القياسية ونوع المهمة في المواصفات (.ads).
مهمة :
task Tasche_T is
entry Coucou
(Parameters : Parameters_Type);
end Tasche_T;
نوع المهمة :
task type Tasche_T is
entry Coucou
(Parameters : Parameters_Type);
end Tasche_T;
[jet@living]~/var/ctags% git diff | cat
git diff | cat
diff --git a/parsers/ada.c b/parsers/ada.c
index 22a7dc01..73b4a458 100644
--- a/parsers/ada.c
+++ b/parsers/ada.c
@@ -929,7 +929,9 @@ static adaTokenInfo *adaParseBlock(adaTokenInfo *parent, adaKind kind)
else if(adaKeywordCmp(ADA_KEYWORD_NEW))
{
/* if this is a "new" something then no need to parse */
- skipPast(";");
+ // skipPast(";");
+ skipPastKeyword(ADA_KEYWORD_WITH);
+ adaParse(ADA_DECLARATIONS, token);
}
else
{
[jet@living]~/var/ctags% make
make
REPOINFO main/repoinfo.h
make all-am
make[1]: Entering directory '/home/jet/var/ctags'
REPOINFO main/repoinfo.h
CCLD ctags
make[1]: Leaving directory '/home/jet/var/ctags'
[jet@living]~/var/ctags% ./ctags --kinds-Ada=+E -o - ~/var/ctags/Units/parser-ada.r/ada-overriding.d/input.ads
./ctags --kinds-Ada=+E -o - ~/var/ctags/Units/parser-ada.r/ada-overriding.d/input.ads
Coucou /home/jet/var/ctags/Units/parser-ada.r/ada-overriding.d/input.ads /^ entry Coucou;$/;" E taskspec:Tasche_T
Input /home/jet/var/ctags/Units/parser-ada.r/ada-overriding.d/input.ads /^package Input$/;" P
Inutile /home/jet/var/ctags/Units/parser-ada.r/ada-overriding.d/input.ads /^ procedure Inutile$/;" R packspec:Input
Tasche_T /home/jet/var/ctags/Units/parser-ada.r/ada-overriding.d/input.ads /^ task type Tasche_T is new Carte_T with$/;" K packspec:Input
يتم التقاط Coucou جيدًا. ومع ذلك ، فإن التغيير متخصص للغاية بالنسبة للإدخال المستهدف.
لذلك هناك حاجة إلى مزيد من العمل.
هل تحتاج إلى المزيد من أمثلة التعليمات البرمجية؟
هل تحتاج إلى المزيد من أمثلة التعليمات البرمجية؟
حاليا ، الأمثلة كافية. شكرا لك على العرض.
ما أبحث عنه هو وقت فراغ يمكن استخدامه لتطوير
انظر # 2401. الآن يتم التقاط Coucou جيدًا.
أود تمديد حالات اختبار وحداتنا لـ Ada. هل يمكنك مساعدتي؟
الأمثلة التي عرضتها:
task Tasche_T is
entry Coucou
(Parameters : Parameters_Type);
end Tasche_T;
و
task type Tasche_T is
entry Coucou
(Parameters : Parameters_Type);
end Tasche_T;
أرغب في الحصول عليها كملفات إعلانات كاملة يقبلها المترجم.
انظر https://github.com/universal-ctags/ctags/issues/1903 .
أعتقد أن ما أظهرته هو أجزاء من التعليمات البرمجية.
لذلك أعتقد أن مترجم Ada قد لا يقبلها.
أود أن المترجم شيء مقبول ملفات الإدخال.
ومع ذلك ، يجب أن تكون صغيرة.
ما أعرفه هو فقط C. لذا أود أن أوضح ما أريده في C.
غير مقبول:
printf("hello, world\n");
مقبول:
#include <stdio.h>
int
main(void)
{
printf("hello, world\n");
return 0;
}
مثال على ملف واحد ، في client.adb
:
with Ada.Text_IO;
procedure Client is
---------------------------------------------------------------------------
-- Define the tasks
task Ma_Tasche is
entry Accepter
(Continuer : Boolean);
end Ma_Tasche;
task Mon_Autre_Tasche;
-- Define body of the tasks
task body Ma_Tasche is
Var_Continuer : Boolean := False;
begin
Boucle_Principale :
loop
accept Accepter
(Continuer : Boolean)
do
Var_Continuer := Continuer;
end Accepter;
end loop Boucle_Principale;
end Ma_Tasche;
task body Mon_Autre_Tasche is
begin
null;
end Mon_Autre_Tasche;
---------------------------------------------------------------------------
begin
Ada.Text_IO.Put_Line ("Tasks won't stop, kill it with CTRL-C");
Ma_Tasche.Accepter (Continuer => True);
end Client;
أنت بحاجة إلى إصدار FSF gcc-ada أو GNAT على موقع Adacore الإلكتروني.
تجميعها مع
gcc -c client.adb;
(واربط بـ gnatbind client; gnatlink client
إذا كنت ترغب في exe) مع FSF GCC.gnatmake client.adb
client.gpr
وقم بتجميعه باستخدام gprbuild -Pclient.gpr
سأضيف إصدارًا متعدد الملفات قريبًا.
إصدار الملفات المتعددة:
في ملف باسم client.gpr
project Client is
for Main use ("client.adb");
for Source_Dirs use ("src/**");
for Object_Dir use "obj/";
for Exec_Dir use "bin/";
for Create_Missing_Dirs use "True";
package Compiler is
for Default_Switches ("Ada") use ("-O0", "-Wall");
end Compiler;
end Client;
في ملف باسم src/client.adb
with Ada.Text_IO;
with Mes_Tasches_P;
procedure Client is
begin
Ada.Text_IO.Put_Line ("Tasks won't stop, kill it with CTRL-C");
Mes_Tasches_P.Ma_Tasche.Accepter (Continuer => True);
end Client;
في ملف باسم src/mes_tasches_p.ads
package Mes_Tasches_P is
task Ma_Tasche is
entry Accepter
(Continuer : Boolean);
end Ma_Tasche;
task Mon_Autre_Tasche;
end Mes_Tasches_P;
في ملف باسم src/mes_tasches_p.adb
package body Mes_Tasches_P is
task body Ma_Tasche is
Var_Continuer : Boolean := False;
begin
Boucle_Principale :
loop
accept Accepter
(Continuer : Boolean)
do
Var_Continuer := Continuer;
end Accepter;
end loop Boucle_Principale;
end Ma_Tasche;
task body Mon_Autre_Tasche is
begin
null;
end Mon_Autre_Tasche;
end Mes_Tasches_P;
نتيجة الأمر tree .
.
├── client.gpr
└── src
├── mes_tasches_p.adb
├── mes_tasches_p.ads
└── client.adb
قم بتجميعها بـ gprbuild -Pclient.gpr
لقد نسيت نوع المهمة ، نوع المهمة مع نوع مميز ، محمي ، محمي ، نوع محمي مع تمييز.
ملف mes_tasches_p.ads
package Mes_Tasches_P is
task Ma_Tasche is
entry Accepter
(Continuer : Boolean);
end Ma_Tasche;
task Mon_Autre_Tasche;
task type Tasche_Type_1_T;
Une_Tasche : Tasche_Type_1_T;
task type Tasche_Type_2_T is
entry Start;
entry Lire
(Donnee : out Integer);
end Tasche_Type_2_T;
-- Task type with discriminant.
task type Tasche_Type_3_T
-- We could have any number of arguments in discriminant
-- Work exactly like argument in procedure/function/entry/accept
(Taille : Integer)
is
entry Start;
end Tasche_Type_3_T;
-- protected objects.
protected Objet_Protege is
entry Demarrer;
procedure Faire;
function Tester return Boolean;
private
Variable : Boolean := True;
end Objet_Protege;
protected type Type_Protege is
entry Demarrer;
procedure Faire;
function Tester return Boolean;
private
Variable : Boolean := True;
end Type_Protege;
protected type Discriminant_Protege
(Priorite : Natural)
is
entry Demarrer;
procedure Faire;
function Tester return Boolean;
private
Variable : Boolean := True;
end Discriminant_Protege;
end Mes_Tasches_P;
ملف mes_tasches_p.adb
package body Mes_Tasches_P is
---------------------------------------------------------------------------
task body Ma_Tasche is
Var_Continuer : Boolean := False;
begin
Boucle_Principale :
loop
accept Accepter
(Continuer : Boolean)
do
Var_Continuer := Continuer;
end Accepter;
end loop Boucle_Principale;
end Ma_Tasche;
---------------------------------------------------------------------------
---------------------------------------------------------------------------
task body Mon_Autre_Tasche is
begin
null;
end Mon_Autre_Tasche;
---------------------------------------------------------------------------
Une_Autre_Tasche_1 : Tasche_Type_1_T;
---------------------------------------------------------------------------
task body Tasche_Type_1_T is
begin
null;
end Tasche_Type_1_T;
---------------------------------------------------------------------------
---------------------------------------------------------------------------
task body Tasche_Type_2_T is
begin
null;
end Tasche_Type_2_T;
---------------------------------------------------------------------------
---------------------------------------------------------------------------
task body Tasche_Type_3_T is
begin
null;
end Tasche_Type_3_T;
---------------------------------------------------------------------------
Une_Autre_Tasche_2 : Tasche_Type_2_T;
Une_Autre_Tasche_3 : Tasche_Type_3_T (Taille => 5);
---------------------------------------------------------------------------
protected body Objet_Protege is
entry Demarrer
when Variable
is
begin
null;
end Demarrer;
procedure Faire is
begin
null;
end Faire;
function Tester
return Boolean
is
begin
return Variable;
end Tester;
end Objet_Protege;
---------------------------------------------------------------------------
---------------------------------------------------------------------------
protected body Type_Protege is
entry Demarrer
when Variable
is
begin
null;
end Demarrer;
procedure Faire is
begin
null;
end Faire;
function Tester
return Boolean
is
begin
return Variable;
end Tester;
end Type_Protege;
---------------------------------------------------------------------------
---------------------------------------------------------------------------
protected body Discriminant_Protege is
entry Demarrer
when Variable
is
begin
null;
end Demarrer;
procedure Faire is
begin
null;
end Faire;
function Tester
return Boolean
is
begin
return Variable;
end Tester;
end Discriminant_Protege;
---------------------------------------------------------------------------
end Mes_Tasches_P;
لا تغيير في client.adb
و client.gpr
.
شكرا لك. تم بناؤه بنجاح.
سوف أقوم بتحويله إلى حالة اختبار.
تم دمج حالة الاختبار. شكرا جزيلا.
لدي طلب آخر.
في دليل الوحدات / review-needed.r. هناك حالة اختبار لـ Ada ، generalized_stack.ads.t.
يحتوي الدليل على حالات اختبار مع الاحتفاظ بها كما هي منذ أن بدأنا هذا المشروع عن طريق التفرغ من ctags الغزيرة. عند التفرع ، لم أكن أعرف Ada ، لذلك لم يتم اختبار حالة الاختبار حقًا ؛ لم يتم التحقق من إخراج علامات الإدخال للإدخال حتى الآن.
الان انت هنا لذا أود منكم مساعدتي في التحقق من المخرجات المتوقعة.
1 -- Object-oriented generalized stack. This illustrates the use of a
2 -- controlled type, which is one that has construction and destructions.
3 -- It also shows how to create two related types in the same package so
4 -- that they can share private declarations. This sort of thing is
5 -- accomplished in Java or C++ using nested classes, or using friend
6 -- declarations in C++.
7 --
8 with Ada.Finalization; use Ada.Finalization;
9
10 package GenStack is
11 -- This is the stack type.
12 type Stack is new Controlled with private;
13
14 -- This is the base type for nodes. Client packages must derive their
15 -- nodes from StackData. Since it comes from Controlled, the user can
16 -- override the Initialize, Adjust, and Finalize methods as needed.
17 type StackData is new Controlled with null record;
18
19 -- Initialization operations.
20 procedure Initialize(S: in out Stack);
21 procedure Adjust(S: in out Stack);
22 procedure Finalize(S: in out Stack);
23
24 -- Stack operations.
25 procedure Push(S: in out Stack; D: StackData'class);
26 procedure Pop(S: in out Stack; D: in out StackData'class);
27 procedure Top(S: Stack; Data: in out StackData'class);
28 function Empty(S: Stack) return Boolean;
29
30 private
31 -- Pointer to the node type.
32 type Node;
33 type Node_Ptr is access Node;
34
35 -- Here is the generalized stack itself. We would just make it the
36 -- pointer itself, but it needs to be a record so it can be in a with.
37 type Stack is new Controlled with record
38 Head: Node_Ptr;
39 end record;
40
41 -- Now, we need a pointer to the data part.
42 type Data_Ptr is access StackData'Class;
43
44 -- This is the node type.
45 type Node is record
46 Data: Data_Ptr;
47 Next: Node_Ptr;
48 end record;
49
50 end GenStack;
أثناء العمل على طلب السحب هذا ، قمت بدراسة Ada قليلاً. لذلك أنا أفهم ما يجب وضع علامة عليه في الغالب. ومع ذلك ، هناك واحد لا يمكنني تحديد ما إذا كان يجب وضع علامة عليه أم لا.
انظر السطر 32:
32 type Node;
هل تعتقد أنه يجب علينا وضع علامة على Node
؟
التنفيذ الحالي لمحلل Ada لا يضع علامة عليه.
لذا ، إذا كانت إجابتك نعم ، فإن محلل Ada لديه خطأ. أود أن أصلحه.
إذا كانت إجابتك لا ، أود معرفة السبب. أود أن أضع ما تقوله في حالة الاختبار.
السطر 32 type Node;
يشترك في نفس المعنى مثل typedef struct s_List List;
في C
، في الواقع أعتقد أن علامات ctags يجب أن تشير إليه. هل يمكننا إضافة تلميح مثل type name declaration
بجانب name؟ تكمن الفكرة في تمييزه عن سطر البيان الكامل 45.
لم أدرك أن لديك القليل من الأمثلة ، هل تريد مني أن أكتب المزيد؟
أوه ، أنا آسف جدا. يلتقط u-ctags العقدة في السطر 32:
% u-ctags -n -o - --kinds-Ada='*' input.ads | grep ^Node
Node input.ads 32;" T language:Ada packspec:GenStack file:
Node input.ads 45;" t language:Ada packspec:GenStack file:
Node_Ptr input.ads 33;" t language:Ada packspec:GenStack file:
لقد أخطأت في قراءة الإخراج.
لم أدرك أن لديك القليل من الأمثلة ، هل تريد مني أن أكتب المزيد؟
شكرا لك على العرض. ومع ذلك ، هذه المرة ، تلقيت الكثير من المدخلات منك. لذلك هذا يكفي الآن.
بعد إضافة --kinds-Ada = * ، تلتقط ctags العقدة في السطر 32.
ومع ذلك ، لا يتم التقاط "الرأس" في السطر 38 من خلال التقاط البيانات والتالي في السطر 46 والخط 47.
قد تكون هناك حاجة إلى رقعة أخرى.
لقد دمجت التغيير لإصلاح هذه المشكلة.
شكرًا لك على تقديم مدخلات الاختبار والمعرفة حول Ada.