TheAutomator

activex GOLD parser in autoit, is this possible?

13 posts in this topic

#1 ·  Posted (edited)

hi everyone ;)

i have an interesting question about the gold parser:

info:

http://www.goldparser.org/index.htm

download (regsvr32 to register):

http://www.goldparser.org/engine/1/vb6/index.htm

on the website it seems that this dll can be used as an activex object,

does that mean that it can be used in autoit to?

help for the activeX dll:

http://www.goldparser.org/engine/1/vb6/doc/index.htm

it gives me error code '4' if i try to use it...  :mellow:

Const $gpMsgAccept = 3
Const $gpMsgCommentBlockRead = 9
Const $gpMsgCommentError = 7
Const $gpMsgCommentLineRead = 10
Const $gpMsgInternalError = 8
Const $gpMsgLexicalError = 5
Const $gpMsgNotLoadedError = 4
Const $gpMsgReduction = 2
Const $gpMsgSyntaxError = 6
Const $gpMsgTokenRead = 1

$Parser = ObjCreate("goldparserengine.goldparser")

$Parser.LoadCompiledGrammar("test_script.cgt")
$Parser.OpenFile("Program.txt")

$Response = $Parser.Parse()
MsgBox(0,'test',$Response)

If there are people interested in answering or helping feel free to reply and then i will upload the "test_script.cgt" somewhere if you want :)

i know this question is a bit specific but you never know..  :whistle:

Thanks for reading!

TheAutomator.

Edited by TheAutomator

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

gpMsgNotLoadedError 4 Before any parsing can take place, a Compiled Grammar Table file must be loaded.

 

can you post here:

test_script.cgt

Program.txt

?

Edited by mLipok

Signature beginning:   Wondering who uses AutoIT and what it can be used for ?
* GHAPI UDF - modest begining - comunication with GitHub REST API *
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 API *

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 - BETA * ADO.au3 UDF SMTP Mailer 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 * Best coding practices * 

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) * 

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

Signature last update: 2017-06-04

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Working example:

;~ http://www.goldparser.org/doc/templates/example-vb-activex.htm

Global Const $__eGOLDPARSER_gpMsgTokenRead = 1 ; Each time a token is read, this message is generated.
Global Const $__eGOLDPARSER_gpMsgReduction = 2 ; When the engine is able to reduce a rule, this message is returned. The rule that was reduced is set in the GOLDParser's ReduceRule property. The tokens that are reduced and correspond the rule's definition are stored in the Tokens() property.
Global Const $__eGOLDPARSER_gpMsgAccept = 3 ; The engine will returns this message when the source text has been accepted as both complete and correct. In other words, the source text was successfully analyzed.
Global Const $__eGOLDPARSER_gpMsgNotLoadedError = 4 ; Before any parsing can take place, a Compiled Grammar Table file must be loaded.
Global Const $__eGOLDPARSER_gpMsgLexicalError = 5 ; The tokenizer will generate this message when it is unable to recognize a series of characters as a valid token. To recover, pop the invalid token from the input queue.
Global Const $__eGOLDPARSER_gpMsgSyntaxError = 6 ; Often the parser will read a token that is not expected in the grammar. When this happens, the Tokens() property is filled with tokens the parsing engine expected to read. To recover: push one of the expected tokens on the input queue.
Global Const $__eGOLDPARSER_gpMsgCommentError = 7 ; The parser reached the end of the file while reading a comment. This is caused when the source text contains a "run-away" comment, or in other words, a block comment that lacks the delimiter.
Global Const $__eGOLDPARSER_gpMsgInternalError = 8 ; Something is wrong, very wrong.
Global Const $__eGOLDPARSER_gpMsgCommentBlockRead = 9 ; Added in version 2.4. This message is returned anytime a block comment is read by the system. When the system is reading a block comment, line comments are  completely ignored. The content of the block comment is stored in the CurrentComment( ) method.
Global Const $__eGOLDPARSER_gpMsgCommentLineRead = 10 ; Added In version 2.4. Each time the system reads a line comment, this message is returned. The content of the line comment is stored In the CurrentComment() method.

Global Const $__eGOLDPARSER_SymbolTypeNonterminal = 0 ; A normal nonterminal.
Global Const $__eGOLDPARSER_SymbolTypeTerminal = 1 ; A normal terminal.
Global Const $__eGOLDPARSER_SymbolTypeWhitespace = 2 ; This Whitespace symbols is a special terminal that is automatically ignored the the parsing engine. Any text accepted as whitespace is considered to be inconsequential and "meaningless".
Global Const $__eGOLDPARSER_SymbolTypeEnd = 3 ; The End symbol is generated when the tokenizer reaches the end of the source text.
Global Const $__eGOLDPARSER_SymbolTypeCommentStart = 4 ; This type of symbol designates the start of a block quote.
Global Const $__eGOLDPARSER_SymbolTypeCommentEnd = 5 ; This type of symbol designates the end of a block quote.
Global Const $__eGOLDPARSER_SymbolTypeCommentLine = 6 ; When the engine reads a token that is recognized as a line comment, the remaining characters on the line are automatically ignored by the parser.
Global Const $__eGOLDPARSER_SymbolTypeError = 7 ; The Error symbol is a general-purpose means of representing characters that were not recognized by the tokenizer. In other words, when the tokenizer reads a series of characters that is not accepted by the DFA engine, a token of this type is created.

_GP_Example_1()

Func _GP_Example_1()
    Local $oParser = ObjCreate("goldparserengine.goldparser") ; http://www.goldparser.org/engine/1/vb6/doc/object-goldparser.htm


    Local $iLoadStatus = $oParser.LoadCompiledGrammar(@ScriptDir & "\test_script.cgt")
    MsgBox(0, '$iLoadStatus', $iLoadStatus)

    Local $iOpenStatus = $oParser.OpenFile("Program.txt")
    MsgBox(0, '$iOpenStatus', $iOpenStatus)

    Local $iResponse = $oParser.Parse()
    MsgBox(0, '$iResponse', $iResponse)

    Switch $iResponse
        Case $__eGOLDPARSER_gpMsgTokenRead
            MsgBox(0, '$iResponse = $__eGOLDPARSER_gpMsgTokenRead', 'make some task..')

        Case Else
            ; .......

    EndSwitch

    ; CleanUp
    $oParser = ''
EndFunc   ;==>_GP_Example_1
Edited by mLipok

Signature beginning:   Wondering who uses AutoIT and what it can be used for ?
* GHAPI UDF - modest begining - comunication with GitHub REST API *
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 API *

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 - BETA * ADO.au3 UDF SMTP Mailer 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 * Best coding practices * 

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) * 

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

Signature last update: 2017-06-04

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Now, my request to you:

Make a very little interesting example of how to use the "GOLD Parser" in practice.

edit:

of course make a litle description.

Edited by mLipok

Signature beginning:   Wondering who uses AutoIT and what it can be used for ?
* GHAPI UDF - modest begining - comunication with GitHub REST API *
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 API *

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 - BETA * ADO.au3 UDF SMTP Mailer 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 * Best coding practices * 

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) * 

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

Signature last update: 2017-06-04

Share this post


Link to post
Share on other sites

(so the problem was that i must use the full path of the cgt file)

Now, my request to you:

Make a very little interesting example of how to use the "GOLD Parser" in practice.

 

well, i'm as far as knowing the basics of how to make a grammar and compile it to a cgt-file, load it into my script

and now i'm trying to use the documentation and good examples (if i find those) to make my test language work..

as soon as i have something working i will post it here (yes with comments or a description ;) ) but don't expect it to be done tomorrow  :)

i wanna thank you mlipok for the quick response,

i did't expect an answer because my question was so specific  :)

if there are people who can learn me about this things i wont hesitate to read all about it and in the meantime i'm coding in autoit to make a good test script.

regards!

Share this post


Link to post
Share on other sites

(so the problem was that i must use the full path of the cgt file)

 

 

well, i'm as far as knowing the basics of how to make a grammar and compile it to a cgt-file, load it into my script

and now i'm trying to use the documentation and good examples (if i find those) to make my test language work..

 

as soon as i have something working i will post it here (yes with comments or a description ;) ) but don't expect it to be done tomorrow  :)

 

Good.

I be waiting.

i wanna thank you mlipok for the quick response,

i did't expect an answer because my question was so specific  :)

 

You're welcome.

It seemed interesting so I got involved :)

 

If there are people who can learn me about this things i wont hesitate to read all about it and in the meantime i'm coding in autoit to make a good test script.

 

"about this things"

Can you be more specyfic ?

This time I gave a helping hand, I think only of you and your attitude depends on how many other / further hand you will be given.

Best regards,

mLipok


Signature beginning:   Wondering who uses AutoIT and what it can be used for ?
* GHAPI UDF - modest begining - comunication with GitHub REST API *
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 API *

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 - BETA * ADO.au3 UDF SMTP Mailer 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 * Best coding practices * 

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) * 

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

Signature last update: 2017-06-04

Share this post


Link to post
Share on other sites
mlipok,

"about this things"

Can you be more specyfic ?

yes, sorry, about how to use the gold parser i mean  :)

at the moment i'm reading this:

http://www.goldparser.org/engine/1/vb6/doc/index.htm

and this:

http://www.codeproject.com/Articles/10492/Introduction-to-GOLD-Parser

and i am also trying to "decode" what's happening in the vb6 example project from here, i'm not a pro vb6 programmer:

http://www.goldparser.org/engine/1/vb6/index.htm

download: cook-project-simple-interpreter-v3.0.0

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

sigh! had a long day today  :sweating:

i want to give the possible readers (especially mlipok) a quick update about today:

since my last answer i made a script to test if it is possible to use the gold parser engine in autoit.

the website says "All languages that support ActiveX" can use the gold parser so i did take a look

into the source code of an example interpreter made in vb6 using the activeX gold parser dll.

so far i have only created a skeleton program (that i will post here in a minute) and from that point ... i got stuck, which was a bit disappointing because

i didn't want to go back here until i got something working..  >_<

one of the problems is that vb6 is object-oriented and autoit is not, so i can't just copy and past most of the code because it works differently,

for example, this is a bit of vb code found back in "Allen-Benton-Simple-Interpreter-rev1.3":

...    With TheReduction
        Select Case .ParentRule.TableIndex
        Case Rule_Statements                 ' <Statements> ::= <Statement> <Statements>
            Set NewSimpleObject = New SimpleStmList
            Call NewSimpleObject.Init(.Tokens(0).Data, .Tokens(1).Data)
        
        Case Rule_Statements2                ' <Statements> ::= <Statement>
            Set NewSimpleObject = New SimpleStmList
            Call NewSimpleObject.Init(.Tokens(0).Data)
...

at this point even after all the research i have done i really don't know what is going on in the vb6 code  :wacko:

for every rule there is a new object made and initialized, and after that the "init" sub for that object is called, then there are a few tokens i think passed trough to that object?

i don't get how that can execute code that for example does this:

assign test = 1 + 2 * 3

which part of the code does the actual math on the resulting tokens and how does it know what to do with what?

i have a lot of questions so if someone can help me that would be very appreciated but i can't expect any help because this questions are not that autoit related..

at least here is the code i already have:

#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <Debug.au3>

#Region GoldParser - Variables
Global Const $g__gpMsgTokenRead = 1 ; Each time a token is read, this message is generated.
Global Const $g__gpMsgReduction = 2 ; When the engine is able to reduce a rule, this message is returned. The rule that was reduced is set in the GOLDParser's ReduceRule property. The tokens that are reduced and correspond the rule's definition are stored in the Tokens() property.
Global Const $g__gpMsgAccept = 3 ; The engine will returns this message when the source text has been accepted as both complete and correct. In other words, the source text was successfully analyzed.
Global Const $g__gpMsgNotLoadedError = 4 ; Before any parsing can take place, a Compiled Grammar Table file must be loaded.
Global Const $g__gpMsgLexicalError = 5 ; The tokenizer will generate this message when it is unable to recognize a series of characters as a valid token. To recover, pop the invalid token from the input queue.
Global Const $g__gpMsgSyntaxError = 6 ; Often the parser will read a token that is not expected in the grammar. When this happens, the Tokens() property is filled with tokens the parsing engine expected to read. To recover: push one of the expected tokens on the input queue.
Global Const $g__gpMsgCommentError = 7 ; The parser reached the end of the file while reading a comment. This is caused when the source text contains a "run-away" comment, or in other words, a block comment that lacks the delimiter.
Global Const $g__gpMsgInternalError = 8 ; Something is wrong, very wrong.
Global Const $g__gpMsgCommentBlockRead = 9 ; Added in version 2.4. This message is returned anytime a block comment is read by the system. When the system is reading a block comment, line comments are  completely ignored. The content of the block comment is stored in the CurrentComment( ) method.
Global Const $g__gpMsgCommentLineRead = 10 ; Added In version 2.4. Each time the system reads a line comment, this message is returned. The content of the line comment is stored In the CurrentComment() method.

Global Const $g__gpSymbolTypeNonterminal = 0 ; A normal nonterminal.
Global Const $g__gpSymbolTypeTerminal = 1 ; A normal terminal.
Global Const $g__gpSymbolTypeWhitespace = 2 ; This Whitespace symbols is a special terminal that is automatically ignored the the parsing engine. Any text accepted as whitespace is considered to be inconsequential and "meaningless".
Global Const $g__gpSymbolTypeEnd = 3 ; The End symbol is generated when the tokenizer reaches the end of the source text.
Global Const $g__gpSymbolTypeCommentStart = 4 ; This type of symbol designates the start of a block quote.
Global Const $g__gpSymbolTypeCommentEnd = 5 ; This type of symbol designates the end of a block quote.
Global Const $g__gpSymbolTypeCommentLine = 6 ; When the engine reads a token that is recognized as a line comment, the remaining characters on the line are automatically ignored by the parser.
Global Const $g__gpSymbolTypeError = 7 ; The Error symbol is a general-purpose means of representing characters that were not recognized by the tokenizer. In other words, when the tokenizer reads a series of characters that is not accepted by the DFA engine, a token of this type is created.

Global Const $g__gpRule_Statements1 = 0 ; <statements>  ::= <statement> <statements>
Global Const $g__gpRule_Statements2 = 1 ; <statements>  ::= <statement>
Global Const $g__gpRule_Statement_NameIsExpression = 2 ; <statement>   ::= name '=' <expression>
Global Const $g__gpRule_Statement_MsgExpression = 3 ; <statement>   ::= msg <expression>
Global Const $g__gpRule_Statement_IfThenEnd = 4 ; <statement>   ::= if <expression> then <statements> end
Global Const $g__gpRule_Statement_IfThenElseEnd = 5 ; <statement>   ::= if <expression> then <statements> else <statements> end
Global Const $g__gpRule_Expression_BiggerThen = 6 ; <expression>  ::= <expression> '>' <add exp>
Global Const $g__gpRule_Expression_SmallerThen = 7 ; <expression>  ::= <expression> '<' <add exp>
Global Const $g__gpRule_Expression_BiggerEqualThen1 = 8 ; <expression>  ::= <expression> '<=' <add exp>
Global Const $g__gpRule_Expression_BiggerEqualThen2 = 9 ; <expression>  ::= <expression> '>=' <add exp>
Global Const $g__gpRule_Expression_SmallerEqualThen1 = 10; <expression>  ::= <expression> '=>' <add exp>
Global Const $g__gpRule_Expression_SmallerEqualThen2 = 11; <expression>  ::= <expression> '=<' <add exp>
Global Const $g__gpRule_Expression_EqualThen = 12 ; <expression>  ::= <expression> '=' <add exp>
Global Const $g__gpRule_Expression_NotEqualThen = 13 ; <expression>  ::= <expression> '!' <add exp>
Global Const $g__gpRule_Expression = 14 ; <expression>  ::= <add exp>
Global Const $g__gpRule_Add_Plus = 15 ; <add exp>     ::= <add exp> '+' <mult exp>
Global Const $g__gpRule_Add_Minus = 16 ; <add exp>     ::= <add exp> '-' <mult exp>
Global Const $g__gpRule_Add_Amp = 17 ; <add exp>     ::= <add exp> '&' <mult exp>
Global Const $g__gpRule_Add_Expression = 18 ; <add exp>     ::= <mult exp>
Global Const $g__gpRule_Mult_Mult = 19 ; <mult exp>    ::= <mult exp> '*' <value>
Global Const $g__gpRule_Mult_Div = 20 ; <mult exp>    ::= <mult exp> '/' <value>
Global Const $g__gpRule_Mult_Value = 21 ; <mult exp>    ::= <value>
Global Const $g__gpRule_Value_Name = 22 ; <value>       ::= name
Global Const $g__gpRule_Value_String = 23 ; <value>       ::= string
Global Const $g__gpRule_Value_Number = 24 ; <value>       ::= number
Global Const $g__gpRule_Value_GroupedExpression = 25 ; <value>       ::= '(' <expression> ')'
#EndRegion GoldParser - Variables

