Skip to content

Instantly share code, notes, and snippets.

@bonprosoft
Created November 6, 2012 16:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bonprosoft/4025672 to your computer and use it in GitHub Desktop.
Save bonprosoft/4025672 to your computer and use it in GitHub Desktop.
Hello,World on VBCPP AST
Imports VBCPP
Imports VBCPPPlugin
Imports VBCPPPlugin.Tables
Imports VBCPPPlugin.AST
Imports VBCPPPlugin.AST.AST_Class
Imports VBCPPPlugin.AST.AST_Enum
Module HelloWorld
Sub Main()
'SourceCode Information
'(VBCPPにてエラー発生時に使用されます。本来なら木ごとに設定します。)
Const Line As Integer = 0
Const FileName As String = "sample.vb"
Const LangName As String = "VB"
Const MethodName As String = "SampleMethod"
'バイナリの出力パス
Dim outputPath As String = "C:\hoge\hello.exe"
'Generator(VBCPP.Core)
Dim generator As New Generator
'★Hello,World!(ここがAST本体です。画像にあった部分です。)★
' 一応これでも、"1文"です。
Dim tree As New VBCPP_Program(New VBCPP_ClassList, _
New VBCPP_MethodList(New VBCPP_Method( _
MethodName, _
New VBCPP_Type(GetType(Void)), _
New VBCPP_ParameterList(), _
New VBCPP_Body(New VBCPP_StatementList( _
New VBCPP_CallStatement("Console", _
New VBCPP_CallExpression("WriteLine", _
New VBCPP_IndexList(), _
New VBCPP_ArgumentList( _
New VBCPP_Argument(New VBCPP_Literal("Hello,World!", VBCPP_LiteralType.VBCPP_STRING), Line)), _
Nothing), _
Line) _
) _
), _
System.Reflection.MethodAttributes.Static Or Reflection.MethodAttributes.Public, _
LangName, _
Line, _
FileName)), _
New VBCPP_EnumList(), _
New VBCPP_ImportList(New VBCPP_Import(New NameList("System"))))
'Generate!
generator.Generate("SampleApplication", tree, Nothing, New NameTableList, New NameList(MethodName), outputPath)
End Sub
End Module
'Hello,World!(★部分を、1行にまとめてみました!)
Dim tree As New VBCPP_Program(New VBCPP_ClassList,New VBCPP_MethodList(New VBCPP_Method("SampleMethod",New VBCPP_Type(GetType(Void)),New VBCPP_ParameterList(),New VBCPP_Body(New VBCPP_StatementList(New VBCPP_CallStatement("Console",New VBCPP_CallExpression("WriteLine",New VBCPP_IndexList(),New VBCPP_ArgumentList(New VBCPP_Argument(New VBCPP_Literal("Hello,World!", VBCPP_LiteralType.VBCPP_STRING), 0)),Nothing),0))),System.Reflection.MethodAttributes.Static Or Reflection.MethodAttributes.Public,"VB",0,"sample.vb")),New VBCPP_EnumList(),New VBCPP_ImportList(New VBCPP_Import(New NameList("System"))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment