mirror of
https://github.com/fedapo/vb6-parser.git
synced 2025-12-17 08:44:34 +03:00
First commit
This commit is contained in:
89
docs/ast_vs_grammar_table.txt
Normal file
89
docs/ast_vs_grammar_table.txt
Normal file
@@ -0,0 +1,89 @@
|
||||
AST ELEMENT GRAMMAR RULE
|
||||
----------------------------------------------------------------------
|
||||
empty_line empty_line
|
||||
lonely_comment lonely_comment
|
||||
quoted_string quoted_string
|
||||
var_identifier basic_identifier
|
||||
identifier_context identifier_context
|
||||
type_identifier
|
||||
|
||||
vb6_ast::variable vb6_grammar::single_var_declaration
|
||||
decorated_variable decorated_variable
|
||||
vb6_ast::global_var_decls vb6_grammar::global_var_declaration
|
||||
integer_dec
|
||||
integer_hex
|
||||
integer_oct
|
||||
long_dec
|
||||
long_hex
|
||||
long_oct
|
||||
vb6_ast::const_expr vb6_grammar::const_expression
|
||||
vb6_ast::const_var
|
||||
vb6_ast::const_var_stat vb6_grammar::const_var_declaration
|
||||
vb6_ast::record vb6_grammar::record_declaration
|
||||
vb6_ast::enum_item
|
||||
vb6_ast::vb_enum vb6_grammar::enum_declaration
|
||||
expression expression
|
||||
func_call functionCall
|
||||
vb6_ast::func_param vb6_grammar::param_decl
|
||||
vb6_ast::external_decl vb6_grammar::
|
||||
vb6_ast::subHead vb6_grammar::subHead
|
||||
eventHead vb6_grammar::eventHead
|
||||
vb6_ast::functionHead vb6_grammar::functionHead
|
||||
propertyLetHead vb6_grammar::property_letHead
|
||||
propertySetHead vb6_grammar::property_setHead
|
||||
propertyGetHead vb6_grammar::property_getHead
|
||||
vb6_ast::externalSub vb6_grammar::external_sub_decl
|
||||
vb6_ast::externalFunction vb6_grammar::external_function_decl
|
||||
|
||||
vb6_ast::assignStatement vb6_grammar::
|
||||
localVarDeclStat localvardeclStatement
|
||||
redimStatement redimStatement
|
||||
exitStatement exitStatement
|
||||
gotoStatement gotoStatement
|
||||
onerrorStatement onerrorStatement
|
||||
resumeStatement resumeStatement
|
||||
labelStatement labelStatement
|
||||
callStatement callimplicitStatement
|
||||
callStatement callexplicitStatement
|
||||
raiseeventStatement raiseeventStatement
|
||||
|
||||
vb6_ast::whileStatement vb6_grammar::whileStatement
|
||||
vb6_ast::doStatement vb6_grammar::doStatement
|
||||
vb6_ast::dowhileStatement vb6_grammar::dowhileStatement
|
||||
vb6_ast::loopwhileStatement vb6_grammar::loopwhileStatement
|
||||
vb6_ast::dountilStatement vb6_grammar::dountilStatement
|
||||
vb6_ast::loopuntilStatement vb6_grammar::loopuntilStatement
|
||||
|
||||
vb6_ast::forStatement vb6_grammar::forStatement
|
||||
vb6_ast::foreachStatement vb6_grammar::foreachStatement
|
||||
if_branch
|
||||
vb6_ast::ifelseStatement vb6_grammar::ifelseStatement
|
||||
vb6_ast::withStatement vb6_grammar::withStatement
|
||||
case_relational_expr
|
||||
case_block case_block
|
||||
vb6_ast::selectStatement vb6_grammar::selectStatement
|
||||
|
||||
vb6_ast::if_branch ifBranch
|
||||
vb6_ast::if_branch elsifBranch
|
||||
vb6_ast::statement_block elseBranch
|
||||
|
||||
vb6_ast::singleStatement vb6_grammar::singleStatement
|
||||
vb6_ast::statement_block vb6_grammar::statement_block
|
||||
|
||||
vb6_ast::subDef vb6_grammar::subDef
|
||||
vb6_ast::functionDef vb6_grammar::functionDef
|
||||
vb6_ast::get_prop vb6_grammar::
|
||||
vb6_ast::let_prop vb6_grammar::
|
||||
vb6_ast::set_prop vb6_grammar::
|
||||
|
||||
STRICT_MODULE_STRUCTURE
|
||||
module_attributes
|
||||
option_block
|
||||
declaration
|
||||
functionList
|
||||
vb_module
|
||||
|
||||
#vb6_ast::decl_item vb6_grammar::declaration
|
||||
vb6_ast::declaration vb6_grammar::declaration
|
||||
module_attribute
|
||||
vb6_ast::vb_module
|
||||
4
docs/notes_Spirit.md
Normal file
4
docs/notes_Spirit.md
Normal file
@@ -0,0 +1,4 @@
|
||||
# Boost Spirit
|
||||
|
||||
https://stackoverflow.com/questions/38039237/parsing-identifiers-except-keywords \
|
||||
https://www.codevamping.com/2018/09/identifier-parsing-in-boost-spirit-x3-custom-parser/
|
||||
115
docs/notes_vb6.md
Normal file
115
docs/notes_vb6.md
Normal file
@@ -0,0 +1,115 @@
|
||||
# VB6 - Visual Basic 6
|
||||
|
||||
https://en.wikipedia.org/wiki/Visual_Basic_(classic) \
|
||||
https://en.wikipedia.org/wiki/BASIC
|
||||
|
||||
BASIC = Beginner's All-purpose Symbolic Instruction Code
|
||||
|
||||
> At least for the people who send me mail about a new language that they're
|
||||
> designing, the general advice is: do it to learn about how to write a compiler.
|
||||
> Don't have any expectations that anyone will use it, unless you hook up with
|
||||
> some sort of organization in a position to push it hard. It's a lottery, and
|
||||
> some can buy a lot of the tickets. There are plenty of beautiful languages
|
||||
> (more beautiful than C) that didn't catch on. But someone does win the lottery,
|
||||
> and doing a language at least teaches you something. \
|
||||
> _Dennis Ritchie (1941-2011)_ \
|
||||
> _Creator of the C programming language and of Unix_
|
||||
|
||||
---
|
||||
## Press
|
||||
|
||||
Visual Basic 6 Renewed to Run on Windows 8 \
|
||||
https://www.infoq.com/news/2012/02/vb6_supported_on_win8
|
||||
|
||||
---
|
||||
## Complete VB6 Grammars
|
||||
|
||||
ANTLR4-based Grammars
|
||||
|
||||
https://github.com/antlr/grammars-v4/tree/master/vb6
|
||||
|
||||
https://github.com/uwol/vb6parser \
|
||||
https://github.com/uwol/vb6parser/blob/master/src/main/antlr4/io/proleap/vb6/VisualBasic6.g4
|
||||
|
||||
Grammar Zoo: http://slebok.github.io/zoo/index.html
|
||||
|
||||
http://boost.2283326.n4.nabble.com/Parser-operator-Difference-td4675788.html
|
||||
|
||||
---
|
||||
## Expression Parsing
|
||||
|
||||
https://en.wikipedia.org/wiki/Operator-precedence_parser
|
||||
|
||||
---
|
||||
## CodeProject Articles
|
||||
|
||||
Crafting an interpreter Part 1 - Parsing and Grammars \
|
||||
https://www.codeproject.com/Articles/10115/Crafting-an-interpreter-Part-1-Parsing-and-Grammar \
|
||||
|
||||
Visual Basic 6.0: A giant more powerful than ever\
|
||||
https://www.codeproject.com/Articles/710181/Visual-Basic-6-0-A-giant-more-powerful-than-ever
|
||||
|
||||
---
|
||||
## Misc
|
||||
|
||||
**Grako** (grammar compiler) is a tool that takes grammars in a variation of EBNF as input, and outputs memoizing (Packrat) PEG parsers in Python. \
|
||||
A generator of PEG/Packrat parsers from EBNF grammars. \
|
||||
https://pypi.python.org/pypi/grako/
|
||||
|
||||
**TatSu** is a tool that takes grammars in a variation of EBNF as input, and outputs memoizing (Packrat) PEG parsers in Python. \
|
||||
https://pypi.org/project/TatSu/
|
||||
|
||||
GOLD Parsing System \
|
||||
http://goldparser.org/engine/1/vb6/index.htm \
|
||||
http://goldparser.org/about/comparison-parsers.htm
|
||||
|
||||
http://www.eclipse.org/gmt/modisco/technologies/VisualBasic/#download
|
||||
|
||||
https://tomassetti.me/how-to-write-a-transpiler/
|
||||
|
||||
The vb2Py project is developing a suite of conversion tools to aid in translating Visual Basic projects into Python.\
|
||||
http://vb2py.sourceforge.net/index.html
|
||||
|
||||
http://vb6awards.blogspot.com/2016/04/microsoft-update-or-open-source-vb6.html
|
||||
|
||||
---
|
||||
## VB6 Named parameters
|
||||
|
||||
```vb
|
||||
Function foo(Optional val1 = 1, Optional val2 = 2, Optional val3 = 3)
|
||||
MsgBox "val1: " & val1 & " val2: " & val2 & " val3: " & val3
|
||||
foo = val3
|
||||
End Function
|
||||
|
||||
Private Sub Form_Load()
|
||||
MsgBox "foo returned: " & foo(val3:=4)
|
||||
End Sub
|
||||
```
|
||||
|
||||
## VB6 Dot notation (x.y)
|
||||
|
||||
Access to members of
|
||||
|
||||
- Modules
|
||||
- Classes, forms, controls
|
||||
- Types
|
||||
|
||||
Types of members
|
||||
|
||||
- Data members
|
||||
- Member functions
|
||||
- Member subroutines
|
||||
- Properties
|
||||
|
||||
```
|
||||
module.variable
|
||||
module.function
|
||||
module.subroutine
|
||||
module.enum
|
||||
module.type
|
||||
|
||||
object.variable
|
||||
object.function
|
||||
object.subroutine
|
||||
object.property
|
||||
```
|
||||
114
docs/vb6_attributes.md
Normal file
114
docs/vb6_attributes.md
Normal file
@@ -0,0 +1,114 @@
|
||||
# VB6 Attributes
|
||||
|
||||
## Class (.cls)
|
||||
|
||||
```vb
|
||||
VERSION 1.0 CLASS
|
||||
BEGIN
|
||||
MultiUse = -1 'True
|
||||
Persistable = 0 'NotPersistable
|
||||
DataBindingBehavior = 0 'vbNone
|
||||
DataSourceBehavior = 0 'vbNone
|
||||
MTSTransactionMode = 0 'NotAnMTSObject
|
||||
END
|
||||
Attribute VB_Name = "Interactive"
|
||||
Attribute VB_GlobalNameSpace = False
|
||||
Attribute VB_Creatable = True
|
||||
Attribute VB_PredeclaredId = False
|
||||
Attribute VB_Exposed = False
|
||||
...
|
||||
```
|
||||
|
||||
## Form (.frm), Control (.ctl), Property Page (.pag)
|
||||
|
||||
```vb
|
||||
VERSION 5.00
|
||||
Object = "{8DDE6232-1BB0-11D0-81C3-0080C7A2EF7D}#3.0#0"; "flp32a30.ocx"
|
||||
Begin VB.Form frmCalendar
|
||||
...
|
||||
```
|
||||
|
||||
```vb
|
||||
VERSION 5.00
|
||||
Object = "{8DDE6232-1BB0-11D0-81C3-0080C7A2EF7D}#3.0#0"; "flp32a30.ocx"
|
||||
Begin VB.UserControl ConfSelection
|
||||
...
|
||||
```
|
||||
|
||||
```vb
|
||||
VERSION 5.00
|
||||
Object = "{8DDE6232-1BB0-11D0-81C3-0080C7A2EF7D}#3.0#0"; "flp32a30.ocx"
|
||||
Begin VB.PropertyPage PropertyPage1
|
||||
...
|
||||
```
|
||||
|
||||
## Module (.bas)
|
||||
|
||||
```vb
|
||||
Attribute VB_Name = "CENTSERV"
|
||||
...
|
||||
```
|
||||
|
||||
## Attributes
|
||||
|
||||
https://christopherjmcclellan.wordpress.com/2015/04/21/vb-attributes-what-are-they-and-why-should-we-use-them/
|
||||
|
||||
### Module Level Attributes
|
||||
|
||||
```vb
|
||||
VB_Name = "Interactive"
|
||||
VB_GlobalNameSpace = False
|
||||
VB_Creatable = True
|
||||
VB_PredeclaredId = False
|
||||
VB_Exposed = False
|
||||
```
|
||||
|
||||
### Other Attributes
|
||||
|
||||
There are also a number of attributes that can be applied to module variables (fields), properties, and procedures.
|
||||
|
||||
| Attribute | Description |
|
||||
| --------- | ----------- |
|
||||
|VB_VarUserMemId| Determines the order of the variables in the Object Broswer. A value of 0 (zero) declares the variable to be the default member of the class.|
|
||||
|VB_VarDescription| The value of this attribute will be displayed in the Object Broswer.|
|
||||
|VB_UserMemId| |
|
||||
VB_Description| |
|
||||
|
||||
```vb
|
||||
LmoIEIDXRad.VB_VarHelpID = -1
|
||||
Item.VB_UserMemId = 0
|
||||
NewEnum.VB_UserMemId = -4
|
||||
```
|
||||
|
||||
There is one more special value for `VB_UserMemId` and that value is -4.
|
||||
Negative 4 always indicates that the function being marked should return
|
||||
a [_NewEnum] enumerator.
|
||||
|
||||
```vb
|
||||
' Header
|
||||
Attribute VB_Name = "ClassOrModuleName"
|
||||
Attribute VB_GlobalNameSpace = False ' ignored
|
||||
Attribute VB_Creatable = False ' ignored
|
||||
Attribute VB_PredeclaredId = False ' a Value of True creates a default global instance
|
||||
Attribute VB_Exposed = True ' Controls how the class can be instanced.
|
||||
|
||||
' Module Scoped Variables
|
||||
Attribute variableName.VB_VarUserMemId = 0 ' Zero indicates that this is the default member of the class.
|
||||
Attribute variableName.VB_VarDescription = "some string" ' Adds the text to the Object Browser information for this variable.
|
||||
|
||||
' Procedures
|
||||
Attribute procName.VB_Description = "some string" ' Adds the text to the Object Browser information for the procedure.
|
||||
Attribute procName.VB_UserMemId = someInteger
|
||||
' 0: Makes the function the default member of the class.
|
||||
' -4: Specifies that the function returns an Enumerator.
|
||||
```
|
||||
|
||||
In a control.
|
||||
|
||||
```vb
|
||||
Public Sub SpeechMarkBeg()
|
||||
Attribute SpeechMarkBeg.VB_MemberFlags = "40"
|
||||
|
||||
Public Property Get MaxLength() As Single
|
||||
Attribute MaxLength.VB_Description = "When the length of the dictation hits this number (in minutes) then the system stops recording and asks the user if he/she wants to proceed."
|
||||
```
|
||||
Reference in New Issue
Block a user