_DebugSetup(Default, True, 1, Default, True) ; 1 = GUI output with timestamping

Global $oVariables = ObjCreate("scripting.dictionary")
$oVariables.CompareMode = 1

Example()

Func Example()
    ; Set up the COM error handler to write error messages using a GUI and exit on error
    _DebugCOMError(1)

    Local $hGUI = GUICreate("Form", 611, 431, 100, 0)
    WinMove($__gsReportTitle_Debug, '', 611 + 106, 0)
    #forceref $hGUI

    Local $idEdit_In = GUICtrlCreateEdit("a = 1", 10, 10, 301, 411)
    GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
    GUICtrlSetColor(-1, 0x00FF00)
    GUICtrlSetBkColor(-1, 0x464646)
    GUICtrlSetCursor(-1, 5)

;~  $idEdit_Out = GUICtrlCreateEdit("", 320, 210, 281, 211, BitOR($ES_READONLY,$ES_WANTRETURN)) ; for some reason i hear windows ding.wav going of like crazy if i push the run button with this rule of code?
    Local $idEdit_Out = GUICtrlCreateEdit("", 320, 210, 281, 211)
    GUICtrlSetColor(-1, 0xFF0000)
    GUICtrlSetBkColor(-1, 0x000000)

    Local $idButton_Test = GUICtrlCreateButton("test", 320, 10, 281, 41)
    Local $idButton_Run = GUICtrlCreateButton("run", 320, 60, 281, 41)
    Local $idButton_Clean = GUICtrlCreateButton("clean", 320, 110, 281, 41)
    Local $idButton_Quit = GUICtrlCreateButton("quit", 320, 160, 281, 41)

    GUISetState(@SW_SHOW)


    Local $oParser = ObjCreate("goldparserengine.goldparser")
    Local $bLoadStatus = $oParser.LoadCompiledGrammar(@ScriptDir & "\test_script.cgt");~ $OpenStatus = $oParser.OpenFile("Program.txt")
    _DebugOut('$bLoadStatus=' & $bLoadStatus)
    $oParser.TrimReductions = True

    Local $iResponse
    Local $bDone, $bReadStatus
    While True
        Switch GUIGetMsg()

            Case $GUI_EVENT_CLOSE, $idButton_Quit
                ExitLoop

            Case $idButton_Clean
                GUICtrlSetData($idEdit_Out, '')

            Case $idButton_Test
                GUICtrlSetData($idEdit_Out, '')
                $bDone = False
                $bReadStatus = $oParser.OpenTextString(GUICtrlRead($idEdit_In))
                _DebugOut('$bReadStatus=' & $bReadStatus)
                Do
                    $iResponse = $oParser.Parse()

                    Switch $iResponse
                        Case $g__gpMsgLexicalError
                            _DebugOut('Illegal or unrecognized token!', True)
                        Case $g__gpMsgSyntaxError
                            _DebugOut('Token not expected!', True)
                        Case $g__gpMsgCommentError
                            _DebugOut('Comment was not terminated!', True)
                        Case $g__gpMsgInternalError
                            _DebugOut('Something horrid happened inside the parser!', True)
                        Case $g__gpMsgNotLoadedError
                            _DebugOut('Compiled grammar not loaded!', True)

                        Case $g__gpMsgTokenRead
                            _DebugOut('[CURRENT TOKEN]=[' & $oParser.CurrentToken.Name & ']')
                        Case $g__gpMsgCommentBlockRead
                            _DebugOut("This script can't contain block comments!", True)
                        Case $g__gpMsgCommentLineRead
                            ;comment line read..
                        Case $g__gpMsgReduction
