Jump to content

How interested are you?  

61 members have voted

  1. 1. How interested are you?

    • I am willing to work on the code
    • I am willing to help with testing
    • I would love to see this becoming a reality
    • Nah mate, I don't think this is a good idea


Recommended Posts

Posted

@junkew Thanks, but it looks like the latest version of ANTLR doesn't support C according to wikipedia:

Quote

the current release at present only targets Java, C#, C++,[2] JavaScript, Python2, Python3, Swift, and Go.

C++ is supported, but no way I am going to use C++ source files in a C project!

There are many other parser generators available from what I can see, but as I have mentioned many times earlier, I am not planning to use one at the moment. I want to write my own home-grown parser :)

If reality is too cruel and if it becomes mountain of a task, then I will consider one of these generators... it will be easier to use them as I would be more familiar with defining grammers then :D

EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time)

DcodingTheWeb Forum - Follow for updates and Join for discussion

Posted

The g4 grammar files for ANTLR will give you an idea on how big your task will be

There are many out there and iif you pick such a grammar and visualize it in Eclipse Antlr IDE you get a broader idea where you are looking at

Some nice things in AutoIt (and other languages) you have to parse

  • strings with double or single quotes in them
    • "Fun with a " in my string"

 

Posted

@junkew Thanks, I will try out the IDE and see if it can better help me visualize, though I have to say that the syntax doesn't really resemble BNF.

7 hours ago, junkew said:

Some nice things in AutoIt (and other languages) you have to parse

  • strings with double or single quotes in them
    • "Fun with a " in my string"

It is fun, but not very challenging I guess, string literals could start with either of the quotation marks and only end when the same quotation mark is encountered, anything after it is simply another set of malformed tokens!

EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time)

DcodingTheWeb Forum - Follow for updates and Join for discussion

Posted

Use quicktest.au3 at bottom in your first lexer/parser trials and see how easy it is😅

I experiment a little with Antlr (using Eclipse/Java) as I am nowadays doing much more with Java. Antlr was new to me and took me a few hours to get it running within Eclipse.

With the g4 and visual studio you should also be able to create a C++ lexer/parser (no C lexer/parser seen anymore)

Steps to start with this

  1. https://github.com/antlr4ide/antlr4ide (just follow the steps with the exception I used latest versions)
    1. Install eclipse 2019-09
    2. Install xtext 2.19.0  (just thru the marketplace)
    3. Install Faceted Project Framework
    4. Install ANTLR 4 IDE (just thru the marketplace)
    5. Obtain a copy of antlr-4.x-complete.jar (I have antlr-4.7.2)
  2. Create your project (just follow the steps as given on github, read carefully the steps, i did not initially and missed some version stuff)
    1. Create the au3.g4 file
    2. Create the Au3Runner.java file
  3. Rest is "straight forward' Java and eclipse debug/run

 

save as au3.g4

/**
 * Define a grammar called au3
 */
grammar au3;

au3program  : line+;         // match line

line:   expr+;

//From highest precedence to lowest:
//Not
//^
//* /
//+ -
//&
//< > <= >= = <> ==
//And Or

expr: ID '(' exprList? ')' // func call like f(), f(x), f(1,2)
| expr '[' expr ']' // array index like a[i], a[i][j]
| '-' expr // unary minus
| '!' expr // boolean not
| expr (TOK_MULT | TOK_DIV )expr
| expr (TOK_PLUS | TOK_MINUS) expr
| expr TOK_EQUAL expr // equality comparison (lowest priority op)
| ID // variable reference
| NUMBER
| '(' expr ')'
;
exprList : expr (',' expr)* ; // arg list

TOK_END           : ';' ;
TOK_VARIABLE      : ('$'?) ID;
TOK_MACRO         : '@'ID;

TOK_PLUS          : '+';
TOK_MINUS         : '-';
TOK_DIV           : '/';
TOK_MULT          : '*';
TOK_POW           : '^';

TOK_CONCAT        : '&';

TOK_PLUS_ASSIGN   : '+=';
TOK_MINUS_ASSIGN  : '-=';
TOK_DIV_ASSIGN    : '/=';
TOK_MULT_ASSIGN   : '*=';

TOK_CONCAT_ASSIGN : '&=';

TOK_LEFTPAREN     : '(';
TOK_RIGHTPAREN    : ')';
TOK_LEFTBRACE     : '{';
TOK_RIGHTBRACE    : '}';

TOK_LEFTSUBSCRIPT : '[';
TOK_RIGHTSUBSCRIPT: ']';

TOK_COMMA         : ',';
TOK_STRINGEQUAL   : '==';
TOK_EQUAL         : '=';
TOK_NOTEQUAL      : '<>';
TOK_LESSEQUAL     : '<=';
TOK_LESS          : '<';
TOK_GREATEREQUAL  : '>=';
TOK_GREATER       : '>';
TOK_DOT           : '.';
TOK_INC           : '++';
TOK_DEC           : '--';

TOK_TILDE         : '~';

//TOK_END
//TOK_VARIABLE starts with a $ or has a _ in it
//TOK_MACRO
//TOK_STRING
//TOK_INT32
//TOK_DOUBLE   ;FLOAT
//TOK_INT64
//TOK_FUNCTION
//TOK_USERFUNCTION
// Fragment rules

fragment ExponentPart
    : [eE] [+-]? Digits
    ;

//fragment EscapeSequence
//    : '\\' [btnfr"'\\]
//    | '\\' ([0-3]? [0-7])? [0-7]
//    | '\\' 'u'+ HexDigit HexDigit HexDigit HexDigit
//    ;
    
fragment HexDigits
    : HexDigit ((HexDigit | '_')* HexDigit)?
    ;
fragment HexDigit
    : [0-9a-fA-F]
    ;
fragment Digits
    : [0-9] ([0-9_]* [0-9])?
    ;
fragment LetterOrDigit
    : Letter
    | [0-9]
    ;
    
fragment Letter : [a-zA-Z$_];

TAB : '\t' -> skip ; // match but don't pass to the parser

//Directives
COMMENTSTART         : ('#comments-start' | '#cs') ;
INCLUDE              : '#include';
INCLUDE_ONCE         : '#include-once';
NOTRAYICON           : '#' N O T R A Y I C O N;
ONAUTOITREGISTER     : '#OnAutoItRegister';
PRAGMA               : '#pragma';
REQUIREADMIN         : '#requireadmin';
DIRECTIVEOPERATOR    : '#';



//AutoIt supports NUMBERS, STRINGS, BOOLEANS, 
//BOOLEAN operators AND, OR, NOT
//BINARY type (is a result of a function and results into a 0x..... string)
//POINTER depends on 32 or 64 bits runtime
// CONST and ENUM 

//Keywords
KW_False                          : F A L S E ; 
KW_True                           : T R U E ; 
KW_ContinueCase                   : C O N T I N U E C A S E ; 
KW_ContinueLoop                   : C O N T I N U E L O O P ; 
KW_Default                        : D E F A U L T ; 
KW_Dim                            : D I M ; 
KW_Global                         : G L O B A L ; 
KW_Local                          : L O C A L ; 
KW_Const                          : C O N S T ; 
KW_Do                             : D O ; 
KW_Until                          : U N T I L ; 
KW_Enum                           : E N U M ; 
KW_Exit                           : E X I T ; 
KW_ExitLoop                       : E X I T L O O P ; 
KW_For                            : F O R ; 
KW_To                             : T O ; 
KW_Step                           : S T E P ; 
KW_In                             : I N ; 
KW_Next                           : N E X T ; 
KW_Func                           : F U N C ; 
KW_Return                         : R E T U R N ; 
KW_EndFunc                        : E N D F U N C ; 
KW_If                             : I F ; 
KW_Then                           : T H E N ; 
KW_Elseif                         : E L S E I F ; 
KW_Else                           : E L S E ; 
KW_Endif                          : E N D I F ; 
KW_Null                           : N U L L ; 
KW_ReDim                          : R E D I M ; 
KW_Select                         : S E L E C T ; 
KW_Case                           : C A S E ; 
KW_EndSelect                      : E N D S E L E C T ; 
KW_Static                         : S T A T I C ; 
KW_Switch                         : S W I T C H ; 
KW_EndSwitch                      : E N D S W I T C H ; 
KW_Volatile                       : V O L A T I L E ; 
KW_While                          : W H I L E ; 
KW_Wend                           : W E N D ; 
KW_With                           : W I T H ; 
KW_EndWith                        : E N D W I T H ; 


fragment DIGIT : [0-9] ;
NUMBER : DIGIT+ ([.,] DIGIT+)? ;

FLOAT: DIGIT+ '.' DIGIT* // match 1. 39. 3.14159 etc...
| '.' DIGIT+ // match .1 .14159
;

//LINE_COMMENT : '//' .*? '\n' -> skip ;
//COMMENT : '/*' .*? '*/' -> skip ;

