Syntax highlighting for Asterisk AEL

Syntax highlighting for Asterisk AEL

3

    Dec 19, 2010#1

    I'm starting to use UltraEdit.
    Language AEL has some similarities to C :
    https://wiki.asterisk.org/wiki/display/ ... sion+2+BNF

    After reading the document I tried to modify one copy of C wordfile for work with an asterisk AEL file.
    But some option of this language is different from C file, example function in uew is similar below:

    macro xxx( ext , dev ) {
    }

    context yyy {
    }

    Can any expert help me to complete it?
    ael.zip (2.17 KiB)   188
    This ZIP file contains first version of ael.uew wordfile.

    6,602548
    Grand MasterGrand Master
    6,602548

      Dec 20, 2010#2

      Without reading the referenced page because I'm busy this morning, what about using the modified wordfile as attached to my post?

      Please note that I removed the color and font style settings because published wordfiles should be always without personal settings. So you need to add them again when the modified wordfile works fine for you.
      ael.zip (1.87 KiB)   176
      The ZIP file contains the modified wordfile for AEL.
      Best regards from an UC/UE/UES for Windows user from Austria

      3

        Dec 20, 2010#3

        hi mofi,

        i check below section of your code :

        Code: Select all

        /TGBegin "Function"
        /TGFindStr = "%macro[ ^t]+^([a-z0-9_]+^)[ ^t]++(*)[ ^t]+{"
        /TGFindStr = "%context[ ^t]+^([a-z0-9_]+^)[ ^t]+{"
        /TGBegin "Parameter"
        /TGFindStr = "[ ^t^p]++^([~,]+^)"
        /TGFindBStart = "("
        /TGFindBEnd = ")"
        /TGEnd
        /TGBegin "Variable"
        /TGFindStr = "%[ ^t]++^([a-z0-9_]+[ ^t^*]+[a-z0-9^[^]_]+^);"
        /TGFindBStart = "{"
        /TGFindBEnd = "}"
        /TGFindStr = "%[ ^t]++^([a-z0-9_]+[ ^t^*]+[a-z0-9^[^]_]+^)[ ^t]++=*;"
        /TGFindBStart = "{"
        /TGFindBEnd = "}"
        /TGEnd
        /TGEnd
        seems can not true find macro & context please some check it ....

        i more try and replace two lines of your code with this code and solve the problem which can not find macro and extension , but parameter and variable of context & macro still don't find

        Code: Select all

        /TGFindStr = "macro [a-zA-Z0-9]+( [a-zA-Z0-9]"         
        /TGFindStr = "context [a-zA-Z0-9{]"                         
        

        for your check i add small ael file for yours :

        Code: Select all

        macro waehle( dev, ext, nummer, pkz, callernumber ){
        	agi(showcallee.php|${nummer}|${pkz});
        	Set(CALLERID(name)=${callernumber});
        	Dial(${dev}/${ext},240,g);
        	SendText(Beendet);
        	Hangup();
        };
        
        context rauswaehlen{
        	// fuer florian
        	_10.  => { // dus.net
        	   &waehle(SIP,${EXTEN:1}@000123456,${EXTEN:1},1,49228243546);
        	};
        	_150. => { // sipgate
        	  &waehle(SIP,${EXTEN:2}@87654321,${EXTEN:2},1,49228975421);
        	};
        	_190. => { // dus.net: Anonym
        	  &waehle(SIP,${EXTEN:2}@000123456,${EXTEN:2},1,anonymous);
        	};
        	// fuer mareike
        	_20.  => { // dus.net
        	   &waehle(SIP,${EXTEN:1}@000654321,${EXTEN:1},2,49228132435);
        	};
        };


        ?

        6,602548
        Grand MasterGrand Master
        6,602548

          Dec 20, 2010#4

          I used the page Asterisk AEL2 because your referenced webpage is a secure webpage which requires cookies and my settings for cookies are very restricted (blocked for all accept a few manually defined sites) which results in not being able to load this secure webpage.

          I think the following set of UltraEdit regular expressions make a good job without really looking deeply into the syntax as explained on the referenced page.

          /TGBegin "Macros"
          /TGFindStr = "%macro[ ^t]+^([a-z0-9_^-]+^)[ ^t]++(*)[ ^t]++{"
          /TGBegin "Parameter"
          /TGFindStr = "[ ^t^p]++^([~,]+^)"
          /TGFindBStart = "("
          /TGFindBEnd = ")"
          /TGEnd
          /TGEnd
          /TGBegin "Contexts"
          /TGFindStr = "%context[ ^t]+^([a-z0-9_^-]+^)[ ^t]++{"
          /TGBegin "Extensions"
          /TGFindStr = "^([a-z0-9_./^-]+^)[ ^t]++=>"
          /TGFindBStart = "{"
          /TGFindBEnd = "}"
          /TGBegin "Labels"
          /TGFindStr = "[ ^t]++^([a-z0-9_^-]+^):"
          /TGFindBStart = "{"
          /TGFindBEnd = "}"
          /TGEnd
          /TGBegin "Variables"
          /TGFindStr = "[ ^t]+^([a-z0-9_^-]+^)[ ^t]++=[ ^t]++[a-z0-9./^-]+;"
          /TGFindBStart = "{"
          /TGFindBEnd = "}"
          /TGEnd
          /TGEnd
          /TGEnd
          /TGBegin "Globals"
          /TGFindStr = "%^(globals^)[ ^t]++{"
          /TGBegin "Variables"
          /TGFindStr = "[ ^t]+^([a-z0-9_^-]+^)[ ^t]++=[ ^t]++[a-z0-9./^-]+;"
          /TGFindBStart = "{"
          /TGFindBEnd = "}"
          /TGEnd
          /TGEnd


          You should delete the 2 lines starting with /Member String = and /Variable String because they are interpreted only by UEStudio for integrated symbol parser and therefore don't make sense here.

          Further I suggest to replace Escape Char = \ String Chars = "' in the first line by Noquote because it looks like AEL has no special definitions for multi-character and single-character strings.
          Best regards from an UC/UE/UES for Windows user from Austria

          3

            Dec 22, 2010#5

            Hi mofi is now so better but some problem still av. for example
            1. macro not found true
            2.some global var not found

            Code: Select all

            globals {
            	static=yes
            	writeprotect=no
            	clearglobalvars=no
            	OUTBOUNDTRANK=Dahdi/g1;
            	REC_PATH=/SDB/REC/1/;
            	//Set(TIMEOUT(absolute)=750);	
            };
            
            macro Dial-Record (ext , dev , cid , ctx){
            	Answer();
            	Hangup();
              catch h  {
              }  
            };
            
            context  users {
            	_xxx => {
            		 &Dial-Record(${EXTEN},"SIP",${CALLERID(num)},"NOTUSED");
            	}
            };
            
            context BLF_Group_1 {
            	 _xxx => {
            	 		hints(sip/${EXTEN});
            	 	}
            };
            
            context BLF_group_pickup {
            	_xxx =>{
            		Hangup();
            	}
            };
            
            context PSTNline {
            	s => {
            	   Set(TIMEOUT(digit)=4);
            
            	}
            	_xxx => 		{
            		&Dial-Record(${EXTEN},"SIP",${CALLERID(num)},"NOTUSED");
            	}
            
            };

            6,602548
            Grand MasterGrand Master
            6,602548

              Dec 22, 2010#6

              You should open the help page titled Regular Expressions (Legacy) and use the first table to understand the regular expressions I posted for your AEL wordfile. It is quite easy to understand them with this table and it would give you the possibility to adapt them by yourself.

              The macro with name Dial-Record is not listed in the function list view because of the hyphen. Up to now I have thought that only letters a-z in any case, number 0-9 and underscores are valid characters for symbol names. If a hyphen is also a valid character for a symbol name as it looks like you should modify all [a-z0-9_] expressions to [a-z0-9_^-]. The hyphen character has no special regular expression meaning except inside [...] which is the reason why the hyphen should be escaped with character ^ inside a square bracket expression. Escaping a hyphen character is not needed anywhere else in an UltraEdit regular expression, just when specified inside a square bracket without meaning "from ... to". I added ^- several times in my previous post.

              Why some of the variables are not found in globals section is also easy to explain when interpreting the expression [ ^t]+^([a-z0-9_^-]+^)[ ^t]++=[ ^t]++[a-z0-9./^-]+; used twice.

              [ ^t]+ finds 1 or more spaces tabs. Hm, the [ ^t] is not really needed and should be removed.

              ^(...^) tag this part of the found string. Only this part of the found string is displayed in the function list view.

              [a-z0-9_^-]+ finds a string with 1 or more characters consisting of only letters, numbers, underscores or hyphens.

              [ ^t]++=[ ^t]++ next character(s) can be a space and/or tab before an equal sign is found and after the equal sign there can be 0 or more spaces/tabs.

              [a-z0-9./^-]+ means the next found string should consist of only letters, numbers, points, slashes or hyphens.

              ; and finally a semicolon must follow. And that is the reason why some of the variables are not found.

              From the referenced documentation it was totally unclear for me if a variable definition with value assignment must be terminated with a semicolon like in C or not. All example lines except one in the section about variables have a semicolon at end. So I thought that on the one line without semicolon it was just forgotten. It looks like the semicolon is optional or there is a rule when it must be used and when it can be omitted.

              It would be no problem to remove the semicolon from the regular expression. But this could result in showing many expressions with an equal sign between to words (symbols) in the function list view. It looks like there is no real rule what defines a variable which is bad for finding them.
              Best regards from an UC/UE/UES for Windows user from Austria