;~                      _DebugOut('$g__gpMsgReduction='& $oParser.CurrentReduction.ParentRule.TableIndex)

                            Switch $oParser.CurrentReduction.ParentRule.TableIndex ;stuck here
                                Case $g__gpRule_Statements1

                                Case $g__gpRule_Statements2

                                Case $g__gpRule_Statement_NameIsExpression

                                Case $g__gpRule_Statement_MsgExpression

                                Case $g__gpRule_Statement_IfThenEnd

                                Case $g__gpRule_Statement_IfThenElseEnd

                                Case $g__gpRule_Expression_BiggerThen, $g__gpRule_Expression_SmallerThen, $g__gpRule_Expression_BiggerEqualThen1, $g__gpRule_Expression_BiggerEqualThen2, $g__gpRule_Expression_SmallerEqualThen1, $g__gpRule_Expression_SmallerEqualThen2, $g__gpRule_Expression_EqualThen, $g__gpRule_Expression_NotEqualThen

                                Case $g__gpRule_Add_Plus

                                Case $g__gpRule_Add_Minus

                                Case $g__gpRule_Add_Amp

                                Case $g__gpRule_Mult_Mult

                                Case $g__gpRule_Mult_Div

                                Case $g__gpRule_Mult_Value

                                Case $g__gpRule_Value_Name

                                Case $g__gpRule_Value_String

                                Case $g__gpRule_Value_Number

                                Case $g__gpRule_Value_GroupedExpression
                                    ; this 2 case options are ignored because of "TrimReductions = True"
                                    ; Case $g__gpRule_Expression
                                    ; Case $g__gpRule_Add_Expression
                            EndSwitch

                        Case $g__gpMsgAccept
                            _DebugOut('Done!')
                            $bDone = True

                    EndSwitch

                Until $bDone = True

            Case $idButton_Run
                ;...
        EndSwitch
    WEnd

    ; CleanUp
    WinClose($__gsReportTitle_Debug)
    _DebugCOMError(0)
    $oParser = ''

EndFunc   ;==>Example

TheAutomator.

Edited by TheAutomator

Share this post


Link to post
Share on other sites

Little update:

I'm reading the source code over and over again and i think i get what's going on in the vb6 code.

because vbscript is object-oriented my first tests will happen there, after that i will try to convert to autoit :)

Share this post


Link to post
Share on other sites

It is good news.

So keep on.
And I'm keeping my fingers crossed.
 
mLipok
1 person likes this

Signature beginning:   Wondering who uses AutoIT and what it can be used for ?
* GHAPI UDF - modest begining - comunication with GitHub REST API *
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 API *

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 - BETA * ADO.au3 UDF SMTP Mailer 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 * Best coding practices * 

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) * 

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

Signature last update: 2017-06-04

Share this post


Link to post
Share on other sites

#12 ·  Posted (edited)

Update:

I maybe have some bad news...

I successfully wrote a programming language grammar in 'BNF' and i also made a working interpreter for it in vbscript.

The way you have to work with the activeX version of the gold parser:

load gold parser object.

load grammar.

load test script you made for the grammar.

gold parser makes AST.

you have to map every node of the AST by replacing it with your own customized class.

when done execute the class code of the root node.

 

      Case gpMsgReduction
         'This message is returned when a rule was reduced by the parse engine.
        'The CurrentReduction property is assigned a Reduction object
        'containing the rule and its related tokens. You can reassign this
        'property to your own customized class. If this is not the case,
         'this message can be ignored and the Reduction object will be used
        'to store the parse tree.       
         Select Case Parser.CurrentReduction.ParentRule.TableIndex
           ...
         End Select

         Parser.CurrentReduction = 'Object you created to store the rule

 

AutoIt is not able to make its own classes so i guess it ends here?

[EDIT:]

I'm not saying i give up on this.

Maybe there is some way to fill a customized AST (some array or something) with references to functions.  :think:

Let me think about it, do some tests if i have time, ill post when i know something more  :)

Regards,

TheAutomator

Edited by TheAutomator

Share this post


Link to post
Share on other sites

#13 ·  Posted (edited)

Ok, for people that want to make a more advanced interpreter i recommend vb6 or vbscript or any other language that is object-oriented...

I made the most useless scripting language in the world (i guess) as an example, its called "TO TINY" and that's what it is  :D.

you can only assign numeric variables and show them in a message.

here an example script:

test = 5
lol = 100

msg test
msg lol

source code is in the attachments  :)

(rename "TOTINY.cgt.txt" to "TOTINY.cgt")

If someone finds a way to make a more advanced language without classes then please let me know  ;)

regards

TheAutomator.

INTERPRETER.au3

totiny.ico

TOTINY.cgt.txt

Edited by TheAutomator

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

  • Similar Content

    • Ubermensch
      By Ubermensch
      Hello,
      I am currently trying to automatically click the "Yes" button in the ActiveX prompt/popup message after opening the IE (html).
      At 1st, I encounter the "Allow Blocked Content". I already resolve it just by changing settings in the IE Options. But after resolving the "Allow Blocked Content", there's a popup message appear.
      I have attached the ActiveX Prompt.
      Here is the 1st code that I try to use.
      #include <IE.au3> #include <MsgBoxConstants.au3> #include <WinAPI.au3> _IECreate("C:\Users\april\Documents\Logo\JRB\AutoIt\AutoBOT\AWD10\sampleAWD10.html",0,1,0) Local $oIE = _IEAttach("", "instance", 1) _IELoadWait($oIE) AdlibRegister("_ActiveXRun",250) Local $oLastName = _IEGetObjByName($oIE, "Text4") Local $oGetItem = _IEGetObjByName($oIE, "getitem") _IEAction($oGetItem, "click") MsgBox($MB_SYSTEMMODAL, "Form Element Value", _IEFormElementGetValue($oGetItem)) Func _ActiveXRun() $retWin = WinGetHandle("[Class:Button]","") $winTitle = "[HANDLE:" & $retWin &"]" $ctrlHandle = ControlGetHandle($winTitle,"", "[CLASS:Button; INSTANCE:2]") $ctrlTitle = "HANDLE:" & $ctrlHandle &"]" WinWaitActive($ctrlTitle,"[CLASS:Button; INSTANCE:2]",10) $k = ControlGetPos($winTitle, "","[CLASS:Button; INSTANCE:2]") $x = $k[0] $y = $k[1] WinActivate ($winTitle,"An ActiveX control on this page might be unsafe to interact with other parts of the page. Do you want to allow this interaction?") ControlFocus($winTitle,"An ActiveX control on this page might be unsafe to interact with other parts of the page. Do you want to allow this interaction?","[CLASS:Button; INSTANCE:2]") ControlClick($winTitle, "","[CLASS:Button; INSTANCE:2]","primary",1,$x,$y) ControlSend($winTitle, "", "[CLASS:Button; INSTANCE:2]", "{ENTER}", 0) EndFunc Here is the console output.
      >"C:\Program Files (x86)\AutoIt3\SciTE\..\AutoIt3.exe" "C:\Program Files (x86)\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.au3" /run /prod /ErrorStdOut /in "C:\Users\april\Documents\Logo\JRB\AutoIt\AutoBOT\AWD10\AWD10.1.au3" /UserParams +>12:44:11 Starting AutoIt3Wrapper v.17.224.935.0 SciTE v.3.7.3.0 Keyboard:00000409 OS:WIN_10/ CPU:X64 OS:X64 Environment(Language:0409) CodePage:0 utf8.auto.check:4 +> SciTEDir => C:\Program Files (x86)\AutoIt3\SciTE UserDir => C:\Users\april\AppData\Local\AutoIt v3\SciTE\AutoIt3Wrapper SCITE_USERHOME => C:\Users\april\AppData\Local\AutoIt v3\SciTE >Running AU3Check (3.3.14.2) from:C:\Program Files (x86)\AutoIt3 input:C:\Users\april\Documents\Logo\JRB\AutoIt\AutoBOT\AWD10\AWD10.1.au3 +>12:44:11 AU3Check ended.rc:0 >Running:(3.3.14.2):C:\Program Files (x86)\AutoIt3\autoit3.exe "C:\Users\april\Documents\Logo\JRB\AutoIt\AutoBOT\AWD10\AWD10.1.au3" --> Press Ctrl+Alt+Break to Restart or Ctrl+Break to Stop "C:\Users\april\Documents\Logo\JRB\AutoIt\AutoBOT\AWD10\AWD10.1.au3" (31) : ==> Subscript used on non-accessible variable.: $x = $k[0] $x = $k^ ERROR ->12:44:24 AutoIt3.exe ended.rc:1 +>12:44:24 AutoIt3Wrapper Finished. >Exit code: 1 Time: 13.76 I also tried a simpler code.
      include <IE.au3> #include <MsgBoxConstants.au3> #include <WinAPI.au3> _IECreate("C:\Users\april\Documents\Logo\JRB\AutoIt\AutoBOT\AWD10\sampleAWD10.html",0,1,0) Local $oIE = _IEAttach("", "instance", 1) _IELoadWait($oIE) $k = ControlGetPos("[CLASS:#32770]", "","[CLASS:Button; INSTANCE:2]") $x = $k[0] $y = $k[1] ControlClick("[CLASS:#32770]", "","[CLASS:Button; INSTANCE:2]","primary",1,$x,$y) Local $oLastName = _IEGetObjByName($oIE, "Text4") Local $oGetItem = _IEGetObjByName($oIE, "getitem") _IEAction($oGetItem, "click") MsgBox($MB_SYSTEMMODAL, "Form Element Value", _IEFormElementGetValue($oGetItem)) There's no error in the console output for the 2nd code I have tried.
      And here is the Window Info for the ActiveX prompt.
      >>>> Window <<<< Title: Internet Explorer Class: #32770 Position: 580, 338 Size: 376, 146 Style: 0x94C808C4 ExStyle: 0x00010101 Handle: 0x00000000001516FA >>>> Control <<<< Class: Button Instance: 2 ClassnameNN: Button2 Name: Advanced (Class): [CLASS:Button; INSTANCE:2] ID: 1 Text: &Yes Position: 184, 77 Size: 80, 22 ControlClick Coords: 37, 12 Style: 0x50010000 ExStyle: 0x00000004 Handle: 0x00000000001215DE >>>> Mouse <<<< Position: 228, 120 Cursor ID: 0 Color: 0xFFFFFF >>>> StatusBar <<<< >>>> ToolsBar <<<< >>>> Visible Text <<<< &No An ActiveX control on this page might be unsafe to interact with other parts of the page. Do you want to allow this interaction? &Yes >>>> Hidden Text <<<<  

    • Fade91
      By Fade91
      Hello, first time poster here
      I am working on a project that has to parse a log file in real time. The thing is I know it's hard for Autoit to attach itself to log files when they're already in use by other programs, at least in my experience.
      I was taking a look at this thread because the log file is quite large and I think Autoit might be a little slow on it's own.

      The thing is I don't know how to use this properly to extract all data out of a log file or is there a native way to do this using Autoit.
      Basically , I just need a log parser that is able to read from a log that is 'already opened' and 'being written to'
       
      Thanks!
    • TheAutomator
      By TheAutomator
      Hello 
      I'm not so familiar with the scriptcontrol, can you help me with this little problem?
      Why is this script not working correctly?
      Global $oVbs = ObjCreate('MSScriptControl.ScriptControl') With $ovbs .Language = "VBScript" .AllowUI = True .AddCode('Class Test:Public Function X:X = 123:End Function:Set C = New Test') .AddCode('MsgBox IsObject(C)'); should be true, no? EndWith MsgBox(0,'',$oVbs.Eval('C').X) Also: how do I add code to the global module?
      Thanks,
      TheAutomator
    • TheAutomator
      By TheAutomator
      Hi everyone
      Are there any people here that know how to use a parser generator that uses 'bnf' (not 'ebnf'!)
      i'm using the gold parser:
      http://goldparser.org/index.htm
      not possible in autoit:
      https://www.autoitscript.com/forum/topic/167663-activex-gold-parser-in-autoit-is-this-possible/
      What i'm looking for is the best way to parse a list:
      <List> ::= <Item> ',' <List> | <Item> <Item> ::= Number | String for example, the tree returned from:
      'test', 1, 2 is:

      since its not possible in AutoIT code I did it in vb script.
      this is what i did:
      ' in the parse loop: Case Rule_List_Comma set result = new list call result.input(.tokens(0).data,.tokens(2).data) ' the list class: class list private arg0 private arg1 public sub input(a,b) set arg0 = a set arg1 = b end sub private sub push(item,byref stack) redim preserve stack(ubound(stack) + 1) stack(ubound(stack)) = item end sub public function value value = array(arg0.value) value2 = arg1.value if isarray(value2) then for each thing in value2 push thing,value next else push value2,value end if end function end class  
      is there a better way to do this?
       
      regards,
      TheAutomator