//STRING : '"' .*? '"' ; // match anything in "..."
//STRING : '"' (~[\r\n"] | '""')* '"' | '\'' (~[\r\n\'] | '\'\'')* '\'';
STRING : '"' (~[\r\n"] | '""')* '"' ;
STRING2 : '\'' (~[\r\n'] | '\'\'')* '\'' ;


//STRING : '"' ('""' | ~'"')* '"' ; // quote-quote is an escaped quote
//STRING2 : '\'' ('""'|~'"')* '\'' ; // quote-quote is an escaped quote
//STRING : '"' ( ESC | . )*? '"' ;
fragment ESC : ('\\' | '\b' | '\t' | '\n'); // \b, \t, \n etc...  

//STRING_LITERAL: (STRING_LITERAL1 | STRING_LITERAL2);
//STRING_LITERAL1:     '"' (LETTER | EscapeSequence)* '"';
//STRING_LITERAL2:     '\'' (LETTER | EscapeSequence)* '\'';
//EscapeSequence: ('""' | '\'\''); 

fragment HEX_DIGIT : ('0'..'9' | 'a'..'f' | 'A'..'F') ;
fragment LETTER : (LOWERCASE | UPPERCASE);
fragment LOWERCASE : [a-z] ;
fragment UPPERCASE : [A-Z] ;

ID : (LETTER | '_')+(LETTER | DIGIT | '_') ;
VARIABLE: '$'ID;
MACRO: '@'ID;

// au3 keywords
// Local, Global and Dim which is not adviced


//NEWLINE : ('\r'? '\n' | '\r')+ ;
LineComment : '//' ~[\r\n]* -> skip;
LineComment2: ';~' ~[\r\n]* -> skip;

WS : [ \t\r\n]+ -> skip ; // skip spaces, tabs, newlines

//au3 functions
F_Abs                            : A B S ; 
F_ACos                           : A C O S ; 
F_AdlibRegister                  : A D L I B R E G I S T E R ; 
F_AdlibUnRegister                : A D L I B U N R E G I S T E R ; 
F_Asc                            : A S C ; 
F_AscW                           : A S C W ; 
F_ASin                           : A S I N ; 
F_Assign                         : A S S I G N ; 
F_ATan                           : A T A N ; 
F_AutoItSetOption                : A U T O I T S E T O P T I O N ; 
F_AutoItWinGetTitle              : A U T O I T W I N G E T T I T L E ; 
F_AutoItWinSetTitle              : A U T O I T W I N S E T T I T L E ; 
F_Beep                           : B E E P ; 
F_Binary                         : B I N A R Y ; 
F_BinaryLen                      : B I N A R Y L E N ; 
F_BinaryMid                      : B I N A R Y M I D ; 
F_BinaryToString                 : B I N A R Y T O S T R I N G ; 
F_BitAND                         : B I T A N D ; 
F_BitNOT                         : B I T N O T ; 
F_BitOR                          : B I T O R ; 
F_BitRotate                      : B I T R O T A T E ; 
F_BitShift                       : B I T S H I F T ; 
F_BitXOR                         : B I T X O R ; 
F_BlockInput                     : B L O C K I N P U T ; 
F_Break                          : B R E A K ; 
F_Call                           : C A L L ; 
F_CDTray                         : C D T R A Y ; 
F_Ceiling                        : C E I L I N G ; 
F_Chr                            : C H R ; 
F_ChrW                           : C H R W ; 
F_ClipGet                        : C L I P G E T ; 
F_ClipPut                        : C L I P P U T ; 
F_ConsoleRead                    : C O N S O L E R E A D ; 
F_ConsoleWrite                   : C O N S O L E W R I T E ; 
F_ConsoleWriteError              : C O N S O L E W R I T E E R R O R ; 
F_ControlClick                   : C O N T R O L C L I C K ; 
F_ControlCommand                 : C O N T R O L C O M M A N D ; 
F_ControlDisable                 : C O N T R O L D I S A B L E ; 
F_ControlEnable                  : C O N T R O L E N A B L E ; 
F_ControlFocus                   : C O N T R O L F O C U S ; 
F_ControlGetFocus                : C O N T R O L G E T F O C U S ; 
F_ControlGetHandle               : C O N T R O L G E T H A N D L E ; 
F_ControlGetPos                  : C O N T R O L G E T P O S ; 
F_ControlGetText                 : C O N T R O L G E T T E X T ; 
F_ControlHide                    : C O N T R O L H I D E ; 
F_ControlListView                : C O N T R O L L I S T V I E W ; 
F_ControlMove                    : C O N T R O L M O V E ; 
F_ControlSend                    : C O N T R O L S E N D ; 
F_ControlSetText                 : C O N T R O L S E T T E X T ; 
F_ControlShow                    : C O N T R O L S H O W ; 
F_ControlTreeView                : C O N T R O L T R E E V I E W ; 
F_Cos                            : C O S ; 
F_Dec                            : D E C ; 
F_DirCopy                        : D I R C O P Y ; 
F_DirCreate                      : D I R C R E A T E ; 
F_DirGetSize                     : D I R G E T S I Z E ; 
F_DirMove                        : D I R M O V E ; 
F_DirRemove                      : D I R R E M O V E ; 
F_DllCall                        : D L L C A L L ; 
F_DllCallAddress                 : D L L C A L L A D D R E S S ; 
F_DllCallbackFree                : D L L C A L L B A C K F R E E ; 
F_DllCallbackGetPtr              : D L L C A L L B A C K G E T P T R ; 
F_DllCallbackRegister            : D L L C A L L B A C K R E G I S T E R ; 
F_DllClose                       : D L L C L O S E ; 
F_DllOpen                        : D L L O P E N ; 
F_DllStructCreate                : D L L S T R U C T C R E A T E ; 
F_DllStructGetData               : D L L S T R U C T G E T D A T A ; 
F_DllStructGetPtr                : D L L S T R U C T G E T P T R ; 
F_DllStructGetSize               : D L L S T R U C T G E T S I Z E ; 
F_DllStructSetData               : D L L S T R U C T S E T D A T A ; 
F_DriveGetDrive                  : D R I V E G E T D R I V E ; 
F_DriveGetFileSystem             : D R I V E G E T F I L E S Y S T E M ; 
F_DriveGetLabel                  : D R I V E G E T L A B E L ; 
F_DriveGetSerial                 : D R I V E G E T S E R I A L ; 
F_DriveGetType                   : D R I V E G E T T Y P E ; 
F_DriveMapAdd                    : D R I V E M A P A D D ; 
F_DriveMapDel                    : D R I V E M A P D E L ; 
F_DriveMapGet                    : D R I V E M A P G E T ; 
F_DriveSetLabel                  : D R I V E S E T L A B E L ; 
F_DriveSpaceFree                 : D R I V E S P A C E F R E E ; 
F_DriveSpaceTotal                : D R I V E S P A C E T O T A L ; 
F_DriveStatus                    : D R I V E S T A T U S ; 
F_EnvGet                         : E N V G E T ; 
F_EnvSet                         : E N V S E T ; 
F_EnvUpdate                      : E N V U P D A T E ; 
F_Eval                           : E V A L ; 
F_Execute                        : E X E C U T E ; 
F_Exp                            : E X P ; 
F_FileChangeDir                  : F I L E C H A N G E D I R ; 
F_FileClose                      : F I L E C L O S E ; 
F_FileCopy                       : F I L E C O P Y ; 
F_FileCreateNTFSLink             : F I L E C R E A T E N T F S L I N K ; 
F_FileCreateShortcut             : F I L E C R E A T E S H O R T C U T ; 
F_FileDelete                     : F I L E D E L E T E ; 
F_FileExists                     : F I L E E X I S T S ; 
F_FileFindFirstFile              : F I L E F I N D F I R S T F I L E ; 
F_FileFindNextFile               : F I L E F I N D N E X T F I L E ; 
F_FileFlush                      : F I L E F L U S H ; 
F_FileGetAttrib                  : F I L E G E T A T T R I B ; 
F_FileGetEncoding                : F I L E G E T E N C O D I N G ; 
F_FileGetLongName                : F I L E G E T L O N G N A M E ; 
F_FileGetPos                     : F I L E G E T P O S ; 
F_FileGetShortcut                : F I L E G E T S H O R T C U T ; 
F_FileGetShortName               : F I L E G E T S H O R T N A M E ; 
F_FileGetSize                    : F I L E G E T S I Z E ; 
F_FileGetTime                    : F I L E G E T T I M E ; 
F_FileGetVersion                 : F I L E G E T V E R S I O N ; 
F_FileInstall                    : F I L E I N S T A L L ; 
F_FileMove                       : F I L E M O V E ; 
F_FileOpen                       : F I L E O P E N ; 
F_FileOpenDialog                 : F I L E O P E N D I A L O G ; 
F_FileRead                       : F I L E R E A D ; 
F_FileReadLine                   : F I L E R E A D L I N E ; 
F_FileReadToArray                : F I L E R E A D T O A R R A Y ; 
F_FileRecycle                    : F I L E R E C Y C L E ; 
F_FileRecycleEmpty               : F I L E R E C Y C L E E M P T Y ; 
F_FileSaveDialog                 : F I L E S A V E D I A L O G ; 
F_FileSelectFolder               : F I L E S E L E C T F O L D E R ; 
F_FileSetAttrib                  : F I L E S E T A T T R I B ; 
F_FileSetEnd                     : F I L E S E T E N D ; 
F_FileSetPos                     : F I L E S E T P O S ; 
F_FileSetTime                    : F I L E S E T T I M E ; 
F_FileWrite                      : F I L E W R I T E ; 
F_FileWriteLine                  : F I L E W R I T E L I N E ; 
F_Floor                          : F L O O R ; 
F_FtpSetProxy                    : F T P S E T P R O X Y ; 
F_FuncName                       : F U N C N A M E ; 
F_GUICreate                      : G U I C R E A T E ; 
F_GUICtrlCreateAvi               : G U I C T R L C R E A T E A V I ; 
F_GUICtrlCreateButton            : G U I C T R L C R E A T E B U T T O N ; 
F_GUICtrlCreateCheckbox          : G U I C T R L C R E A T E C H E C K B O X ; 
F_GUICtrlCreateCombo             : G U I C T R L C R E A T E C O M B O ; 
F_GUICtrlCreateContextMenu       : G U I C T R L C R E A T E C O N T E X T M E N U ; 
F_GUICtrlCreateDate              : G U I C T R L C R E A T E D A T E ; 
F_GUICtrlCreateDummy             : G U I C T R L C R E A T E D U M M Y ; 
F_GUICtrlCreateEdit              : G U I C T R L C R E A T E E D I T ; 
F_GUICtrlCreateGraphic           : G U I C T R L C R E A T E G R A P H I C ; 
F_GUICtrlCreateGroup             : G U I C T R L C R E A T E G R O U P ; 
F_GUICtrlCreateIcon              : G U I C T R L C R E A T E I C O N ; 
F_GUICtrlCreateInput             : G U I C T R L C R E A T E I N P U T ; 
F_GUICtrlCreateLabel             : G U I C T R L C R E A T E L A B E L ; 
F_GUICtrlCreateList              : G U I C T R L C R E A T E L I S T ; 
F_GUICtrlCreateListView          : G U I C T R L C R E A T E L I S T V I E W ; 
F_GUICtrlCreateListViewItem      : G U I C T R L C R E A T E L I S T V I E W I T E M ; 
F_GUICtrlCreateMenu              : G U I C T R L C R E A T E M E N U ; 
F_GUICtrlCreateMenuItem          : G U I C T R L C R E A T E M E N U I T E M ; 
F_GUICtrlCreateMonthCal          : G U I C T R L C R E A T E M O N T H C A L ; 
F_GUICtrlCreateObj               : G U I C T R L C R E A T E O B J ; 
F_GUICtrlCreatePic               : G U I C T R L C R E A T E P I C ; 
F_GUICtrlCreateProgress          : G U I C T R L C R E A T E P R O G R E S S ; 
F_GUICtrlCreateRadio             : G U I C T R L C R E A T E R A D I O ; 
F_GUICtrlCreateSlider            : G U I C T R L C R E A T E S L I D E R ; 
F_GUICtrlCreateTab               : G U I C T R L C R E A T E T A B ; 
F_GUICtrlCreateTabItem           : G U I C T R L C R E A T E T A B I T E M ; 
F_GUICtrlCreateTreeView          : G U I C T R L C R E A T E T R E E V I E W ; 
F_GUICtrlCreateTreeViewItem      : G U I C T R L C R E A T E T R E E V I E W I T E M ; 
F_GUICtrlCreateUpdown            : G U I C T R L C R E A T E U P D O W N ; 
F_GUICtrlDelete                  : G U I C T R L D E L E T E ; 
F_GUICtrlGetHandle               : G U I C T R L G E T H A N D L E ; 
F_GUICtrlGetState                : G U I C T R L G E T S T A T E ; 
F_GUICtrlRead                    : G U I C T R L R E A D ; 
F_GUICtrlRecvMsg                 : G U I C T R L R E C V M S G ; 
F_GUICtrlRegisterListViewSort    : G U I C T R L R E G I S T E R L I S T V I E W S O R T ; 
F_GUICtrlSendMsg                 : G U I C T R L S E N D M S G ; 
F_GUICtrlSendToDummy             : G U I C T R L S E N D T O D U M M Y ; 
F_GUICtrlSetBkColor              : G U I C T R L S E T B K C O L O R ; 
F_GUICtrlSetColor                : G U I C T R L S E T C O L O R ; 
F_GUICtrlSetCursor               : G U I C T R L S E T C U R S O R ; 
F_GUICtrlSetData                 : G U I C T R L S E T D A T A ; 
F_GUICtrlSetDefBkColor           : G U I C T R L S E T D E F B K C O L O R ; 
F_GUICtrlSetDefColor             : G U I C T R L S E T D E F C O L O R ; 
F_GUICtrlSetFont                 : G U I C T R L S E T F O N T ; 
F_GUICtrlSetGraphic              : G U I C T R L S E T G R A P H I C ; 
F_GUICtrlSetImage                : G U I C T R L S E T I M A G E ; 
F_GUICtrlSetLimit                : G U I C T R L S E T L I M I T ; 
F_GUICtrlSetOnEvent              : G U I C T R L S E T O N E V E N T ; 
F_GUICtrlSetPos                  : G U I C T R L S E T P O S ; 
F_GUICtrlSetResizing             : G U I C T R L S E T R E S I Z I N G ; 
F_GUICtrlSetState                : G U I C T R L S E T S T A T E ; 
F_GUICtrlSetStyle                : G U I C T R L S E T S T Y L E ; 
F_GUICtrlSetTip                  : G U I C T R L S E T T I P ; 
F_GUIDelete                      : G U I D E L E T E ; 
F_GUIGetCursorInfo               : G U I G E T C U R S O R I N F O ; 
F_GUIGetMsg                      : G U I G E T M S G ; 
F_GUIGetStyle                    : G U I G E T S T Y L E ; 
F_GUIRegisterMsg                 : G U I R E G I S T E R M S G ; 
F_GUISetAccelerators             : G U I S E T A C C E L E R A T O R S ; 
F_GUISetBkColor                  : G U I S E T B K C O L O R ; 
F_GUISetCoord                    : G U I S E T C O O R D ; 
F_GUISetCursor                   : G U I S E T C U R S O R ; 
F_GUISetFont                     : G U I S E T F O N T ; 
F_GUISetHelp                     : G U I S E T H E L P ; 
F_GUISetIcon                     : G U I S E T I C O N ; 
F_GUISetOnEvent                  : G U I S E T O N E V E N T ; 
F_GUISetState                    : G U I S E T S T A T E ; 
F_GUISetStyle                    : G U I S E T S T Y L E ; 
F_GUIStartGroup                  : G U I S T A R T G R O U P ; 
F_GUISwitch                      : G U I S W I T C H ; 
F_Hex                            : H E X ; 
F_HotKeySet                      : H O T K E Y S E T ; 
F_HttpSetProxy                   : H T T P S E T P R O X Y ; 
F_HttpSetUserAgent               : H T T P S E T U S E R A G E N T ; 
F_HWnd                           : H W N D ; 
F_InetClose                      : I N E T C L O S E ; 
F_InetGet                        : I N E T G E T ; 
F_InetGetInfo                    : I N E T G E T I N F O ; 
F_InetGetSize                    : I N E T G E T S I Z E ; 
F_InetRead                       : I N E T R E A D ; 
F_IniDelete                      : I N I D E L E T E ; 
F_IniRead                        : I N I R E A D ; 
F_IniReadSection                 : I N I R E A D S E C T I O N ; 
F_IniReadSectionNames            : I N I R E A D S E C T I O N N A M E S ; 
F_IniRenameSection               : I N I R E N A M E S E C T I O N ; 
F_IniWrite                       : I N I W R I T E ; 
F_IniWriteSection                : I N I W R I T E S E C T I O N ; 
F_InputBox                       : I N P U T B O X ; 
F_Int                            : I N T ; 
F_IsAdmin                        : I S A D M I N ; 
F_IsArray                        : I S A R R A Y ; 
F_IsBinary                       : I S B I N A R Y ; 
F_IsBool                         : I S B O O L ; 
F_IsDeclared                     : I S D E C L A R E D ; 
F_IsDllStruct                    : I S D L L S T R U C T ; 
F_IsFloat                        : I S F L O A T ; 
F_IsFunc                         : I S F U N C ; 
F_IsHWnd                         : I S H W N D ; 
F_IsInt                          : I S I N T ; 
F_IsKeyword                      : I S K E Y W O R D ; 
F_IsNumber                       : I S N U M B E R ; 
F_IsObj                          : I S O B J ; 
F_IsPtr                          : I S P T R ; 
F_IsString                       : I S S T R I N G ; 
F_Log                            : L O G ; 
F_MemGetStats                    : M E M G E T S T A T S ; 
F_Mod                            : M O D ; 
F_MouseClick                     : M O U S E C L I C K ; 
F_MouseClickDrag                 : M O U S E C L I C K D R A G ; 
F_MouseDown                      : M O U S E D O W N ; 
F_MouseGetCursor                 : M O U S E G E T C U R S O R ; 
F_MouseGetPos                    : M O U S E G E T P O S ; 
F_MouseMove                      : M O U S E M O V E ; 
F_MouseUp                        : M O U S E U P ; 
F_MouseWheel                     : M O U S E W H E E L ; 
F_MsgBox                         : M S G B O X ; 
F_Number                         : N U M B E R ; 
F_ObjCreate                      : O B J C R E A T E ; 
F_ObjCreateInterface             : O B J C R E A T E I N T E R F A C E ; 
F_ObjEvent                       : O B J E V E N T ; 
F_ObjGet                         : O B J G E T ; 
F_ObjName                        : O B J N A M E ; 
F_OnAutoItExitRegister           : O N A U T O I T E X I T R E G I S T E R ; 
F_OnAutoItExitUnRegister         : O N A U T O I T E X I T U N R E G I S T E R ; 
F_Ping                           : P I N G ; 
F_PixelChecksum                  : P I X E L C H E C K S U M ; 
F_PixelGetColor                  : P I X E L G E T C O L O R ; 
F_PixelSearch                    : P I X E L S E A R C H ; 
F_ProcessClose                   : P R O C E S S C L O S E ; 
F_ProcessExists                  : P R O C E S S E X I S T S ; 
F_ProcessGetStats                : P R O C E S S G E T S T A T S ; 
F_ProcessList                    : P R O C E S S L I S T ; 
F_ProcessSetPriority             : P R O C E S S S E T P R I O R I T Y ; 
F_ProcessWait                    : P R O C E S S W A I T ; 
F_ProcessWaitClose               : P R O C E S S W A I T C L O S E ; 
F_ProgressOff                    : P R O G R E S S O F F ; 
F_ProgressOn                     : P R O G R E S S O N ; 
F_ProgressSet                    : P R O G R E S S S E T ; 
F_Ptr                            : P T R ; 
F_Random                         : R A N D O M ; 
F_RegDelete                      : R E G D E L E T E ; 
F_RegEnumKey                     : R E G E N U M K E Y ; 
F_RegEnumVal                     : R E G E N U M V A L ; 
F_RegRead                        : R E G R E A D ; 
F_RegWrite                       : R E G W R I T E ; 
F_Round                          : R O U N D ; 
F_Run                            : R U N ; 
F_RunAs                          : R U N A S ; 
F_RunAsWait                      : R U N A S W A I T ; 
F_RunWait                        : R U N W A I T ; 
F_Send                           : S E N D ; 
F_SendKeepActive                 : S E N D K E E P A C T I V E ; 
F_SetError                       : S E T E R R O R ; 
F_SetExtended                    : S E T E X T E N D E D ; 
F_ShellExecute                   : S H E L L E X E C U T E ; 
F_ShellExecuteWait               : S H E L L E X E C U T E W A I T ; 
F_Shutdown                       : S H U T D O W N ; 
F_Sin                            : S I N ; 
F_Sleep                          : S L E E P ; 
F_SoundPlay                      : S O U N D P L A Y ; 
F_SoundSetWaveVolume             : S O U N D S E T W A V E V O L U M E ; 
F_SplashImageOn                  : S P L A S H I M A G E O N ; 
F_SplashOff                      : S P L A S H O F F ; 
F_SplashTextOn                   : S P L A S H T E X T O N ; 
F_Sqrt                           : S Q R T ; 
F_SRandom                        : S R A N D O M ; 
F_StatusbarGetText               : S T A T U S B A R G E T T E X T ; 
F_StderrRead                     : S T D E R R R E A D ; 
F_StdinWrite                     : S T D I N W R I T E ; 
F_StdioClose                     : S T D I O C L O S E ; 
F_StdoutRead                     : S T D O U T R E A D ; 
F_String                         : S T R I N G ; 
F_StringAddCR                    : S T R I N G A D D C R ; 
F_StringCompare                  : S T R I N G C O M P A R E ; 
F_StringFormat                   : S T R I N G F O R M A T ; 
F_StringFromASCIIArray           : S T R I N G F R O M A S C I I A R R A Y ; 
F_StringInStr                    : S T R I N G I N S T R ; 
F_StringIsAlNum                  : S T R I N G I S A L N U M ; 
F_StringIsAlpha                  : S T R I N G I S A L P H A ; 
F_StringIsASCII                  : S T R I N G I S A S C I I ; 
F_StringIsDigit                  : S T R I N G I S D I G I T ; 
F_StringIsFloat                  : S T R I N G I S F L O A T ; 
F_StringIsInt                    : S T R I N G I S I N T ; 
F_StringIsLower                  : S T R I N G I S L O W E R ; 
F_StringIsSpace                  : S T R I N G I S S P A C E ; 
F_StringIsUpper                  : S T R I N G I S U P P E R ; 
F_StringIsXDigit                 : S T R I N G I S X D I G I T ; 
F_StringLeft                     : S T R I N G L E F T ; 
F_StringLen                      : S T R I N G L E N ; 
F_StringLower                    : S T R I N G L O W E R ; 
F_StringMid                      : S T R I N G M I D ; 
F_StringRegExp                   : S T R I N G R E G E X P ; 
F_StringRegExpReplace            : S T R I N G R E G E X P R E P L A C E ; 
F_StringReplace                  : S T R I N G R E P L A C E ; 
F_StringReverse                  : S T R I N G R E V E R S E ; 
F_StringRight                    : S T R I N G R I G H T ; 
F_StringSplit                    : S T R I N G S P L I T ; 
F_StringStripCR                  : S T R I N G S T R I P C R ; 
F_StringStripWS                  : S T R I N G S T R I P W S ; 
F_StringToASCIIArray             : S T R I N G T O A S C I I A R R A Y ; 
F_StringToBinary                 : S T R I N G T O B I N A R Y ; 
F_StringTrimLeft                 : S T R I N G T R I M L E F T ; 
F_StringTrimRight                : S T R I N G T R I M R I G H T ; 
F_StringUpper                    : S T R I N G U P P E R ; 
F_Tan                            : T A N ; 
F_TCPAccept                      : T C P A C C E P T ; 
F_TCPCloseSocket                 : T C P C L O S E S O C K E T ; 
F_TCPConnect                     : T C P C O N N E C T ; 
F_TCPListen                      : T C P L I S T E N ; 
F_TCPNameToIP                    : T C P N A M E T O I P ; 
F_TCPRecv                        : T C P R E C V ; 
F_TCPSend                        : T C P S E N D ; 
F_TCPShutdown                    : T C P S H U T D O W N ; 
F_UDPShutdown                    : U D P S H U T D O W N ; 
F_TCPStartup                     : T C P S T A R T U P ; 
F_UDPStartup                     : U D P S T A R T U P ; 
F_TimerDiff                      : T I M E R D I F F ; 
F_TimerInit                      : T I M E R I N I T ; 
F_ToolTip                        : T O O L T I P ; 
F_TrayCreateItem                 : T R A Y C R E A T E I T E M ; 
F_TrayCreateMenu                 : T R A Y C R E A T E M E N U ; 
F_TrayGetMsg                     : T R A Y G E T M S G ; 
F_TrayItemDelete                 : T R A Y I T E M D E L E T E ; 
F_TrayItemGetHandle              : T R A Y I T E M G E T H A N D L E ; 
F_TrayItemGetState               : T R A Y I T E M G E T S T A T E ; 
F_TrayItemGetText                : T R A Y I T E M G E T T E X T ; 
F_TrayItemSetOnEvent             : T R A Y I T E M S E T O N E V E N T ; 
F_TrayItemSetState               : T R A Y I T E M S E T S T A T E ; 
F_TrayItemSetText                : T R A Y I T E M S E T T E X T ; 
F_TraySetClick                   : T R A Y S E T C L I C K ; 
F_TraySetIcon                    : T R A Y S E T I C O N ; 
F_TraySetOnEvent                 : T R A Y S E T O N E V E N T ; 
F_TraySetPauseIcon               : T R A Y S E T P A U S E I C O N ; 
F_TraySetState                   : T R A Y S E T S T A T E ; 
F_TraySetToolTip                 : T R A Y S E T T O O L T I P ; 
F_TrayTip                        : T R A Y T I P ; 
F_UBound                         : U B O U N D ; 
F_UDPBind                        : U D P B I N D ; 
F_UDPCloseSocket                 : U D P C L O S E S O C K E T ; 
F_UDPOpen                        : U D P O P E N ; 
F_UDPRecv                        : U D P R E C V ; 
F_UDPSend                        : U D P S E N D ; 
F_VarGetType                     : V A R G E T T Y P E ; 
F_WinActivate                    : W I N A C T I V A T E ; 
F_WinActive                      : W I N A C T I V E ; 
F_WinClose                       : W I N C L O S E ; 
F_WinExists                      : W I N E X I S T S ; 
F_WinFlash                       : W I N F L A S H ; 
F_WinGetCaretPos                 : W I N G E T C A R E T P O S ; 
F_WinGetClassList                : W I N G E T C L A S S L I S T ; 
F_WinGetClientSize               : W I N G E T C L I E N T S I Z E ; 
F_WinGetHandle                   : W I N G E T H A N D L E ; 
F_WinGetPos                      : W I N G E T P O S ; 
F_WinGetProcess                  : W I N G E T P R O C E S S ; 
F_WinGetState                    : W I N G E T S T A T E ; 
F_WinGetText                     : W I N G E T T E X T ; 
F_WinGetTitle                    : W I N G E T T I T L E ; 
F_WinKill                        : W I N K I L L ; 
F_WinList                        : W I N L I S T ; 
F_WinMenuSelectItem              : W I N M E N U S E L E C T I T E M ; 
F_WinMinimizeAll                 : W I N M I N I M I Z E A L L ; 
F_WinMinimizeAllUndo             : W I N M I N I M I Z E A L L U N D O ; 
F_WinMove                        : W I N M O V E ; 
F_WinSetOnTop                    : W I N S E T O N T O P ; 
F_WinSetState                    : W I N S E T S T A T E ; 
F_WinSetTitle                    : W I N S E T T I T L E ; 
F_WinSetTrans                    : W I N S E T T R A N S ; 
F_WinWait                        : W I N W A I T ; 
F_WinWaitActive                  : W I N W A I T A C T I V E ; 
F_WinWaitClose                   : W I N W A I T C L O S E ; 
F_WinWaitNotActive               : W I N W A I T N O T A C T I V E ; 

// case insensitive chars
fragment A:('a'|'A');
fragment B:('b'|'B');
fragment C:('c'|'C');
fragment D:('d'|'D');
fragment E:('e'|'E');
fragment F:('f'|'F');
fragment G:('g'|'G');
fragment H:('h'|'H');
fragment I:('i'|'I');
fragment J:('j'|'J');
fragment K:('k'|'K');
fragment L:('l'|'L');
fragment M:('m'|'M');
fragment N:('n'|'N');
fragment O:('o'|'O');
fragment P:('p'|'P');
fragment Q:('q'|'Q');
fragment R:('r'|'R');
fragment S:('s'|'S');
fragment T:('t'|'T');
fragment U:('u'|'U');
fragment V:('v'|'V');
fragment W:('w'|'W');
fragment X:('x'|'X');
fragment Y:('y'|'Y');
fragment Z:('z'|'Z');

 

test java program to see if files tokenizes in a decent way

import java.nio.file.Paths;

import org.antlr.v4.runtime.*;
import org.antlr.v4.runtime.tree.*;

public class Au3Runner 
    {
        public static void main(String[] args) throws Exception
        {
          CharStream charStream = CharStreams.fromPath(Paths.get(args[0]));
          Lexer lexer = new au3Lexer(charStream);
          CommonTokenStream tokens = new CommonTokenStream(lexer);
          tokens.fill();
          for (Token token : tokens.getTokens()) {
            System.out.println("Got token: " + token.toString());
        //    System.out.println("'" + token.getText() + "<" + token.getType() + ">' ");
          }
        }  
    }

 

quicktest.au3 file that I feed as a file to lex

consolewrite("a str a" & @CRLF)
consolewrite('b str b' & @CRLF)

consolewrite("c str "" c" & @CRLF)
consolewrite('d str '' d' & @CRLF)

consolewrite('e str " e' & @CRLF)
consolewrite("f str ' f" & @CRLF)

consolewrite('e str "" e' & @CRLF)
consolewrite("f str '' f" & @CRLF)

;~ consolewrite('g str ' g' & @CRLF)
;~ consolewrite("h str " h" & @CRLF)

#comments-start

#ce
consolewrite("Below is an alphabetized list of all the macros available in AutoIt.")
consolewrite(@appdatacommondir  & @CRLF)
consolewrite(@appdatadir  & @CRLF)
consolewrite(@autoitexe  & @CRLF)
consolewrite(@autoitpid  & @CRLF)
consolewrite(@autoitversion  & @CRLF)
consolewrite(@autoitx64  & @CRLF)
;~ consolewrite(@com_eventobj  & @CRLF)
consolewrite(@commonfilesdir  & @CRLF)
consolewrite(@compiled  & @CRLF)
consolewrite(@computername  & @CRLF)
consolewrite(@comspec  & @CRLF)
consolewrite(@cpuarch    & @CRLF)
consolewrite(@cr  & @CRLF)
consolewrite(@crlf  & @CRLF)
consolewrite(@desktopcommondir  & @CRLF)
consolewrite(@desktopdepth  & @CRLF)
consolewrite(@desktopdir  & @CRLF)
consolewrite(@desktopheight  & @CRLF)
consolewrite(@desktoprefresh     & @CRLF)
consolewrite(@desktopwidth  & @CRLF)
consolewrite(@documentscommondir  & @CRLF)
consolewrite(@error  & @CRLF)
;~ consolewrite(@exitcode  & @CRLF)
;~ consolewrite(@exitmethod  & @CRLF)
consolewrite(@extended  & @CRLF)
consolewrite(@favoritescommondir     & @CRLF)
consolewrite(@favoritesdir  & @CRLF)
;~ consolewrite(@gui_ctrlhandle  & @CRLF)
;~ consolewrite(@gui_ctrlid  & @CRLF)
;~ consolewrite(@gui_dragfile  & @CRLF)
;~ consolewrite(@gui_dragid  & @CRLF)
;~ consolewrite(@gui_dropid  & @CRLF)
;~ consolewrite(@gui_winhandle   & @CRLF)
consolewrite(@homedrive  & @CRLF)
consolewrite(@homepath  & @CRLF)
consolewrite(@homeshare  & @CRLF)
consolewrite(@hotkeypressed  & @CRLF)
consolewrite(@hour  & @CRLF)
consolewrite(@ipaddress1  & @CRLF)
consolewrite(@ipaddress2  & @CRLF)
consolewrite(@ipaddress3     & @CRLF)
consolewrite(@ipaddress4  & @CRLF)
consolewrite(@kblayout  & @CRLF)
consolewrite(@lf  & @CRLF)
consolewrite(@localappdatadir  & @CRLF)
consolewrite(@logondnsdomain  & @CRLF)
consolewrite(@logondomain  & @CRLF)
consolewrite(@logonserver & @CRLF)
consolewrite(@mday  & @CRLF)
consolewrite(@min  & @CRLF)
consolewrite(@mon  & @CRLF)
consolewrite(@msec  & @CRLF)
consolewrite(@muilang  & @CRLF)
consolewrite(@mydocumentsdir  & @CRLF)
consolewrite(@numparams  & @CRLF)
consolewrite(@osarch  & @CRLF)
consolewrite(@osbuild  & @CRLF)
consolewrite(@oslang     & @CRLF)
consolewrite(@osservicepack  & @CRLF)
consolewrite(@ostype  & @CRLF)
consolewrite(@osversion  & @CRLF)
consolewrite(@programfilesdir  & @CRLF)
consolewrite(@programscommondir  & @CRLF)
consolewrite(@programsdir    & @CRLF)
consolewrite(@scriptdir  & @CRLF)
consolewrite(@scriptfullpath  & @CRLF)
consolewrite(@scriptlinenumber  & @CRLF)
consolewrite(@scriptname  & @CRLF)
consolewrite(@sec  & @CRLF)
consolewrite(@startmenucommondir     & @CRLF)
consolewrite(@startmenudir  & @CRLF)
consolewrite(@startupcommondir  & @CRLF)
consolewrite(@startupdir  & @CRLF)
consolewrite(@sw_disable  & @CRLF)
consolewrite(@sw_enable  & @CRLF)
consolewrite(@sw_hide  & @CRLF)
consolewrite(@sw_lock    & @CRLF)
consolewrite(@sw_maximize  & @CRLF)
consolewrite(@sw_minimize  & @CRLF)
consolewrite(@sw_restore  & @CRLF)
consolewrite(@sw_show  & @CRLF)
consolewrite(@sw_showdefault  & @CRLF)
consolewrite(@sw_showmaximized   & @CRLF)
consolewrite(@sw_showminimized  & @CRLF)
consolewrite(@sw_showminnoactive  & @CRLF)
consolewrite(@sw_showna  & @CRLF)
consolewrite(@sw_shownoactivate  & @CRLF)
consolewrite(@sw_shownormal  & @CRLF)
consolewrite(@sw_unlock  & @CRLF)
consolewrite(@systemdir  & @CRLF)
consolewrite(@tab  & @CRLF)
consolewrite(@tempdir  & @CRLF)
;~ consolewrite(@tray_id  & @CRLF)
consolewrite(@trayiconflashing  & @CRLF)
consolewrite(@trayiconvisible  & @CRLF)
consolewrite(@username   & @CRLF)
consolewrite(@userprofiledir  & @CRLF)
consolewrite(@wday  & @CRLF)
consolewrite(@windowsdir  & @CRLF)
consolewrite(@workingdir  & @CRLF)
consolewrite(@yday  & @CRLF)
consolewrite(@year & @CRLF)

 

Posted

When you build a compiler by hand its easier to have an ID matched and look it up in a kw/function symbol table to determince what tokentype you have.  

When you use compiler tools its more a "best practice" to detail out as much as you know.

ANTLR generates directly an "empty" parser.

  • You only have to implement the actual work that the function has to do. 
  • You do not have to write a dispatcher yourself to the implementation of the keyword/function.

So logic more like

  • Predefined internal functions we do no have source on probably needs an implementation we build in C++/Java or any other target language you have
    • Keywords to be in the G4 grammar
    • Base AutoIT functions in the G4 grammar
    • # directives to be in the G4 grammar
  • The UDF functions will probably be dealt with in a different way as you have to implement and dispatch them based on the UDF source.
    • So based on lexer that gives back an ID token you decide if its a function, .....

My background on this compiler/interpreter is not much except the theory so I felt its fun to actually start now in this thread some experimenting with it. And first steps with ANTLR are not that hard when you look at existing Grammars and do some google stuff on things like: ANTL quote in string etc.

Will update previous post later this week as I know have tokenized IE.AU3 which led to some improvements to the G4 grammar

 

Posted

@junkew I guess that is an approach that one can use.

But I do not think this fits well with the goal as I want a proper implementation and not a product of some grammer files... no offense by the way, I know that you are only showing the possibilities :)

Thanks for the link to the meta-question in SE, the "Engineering a Compiler" books sounds like an interesting read... I might read it soon. If anyone is interested in the book then there is a 2nd edition available which is err... "available" in web if you know what I mean ;)

EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time)

DcodingTheWeb Forum - Follow for updates and Join for discussion

  • 1 month later...
Posted

It has been more than a month since the last post in this thread and I did not manage to start working on the reference script until now... I blame the many things that I am try to balance in my schedule, which includes gaming on my new PS4 and watching a ton of YouTube when I am not working :muttley:

Anyway, I finally made a very basic reference script covering comments and variables, this should be enough to get me started:

#cs
This is a simple reference script which aims to include every possible combination of AutoIt Syntax
As a matter of fact, we are demonstrating multi-line comments now!
#ce

#Region Comments

; == Single-line
; This is a single line comment

; == Multi-line
#comments-start
This
is
a
comment
spanning
multiple
lines
#comments-end

; NOTE: Technically multi-line comments are directives which are processed by the preprocessor

#EndRegion

#Region Variables

; == Declaration
Local $vLocalVariableDemo
Global $g_vGlobalVariableDemo
Dim $g_vDimVariableDemo ; Dynamic scope, avoid at all costs!

Global Const $g_vGlobalConstantDemo = 3.14 ; You can't change PI!
Enum $FOO, $BAR ; $FOO = 0 and $BAR = 1
Enum Step 2 $MAYBE_EVEN, $EVEN, $EVEN_AGAIN ; $MAYBE_EVEN = 0, $EVEN = 2, $EVEN_AGAIN = 4
Enum Step *2 $ONE_BIT, $TWO_BIT, $FOUR_BIT, $ONE_BYTE, $TWO_BYTES, $FOUR_BYTES ; Exponents of 2: 1, 2, 4, 8, 16, 32, ...

; === Array declaration
Global $g_aArrayDemo[10]

; == Initialization
Global $g_sInitializedString = "Test"
Global $g_nInitializedNumber = 42
Global $g_vInitializedVarFromExp = (@SEC / 2) - Floor(@SEC / 2) = 0.5 ? "Even" : 0xDD ; Initialization with an expression whose type is dynamic

; === Array initialization
Global $g_aInitializedArray[2] = ["Foo", "bar"]

#EndRegion

If anyone wants to expand the list, then feel free to do so! I will probably adapt your changes with modifications in my next iteration :)

EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time)

DcodingTheWeb Forum - Follow for updates and Join for discussion

Posted

Is there any reason to include Dim in your testing? I thought it had to be used to wipe an array, but that can be done with Local/Global (as I recently learned)

You might want to include that you can initialize a variable with another (previously declared) variable... like Local $fDiameter = $fRadius * 2

All my code provided is Public Domain... but it may not work. ;) Use it, change it, break it, whatever you want.

Spoiler

My Humble Contributions:
Personal Function Documentation - A personal HelpFile for your functions
Acro.au3 UDF - Automating Acrobat Pro
ToDo Finder - Find #ToDo: lines in your scripts
UI-SimpleWrappers UDF - Use UI Automation more Simply-er
KeePass UDF - Automate KeePass, a password manager
InputBoxes - Simple Input boxes for various variable types

Posted

AFAICT Dim has one and only one use case: force redeclaration to a given datatype of a variable passed ByRef to a function, irrespective of the datatype that was passed.

Example:

Local $a = "abc"
f($a)
 _ArrayDisplay($a)

 Func f(ByRef $var)
    Dim $var = [1, 2, 3, 4, 5]
 EndFunc

Any other case can be handled with Global/Local, even if I'd love to see file scope introduced.

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Posted (edited)
19 hours ago, seadoggie01 said:

