Jump to content

Search the Community

Showing results for tags 'ast'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • General
    • Announcements and Site News
    • Administration
  • AutoIt v3
    • AutoIt Help and Support
    • AutoIt Technical Discussion
    • AutoIt Example Scripts
  • Scripting and Development
    • Developer General Discussion
    • Language Specific Discussion
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Categories

  • AutoIt Team
    • Beta
    • MVP
  • AutoIt
    • Automation
    • Databases and web connections
    • Data compression
    • Encryption and hash
    • Games
    • GUI Additions
    • Hardware
    • Information gathering
    • Internet protocol suite
    • Maths
    • Media
    • PDF
    • Security
    • Social Media and other Website API
    • Windows
  • Scripting and Development
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Member Title


Location


WWW


Interests

Found 2 results

  1. Hi all! I am working on a AutoIt grammar in the Peggy syntax, and have recently started working towards being able to output the generated parser in AutoIt syntax via a Peggy plugin. The parser/grammar is not yet 100% AutoIt syntax compatible, but I think the generated parser is now in an acceptable state. If you have any performance optimization suggestions, let me know! 😄 When the plugin is ready for release, I will add a GitHub link to latest GitHub release generated asset, for the parser, but for now i will just attach the script here, and the grammar with modified code blocks. The parser outputs an abstract syntax tree, representing the parsed input. Example: #include <Array.au3> #include "parser.au3" $ast = peg_parse("2 * (3 + 4)") If Not (@error = 0) Then ConsoleWrite("Error: "&@error&@CRLF) Exit 1 EndIf $result = Process($ast) _ArrayDisplay($result) Func Process($ast) Switch $ast.type Case 'Program' Local $body = $ast.body Local $results[UBound($body)] For $i = 0 To UBound($body) - 1 Local $node = $body[$i] $results[$i] = Process($node) If Not (@error = 0) Then Return SetError(@error) Next Return $results Case 'ExpressionStatement' Local $result = Process($ast.expression) If Not (@error = 0) Then Return SetError(@error) Return $result Case 'BinaryExpression' Local $left = Process($ast.left) If Not (@error = 0) Then Return SetError(@error) Local $right = Process($ast.right) If Not (@error = 0) Then Return SetError(@error) Switch $ast.operator Case '+' Return $left + $right Case '-' Return $left - $right Case '*' Return $left * $right Case '/' Return $left / $right Case '&' Return $left & $right Case Else ConsoleWriteError("Unknown operator: "&$ast.operator&@CRLF) Return SetError(1) EndSwitch Case 'Literal' Return $ast.value Case 'ParenthesizedExpression' Local $result = Process($ast.expression) If Not (@error = 0) Then Return SetError(@error) Return $result Case Else ConsoleWrite("Unknown node type: "&$ast.type&@CRLF) Return SetError(1) EndSwitch EndFunc Link to grammar: autoit3.pegjs Link to Peggy plugin: peggy-au3.ts parser.au3 autoit3-modified.pegjs
  2. 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, 2is: 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
×
×
  • Create New...