Question: given the following grammar I have to find the appropriate semantic actions to calculate, for each string of the language, the number of pairs of parentheses in the string.

**S -> (L)**

**S -> a**

**L -> L, S**

**L -> S**

Usually, to perform this type of exercise, I build a derivation tree of a sample string and then I add the attributes. After that it is easier to find the semantic rules.

So I built this derivation tree for the string "**((a, (a), a))**", but I can't proceed with the resolution of the exercise. How do I count the pairs of parentheses? I'am not able to do that...

![enter image description here](https://i.stack.imgur.com/KJMZH.png)

I do't want the solution but I'd like someone to help me with the reasoning to be made in these cases.

(I'm sorry for the bad tree...)

Answer: 
AsteriskNow is a complete distribution based on CentOS available as an ISO file. There doesn't appear to be an EC2 AMI available for it so you would have to build an image yourself.

[Here's an overview of the process for Oracle Linux](http://www.rittmanmead.com/2014/09/obiee-sampleapp-in-the-cloud-importing-virtualbox-machines-to-aws-ec2/) which boils down to:

* Install AsteriskNow onto a VirtualBox or VMWare instance locally.
* Configure all the EC2 specifics (This is the fiddly bit)
* Export that virtual machine as a VMDK.
* Copy the VMDK to S3
* Import the VMDK to an EBS volume and launch on Amazon EC2.

Before you export you will have to make sure AsteriskNow has a [kernel that supports EC2](https://aws.amazon.com/blogs/aws/use-your-own-kernel-with-amazon-ec2/). In CentOS this would be the Xen kernel but I don't know if Asterisk would supply one, which means compiling. The [PV-GRUB docco](http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/UserProvidedKernels.html) also covers a lot of what can and can't be used on EC2. If it doesn't work out of the box it will take some Linux smarts to figure it all out. 

It will probably take a number of exports/imports to get it running. Once you have it up on EC2 you can turn that instance into an AMI to quickly create clones in the future without going through the whole export/import process.
can you not just download the ISO directly?

```
ubuntu@ip-172-31-14-19:~/iso$ 
ubuntu@ip-172-31-14-19:~/iso$ wget -v https://downloads.asterisk.org/pub/telephony/asterisk-now/AsteriskNow-1013-current-64.iso
--2017-11-17 05:52:53--  https://downloads.asterisk.org/pub/telephony/asterisk-now/AsteriskNow-1013-current-64.iso
Resolving downloads.asterisk.org (downloads.asterisk.org)... 76.164.171.238, 2001:470:e0d4::ee
Connecting to downloads.asterisk.org (downloads.asterisk.org)|76.164.171.238|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1343909888 (1.3G) [application/x-iso9660-image]
Saving to: ‘AsteriskNow-1013-current-64.iso’

AsteriskNow-1013-curr 100%[======================>]   1.25G  1.79MB/s    in 9m 54s  

2017-11-17 06:02:48 (2.16 MB/s) - ‘AsteriskNow-1013-current-64.iso’ saved [1343909888/1343909888]

ubuntu@ip-172-31-14-19:~/iso$ 

```

<https://downloads.asterisk.org/pub/telephony/asterisk-now/>