Is there any reason to include Dim in your testing?

Yes, for the sake of completeness, I intend to use every available keyword in the reference script :)

19 hours ago, seadoggie01 said:

I thought it had to be used to wipe an array, but that can be done with Local/Global (as I recently learned) 

This belief seems to have stemmed from some kind of misconception and then spread throughout the scripts shared as examples in this forum. If you read the help file entry for Dim, you will get to know that it is not really different from other declaration keywords.

The only special thing about it is that the scope of the variable defined using Dim is dependent on the availability of a variable with the same name in the Global scope. If a variable already exists in the global scope in the same name, nothing is done and the variable will refer to the global variable, otherwise it is created as a normal local variable which is only valid inside the function.

It is generally not a good idea to depend on hacks such as this... and this will certainly throw in a cog for me when developing the actual interpreter as the scope cannot be determined during compile time.

Also do not confuse it with the similar ReDim keyword, which is used to resize arrays :D

18 hours ago, jchd said:

AFAICT Dim has one and only one use case: force redeclaration to a given datatype of a variable passed ByRef to a function, irrespective of the datatype that was passed. 

Are you sure that this is true? I do not see anything special about Dim in this case, you can use Local to redeclare the variable in this case and it would work just as fine I am guessing. Correct me if I am wrong.

18 hours ago, argumentum said:

the code @TheDcoder wrote is not a sample code to run @seadoggie01 

Indeed, it is just a script which can be used as a good reference to display all possible syntax variations in AutoIt. It will also be useful to test my parser when I get around to writing it.

Edited by TheDcoder

EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time)

DcodingTheWeb Forum - Follow for updates and Join for discussion

Posted
2 hours ago, TheDcoder said:

Correct me if I am wrong.

It was just a remark about usefulness of Dim vs Global/Local.  In all use cases except what I mentionned, Dim isn't wrong, it just is bad style ny not telling wich side of the water it seats.

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Posted
14 hours ago, argumentum said:

the code @TheDcoder wrote is not a sample code to run @seadoggie01  :)

Right, he's using it for testing. I was trying to give another example of something that could be done with variables. (And mention Dim, which I see kind of exploded)

8 hours ago, TheDcoder said:

Also do not confuse it with the similar ReDim keyword, which is used to resize arrays :D

So after looking in the help file for both Dim/Global/Local/Const and ReDim, I think I see why I was struggling. I originally started coding in VBA, so I carried over my understanding of ReDim, and I must've read/seen someone using Dim to clear an array, which I figured must be how to do it since there was no Erase keyword :) It's also interesting that only ReDim mentions clearing an array with Global/Local.

6 hours ago, jchd said:

It was just a remark about usefulness of Dim vs Global/Local.  In all use cases except what I mentionned, Dim isn't wrong, it just is bad style ny not telling wich side of the water it seats.

Do you mean whether it's global or local? I don't understand the phrase "which side of the water it sits"

All my code provided is Public Domain... but it may not work. ;) Use it, change it, break it, whatever you want.

Spoiler

My Humble Contributions:
Personal Function Documentation - A personal HelpFile for your functions
Acro.au3 UDF - Automating Acrobat Pro
ToDo Finder - Find #ToDo: lines in your scripts
UI-SimpleWrappers UDF - Use UI Automation more Simply-er
KeePass UDF - Automate KeePass, a password manager
InputBoxes - Simple Input boxes for various variable types

Posted
2 hours ago, seadoggie01 said:

It's also interesting that only ReDim mentions clearing an array with Global/Local.

Might be due to the fact that there is no such scope as "Dim", only local and global scopes exist in AutoIt :)

2 hours ago, seadoggie01 said:

I think I see why I was struggling. I originally started coding in VBA

No worries.

EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time)

DcodingTheWeb Forum - Follow for updates and Join for discussion

Posted (edited)
18 hours ago, jchd said:

force redeclaration to a given datatype of a variable passed ByRef to a function, irrespective of the datatype that was passed. 

Actually you are correct, I just checked by replacing Dim with Global/Local in your code and I got an error about not being able to redeclare the variable. It is a surprising feature and it is not even documented!

Edited by TheDcoder

EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time)

DcodingTheWeb Forum - Follow for updates and Join for discussion

Posted
20 hours ago, seadoggie01 said:

Do you mean whether it's global or local? I don't understand the phrase "which side of the water it sits"

That's what I meant.  One side is Global, the other Local and Dim is the bridge that covers both.

When saying "bad style", I mean it's much less clear than using either Global or Local, unless the (rare) only use case I mentionned.

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

  • 2 months later...
Posted (edited)

@TheDcoder If you haven't looked into it already... Microsoft has ported Powershell to Linux and actively maintains it. May be a thing to look into.

https://docs.microsoft.com/en-us/powershell/scripting/install/installing-powershell-core-on-linux?view=powershell-7

 

Although this may just be another Microsoft 3E strategy.

Edited by rcmaehl

My UDFs are generally for me. If they aren't updated for a while, it means I'm not using them myself. As soon as I start using them again, they'll get updated.

My Projects

WhyNotWin11
Cisco FinesseGithubIRC UDFWindowEx UDF

 

Posted

I am aware of MS porting Powershell (Core) to Linux, but as far as I know, it is written in C# which is a high-level language with a runtime (Mono) available for Linux, so it would have been relatively easy to port that over to linux IMO :)

EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time)

DcodingTheWeb Forum - Follow for updates and Join for discussion

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...