Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

Question about using Gold Parser

activex gold parser

This topic has been archived. This means that you cannot reply to this topic.
1 reply to this topic

#1 TheAutomator

TheAutomator

    CC Lurker

  • New Member
  • Pip
  • 8 posts

Posted 24 February 2015 - 08:13 AM

hi everyone wink.png

 

i have a question about the gold parser:

 

info:

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

 

download (regsvr32 to register):

http://www.goldparse...1/vb6/index.htm

 

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

so that does mean that it can be used in vbscript to right?

 

help for the activeX dll:

http://www.goldparse...6/doc/index.htm

 

so far i have only managed to create a skeleton program (that i will post here in a minute) and from that point ... i got stuck,

which was a bit disappointing..

 

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

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

 

i'm searching for a very clear and simple example.

 

at least here is the vb script code i already have:

Const Symboltypecommentend = 5
Const Symboltypecommentline = 6
Const Symboltypecommentstart = 4
Const Symboltypeend = 3
Const Symboltypeerror = 7
Const Symboltypenonterminal = 0
Const Symboltypeterminal = 1
Const Symboltypewhitespace = 2
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

Const Rule_Statements1 = 0					' <statements> ::= <statement> <statements>
Const Rule_Statements2 = 1					' <statements> ::= <statement>
Const Rule_Statement_Nameisexpression = 2	' <statement> ::= name '=' <expression>
Const Rule_Statement_Msgexpression = 3		' <statement> ::= msg <expression>
Const Rule_Statement_Ifthenend = 4			' <statement> ::= if <expression> then <statements> end
Const Rule_Statement_Ifthenelseend = 5		' <statement> ::= if <expression> then <statements> else <statements> end
Const Rule_Expression_Biggerthen = 6		' <expression> ::= <expression> '>' <add exp>
Const Rule_Expression_Smallerthen = 7		' <expression> ::= <expression> '<' <add exp>
Const Rule_Expression_Biggerequalthen1 = 8	' <expression> ::= <expression> '<=' <add exp>
Const Rule_Expression_Biggerequalthen2 = 9	' <expression> ::= <expression> '>=' <add exp>
Const Rule_Expression_Smallerequalthen1 = 10' <expression> ::= <expression> '=>' <add exp>
Const Rule_Expression_Smallerequalthen2 = 11' <expression> ::= <expression> '=<' <add exp>
Const Rule_Expression_Equalthen = 12		' <expression> ::= <expression> '=' <add exp>
Const Rule_Expression_Notequalthen = 13		' <expression> ::= <expression> '!' <add exp>
Const Rule_Expression = 14					' <expression> ::= <add exp>
Const Rule_Add_Plus = 15					' <add exp> ::= <add exp> '+' <mult exp>
Const Rule_Add_Minus = 16					' <add exp> ::= <add exp> '-' <mult exp>
Const Rule_Add_Amp = 17						' <add exp> ::= <add exp> '&' <mult exp>
Const Rule_Add_Expression = 18				' <add exp> ::= <mult exp>
Const Rule_Mult_Mult = 19					' <mult exp> ::= <mult exp> '*' <value>
Const Rule_Mult_Div = 20					' <mult exp> ::= <mult exp> '/' <value>
Const Rule_Mult_Value = 21					' <mult exp> ::= <value>
Const Rule_Value_Name = 22					' <value> ::= name
Const Rule_Value_String = 23				' <value> ::= string
Const Rule_Value_Number = 24				' <value> ::= number
Const Rule_Value_Groupedexpression = 25		' <value> ::= '(' <expression> ')'

Set Parser = CreateObject("goldparserengine.goldparser")
With Parser
	.Loadcompiledgrammar "F:\Tom_Schrauwen\Projects\bezig nu!\verryBasic\test_script.cgt"
	.Trimreductions = True
	.Openfile "F:\Tom_Schrauwen\Projects\bezig nu!\verryBasic\program.txt"
End With

Done = False

Do
	Response = Parser.Parse()
	Select Case Response
		Case Gpmsglexicalerror
			Call Msg("Illegal or unrecognized token!", True)
		Case Gpmsgsyntaxerror
			Call Msg("Token not expected!", True)
		Case Gpmsgcommenterror
			Call Msg("Comment was not terminated!", True)
		Case Gpmsginternalerror
			Call Msg("Something horrid happened inside the parser!", True)
		Case Gpmsgnotloadederror
			Call Msg("Compiled grammar not loaded!", True)
			
		Case Gpmsgtokenread
			'Call Msg("[CURRENT TOKEN]=[" & Parser.Currenttoken.Name & "]", false)
		Case Gpmsgcommentblockread
			Call Msg("This script can't contain block comments!", True)
		Case Gpmsgcommentlineread
			'comment line read..
		Case Gpmsgreduction
			Select Case Parser.Currentreduction.Parentrule.Tableindex
				Case Rule_Statements1
					msgbox "Rule_Statements1"
				Case Rule_Statements2
					msgbox "Rule_Statements2"
				Case Rule_Statement_Nameisexpression
					msgbox "Rule_Statement_Nameisexpression"
				Case Rule_Statement_Msgexpression
					msgbox "Rule_Statement_Msgexpression"
				Case Rule_Statement_Ifthenend
					msgbox "Rule_Statement_Ifthenend"
				Case Rule_Statement_Ifthenelseend
					msgbox "Rule_Statement_Ifthenelseend"
				Case Rule_Expression_Biggerthen, Rule_Expression_Smallerthen, Rule_Expression_Biggerequalthen1, Rule_Expression_Biggerequalthen2, Rule_Expression_Smallerequalthen1, Rule_Expression_Smallerequalthen2, Rule_Expression_Equalthen, Rule_Expression_Notequalthen
					msgbox "Rule_Expression ..."
				Case Rule_Add_Plus
					msgbox "Rule_Add_Plus"
				Case Rule_Add_Minus
					msgbox "Rule_Add_Minus"
				Case Rule_Add_Amp
					msgbox "Rule_Add_Amp"
				Case Rule_Mult_Mult
					msgbox "Rule_Mult_Mult"
				Case Rule_Mult_Div
					msgbox "Rule_Mult_Div"
				Case Rule_Mult_Value
					msgbox "Rule_Mult_Value"
				Case Rule_Value_Name
					msgbox "Rule_Value_Name"
				Case Rule_Value_String
					msgbox "Rule_Value_String"
				Case Rule_Value_Number
					msgbox "Rule_Value_Number"
				Case Rule_Value_Groupedexpression
					msgbox "Rule_Value_Groupedexpression"
					
				'this 2 case options are ignored because of "TrimReductions = True"
				'Case Rule_Expression
				'Case Rule_Add_Expression
			End Select
			
		Case Gpmsgaccept
			Msgbox "Done!",32
			Done = True
			
	End Select
Loop Until Done = True

Sub Msg(Input, Bool)
	MsgBox Input
	If Bool Then WScript.Quit
End Sub

hope someone can help me with this :)

regards!

 

-TheAutomator



#2 TheAutomator

TheAutomator

    CC Lurker

  • New Member
  • Pip
  • 8 posts

Posted 24 February 2015 - 08:43 AM

I can't change the title and edit my question?  :confused:  help me please  :wacko: