comp.lang.ada
 help / color / mirror / Atom feed
* ANN: Simple Components v
@ 2021-01-13 12:01 Dmitry A. Kazakov
  2021-01-15 19:42 ` reinert
  0 siblings, 1 reply; 13+ messages in thread
From: Dmitry A. Kazakov @ 2021-01-13 12:01 UTC (permalink / raw)


The current version provides implementations of smart pointers, directed 
graphs, sets, maps, B-trees, stacks, tables, string editing, unbounded 
arrays, expression analyzers, lock-free data structures, synchronization 
primitives (events, race condition free pulse events, arrays of events, 
reentrant mutexes, deadlock-free arrays of mutexes), pseudo-random 
non-repeating numbers, symmetric encoding and decoding, IEEE 754 
representations support, streams, multiple connections server/client 
designing tools and protocols implementations.

    http://www.dmitry-kazakov.de/ada/components.htm

Changes to the previous version:

- The packages Universally_Unique_Identifiers and 
Universally_Unique_Identifiers.Edit were added to support UUID;
- Reboot procedure was added to the package 
GNAT.Sockets.Connection_State_Machine.ELV_MAX_Cube_Client.

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: ANN: Simple Components v
  2021-01-13 12:01 ANN: Simple Components v Dmitry A. Kazakov
@ 2021-01-15 19:42 ` reinert
  2021-01-15 20:05   ` Dmitry A. Kazakov
  0 siblings, 1 reply; 13+ messages in thread
From: reinert @ 2021-01-15 19:42 UTC (permalink / raw)


Convert between prefix, infix, postfix notation?

reinert

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: ANN: Simple Components v
  2021-01-15 19:42 ` reinert
@ 2021-01-15 20:05   ` Dmitry A. Kazakov
  2021-01-17  5:34     ` reinert
  0 siblings, 1 reply; 13+ messages in thread
From: Dmitry A. Kazakov @ 2021-01-15 20:05 UTC (permalink / raw)


On 2021-01-15 20:42, reinert wrote:
> Convert between prefix, infix, postfix notation?

Convert what?

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: ANN: Simple Components v
  2021-01-15 20:05   ` Dmitry A. Kazakov
@ 2021-01-17  5:34     ` reinert
  2021-01-17  5:37       ` reinert
  2021-01-17  6:54       ` Dmitry A. Kazakov
  0 siblings, 2 replies; 13+ messages in thread
From: reinert @ 2021-01-17  5:34 UTC (permalink / raw)


> > Convert between prefix, infix, postfix notation?
> Convert what?
> -- 

Here is a reference to the topic:

https://www.geeksforgeeks.org/convert-infix-prefix-notation:

Simple example:

a + b <-> +(a,b)

The expressions could be more complex:

(a op1 b op2 (c + (d op3 e))) op4 ((f op5 g) op6)

where op1, op2 etc are operators (functions).

This may be standard for those making compilers.
I use it to process sets (where operators are intersection, union etc)
and a, b, c, ... above can be references to functions returning Ordered_Sets.
This is a good  exercise in using recursive procedures/functions :-) However, I would
like to see possibilities to generalize my approach (using for example generics).

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: ANN: Simple Components v
  2021-01-17  5:34     ` reinert
@ 2021-01-17  5:37       ` reinert
  2021-01-17  6:54       ` Dmitry A. Kazakov
  1 sibling, 0 replies; 13+ messages in thread
From: reinert @ 2021-01-17  5:37 UTC (permalink / raw)


Forgot to say that prefix notation seems to make things simpler (that is a main point).

reinert


søndag 17. januar 2021 kl. 06:34:51 UTC+1 skrev reinert:
> > > Convert between prefix, infix, postfix notation? 
> > Convert what? 
> > --
> Here is a reference to the topic: 
> 
> https://www.geeksforgeeks.org/convert-infix-prefix-notation: 
> 
> Simple example: 
> 
> a + b <-> +(a,b) 
> 
> The expressions could be more complex: 
> 
> (a op1 b op2 (c + (d op3 e))) op4 ((f op5 g) op6) 
> 
> where op1, op2 etc are operators (functions). 
> 
> This may be standard for those making compilers. 
> I use it to process sets (where operators are intersection, union etc) 
> and a, b, c, ... above can be references to functions returning Ordered_Sets. 
> This is a good exercise in using recursive procedures/functions :-) However, I would 
> like to see possibilities to generalize my approach (using for example generics).

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: ANN: Simple Components v
  2021-01-17  5:34     ` reinert
  2021-01-17  5:37       ` reinert
@ 2021-01-17  6:54       ` Dmitry A. Kazakov
  2021-01-17 16:20         ` reinert
  1 sibling, 1 reply; 13+ messages in thread
From: Dmitry A. Kazakov @ 2021-01-17  6:54 UTC (permalink / raw)


On 2021-01-17 06:34, reinert wrote:
>>> Convert between prefix, infix, postfix notation?
>> Convert what?
>> -- 
> 
> Here is a reference to the topic:
> 
> https://www.geeksforgeeks.org/convert-infix-prefix-notation:
> 
> Simple example:
> 
> a + b <-> +(a,b)

And what is the problem? I mean this is trivial, or I do not understand 
your question.

> The expressions could be more complex:
> 
> (a op1 b op2 (c + (d op3 e))) op4 ((f op5 g) op6)
> 
> where op1, op2 etc are operators (functions).
> 
> This may be standard for those making compilers.
> I use it to process sets (where operators are intersection, union etc)
> and a, b, c, ... above can be references to functions returning Ordered_Sets.

I do not understand this either. Set-theoretic operations form a 
lattice, no different from Ada's logical operations "and", "or", "not" 
plus "in", "not in". Same rules. Are asking about syntax or types involved?

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: ANN: Simple Components v
  2021-01-17  6:54       ` Dmitry A. Kazakov
