Jump to content

Recommended Posts

Hi,

Has anyone tried combining lexical parser and autoit.

Aim is to execute test cases written in simple language.

The below steps would be the outline to be followed:

  • Read test execution steps from a file (*.txt).
  • Do lexical parsing (flex and bison) to understand the grammar.
  • Process based on the grammar.

 

For example in the text file we will simply write as below for starting up MSPAINT, loading an image file in it and exiting the application:

Quote

Start(MSPAINT)

Load(C:\123.jpg)

Exit(MSPAINT)

 

The above 3 lines in the text file will then be analysed by a parser and processed using AuotIT.

I do not know if it is weird to club AutoIT with such a requirement.

Still it would be helpful if some one has tried anything similar at least.

Thanks in advance.

 

Regards,

Amal

Share this post


Link to post
Share on other sites

This is called UDF.

 


Signature beginning:   Wondering who uses AutoIT and what it can be used for ?
* GHAPI UDF - modest begining - comunication with GitHub REST API Forum Rules *
ADO.au3 UDF     POP3.au3 UDF     XML.au3 UDF    How to use IE.au3  UDF with  AutoIt v3.3.14.x  for other useful stuff click the following button

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST APIErrorLog.au3 UDF - A logging Library *

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF *

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * 

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskScheduler

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

11

Signature last update: 2018-10-31

Share this post


Link to post
Share on other sites
9 hours ago, mLipok said:

This is called UDF.

 

Hi mLipok,

 

I am new to AutoIt, so do not know much about such things.

 

Are you saying UDF involves some parsing followed by AutoIT calls to process the parsed statements?

I will try to get some basic info on UDF then.

Thanks for directing me to UDF.

 

Regards,

Amal

Share this post


Link to post
Share on other sites
19 hours ago, amaljesudas said:

Start(MSPAINT)

Load(C:\123.jpg)

Exit(MSPAINT)

 

I mean that this can be done with normal function which should be grouped in separated AU3 file (called UDF) which is used by #include directive .

This could look like this

#inlude "mspaint.au3"

......
_MSPaint_Start()
_MSPaint_Load(C:\123.jpg)
_MSPaint_Exit()
......

But the "mspaint.au3" not exist at this moment, at least I do not know nothing more about ;)

The " mspaint .au3" UDF should be created ... by some programer interested in, I mean you in first step.

 


Signature beginning:   Wondering who uses AutoIT and what it can be used for ?
* GHAPI UDF - modest begining - comunication with GitHub REST API Forum Rules *
ADO.au3 UDF     POP3.au3 UDF     XML.au3 UDF    How to use IE.au3  UDF with  AutoIt v3.3.14.x  for other useful stuff click the following button

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST APIErrorLog.au3 UDF - A logging Library *

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF *

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * 

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskScheduler

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

11

Signature last update: 2018-10-31

Share this post


Link to post
Share on other sites
1 hour ago, mLipok said:

I mean that this can be done with normal function which should be grouped in separated AU3 file (called UDF) which is used by #include directive .

This could look like this

#inlude "mspaint.au3"

......
_MSPaint_Start()
_MSPaint_Load(C:\123.jpg)
_MSPaint_Exit()
......

But the "mspaint.au3" not exist at this moment, at least I do not know nothing more about ;)

The " mspaint .au3" UDF should be created ... by some programer interested in, I mean you in first step.

 

Hi mLipok,

 

Opening file in MSPAINT was just an example.

My intention was not to execute pre-defined procedures.

I am looking for a way to each line from a txt file, understand what is required and call corresponding functionality implemented in AutoIT.

 

Regards,

Amal

Share this post


Link to post
Share on other sites
Posted (edited)

Sure. Just do a file read, loop through lines, switch case based on what is in the line. I'd suggest an ini or xml because it's easier to parse. You can have a node/token for action to perform, and another for all the parameters.

UDF is user defined functions

 

I can see where this would be a nice thing to have...such as having a file drive the execution of the script.  Then you would just have to compile the interpreter, and can update some file on the fly.  It is another layer of overhead though.

Edited by jdelaney

IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.

Share this post


Link to post
Share on other sites
9 hours ago, mLipok said:

UDF should be created ... by some programer interested in, I mean you in first step.

This statement is still valid.


Signature beginning:   Wondering who uses AutoIT and what it can be used for ?
* GHAPI UDF - modest begining - comunication with GitHub REST API Forum Rules *
ADO.au3 UDF     POP3.au3 UDF     XML.au3 UDF    How to use IE.au3  UDF with  AutoIt v3.3.14.x  for other useful stuff click the following button

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST APIErrorLog.au3 UDF - A logging Library *

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF *

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * 

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskScheduler

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

11

Signature last update: 2018-10-31

Share this post


Link to post
Share on other sites
17 hours ago, jdelaney said:

Sure. Just do a file read, loop through lines, switch case based on what is in the line. I'd suggest an ini or xml because it's easier to parse. You can have a node/token for action to perform, and another for all the parameters.

UDF is user defined functions

 

I can see where this would be a nice thing to have...such as having a file drive the execution of the script.  Then you would just have to compile the interpreter, and can update some file on the fly.  It is another layer of overhead though.

Hi jdelaney,

 

Actually what I intend to do is write test cases in text files using simple vocabulary.

These files will be parsed using some sort of compiler logic (flex and bison).

This parsed output will then be processed using AutoIt (could be using UDFs).

The parsing and passing of parsed output to AutoIt is what I am checking for.

For example, say I intend to process two images.

I will simply write basic steps in text files as below:

 

A = Image()

B = Image()

C= A+B

Display(C)

 

The parser is responsible for understanding what each line above is supposed to do.

i.e. A= Image() implies user has to provide an input image which will be referred to as A. 

Similarly C will store the result of adding A and B.

Finally Display() command will display C in some window. 

 

Regards,

Amal

 

Share this post


Link to post
Share on other sites
9 hours ago, mLipok said:

This statement is still valid.

Hi mLipok,

 

UDF should be created ->  Could be AutoIt processing step.

But my main concern is about parsing my input using some compiler logic.

I have added details in my above reply to jdelaney.

 

Regards,

Amal

Share this post


Link to post
Share on other sites

You seem to believe that "some compiler logic" will by itself figure out what you intend in your examples. That's not the way it works.

You have to devise by yourself the grammar and syntax that you're going to use (a context-free grammar is best). From there you can use whatever you like to transform your source file into a parse tree, then into a production compatible with AutoIt.

OTOH if you don't make things too complicated in the grammar definition, you can directly parse the input by your own AutoIt code.

Also UDF isn't a magic wand: it means User-Defined Function(s), functions that you create for your own use or of generic interest to many others.


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)

Share this post


Link to post
Share on other sites
44 minutes ago, jchd said:
Quote

You seem to believe that "some compiler logic" will by itself figure out what you intend in your examples. That's not the way it works.

I do not know from where you got that impression but for the record i have already worked on similar parser. I am only looking for samples where parser and AutoIt has been clubbed and used.

 

Regards,

Amal

Share this post


Link to post
Share on other sites

OK, so show your final grammar.


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)

Share this post


Link to post
Share on other sites
Posted (edited)

What you are trying to do is possible. It's also very specific, so you will probably have to do the legwork yourself. The syntax in your example is also very VBS like, as is autoit...so I don't see the need for you to create such complexity and reinvent this wheel. Seems you can just make your own functions and sring them together.

Edited by jdelaney

IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.

Share this post


Link to post
Share on other sites
Posted (edited)

A simple lexer I am working on for IDL files can shouw you the concept of lexer (without using flex or antlr tooling) I just added current lexer I am working on but should be easy to transform to language lexing you want. Works at a decent speed but not intended for millions of lines of code interpreting

tokenizer("This is 1234 void 0x123 " & """" & "ni  ce doublequoted" & """" & "  just 'more string 123 singlequoted' object<> odl a SIMPLE[] way of tokenizing();123//nice comment at the end" & @CRLF)
    _ArrayDisplay($g_Tokens)

 

Edited by junkew
added example of using tokenizer

Share this post


Link to post
Share on other sites

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...