@ 2021-01-17 16:20         ` reinert
  2021-01-17 16:55           ` Shark8
  2021-01-17 17:26           ` Dmitry A. Kazakov
  0 siblings, 2 replies; 13+ messages in thread
From: reinert @ 2021-01-17 16:20 UTC (permalink / raw)


I use it as part of a system processing scripts. The terms (a, b, c,..) and
operations (op1, op2,...) may represent functions to be defined.

reinert

søndag 17. januar 2021 kl. 07:54:16 UTC+1 skrev Dmitry A. Kazakov:
> On 2021-01-17 06:34, reinert wrote: 
> >>> Convert between prefix, infix, postfix notation? 
> >> Convert what? 
> >> -- 
> > 
> > Here is a reference to the topic: 
> > 
> > https://www.geeksforgeeks.org/convert-infix-prefix-notation: 
> > 
> > Simple example: 
> > 
> > a + b <-> +(a,b)
> And what is the problem? I mean this is trivial, or I do not understand 
> your question.
> > The expressions could be more complex: 
> > 
> > (a op1 b op2 (c + (d op3 e))) op4 ((f op5 g) op6) 
> > 
> > where op1, op2 etc are operators (functions). 
> > 
> > This may be standard for those making compilers. 
> > I use it to process sets (where operators are intersection, union etc) 
> > and a, b, c, ... above can be references to functions returning Ordered_Sets.
> I do not understand this either. Set-theoretic operations form a 
> lattice, no different from Ada's logical operations "and", "or", "not" 
> plus "in", "not in". Same rules. Are asking about syntax or types involved?
> -- 
> Regards, 
> Dmitry A. Kazakov 
> http://www.dmitry-kazakov.de

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: ANN: Simple Components v
  2021-01-17 16:20         ` reinert
@ 2021-01-17 16:55           ` Shark8
  2021-01-17 17:17             ` reinert
  2021-01-17 17:27             ` Dmitry A. Kazakov
  2021-01-17 17:26           ` Dmitry A. Kazakov
  1 sibling, 2 replies; 13+ messages in thread
From: Shark8 @ 2021-01-17 16:55 UTC (permalink / raw)


Dmitry isn't asking about the manner in which you are using prefix-notation, he's asking what the context (types, operations, etc) you're talking about.
In any case, converting between inline/pre-/post-fix operators is trivial: parse the operations and operands into a structure [typically a binary tree], and then walk the tree as needed to produce your desired output.

Type Operator is (Add, Sub, Mul, Div);
Function Image( Input : Operator ) return String is
(case Input is
   when Add => "+",
   when Sub => "-",
   when Mul => "*",
   when Div => "/",
);
Type Simplified_Node( Op : Operator ) is record
  Left, Right : Integer;
end record;

Function Inline( Input : Simplified_Node ) return String is
   ( Input.Left'Image & ' ' & Image(Input.Op) & ' ' & Right'Image );
Function Prefix ( Input : Simplified_Node ) return String is
   ( Image(Input.Op) & ' ' & Input.Left'Image & ' ' & Right'Image );
Function Postfix( Input : Simplified_Node ) return String is
   ( Input.Left'Image & ' ' & Right'Image & ' ' & Image(Input.Op) );

In a non-trivial example, the concept above would be equivalent to the expression-parsing definition found in many language. It would also let you have expressions as the Left or Right child, and might even handle precedence, though there are some languages that even though using inline operators have strict (usually left-to-right) ordering regardless of the operator.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: ANN: Simple Components v
  2021-01-17 16:55           ` Shark8
@ 2021-01-17 17:17             ` reinert
  2021-01-17 17:38               ` Dmitry A. Kazakov
  2021-01-17 17:27             ` Dmitry A. Kazakov
  1 sibling, 1 reply; 13+ messages in thread
From: reinert @ 2021-01-17 17:17 UTC (permalink / raw)


søndag 17. januar 2021 kl. 17:55:59 UTC+1 skrev Shark8:
> Dmitry isn't asking about the manner in which you are using prefix-notation, he's asking what the context (types, operations, etc) you're talking about. 
> In any case, converting between inline/pre-/post-fix operators is trivial: parse the operations and operands into a structure [typically a binary tree], and then walk the tree as needed to produce your desired output. 
> 
> 
Yes, pretty trivial and too simple for "Simple components" :-) One may define operators (function of max two arguments) hard-coded 
in an actual Ada program or  assume it is defined outside of it in a script (a bit more complex). Also note that check of user input and error messages (to the user) adds complexity. 

I am just checking out what is available to avoid spending time to reinvent the wheel.

reinert

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: ANN: Simple Components v
  2021-01-17 16:20         ` reinert
  2021-01-17 16:55           ` Shark8
@ 2021-01-17 17:26           ` Dmitry A. Kazakov
  1 sibling, 0 replies; 13+ messages in thread
From: Dmitry A. Kazakov @ 2021-01-17 17:26 UTC (permalink / raw)


On 2021-01-17 17:20, reinert wrote:
> I use it as part of a system processing scripts. The terms (a, b, c,..) and
> operations (op1, op2,...) may represent functions to be defined.

I see. No, conversion is a bad idea, because if you really mean 
conversion (text in, text out) that is an extra pass, which is totally 
unnecessary. In the case of prefix notation it is actually two extra 
passes because prefix notation is not directly executable. You probably 
meant the reverse Polish notation which is.

Anyway it is not needed. See the calculator example, which parses and 
executes in one pass.

    http://www.dmitry-kazakov.de/ada/components.htm#13.1

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: ANN: Simple Components v
  2021-01-17 16:55           ` Shark8
  2021-01-17 17:17             ` reinert
@ 2021-01-17 17:27             ` Dmitry A. Kazakov
  1 sibling, 0 replies; 13+ messages in thread
From: Dmitry A. Kazakov @ 2021-01-17 17:27 UTC (permalink / raw)


On 2021-01-17 17:55, Shark8 wrote:
> Dmitry isn't asking about the manner in which you are using prefix-notation, he's asking what the context (types, operations, etc) you're talking about.

I understand that even less.

> In any case, converting between inline/pre-/post-fix operators is trivial: parse the operations and operands into a structure [typically a binary tree], and then walk the tree as needed to produce your desired output.

OK, that is not conversion that is generation of the syntax tree. It is 
up to the user callback to execute or to generate the tree. An example 
generating syntax tree for Ada 95 expression in one pass is provided.

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: ANN: Simple Components v
  2021-01-17 17:17             ` reinert
@ 2021-01-17 17:38               ` Dmitry A. Kazakov
  2021-01-18  6:50                 ` reinert
  0 siblings, 1 reply; 13+ messages in thread
From: Dmitry A. Kazakov @ 2021-01-17 17:38 UTC (permalink / raw)


On 2021-01-17 18:17, reinert wrote:
> søndag 17. januar 2021 kl. 17:55:59 UTC+1 skrev Shark8:
>> Dmitry isn't asking about the manner in which you are using prefix-notation, he's asking what the context (types, operations, etc) you're talking about.
>> In any case, converting between inline/pre-/post-fix operators is trivial: parse the operations and operands into a structure [typically a binary tree], and then walk the tree as needed to produce your desired output.
>>
>>
> Yes, pretty trivial and too simple for "Simple components" :-) One may define operators (function of max two arguments) hard-coded
> in an actual Ada program or  assume it is defined outside of it in a script (a bit more complex).

It is table-driven. You provide tables with brackets, 
prefix/suffix/infix operators, commas, ligatures (like Ada's =>) to the 
parser. So, it is fully dynamic, nothing is hard-coded, no grammar involved.

  Also note that check of user input and error messages (to the user) 
adds complexity.

Not much. For a syntax error you get a primitive operation callback from 
where you either:

- raise an exception with the current source location encoded into. E.g. 
mismatched bracket, association violation (e.g. X and Y or Z) etc.

- correct error, e.g. if you detect an unexpected closing bracket or 
missing operation, you might decide that this indicates the end of the 
expression.

> I am just checking out what is available to avoid spending time to reinvent the wheel.

That is reasonable.

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: ANN: Simple Components v
  2021-01-17 17:38               ` Dmitry A. Kazakov
@ 2021-01-18  6:50                 ` reinert
  0 siblings, 0 replies; 13+ messages in thread
From: reinert @ 2021-01-18  6:50 UTC (permalink / raw)


Just a comment (a bit exotic): such symbol-processing can have interest in search for 
models explaining data (may call it "inverse mapping"). It may seem impossible to test
out all possible combinations of symbols to search for a meaningful formula, but with
some good starts and modest mutations/recombinations one may imitate natural
selection - or Darwinism which I believe in :-)

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2021-01-18  6:50 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-13 12:01 ANN: Simple Components v Dmitry A. Kazakov
2021-01-15 19:42 ` reinert
2021-01-15 20:05   ` Dmitry A. Kazakov
2021-01-17  5:34     ` reinert
2021-01-17  5:37       ` reinert
2021-01-17  6:54       ` Dmitry A. Kazakov
2021-01-17 16:20         ` reinert
2021-01-17 16:55           ` Shark8
2021-01-17 17:17             ` reinert
2021-01-17 17:38               ` Dmitry A. Kazakov
2021-01-18  6:50                 ` reinert
2021-01-17 17:27             ` Dmitry A. Kazakov
2021-01-17 17:26           ` Dmitry A. Kazakov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox