├── .editorconfig ├── .gitattributes ├── .gitignore ├── .gitmodules ├── .markdownlint.json ├── ANTLR4ParseTreeVisualizer.Dev.sln ├── ANTLR4ParseTreeVisualizer.sln ├── Debuggee ├── Debuggee.projitems ├── Debuggee.shproj └── VisualizerDataObjectSource.cs ├── Directory.Build.props ├── LICENSE ├── Legacy ├── Debuggee │ └── Legacy.Debuggee.csproj ├── Debugger │ └── Legacy.Debugger.csproj └── Package │ └── Legacy.Package.csproj ├── PostBuild └── PostBuild.csproj ├── README.md ├── Serialization ├── ClassInfo.cs ├── Config.cs ├── Enums.cs ├── Extensions.cs ├── ParseTreeNode.cs ├── PropertyValue.cs ├── Serialization.projitems ├── Serialization.shproj ├── Token.cs └── VisualizerData.cs ├── Standard ├── Debuggee │ └── Standard.Debuggee.csproj ├── Debugger │ └── Standard.Debugger.csproj └── Package │ └── Standard.Package.csproj ├── Test ├── Test.Legacy │ └── Test.Legacy.csproj ├── Test.Shared │ ├── Extensions.cs │ ├── Files │ │ ├── FormatterTest.java │ │ ├── Simple.java │ │ └── WindowsFunctionsForSqLite.sql │ ├── GlobalSuppressions.cs │ ├── Grammars │ │ ├── Java8Lexer.g4 │ │ ├── Java8Parser.g4 │ │ ├── SQLiteLexer.g4 │ │ └── SQLiteParser.g4 │ ├── Test.Shared.projitems │ ├── Test.Shared.shproj │ └── TestContainer.cs └── Test.Standard │ └── Test.Standard.csproj ├── UI ├── Converters.cs ├── Extensions.cs ├── ParserRuleDisplayNameSelector.cs ├── SettingsControl.xaml ├── SettingsControl.xaml.cs ├── UI.projitems ├── UI.shproj ├── ViewModels │ ├── ConfigViewModel.cs │ ├── ParseTreeNodeViewModel.cs │ ├── TokenTypeViewModel.cs │ ├── TokenViewModel.cs │ └── VisualizerDataViewModel.cs ├── VisualizerControl.xaml └── VisualizerControl.xaml.cs ├── Visualizer ├── Visualizer.cs ├── Visualizer.projitems ├── Visualizer.shproj ├── VisualizerWindow.xaml └── VisualizerWindow.xaml.cs ├── appveyor.yml ├── choose-parser.gif ├── parse-tree-filtering.gif ├── screenshot.png ├── selection-sync.gif ├── set-root.gif ├── token-filtering.gif └── visualize-string.gif /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | 4 | [*.{cs,vb}] 5 | indent_size = 4 6 | indent_style = space 7 | end_of_line = crlf 8 | insert_final_newline = true 9 | 10 | dotnet_separate_import_directive_groups = false 11 | dotnet_sort_system_directives_first = false 12 | 13 | dotnet_style_qualification_for_event = false:suggestion 14 | dotnet_style_qualification_for_field = false:suggestion 15 | dotnet_style_qualification_for_method = false:suggestion 16 | dotnet_style_qualification_for_property = false:suggestion 17 | 18 | dotnet_style_predefined_type_for_locals_parameters_members = true:suggestion 19 | dotnet_style_predefined_type_for_member_access = true:suggestion 20 | 21 | dotnet_style_parentheses_in_arithmetic_binary_operators = never_if_unnecessary:silent 22 | dotnet_style_parentheses_in_other_binary_operators = never_if_unnecessary:silent 23 | dotnet_style_parentheses_in_other_operators = never_if_unnecessary:silent 24 | dotnet_style_parentheses_in_relational_binary_operators = never_if_unnecessary:silent 25 | 26 | dotnet_style_require_accessibility_modifiers = for_non_interface_members:silent 27 | 28 | dotnet_style_coalesce_expression = true:suggestion 29 | dotnet_style_collection_initializer = true:suggestion 30 | dotnet_style_explicit_tuple_names = true:suggestion 31 | dotnet_style_null_propagation = true:suggestion 32 | dotnet_style_object_initializer = true:suggestion 33 | dotnet_style_operator_placement_when_wrapping = end_of_line 34 | dotnet_style_prefer_auto_properties = true:suggestion 35 | dotnet_style_prefer_compound_assignment = true:suggestion 36 | dotnet_style_prefer_conditional_expression_over_assignment = true:suggestion 37 | dotnet_style_prefer_conditional_expression_over_return = true:suggestion 38 | dotnet_style_prefer_inferred_anonymous_type_member_names = true:suggestion 39 | dotnet_style_prefer_inferred_tuple_names = true:suggestion 40 | dotnet_style_prefer_is_null_check_over_reference_equality_method = true:suggestion 41 | dotnet_style_prefer_simplified_boolean_expressions = true:suggestion 42 | dotnet_style_prefer_simplified_interpolation = true:suggestion 43 | 44 | 45 | # Naming rules 46 | 47 | dotnet_naming_rule.interface_should_be_begins_with_i.severity = suggestion 48 | dotnet_naming_rule.interface_should_be_begins_with_i.symbols = interface 49 | dotnet_naming_rule.interface_should_be_begins_with_i.style = begins_with_i 50 | 51 | dotnet_naming_rule.types_should_be_pascal_case.severity = suggestion 52 | dotnet_naming_rule.types_should_be_pascal_case.symbols = types 53 | dotnet_naming_rule.types_should_be_pascal_case.style = pascal_case 54 | 55 | dotnet_naming_rule.non_private_members_should_be_pascal_case.severity = suggestion 56 | dotnet_naming_rule.non_private_members_should_be_pascal_case.symbols = non_private_members 57 | dotnet_naming_rule.non_private_members_should_be_pascal_case.style = pascal_case 58 | 59 | dotnet_naming_rule.private_members_should_be_pascal_case.severity = suggestion 60 | dotnet_naming_rule.private_members_should_be_pascal_case.symbols = private_members 61 | dotnet_naming_rule.private_members_should_be_pascal_case.style = camel_case 62 | 63 | dotnet_naming_ruke.non_private_fields_should_be_canel_case.severity = suggestion 64 | dotnet_naming_ruke.non_private_fields_should_be_canel_case.symbols = non_private_fields 65 | dotnet_naming_ruke.non_private_fields_should_be_canel_case.style = camel_case 66 | 67 | 68 | # Symbols for use with naming rules 69 | 70 | dotnet_naming_symbols.interface.applicable_kinds = interface 71 | dotnet_naming_symbols.interface.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected 72 | dotnet_naming_symbols.interface.required_modifiers = 73 | 74 | dotnet_naming_symbols.types.applicable_kinds = class, struct, interface, enum, delegate 75 | dotnet_naming_symbols.types.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected 76 | dotnet_naming_symbols.types.required_modifiers = 77 | 78 | dotnet_naming_symbols.non_private_members.applicable_kinds = property, method, event 79 | dotnet_naming_symbols.non_private_members.applicable_accessibilities = public, internal, protected, private_protected, protected_internal 80 | 81 | dotnet_naming_symbols.private_members.applicable_kinds = property, method, field, event 82 | dotnet_naming_symbols.private_members.applicable_accessibilities = private 83 | 84 | dotnet_naming_symbols.non_private_fields.applicable_kinds = field 85 | dotnet_naming_symbols.non_private_fields.applicable_accessibilities = internal, protected, private_protected, protected_internal 86 | 87 | 88 | # Naming styles 89 | 90 | dotnet_naming_style.pascal_case.required_prefix = 91 | dotnet_naming_style.pascal_case.required_suffix = 92 | dotnet_naming_style.pascal_case.word_separator = 93 | dotnet_naming_style.pascal_case.capitalization = pascal_case 94 | 95 | dotnet_naming_style.begins_with_i.required_prefix = I 96 | dotnet_naming_style.begins_with_i.required_suffix = 97 | dotnet_naming_style.begins_with_i.word_separator = 98 | dotnet_naming_style.begins_with_i.capitalization = pascal_case 99 | 100 | dotnet_naming_style.camel_case.required_prefix = 101 | dotnet_naming_style.camel_case.required_suffix = 102 | dotnet_naming_style.camel_case.word_separator = 103 | dotnet_naming_style.camel_case.capitalization = camel_case 104 | 105 | 106 | [*.cs] 107 | csharp_new_line_before_catch = false 108 | csharp_new_line_before_else = false 109 | csharp_new_line_before_finally = false 110 | csharp_new_line_before_members_in_anonymous_types = true 111 | csharp_new_line_before_members_in_object_initializers = true 112 | csharp_new_line_before_open_brace = none 113 | csharp_new_line_between_query_expression_clauses = true 114 | 115 | csharp_indent_block_contents = true 116 | csharp_indent_braces = false 117 | csharp_indent_case_contents = true 118 | csharp_indent_case_contents_when_block = true 119 | csharp_indent_labels = one_less_than_current 120 | csharp_indent_switch_labels = true 121 | 122 | csharp_space_after_cast = false 123 | csharp_space_after_colon_in_inheritance_clause = true 124 | csharp_space_after_comma = true 125 | csharp_space_after_dot = false 126 | csharp_space_after_keywords_in_control_flow_statements = true 127 | csharp_space_after_semicolon_in_for_statement = true 128 | csharp_space_around_binary_operators = before_and_after 129 | csharp_space_around_declaration_statements = false 130 | csharp_space_before_colon_in_inheritance_clause = true 131 | csharp_space_before_comma = false 132 | csharp_space_before_dot = false 133 | csharp_space_before_open_square_brackets = false 134 | csharp_space_before_semicolon_in_for_statement = false 135 | csharp_space_between_empty_square_brackets = false 136 | csharp_space_between_method_call_empty_parameter_list_parentheses = false 137 | csharp_space_between_method_call_name_and_opening_parenthesis = false 138 | csharp_space_between_method_call_parameter_list_parentheses = false 139 | csharp_space_between_method_declaration_empty_parameter_list_parentheses = false 140 | csharp_space_between_method_declaration_name_and_open_parenthesis = false 141 | csharp_space_between_method_declaration_parameter_list_parentheses = false 142 | csharp_space_between_parentheses = false 143 | csharp_space_between_square_brackets = false 144 | 145 | csharp_preserve_single_line_blocks = true 146 | csharp_preserve_single_line_statements = true 147 | 148 | csharp_prefer_braces = true:warning 149 | 150 | csharp_style_expression_bodied_constructors = true:suggestion 151 | csharp_style_expression_bodied_methods = true:suggestion 152 | csharp_style_expression_bodied_properties = true:suggestion 153 | 154 | csharp_prefer_simple_default_expression = true:suggestion 155 | dotnet_style_prefer_inferred_tuple_names = true:suggestion 156 | 157 | csharp_style_var_elsewhere = true:suggestion 158 | csharp_style_var_for_built_in_types = true:suggestion 159 | csharp_style_var_when_type_is_apparent = true:suggestion 160 | 161 | csharp_preferred_modifier_order = internal,protected,public,private,static,readonly,abstract,override,sealed,virtual:suggestion 162 | 163 | csharp_style_pattern_matching_over_is_with_cast_check = true:suggestion 164 | csharp_style_pattern_matching_over_as_with_null_check = true:suggestion 165 | csharp_style_inlined_variable_declaration = true:suggestion 166 | csharp_style_deconstructed_variable_declaration = true:suggestion 167 | csharp_style_pattern_local_over_anonymous_function = true:suggestion 168 | csharp_style_throw_expression = true:suggestion 169 | csharp_style_conditional_delegate_call = true:suggestion 170 | 171 | 172 | [*.vb] 173 | visual_basic_preferred_modifier_order = partial,default,private,protected,public,friend,notoverridable,overridable,mustoverride,overloads,overrides,mustinherit,notinheritable,static,shared,shadows,readonly,writeonly,dim,const,withevents,widening,narrowing,custom,async,iterator:silent 174 | visual_basic_style_unused_value_assignment_preference = unused_local_variable:suggestion 175 | visual_basic_style_unused_value_expression_statement_preference = unused_local_variable:silent 176 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Set default behavior to automatically normalize line endings. 3 | ############################################################################### 4 | * text=auto 5 | 6 | ############################################################################### 7 | # Set default behavior for command prompt diff. 8 | # 9 | # This is need for earlier builds of msysgit that does not have it on by 10 | # default for csharp files. 11 | # Note: This is only used by command line 12 | ############################################################################### 13 | #*.cs diff=csharp 14 | 15 | ############################################################################### 16 | # Set the merge driver for project and solution files 17 | # 18 | # Merging from the command prompt will add diff markers to the files if there 19 | # are conflicts (Merging from VS is not affected by the settings below, in VS 20 | # the diff markers are never inserted). Diff markers may cause the following 21 | # file extensions to fail to load in VS. An alternative would be to treat 22 | # these files as binary and thus will always conflict and require user 23 | # intervention with every merge. To do so, just uncomment the entries below 24 | ############################################################################### 25 | #*.sln merge=binary 26 | #*.csproj merge=binary 27 | #*.vbproj merge=binary 28 | #*.vcxproj merge=binary 29 | #*.vcproj merge=binary 30 | #*.dbproj merge=binary 31 | #*.fsproj merge=binary 32 | #*.lsproj merge=binary 33 | #*.wixproj merge=binary 34 | #*.modelproj merge=binary 35 | #*.sqlproj merge=binary 36 | #*.wwaproj merge=binary 37 | 38 | ############################################################################### 39 | # behavior for image files 40 | # 41 | # image files are treated as binary by default. 42 | ############################################################################### 43 | #*.jpg binary 44 | #*.png binary 45 | #*.gif binary 46 | 47 | ############################################################################### 48 | # diff behavior for common document formats 49 | # 50 | # Convert binary document formats to text before diffing them. This feature 51 | # is only available from the command line. Turn it on by uncommenting the 52 | # entries below. 53 | ############################################################################### 54 | #*.doc diff=astextplain 55 | #*.DOC diff=astextplain 56 | #*.docx diff=astextplain 57 | #*.DOCX diff=astextplain 58 | #*.dot diff=astextplain 59 | #*.DOT diff=astextplain 60 | #*.pdf diff=astextplain 61 | #*.PDF diff=astextplain 62 | #*.rtf diff=astextplain 63 | #*.RTF diff=astextplain 64 | 65 | *.g4 -linguist-vendored -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | ## 4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore 5 | 6 | # User-specific files 7 | *.rsuser 8 | *.suo 9 | *.user 10 | *.userosscache 11 | *.sln.docstates 12 | 13 | # User-specific files (MonoDevelop/Xamarin Studio) 14 | *.userprefs 15 | 16 | # Build results 17 | [Dd]ebug/ 18 | [Dd]ebugPublic/ 19 | [Rr]elease/ 20 | [Rr]eleases/ 21 | x64/ 22 | x86/ 23 | [Aa][Rr][Mm]/ 24 | [Aa][Rr][Mm]64/ 25 | bld/ 26 | [Bb]in/ 27 | [Oo]bj/ 28 | [Ll]og/ 29 | 30 | # Visual Studio 2015/2017 cache/options directory 31 | .vs/ 32 | # Uncomment if you have tasks that create the project's static files in wwwroot 33 | #wwwroot/ 34 | 35 | # Visual Studio 2017 auto generated files 36 | Generated\ Files/ 37 | 38 | # MSTest test Results 39 | [Tt]est[Rr]esult*/ 40 | [Bb]uild[Ll]og.* 41 | 42 | # NUNIT 43 | *.VisualState.xml 44 | TestResult.xml 45 | 46 | # Build Results of an ATL Project 47 | [Dd]ebugPS/ 48 | [Rr]eleasePS/ 49 | dlldata.c 50 | 51 | # Benchmark Results 52 | BenchmarkDotNet.Artifacts/ 53 | 54 | # .NET Core 55 | project.lock.json 56 | project.fragment.lock.json 57 | artifacts/ 58 | 59 | # StyleCop 60 | StyleCopReport.xml 61 | 62 | # Files built by Visual Studio 63 | *_i.c 64 | *_p.c 65 | *_h.h 66 | *.ilk 67 | *.meta 68 | *.obj 69 | *.iobj 70 | *.pch 71 | *.pdb 72 | *.ipdb 73 | *.pgc 74 | *.pgd 75 | *.rsp 76 | *.sbr 77 | *.tlb 78 | *.tli 79 | *.tlh 80 | *.tmp 81 | *.tmp_proj 82 | *_wpftmp.csproj 83 | *.log 84 | *.vspscc 85 | *.vssscc 86 | .builds 87 | *.pidb 88 | *.svclog 89 | *.scc 90 | 91 | # Chutzpah Test files 92 | _Chutzpah* 93 | 94 | # Visual C++ cache files 95 | ipch/ 96 | *.aps 97 | *.ncb 98 | *.opendb 99 | *.opensdf 100 | *.sdf 101 | *.cachefile 102 | *.VC.db 103 | *.VC.VC.opendb 104 | 105 | # Visual Studio profiler 106 | *.psess 107 | *.vsp 108 | *.vspx 109 | *.sap 110 | 111 | # Visual Studio Trace Files 112 | *.e2e 113 | 114 | # TFS 2012 Local Workspace 115 | $tf/ 116 | 117 | # Guidance Automation Toolkit 118 | *.gpState 119 | 120 | # ReSharper is a .NET coding add-in 121 | _ReSharper*/ 122 | *.[Rr]e[Ss]harper 123 | *.DotSettings.user 124 | 125 | # JustCode is a .NET coding add-in 126 | .JustCode 127 | 128 | # TeamCity is a build add-in 129 | _TeamCity* 130 | 131 | # DotCover is a Code Coverage Tool 132 | *.dotCover 133 | 134 | # AxoCover is a Code Coverage Tool 135 | .axoCover/* 136 | !.axoCover/settings.json 137 | 138 | # Visual Studio code coverage results 139 | *.coverage 140 | *.coveragexml 141 | 142 | # NCrunch 143 | _NCrunch_* 144 | .*crunch*.local.xml 145 | nCrunchTemp_* 146 | 147 | # MightyMoose 148 | *.mm.* 149 | AutoTest.Net/ 150 | 151 | # Web workbench (sass) 152 | .sass-cache/ 153 | 154 | # Installshield output folder 155 | [Ee]xpress/ 156 | 157 | # DocProject is a documentation generator add-in 158 | DocProject/buildhelp/ 159 | DocProject/Help/*.HxT 160 | DocProject/Help/*.HxC 161 | DocProject/Help/*.hhc 162 | DocProject/Help/*.hhk 163 | DocProject/Help/*.hhp 164 | DocProject/Help/Html2 165 | DocProject/Help/html 166 | 167 | # Click-Once directory 168 | publish/ 169 | 170 | # Publish Web Output 171 | *.[Pp]ublish.xml 172 | *.azurePubxml 173 | # Note: Comment the next line if you want to checkin your web deploy settings, 174 | # but database connection strings (with potential passwords) will be unencrypted 175 | *.pubxml 176 | *.publishproj 177 | 178 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 179 | # checkin your Azure Web App publish settings, but sensitive information contained 180 | # in these scripts will be unencrypted 181 | PublishScripts/ 182 | 183 | # NuGet Packages 184 | *.nupkg 185 | # The packages folder can be ignored because of Package Restore 186 | **/[Pp]ackages/* 187 | # except build/, which is used as an MSBuild target. 188 | !**/[Pp]ackages/build/ 189 | # Uncomment if necessary however generally it will be regenerated when needed 190 | #!**/[Pp]ackages/repositories.config 191 | # NuGet v3's project.json files produces more ignorable files 192 | *.nuget.props 193 | *.nuget.targets 194 | 195 | # Microsoft Azure Build Output 196 | csx/ 197 | *.build.csdef 198 | 199 | # Microsoft Azure Emulator 200 | ecf/ 201 | rcf/ 202 | 203 | # Windows Store app package directories and files 204 | AppPackages/ 205 | BundleArtifacts/ 206 | Package.StoreAssociation.xml 207 | _pkginfo.txt 208 | *.appx 209 | 210 | # Visual Studio cache files 211 | # files ending in .cache can be ignored 212 | *.[Cc]ache 213 | # but keep track of directories ending in .cache 214 | !?*.[Cc]ache/ 215 | 216 | # Others 217 | ClientBin/ 218 | ~$* 219 | *~ 220 | *.dbmdl 221 | *.dbproj.schemaview 222 | *.jfm 223 | *.pfx 224 | *.publishsettings 225 | orleans.codegen.cs 226 | 227 | # Including strong name files can present a security risk 228 | # (https://github.com/github/gitignore/pull/2483#issue-259490424) 229 | #*.snk 230 | 231 | # Since there are multiple workflows, uncomment next line to ignore bower_components 232 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 233 | #bower_components/ 234 | 235 | # RIA/Silverlight projects 236 | Generated_Code/ 237 | 238 | # Backup & report files from converting an old project file 239 | # to a newer Visual Studio version. Backup files are not needed, 240 | # because we have git ;-) 241 | _UpgradeReport_Files/ 242 | Backup*/ 243 | UpgradeLog*.XML 244 | UpgradeLog*.htm 245 | ServiceFabricBackup/ 246 | *.rptproj.bak 247 | 248 | # SQL Server files 249 | *.mdf 250 | *.ldf 251 | *.ndf 252 | 253 | # Business Intelligence projects 254 | *.rdl.data 255 | *.bim.layout 256 | *.bim_*.settings 257 | *.rptproj.rsuser 258 | *- Backup*.rdl 259 | 260 | # Microsoft Fakes 261 | FakesAssemblies/ 262 | 263 | # GhostDoc plugin setting file 264 | *.GhostDoc.xml 265 | 266 | # Node.js Tools for Visual Studio 267 | .ntvs_analysis.dat 268 | node_modules/ 269 | 270 | # Visual Studio 6 build log 271 | *.plg 272 | 273 | # Visual Studio 6 workspace options file 274 | *.opt 275 | 276 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.) 277 | *.vbw 278 | 279 | # Visual Studio LightSwitch build output 280 | **/*.HTMLClient/GeneratedArtifacts 281 | **/*.DesktopClient/GeneratedArtifacts 282 | **/*.DesktopClient/ModelManifest.xml 283 | **/*.Server/GeneratedArtifacts 284 | **/*.Server/ModelManifest.xml 285 | _Pvt_Extensions 286 | 287 | # Paket dependency manager 288 | .paket/paket.exe 289 | paket-files/ 290 | 291 | # FAKE - F# Make 292 | .fake/ 293 | 294 | # JetBrains Rider 295 | .idea/ 296 | *.sln.iml 297 | 298 | # CodeRush personal settings 299 | .cr/personal 300 | 301 | # Python Tools for Visual Studio (PTVS) 302 | __pycache__/ 303 | *.pyc 304 | 305 | # Cake - Uncomment if you are using it 306 | # tools/** 307 | # !tools/packages.config 308 | 309 | # Tabs Studio 310 | *.tss 311 | 312 | # Telerik's JustMock configuration file 313 | *.jmconfig 314 | 315 | # BizTalk build output 316 | *.btp.cs 317 | *.btm.cs 318 | *.odx.cs 319 | *.xsd.cs 320 | 321 | # OpenCover UI analysis results 322 | OpenCover/ 323 | 324 | # Azure Stream Analytics local run output 325 | ASALocalRun/ 326 | 327 | # MSBuild Binary and Structured Log 328 | *.binlog 329 | 330 | # NVidia Nsight GPU debugger configuration file 331 | *.nvuser 332 | 333 | # MFractors (Xamarin productivity tool) working folder 334 | .mfractor/ 335 | 336 | # Local History for Visual Studio 337 | .localhistory/ 338 | 339 | # BeatPulse healthcheck temp database 340 | healthchecksdb 341 | 342 | _* 343 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "Debuggee/Periscope.Debuggee"] 2 | path = Debuggee/Periscope.Debuggee 3 | url = https://github.com/zspitz/Periscope.Debuggee.git 4 | [submodule "Visualizer/Periscope"] 5 | path = Visualizer/Periscope 6 | url = https://github.com/zspitz/Periscope.git 7 | -------------------------------------------------------------------------------- /.markdownlint.json: -------------------------------------------------------------------------------- 1 | { 2 | "MD041": false, 3 | "MD013": false, 4 | "MD038": false 5 | } -------------------------------------------------------------------------------- /ANTLR4ParseTreeVisualizer.Dev.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.31424.327 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{A346B5ED-12A8-4540-BBFD-5978AE196620}" 7 | ProjectSection(SolutionItems) = preProject 8 | .editorconfig = .editorconfig 9 | appveyor.yml = appveyor.yml 10 | EndProjectSection 11 | EndProject 12 | Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "Serialization", "Serialization\Serialization.shproj", "{E3B0367B-3649-4B77-878A-85A8A11C4C09}" 13 | EndProject 14 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Legacy", "Legacy", "{5F2046EA-A159-4673-B7B9-F1F3179C5D6C}" 15 | EndProject 16 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Standard", "Standard", "{C0ADF39C-DD3F-4EBD-AC9C-7D1E5D5CD0A8}" 17 | EndProject 18 | Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "Debuggee", "Debuggee\Debuggee.shproj", "{127B215F-F3F8-44DF-A2D1-9AAF95B3F8F3}" 19 | EndProject 20 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Legacy.Debuggee", "Legacy\Debuggee\Legacy.Debuggee.csproj", "{305BA350-A048-4BBE-8B0B-F41BD4A5E2E5}" 21 | EndProject 22 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Standard.Debuggee", "Standard\Debuggee\Standard.Debuggee.csproj", "{AE5A655C-C17C-4FBB-BE45-13E49A5C7BC8}" 23 | EndProject 24 | Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "UI", "UI\UI.shproj", "{E2B06997-76F1-48DE-ABE6-CF90427423BB}" 25 | EndProject 26 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Legacy.Debugger", "Legacy\Debugger\Legacy.Debugger.csproj", "{1E333B8D-7EE1-479B-AAE0-20A6744A03C4}" 27 | EndProject 28 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Standard.Debugger", "Standard\Debugger\Standard.Debugger.csproj", "{74F8A769-77D2-4889-BB81-2FF397C220B9}" 29 | EndProject 30 | Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "Visualizer", "Visualizer\Visualizer.shproj", "{3C553FFD-FA4E-4EAB-AD03-9534C7CB8F3E}" 31 | EndProject 32 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "_visualizerTest", "_visualizerTest\_visualizerTest.csproj", "{34D2CC07-B4FA-4CAE-8A90-2B3081B5B9A3}" 33 | EndProject 34 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PostBuild", "PostBuild\PostBuild.csproj", "{B403610B-1A25-4BB8-8C63-BB6BDC9A6893}" 35 | EndProject 36 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Legacy.Package", "Legacy\Package\Legacy.Package.csproj", "{F09CFEBD-151C-487C-BC87-1EA68B5A4043}" 37 | EndProject 38 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Standard.Package", "Standard\Package\Standard.Package.csproj", "{D7950FB3-F80E-4249-99D1-F08E3A64CA0E}" 39 | EndProject 40 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "_visualizerTestNoRef", "_visualizerTestNoRef\_visualizerTestNoRef.csproj", "{CADA5CBA-1FE0-48A2-BF4F-7158C1CFF44F}" 41 | EndProject 42 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "_visualizerTestStandard", "_visualizerTestStandard\_visualizerTestStandard.csproj", "{1363D6B6-6D48-4A62-A533-3432F74A04F9}" 43 | EndProject 44 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "_visualizerTestStandardNoRef", "_visualizerTestStandardNoRef\_visualizerTestStandardNoRef.csproj", "{05FA4741-B091-4075-8355-53C2BC48AACD}" 45 | EndProject 46 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Test", "Test", "{74A0EB35-5FC5-40D6-BD6A-199A070ED68D}" 47 | EndProject 48 | Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "Test.Shared", "Test\Test.Shared\Test.Shared.shproj", "{ED8BAF15-5B0B-4027-9B23-DD14B24739DB}" 49 | EndProject 50 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Test.Legacy", "Test\Test.Legacy\Test.Legacy.csproj", "{01945C0C-2E1A-4FB7-A26B-544FACEA3DA5}" 51 | EndProject 52 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Test.Standard", "Test\Test.Standard\Test.Standard.csproj", "{0268B6F3-FD77-452C-AFB4-75FA81BF5947}" 53 | EndProject 54 | Global 55 | GlobalSection(SharedMSBuildProjectFiles) = preSolution 56 | Test\Test.Shared\Test.Shared.projitems*{01945c0c-2e1a-4fb7-a26b-544facea3da5}*SharedItemsImports = 5 57 | Test\Test.Shared\Test.Shared.projitems*{0268b6f3-fd77-452c-afb4-75fa81bf5947}*SharedItemsImports = 5 58 | Debuggee\Debuggee.projitems*{127b215f-f3f8-44df-a2d1-9aaf95b3f8f3}*SharedItemsImports = 13 59 | Visualizer\Visualizer.projitems*{3c553ffd-fa4e-4eab-ad03-9534c7cb8f3e}*SharedItemsImports = 13 60 | Debuggee\Debuggee.projitems*{ae5a655c-c17c-4fbb-be45-13e49a5c7bc8}*SharedItemsImports = 5 61 | Serialization\Serialization.projitems*{ae5a655c-c17c-4fbb-be45-13e49a5c7bc8}*SharedItemsImports = 5 62 | UI\UI.projitems*{e2b06997-76f1-48de-abe6-cf90427423bb}*SharedItemsImports = 13 63 | Serialization\Serialization.projitems*{e3b0367b-3649-4b77-878a-85a8a11c4c09}*SharedItemsImports = 13 64 | Test\Test.Shared\Test.Shared.projitems*{ed8baf15-5b0b-4027-9b23-dd14b24739db}*SharedItemsImports = 13 65 | EndGlobalSection 66 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 67 | Debug|Any CPU = Debug|Any CPU 68 | Release|Any CPU = Release|Any CPU 69 | EndGlobalSection 70 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 71 | {305BA350-A048-4BBE-8B0B-F41BD4A5E2E5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 72 | {305BA350-A048-4BBE-8B0B-F41BD4A5E2E5}.Debug|Any CPU.Build.0 = Debug|Any CPU 73 | {305BA350-A048-4BBE-8B0B-F41BD4A5E2E5}.Release|Any CPU.ActiveCfg = Release|Any CPU 74 | {305BA350-A048-4BBE-8B0B-F41BD4A5E2E5}.Release|Any CPU.Build.0 = Release|Any CPU 75 | {AE5A655C-C17C-4FBB-BE45-13E49A5C7BC8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 76 | {AE5A655C-C17C-4FBB-BE45-13E49A5C7BC8}.Debug|Any CPU.Build.0 = Debug|Any CPU 77 | {AE5A655C-C17C-4FBB-BE45-13E49A5C7BC8}.Release|Any CPU.ActiveCfg = Release|Any CPU 78 | {AE5A655C-C17C-4FBB-BE45-13E49A5C7BC8}.Release|Any CPU.Build.0 = Release|Any CPU 79 | {1E333B8D-7EE1-479B-AAE0-20A6744A03C4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 80 | {1E333B8D-7EE1-479B-AAE0-20A6744A03C4}.Debug|Any CPU.Build.0 = Debug|Any CPU 81 | {1E333B8D-7EE1-479B-AAE0-20A6744A03C4}.Release|Any CPU.ActiveCfg = Release|Any CPU 82 | {1E333B8D-7EE1-479B-AAE0-20A6744A03C4}.Release|Any CPU.Build.0 = Release|Any CPU 83 | {74F8A769-77D2-4889-BB81-2FF397C220B9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 84 | {74F8A769-77D2-4889-BB81-2FF397C220B9}.Debug|Any CPU.Build.0 = Debug|Any CPU 85 | {74F8A769-77D2-4889-BB81-2FF397C220B9}.Release|Any CPU.ActiveCfg = Release|Any CPU 86 | {74F8A769-77D2-4889-BB81-2FF397C220B9}.Release|Any CPU.Build.0 = Release|Any CPU 87 | {34D2CC07-B4FA-4CAE-8A90-2B3081B5B9A3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 88 | {34D2CC07-B4FA-4CAE-8A90-2B3081B5B9A3}.Debug|Any CPU.Build.0 = Debug|Any CPU 89 | {34D2CC07-B4FA-4CAE-8A90-2B3081B5B9A3}.Release|Any CPU.ActiveCfg = Release|Any CPU 90 | {34D2CC07-B4FA-4CAE-8A90-2B3081B5B9A3}.Release|Any CPU.Build.0 = Release|Any CPU 91 | {B403610B-1A25-4BB8-8C63-BB6BDC9A6893}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 92 | {B403610B-1A25-4BB8-8C63-BB6BDC9A6893}.Debug|Any CPU.Build.0 = Debug|Any CPU 93 | {B403610B-1A25-4BB8-8C63-BB6BDC9A6893}.Release|Any CPU.ActiveCfg = Release|Any CPU 94 | {B403610B-1A25-4BB8-8C63-BB6BDC9A6893}.Release|Any CPU.Build.0 = Release|Any CPU 95 | {F09CFEBD-151C-487C-BC87-1EA68B5A4043}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 96 | {F09CFEBD-151C-487C-BC87-1EA68B5A4043}.Debug|Any CPU.Build.0 = Debug|Any CPU 97 | {F09CFEBD-151C-487C-BC87-1EA68B5A4043}.Release|Any CPU.ActiveCfg = Release|Any CPU 98 | {F09CFEBD-151C-487C-BC87-1EA68B5A4043}.Release|Any CPU.Build.0 = Release|Any CPU 99 | {D7950FB3-F80E-4249-99D1-F08E3A64CA0E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 100 | {D7950FB3-F80E-4249-99D1-F08E3A64CA0E}.Debug|Any CPU.Build.0 = Debug|Any CPU 101 | {D7950FB3-F80E-4249-99D1-F08E3A64CA0E}.Release|Any CPU.ActiveCfg = Release|Any CPU 102 | {D7950FB3-F80E-4249-99D1-F08E3A64CA0E}.Release|Any CPU.Build.0 = Release|Any CPU 103 | {CADA5CBA-1FE0-48A2-BF4F-7158C1CFF44F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 104 | {CADA5CBA-1FE0-48A2-BF4F-7158C1CFF44F}.Debug|Any CPU.Build.0 = Debug|Any CPU 105 | {CADA5CBA-1FE0-48A2-BF4F-7158C1CFF44F}.Release|Any CPU.ActiveCfg = Release|Any CPU 106 | {CADA5CBA-1FE0-48A2-BF4F-7158C1CFF44F}.Release|Any CPU.Build.0 = Release|Any CPU 107 | {1363D6B6-6D48-4A62-A533-3432F74A04F9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 108 | {1363D6B6-6D48-4A62-A533-3432F74A04F9}.Debug|Any CPU.Build.0 = Debug|Any CPU 109 | {1363D6B6-6D48-4A62-A533-3432F74A04F9}.Release|Any CPU.ActiveCfg = Release|Any CPU 110 | {1363D6B6-6D48-4A62-A533-3432F74A04F9}.Release|Any CPU.Build.0 = Release|Any CPU 111 | {05FA4741-B091-4075-8355-53C2BC48AACD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 112 | {05FA4741-B091-4075-8355-53C2BC48AACD}.Debug|Any CPU.Build.0 = Debug|Any CPU 113 | {05FA4741-B091-4075-8355-53C2BC48AACD}.Release|Any CPU.ActiveCfg = Release|Any CPU 114 | {05FA4741-B091-4075-8355-53C2BC48AACD}.Release|Any CPU.Build.0 = Release|Any CPU 115 | {01945C0C-2E1A-4FB7-A26B-544FACEA3DA5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 116 | {01945C0C-2E1A-4FB7-A26B-544FACEA3DA5}.Debug|Any CPU.Build.0 = Debug|Any CPU 117 | {01945C0C-2E1A-4FB7-A26B-544FACEA3DA5}.Release|Any CPU.ActiveCfg = Release|Any CPU 118 | {01945C0C-2E1A-4FB7-A26B-544FACEA3DA5}.Release|Any CPU.Build.0 = Release|Any CPU 119 | {0268B6F3-FD77-452C-AFB4-75FA81BF5947}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 120 | {0268B6F3-FD77-452C-AFB4-75FA81BF5947}.Debug|Any CPU.Build.0 = Debug|Any CPU 121 | {0268B6F3-FD77-452C-AFB4-75FA81BF5947}.Release|Any CPU.ActiveCfg = Release|Any CPU 122 | {0268B6F3-FD77-452C-AFB4-75FA81BF5947}.Release|Any CPU.Build.0 = Release|Any CPU 123 | EndGlobalSection 124 | GlobalSection(SolutionProperties) = preSolution 125 | HideSolutionNode = FALSE 126 | EndGlobalSection 127 | GlobalSection(NestedProjects) = preSolution 128 | {305BA350-A048-4BBE-8B0B-F41BD4A5E2E5} = {5F2046EA-A159-4673-B7B9-F1F3179C5D6C} 129 | {AE5A655C-C17C-4FBB-BE45-13E49A5C7BC8} = {C0ADF39C-DD3F-4EBD-AC9C-7D1E5D5CD0A8} 130 | {1E333B8D-7EE1-479B-AAE0-20A6744A03C4} = {5F2046EA-A159-4673-B7B9-F1F3179C5D6C} 131 | {74F8A769-77D2-4889-BB81-2FF397C220B9} = {C0ADF39C-DD3F-4EBD-AC9C-7D1E5D5CD0A8} 132 | {F09CFEBD-151C-487C-BC87-1EA68B5A4043} = {5F2046EA-A159-4673-B7B9-F1F3179C5D6C} 133 | {D7950FB3-F80E-4249-99D1-F08E3A64CA0E} = {C0ADF39C-DD3F-4EBD-AC9C-7D1E5D5CD0A8} 134 | {ED8BAF15-5B0B-4027-9B23-DD14B24739DB} = {74A0EB35-5FC5-40D6-BD6A-199A070ED68D} 135 | {01945C0C-2E1A-4FB7-A26B-544FACEA3DA5} = {74A0EB35-5FC5-40D6-BD6A-199A070ED68D} 136 | {0268B6F3-FD77-452C-AFB4-75FA81BF5947} = {74A0EB35-5FC5-40D6-BD6A-199A070ED68D} 137 | EndGlobalSection 138 | GlobalSection(ExtensibilityGlobals) = postSolution 139 | SolutionGuid = {A2A19EFC-E356-4E97-8752-D94ABBE584B0} 140 | EndGlobalSection 141 | EndGlobal 142 | -------------------------------------------------------------------------------- /ANTLR4ParseTreeVisualizer.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.31424.327 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{A346B5ED-12A8-4540-BBFD-5978AE196620}" 7 | ProjectSection(SolutionItems) = preProject 8 | .editorconfig = .editorconfig 9 | appveyor.yml = appveyor.yml 10 | EndProjectSection 11 | EndProject 12 | Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "Serialization", "Serialization\Serialization.shproj", "{E3B0367B-3649-4B77-878A-85A8A11C4C09}" 13 | EndProject 14 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Legacy", "Legacy", "{5F2046EA-A159-4673-B7B9-F1F3179C5D6C}" 15 | EndProject 16 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Standard", "Standard", "{C0ADF39C-DD3F-4EBD-AC9C-7D1E5D5CD0A8}" 17 | EndProject 18 | Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "Debuggee", "Debuggee\Debuggee.shproj", "{127B215F-F3F8-44DF-A2D1-9AAF95B3F8F3}" 19 | EndProject 20 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Legacy.Debuggee", "Legacy\Debuggee\Legacy.Debuggee.csproj", "{305BA350-A048-4BBE-8B0B-F41BD4A5E2E5}" 21 | EndProject 22 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Standard.Debuggee", "Standard\Debuggee\Standard.Debuggee.csproj", "{AE5A655C-C17C-4FBB-BE45-13E49A5C7BC8}" 23 | EndProject 24 | Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "UI", "UI\UI.shproj", "{E2B06997-76F1-48DE-ABE6-CF90427423BB}" 25 | EndProject 26 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Legacy.Debugger", "Legacy\Debugger\Legacy.Debugger.csproj", "{1E333B8D-7EE1-479B-AAE0-20A6744A03C4}" 27 | EndProject 28 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Standard.Debugger", "Standard\Debugger\Standard.Debugger.csproj", "{74F8A769-77D2-4889-BB81-2FF397C220B9}" 29 | EndProject 30 | Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "Visualizer", "Visualizer\Visualizer.shproj", "{3C553FFD-FA4E-4EAB-AD03-9534C7CB8F3E}" 31 | EndProject 32 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Legacy.Package", "Legacy\Package\Legacy.Package.csproj", "{F09CFEBD-151C-487C-BC87-1EA68B5A4043}" 33 | EndProject 34 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Standard.Package", "Standard\Package\Standard.Package.csproj", "{D7950FB3-F80E-4249-99D1-F08E3A64CA0E}" 35 | EndProject 36 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Test", "Test", "{740AF50E-F735-4E54-8091-7DF29ABBD05A}" 37 | EndProject 38 | Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "Test.Shared", "Test\Test.Shared\Test.Shared.shproj", "{ED8BAF15-5B0B-4027-9B23-DD14B24739DB}" 39 | EndProject 40 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Test.Legacy", "Test\Test.Legacy\Test.Legacy.csproj", "{22587B08-85CE-4383-B754-86808D0713E4}" 41 | EndProject 42 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Test.Standard", "Test\Test.Standard\Test.Standard.csproj", "{40F8B1E1-E78C-4231-8ACE-3EE5A9486609}" 43 | EndProject 44 | Global 45 | GlobalSection(SharedMSBuildProjectFiles) = preSolution 46 | Debuggee\Debuggee.projitems*{127b215f-f3f8-44df-a2d1-9aaf95b3f8f3}*SharedItemsImports = 13 47 | Test\Test.Shared\Test.Shared.projitems*{22587b08-85ce-4383-b754-86808d0713e4}*SharedItemsImports = 5 48 | Visualizer\Visualizer.projitems*{3c553ffd-fa4e-4eab-ad03-9534c7cb8f3e}*SharedItemsImports = 13 49 | Test\Test.Shared\Test.Shared.projitems*{40f8b1e1-e78c-4231-8ace-3ee5a9486609}*SharedItemsImports = 5 50 | Debuggee\Debuggee.projitems*{ae5a655c-c17c-4fbb-be45-13e49a5c7bc8}*SharedItemsImports = 5 51 | Serialization\Serialization.projitems*{ae5a655c-c17c-4fbb-be45-13e49a5c7bc8}*SharedItemsImports = 5 52 | UI\UI.projitems*{e2b06997-76f1-48de-abe6-cf90427423bb}*SharedItemsImports = 13 53 | Serialization\Serialization.projitems*{e3b0367b-3649-4b77-878a-85a8a11c4c09}*SharedItemsImports = 13 54 | Test\Test.Shared\Test.Shared.projitems*{ed8baf15-5b0b-4027-9b23-dd14b24739db}*SharedItemsImports = 13 55 | EndGlobalSection 56 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 57 | Debug|Any CPU = Debug|Any CPU 58 | Release|Any CPU = Release|Any CPU 59 | EndGlobalSection 60 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 61 | {305BA350-A048-4BBE-8B0B-F41BD4A5E2E5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 62 | {305BA350-A048-4BBE-8B0B-F41BD4A5E2E5}.Debug|Any CPU.Build.0 = Debug|Any CPU 63 | {305BA350-A048-4BBE-8B0B-F41BD4A5E2E5}.Release|Any CPU.ActiveCfg = Release|Any CPU 64 | {305BA350-A048-4BBE-8B0B-F41BD4A5E2E5}.Release|Any CPU.Build.0 = Release|Any CPU 65 | {AE5A655C-C17C-4FBB-BE45-13E49A5C7BC8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 66 | {AE5A655C-C17C-4FBB-BE45-13E49A5C7BC8}.Debug|Any CPU.Build.0 = Debug|Any CPU 67 | {AE5A655C-C17C-4FBB-BE45-13E49A5C7BC8}.Release|Any CPU.ActiveCfg = Release|Any CPU 68 | {AE5A655C-C17C-4FBB-BE45-13E49A5C7BC8}.Release|Any CPU.Build.0 = Release|Any CPU 69 | {1E333B8D-7EE1-479B-AAE0-20A6744A03C4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 70 | {1E333B8D-7EE1-479B-AAE0-20A6744A03C4}.Debug|Any CPU.Build.0 = Debug|Any CPU 71 | {1E333B8D-7EE1-479B-AAE0-20A6744A03C4}.Release|Any CPU.ActiveCfg = Release|Any CPU 72 | {1E333B8D-7EE1-479B-AAE0-20A6744A03C4}.Release|Any CPU.Build.0 = Release|Any CPU 73 | {74F8A769-77D2-4889-BB81-2FF397C220B9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 74 | {74F8A769-77D2-4889-BB81-2FF397C220B9}.Debug|Any CPU.Build.0 = Debug|Any CPU 75 | {74F8A769-77D2-4889-BB81-2FF397C220B9}.Release|Any CPU.ActiveCfg = Release|Any CPU 76 | {74F8A769-77D2-4889-BB81-2FF397C220B9}.Release|Any CPU.Build.0 = Release|Any CPU 77 | {F09CFEBD-151C-487C-BC87-1EA68B5A4043}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 78 | {F09CFEBD-151C-487C-BC87-1EA68B5A4043}.Debug|Any CPU.Build.0 = Debug|Any CPU 79 | {F09CFEBD-151C-487C-BC87-1EA68B5A4043}.Release|Any CPU.ActiveCfg = Release|Any CPU 80 | {F09CFEBD-151C-487C-BC87-1EA68B5A4043}.Release|Any CPU.Build.0 = Release|Any CPU 81 | {D7950FB3-F80E-4249-99D1-F08E3A64CA0E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 82 | {D7950FB3-F80E-4249-99D1-F08E3A64CA0E}.Debug|Any CPU.Build.0 = Debug|Any CPU 83 | {D7950FB3-F80E-4249-99D1-F08E3A64CA0E}.Release|Any CPU.ActiveCfg = Release|Any CPU 84 | {D7950FB3-F80E-4249-99D1-F08E3A64CA0E}.Release|Any CPU.Build.0 = Release|Any CPU 85 | {22587B08-85CE-4383-B754-86808D0713E4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 86 | {22587B08-85CE-4383-B754-86808D0713E4}.Debug|Any CPU.Build.0 = Debug|Any CPU 87 | {22587B08-85CE-4383-B754-86808D0713E4}.Release|Any CPU.ActiveCfg = Release|Any CPU 88 | {22587B08-85CE-4383-B754-86808D0713E4}.Release|Any CPU.Build.0 = Release|Any CPU 89 | {40F8B1E1-E78C-4231-8ACE-3EE5A9486609}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 90 | {40F8B1E1-E78C-4231-8ACE-3EE5A9486609}.Debug|Any CPU.Build.0 = Debug|Any CPU 91 | {40F8B1E1-E78C-4231-8ACE-3EE5A9486609}.Release|Any CPU.ActiveCfg = Release|Any CPU 92 | {40F8B1E1-E78C-4231-8ACE-3EE5A9486609}.Release|Any CPU.Build.0 = Release|Any CPU 93 | EndGlobalSection 94 | GlobalSection(SolutionProperties) = preSolution 95 | HideSolutionNode = FALSE 96 | EndGlobalSection 97 | GlobalSection(NestedProjects) = preSolution 98 | {305BA350-A048-4BBE-8B0B-F41BD4A5E2E5} = {5F2046EA-A159-4673-B7B9-F1F3179C5D6C} 99 | {AE5A655C-C17C-4FBB-BE45-13E49A5C7BC8} = {C0ADF39C-DD3F-4EBD-AC9C-7D1E5D5CD0A8} 100 | {1E333B8D-7EE1-479B-AAE0-20A6744A03C4} = {5F2046EA-A159-4673-B7B9-F1F3179C5D6C} 101 | {74F8A769-77D2-4889-BB81-2FF397C220B9} = {C0ADF39C-DD3F-4EBD-AC9C-7D1E5D5CD0A8} 102 | {F09CFEBD-151C-487C-BC87-1EA68B5A4043} = {5F2046EA-A159-4673-B7B9-F1F3179C5D6C} 103 | {D7950FB3-F80E-4249-99D1-F08E3A64CA0E} = {C0ADF39C-DD3F-4EBD-AC9C-7D1E5D5CD0A8} 104 | {ED8BAF15-5B0B-4027-9B23-DD14B24739DB} = {740AF50E-F735-4E54-8091-7DF29ABBD05A} 105 | {22587B08-85CE-4383-B754-86808D0713E4} = {740AF50E-F735-4E54-8091-7DF29ABBD05A} 106 | {40F8B1E1-E78C-4231-8ACE-3EE5A9486609} = {740AF50E-F735-4E54-8091-7DF29ABBD05A} 107 | EndGlobalSection 108 | GlobalSection(ExtensibilityGlobals) = postSolution 109 | SolutionGuid = {A2A19EFC-E356-4E97-8752-D94ABBE584B0} 110 | EndGlobalSection 111 | EndGlobal 112 | -------------------------------------------------------------------------------- /Debuggee/Debuggee.projitems: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | $(MSBuildAllProjects);$(MSBuildThisFileFullPath) 5 | true 6 | 127b215f-f3f8-44df-a2d1-9aaf95b3f8f3 7 | 8 | 9 | Debuggee 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /Debuggee/Debuggee.shproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 127b215f-f3f8-44df-a2d1-9aaf95b3f8f3 5 | 14.0 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /Debuggee/VisualizerDataObjectSource.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using ParseTreeVisualizer.Serialization; 3 | using Periscope.Debuggee; 4 | 5 | namespace ParseTreeVisualizer { 6 | public class VisualizerDataObjectSource : VisualizerObjectSourceBase { 7 | static VisualizerDataObjectSource() => SubfolderAssemblyResolver.Hook( 8 | #if ANTLR_LEGACY 9 | "ParseTreeVisualizer.Legacy" 10 | #else 11 | "ParseTreeVisualizer.Standard" 12 | #endif 13 | ); 14 | public override object GetResponse(object target, Config config) => new VisualizerData(target, config); 15 | public override string GetConfigKey(object target) => 16 | target is string ? 17 | "" : 18 | target.GetType().Assembly.GetName().Name; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Directory.Build.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | true 4 | enable 5 | 9.0 6 | 7 | 8 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 Zev Spitz 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Legacy/Debuggee/Legacy.Debuggee.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | net452 5 | ParseTreeVisualizer.Debuggee 6 | ParseTreeVisualizer.Legacy.Debuggee 7 | 9.0 8 | enable 9 | true 10 | VISUALIZER_DEBUGGEE;ANTLR_LEGACY 11 | 12 | false 13 | false 14 | bin/$(Configuration)/net2.0/ 15 | 16 | 17 | 18 | 19 | 20 | 21 | ..\..\..\..\..\..\..\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\PublicAssemblies\Microsoft.VisualStudio.DebuggerVisualizers.dll 22 | false 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /Legacy/Debugger/Legacy.Debugger.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | net472 5 | ParseTreeVisualizer 6 | ParseTreeVisualizer.Legacy.Debugger 7 | 9.0 8 | enable 9 | true 10 | VISUALIZER_DEBUGGEE;ANTLR_LEGACY 11 | true 12 | 0.0.0 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | ..\..\..\..\..\..\..\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\PublicAssemblies\Microsoft.VisualStudio.DebuggerVisualizers.dll 21 | false 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /Legacy/Package/Legacy.Package.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | net472 5 | ParseTreeVisualizer 6 | ParseTreeVisualizer.UI.Legacy 7 | 9.0 8 | enable 9 | true 10 | ANTLR_LEGACY 11 | true 12 | 13 | 1.0.0 14 | ANTLR4 ParseTree Visualizer UI (Legacy) 15 | Zev Spitz 16 | UI components for visualizing ANTLR tokens and parse trees 17 | Copyright (c) 2021 Zev Spitz 18 | MIT 19 | https://github.com/zspitz/ANTLR4ParseTreeVisualizer 20 | https://github.com/zspitz/ANTLR4ParseTreeVisualizer 21 | git 22 | .net csharp antlr4 23 | Initial release 24 | true 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /PostBuild/PostBuild.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | netstandard2.0 5 | OnBuildSuccess 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ANTLR4 Parse Tree Visualizer 2 | 3 | [![GitHub Release](https://img.shields.io/github/release/zspitz/antlr4parsetreevisualizer?style=flat&max-age=86400)](https://github.com/zspitz/ANTLR4ParseTreeVisualizer/releases) [![AppVeyor build status](https://img.shields.io/appveyor/ci/zspitz/antlr4parsetreevisualizer?style=flat&max-age=86400)](https://ci.appveyor.com/project/zspitz/antlr4parsetreevisualizer) 4 | 5 | ![Screenshot](screenshot.png) 6 | 7 | ## Features 8 | 9 | * List of tokens (error tokens are highlighted in red) 10 | * Treeview of rule contexts and terminal nodes (error nodes in red) 11 | * Properties of selected treeview node (properties not declared in the Antlr namespace are checked) 12 | * Input text, or the text from the current channel positioned as in the input 13 | * Selection sync, when selecting in the token list, the tree view, or the source text. 14 | 15 | ![Selection sync](selection-sync.gif) 16 | 17 | * Filtering the token list, by text, whitespace, or error; or by specific token types: 18 | 19 | ![Token filtering](token-filtering.gif) 20 | 21 | * Filtering the parse tree nodes by text, whitespace, or error nodes; or by specific rule types. 22 | 23 | ![Parse tree filtering](parse-tree-filtering.gif) 24 | 25 | * Set a specific node as the root node, either in the current window, or in a new window 26 | 27 | ![Set node as root, in current or new window](set-root.gif) 28 | 29 | * You can also [embed the same UI in your own applications](https://github.com/zspitz/ANTLR4ParseTreeVisualizer/wiki/Embedding-UI-controls-in-third-party-apps). 30 | 31 | ## Requirements 32 | 33 | * Tested with Visual Studio 2019 or 2017 (may work with older versions as well) 34 | * Supports the current Antlr.Runtime.Standard.DLL (4.7.2) as well as the older Antlr.Runtime.DLL (4.6.6). 35 | 36 | ## Installation 37 | 38 | Before installing, you need to determine two things: 39 | 40 | 1. There are two .NET variants of the ANTLR4 runtime library: the "standard" version -- [Antlr4.Runtime.Standard](https://www.nuget.org/packages/Antlr4.Runtime.Standard/) -- and the "legacy" [Antlr4.Runtime](https://www.nuget.org/packages/Antlr4.Runtime/) at version 4.6.6. Which variant is your code using? 41 | 2. Are you using Visual Studio 2019 or 2017? 42 | 43 | Then: 44 | 45 | 1. Go to the [releases](https://github.com/zspitz/ANTLR4ParseTreeVisualizer/releases) page. Choose the appropriate ZIP file(s) based on the Antlr4 variant and your version of Visual Studio. 46 | 47 | For example, if you're in Visual Studio 2019 and debugging code written against `Antlr4.Runtime.Standard`, download the `ParseTreeVisualizer.Standard.2019.zip` file. 48 | 49 | Note: if you need to, you can download and install all four visualizer variants; they won't overwrite each other. 50 | 51 | 2. You may need to [unblock the file](https://github.com/zspitz/ExpressionToString/wiki/Troubleshooting-visualizer-installation). 52 | 3. Unzip the contents of the ZIP file into one of Visual Studio's recognized visualizer folders: 53 | 54 | * _VisualStudioInstallPath_`\Common7\Packages\Debugger\Visualizers` 55 | * `My Documents\Visual Studio `_Version_`\Visualizers` 56 | 57 | You don't have to restart VS, just make sure VS is not currently in a debugging session 58 | 59 | You can also compile the source yourself (`ANTLR4ParseTreeVisualizer.sln`) and place the output DLLs in one of the appropriate visualizer folders. 60 | 61 | For VS 2017, the DLLs will end up in either the `Visualizers` parent folder, or a single subfolder. For VS 2019, there are additional subfolders for debugging various target frameworks. 62 | 63 | ## Usage 64 | 65 | 1. Begin a debugging session, and break at some point. 66 | 2. Hover over an instance of one of the visualizer target types (`Antlr4.Runtime.RuleContext`, `Antlr4.Runtime.BufferedTokenStream`, or `string`), in the code editor, or the Watch or Locals window. This instance can be exposed by any variable, or any expression; the type of the expression doesn't matter. 67 | 3. Click on the magnifying glass to the right of the expression. 68 | 4. You may need to choose a lexer class if you are visualizing a `string` and there are multiple lexers in the debugged assemblies. 69 | 5. You may need to choose a parser class and a parser method from the settings, if you are visualizing a `BufferedTokenStream` or a `string`, and the debugged assemblies have multiple parser classes. 70 | 71 | Note that these choices -- selected lexer, parser and parser method -- persist between sessions, so if you've already chosen, there's no need to do so again. 72 | 73 | ![Visualizing a string](visualize-string.gif) 74 | 75 | ## Troubleshooting 76 | 77 | * You may need to [unblock](https://github.com/zspitz/ExpressionTreeVisualizer/wiki/Troubleshooting-visualizer-installation) the ZIP file. 78 | * If you see an error message "Could not load this custom viewer", [try turning Managed Compatibility off](https://github.com/zspitz/ANTLR4ParseTreeVisualizer/issues/50) (**Tools** -> **Options...** -> **General** -> **Debugging**). 79 | 80 | ## Contributing 81 | 82 | * Test the visualizer. (The significance of this kind of contribution cannot be overestimated.) 83 | * Suggest ideas and enhancements ([issues](https://github.com/zspitz/ANTLR4ParseTreeVisualizer/issues/new)) 84 | * Notify about bugs ([issues](https://github.com/zspitz/ANTLR4ParseTreeVisualizer/issues/new)) 85 | * Provide screenshots which could be used to demonstrate different features of the visualizer (also via ([issues](https://github.com/zspitz/ANTLR4ParseTreeVisualizer/issues/new))) 86 | * Star the project 87 | * Spread the word 88 | * Provide feedback to Microsoft about [these limitations to the visualizer API](https://github.com/zspitz/ExpressionToString/wiki/External-issues) 89 | 90 | ## Roadmap 91 | 92 | * [Parsing errors in a separate pane](https://github.com/zspitz/ANTLR4ParseTreeVisualizer/issues/24) 93 | * [Standalone viewer](https://github.com/zspitz/ANTLR4ParseTreeVisualizer/issues/19) 94 | -------------------------------------------------------------------------------- /Serialization/ClassInfo.cs: -------------------------------------------------------------------------------- 1 | using Antlr4.Runtime; 2 | using Antlr4.Runtime.Tree; 3 | using System; 4 | using System.CodeDom.Compiler; 5 | using System.Collections.ObjectModel; 6 | using System.Linq; 7 | using System.Reflection; 8 | using ZSpitz.Util; 9 | 10 | namespace ParseTreeVisualizer.Serialization { 11 | [Serializable] 12 | public class ClassInfo { 13 | public static readonly ClassInfo None = new("(None)"); 14 | 15 | public string Name { get; } 16 | public string? Namespace { get; } 17 | public string? Assembly { get; } 18 | public string? Antlr { get; } // Runtime - in Antlr.Runtime, - version 19 | public string? FullName { get; } 20 | public string? RuleName { get; } 21 | public int? RuleID { get; } 22 | public bool HasRelevantConstructor { get; } = false; 23 | 24 | public ReadOnlyCollection? MethodNames { get; } 25 | 26 | private ClassInfo(string name) => Name = name; 27 | public ClassInfo(Type t, string? ruleName = null, int? ruleID = null, bool loadMethodNames = false) { 28 | if (t is null) { throw new ArgumentNullException(nameof(t)); } 29 | 30 | Name = t.Name; 31 | Namespace = t.Namespace; 32 | Assembly = t.Assembly.Location; 33 | if (t.Assembly == typeof(IParseTree).Assembly) { 34 | Antlr = "Runtime"; 35 | } else if (t.GetCustomAttribute() is GeneratedCodeAttribute attr) { 36 | Antlr = attr.Version; 37 | } 38 | FullName = t.FullName; 39 | RuleName = ruleName.IsNullOrWhitespace() ? null : ruleName; 40 | RuleID = ruleID; 41 | HasRelevantConstructor = 42 | t.InheritsFromOrImplements() ? t.GetConstructor(new[] { typeof(AntlrInputStream) }) is not null : 43 | t.InheritsFromOrImplements() ? t.GetConstructor(new[] { typeof(CommonTokenStream) }) is not null : 44 | false; 45 | 46 | if (loadMethodNames) { 47 | MethodNames = t.GetMethods() 48 | .Where(x => !x.IsSpecialName && x.ReturnType.InheritsFromOrImplements()) 49 | .Select(x => x.Name) 50 | .Where(x => x != "GetInvokingContext") 51 | .Ordered() 52 | .ToList() 53 | .AsReadOnly(); 54 | } 55 | } 56 | 57 | public override string ToString() => FullName ?? Name; 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /Serialization/Config.cs: -------------------------------------------------------------------------------- 1 | #if VISUALIZER_DEBUGGEE 2 | using Periscope.Debuggee; 3 | #endif 4 | using System; 5 | using System.Collections.Generic; 6 | using ZSpitz.Util; 7 | 8 | namespace ParseTreeVisualizer.Serialization { 9 | [Serializable] 10 | #if VISUALIZER_DEBUGGEE 11 | public class Config : ConfigBase { 12 | #else 13 | public class Config { 14 | #endif 15 | 16 | public string? SelectedParserName { get; set; } 17 | public string? ParseTokensWithRule { get; set; } 18 | public string? SelectedLexerName { get; set; } 19 | public bool ShowTextTokens { get; set; } = true; 20 | public bool ShowWhitespaceTokens { get; set; } = true; 21 | public bool ShowErrorTokens { get; set; } = true; 22 | public HashSet SelectedTokenTypes { get; } = new HashSet(); 23 | public bool ShowTreeTextTokens { get; set; } = true; 24 | public bool ShowTreeWhitespaceTokens { get; set; } = true; 25 | public bool ShowTreeErrorTokens { get; set; } = true; 26 | public bool ShowRuleContextNodes { get; set; } = true; 27 | public HashSet SelectedRuleContexts { get; } = new HashSet(); 28 | public string? RootNodePath { get; set; } 29 | 30 | public bool HasTreeFilter() => !(ShowTreeErrorTokens && ShowTreeWhitespaceTokens && ShowTreeTextTokens && ShowRuleContextNodes && SelectedRuleContexts.None()); 31 | public bool HasTokenListFilter() => !(ShowTextTokens && ShowErrorTokens && ShowWhitespaceTokens && SelectedTokenTypes.None()); 32 | 33 | #if VISUALIZER_DEBUGGEE 34 | // TODO should any parts of the config return ConfigDiffStates.NeedsWrite? 35 | public override ConfigDiffStates Diff(Config baseline) => 36 | ( 37 | baseline.SelectedParserName == SelectedParserName && 38 | baseline.SelectedLexerName == SelectedLexerName && 39 | baseline.ShowTextTokens == ShowTextTokens && 40 | baseline.ShowErrorTokens == ShowErrorTokens && 41 | baseline.ShowWhitespaceTokens == ShowWhitespaceTokens && 42 | baseline.ShowTreeTextTokens == ShowTreeTextTokens && 43 | baseline.ShowTreeErrorTokens == ShowTreeErrorTokens && 44 | baseline.ShowTreeWhitespaceTokens == ShowTreeWhitespaceTokens && 45 | baseline.ShowRuleContextNodes == ShowRuleContextNodes && 46 | baseline.ParseTokensWithRule == ParseTokensWithRule && 47 | baseline.SelectedTokenTypes.SetEquals(SelectedTokenTypes) && 48 | baseline.SelectedRuleContexts.SetEquals(SelectedRuleContexts) 49 | ) ? ConfigDiffStates.NoAction : ConfigDiffStates.NeedsTransfer; 50 | 51 | public override Config Clone() { 52 | #else 53 | public Config Clone() { 54 | #endif 55 | var ret = new Config { 56 | SelectedParserName = SelectedParserName, 57 | SelectedLexerName = SelectedLexerName, 58 | ShowTextTokens = ShowTextTokens, 59 | ShowErrorTokens = ShowErrorTokens, 60 | ShowWhitespaceTokens = ShowWhitespaceTokens, 61 | ShowTreeTextTokens = ShowTreeTextTokens, 62 | ShowTreeErrorTokens = ShowTreeErrorTokens, 63 | ShowTreeWhitespaceTokens = ShowTreeWhitespaceTokens, 64 | ShowRuleContextNodes = ShowRuleContextNodes, 65 | ParseTokensWithRule = ParseTokensWithRule 66 | }; 67 | SelectedTokenTypes.AddRangeTo(ret.SelectedTokenTypes); 68 | SelectedRuleContexts.AddRangeTo(ret.SelectedRuleContexts); 69 | return ret; 70 | } 71 | 72 | public void Deconstruct(out string? lexer, out string? parser, out string? ruleContext) { 73 | lexer = SelectedLexerName; 74 | parser = SelectedParserName; 75 | ruleContext = ParseTokensWithRule; 76 | } 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /Serialization/Enums.cs: -------------------------------------------------------------------------------- 1 | namespace ParseTreeVisualizer.Serialization { 2 | public enum TreeNodeType { 3 | RuleContext, 4 | Token, 5 | ErrorToken, 6 | WhitespaceToken, 7 | Placeholder 8 | } 9 | 10 | public enum FilterStates { 11 | NotMatched, 12 | Matched, 13 | DescendantMatched 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Serialization/Extensions.cs: -------------------------------------------------------------------------------- 1 | using Antlr4.Runtime.Tree; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace ParseTreeVisualizer { 7 | public static class Extensions { 8 | public static IEnumerable Children(this IParseTree tree) { 9 | for (var i = 0; i < tree.ChildCount; i++) { 10 | yield return tree.GetChild(i); 11 | } 12 | } 13 | 14 | public static IEnumerable Descendants(this IParseTree tree) { 15 | for (var i = 0; i < tree.ChildCount; i++) { 16 | var child = tree.GetChild(i); 17 | yield return child; 18 | foreach (var descendant in child.Descendants()) { 19 | yield return descendant; 20 | } 21 | } 22 | } 23 | 24 | public static string GetPositionedText(this IParseTree tree, char filler = ' ') { 25 | var sb = new StringBuilder(); 26 | foreach (var descendant in tree.Descendants().OfType()) { 27 | var fillerCharCount = descendant.Payload.StartIndex - sb.Length; 28 | if (fillerCharCount > 0) { 29 | sb.Append(filler, fillerCharCount); 30 | } 31 | sb.Append(descendant.Payload.Text); 32 | } 33 | return sb.ToString(); 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /Serialization/ParseTreeNode.cs: -------------------------------------------------------------------------------- 1 | using Antlr4.Runtime; 2 | using Antlr4.Runtime.Tree; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using ZSpitz.Util; 7 | 8 | namespace ParseTreeVisualizer.Serialization { 9 | [Serializable] 10 | public class ParseTreeNode { 11 | public static ParseTreeNode GetPlaceholder(ParseTreeNode? actualRoot) => 12 | actualRoot is null ? 13 | throw new ArgumentNullException(nameof(actualRoot)) : 14 | new("(parent nodes)", TreeNodeType.Placeholder, new List { actualRoot }, actualRoot.CharSpan); 15 | 16 | public string? Caption { get; } 17 | public List? Properties { get; } 18 | public List Children { get; } 19 | public (int startTokenIndex, int endTokenIndex) TokenSpan { get; } 20 | public (int startChar, int endChar) CharSpan { get; } 21 | public TreeNodeType? NodeType { get; } 22 | public FilterStates? FilterState { get; } 23 | public string? Path { get; } 24 | 25 | private ParseTreeNode(string caption, TreeNodeType nodeType, List children, (int startChar, int endChar) charSpan) { 26 | Caption = caption; 27 | NodeType = nodeType; 28 | Children = children; 29 | CharSpan = charSpan; 30 | } 31 | public ParseTreeNode(IParseTree tree, List tokens, string[] ruleNames, Dictionary tokenTypeMapping, Config config, Dictionary ruleMapping, string? path) { 32 | if (tree is null) { throw new ArgumentNullException(nameof(tree)); } 33 | if (ruleMapping is null) { throw new ArgumentNullException(nameof(ruleMapping)); } 34 | if (tokens is null) { throw new ArgumentNullException(nameof(tokens)); } 35 | if (config is null) { throw new ArgumentNullException(nameof(config)); } 36 | 37 | var type = tree.GetType(); 38 | 39 | if (tree is ParserRuleContext ruleContext) { 40 | NodeType = TreeNodeType.RuleContext; 41 | 42 | var caption = type.Name; 43 | if (!ruleMapping.TryGetValue(type, out var x)) { 44 | var ruleIndex = (int)(type.GetProperty("RuleIndex")?.GetValue(tree) ?? -1); 45 | if (ruleNames.TryGetValue(ruleIndex, out caption)) { 46 | ruleMapping[type] = (caption, ruleIndex); 47 | } else { 48 | caption = type.Name; 49 | ruleMapping[type] = (null, null); 50 | } 51 | } else { 52 | caption = x.caption; 53 | } 54 | 55 | Caption = caption; 56 | CharSpan = (ruleContext.Start.StartIndex, ruleContext.Stop?.StopIndex ?? int.MaxValue); 57 | } else if (tree is TerminalNodeImpl terminalNode) { 58 | var token = new Token(terminalNode, tokenTypeMapping); 59 | 60 | if (token.IsError) { 61 | Caption = token.Text; 62 | NodeType = TreeNodeType.ErrorToken; 63 | } else { 64 | Caption = $"\"{token.Text}\""; 65 | NodeType = token.IsWhitespace ? TreeNodeType.WhitespaceToken : TreeNodeType.Token; 66 | } 67 | CharSpan = token.Span; 68 | 69 | if (token.ShowToken(config)) { 70 | tokens.Add(token); 71 | } 72 | } 73 | 74 | Path = path; 75 | var pathDelimiter = path.IsNullOrWhitespace() ? "" : "."; 76 | Properties = type.GetProperties().OrderBy(x => x.Name).Select(prp => new PropertyValue(tree, prp)).ToList(); 77 | Children = tree.Children() 78 | .Select((x, index) => new ParseTreeNode(x, tokens, ruleNames, tokenTypeMapping, config, ruleMapping, $"{path}{pathDelimiter}{index}")) 79 | .Where(x => x.FilterState != FilterStates.NotMatched) // intentionally doesn't exclude null 80 | .ToList(); 81 | TokenSpan = (tree.SourceInterval.a, tree.SourceInterval.b); 82 | 83 | var matched = true; 84 | if (config.HasTreeFilter()) { 85 | matched = NodeType switch { 86 | TreeNodeType.RuleContext => 87 | config.ShowRuleContextNodes && ( 88 | config.SelectedRuleContexts.None() || 89 | type.FullName.In(config.SelectedRuleContexts) 90 | ), 91 | TreeNodeType.ErrorToken => config.ShowErrorTokens, 92 | TreeNodeType.WhitespaceToken => config.ShowTreeWhitespaceTokens, 93 | _ => config.ShowTreeTextTokens 94 | }; 95 | 96 | FilterState = 97 | matched ? 98 | FilterStates.Matched : 99 | (Children.Any(x => x.FilterState.In(FilterStates.Matched, FilterStates.DescendantMatched)) ? 100 | FilterStates.DescendantMatched : 101 | FilterStates.NotMatched); 102 | } 103 | 104 | var toPromote = Children 105 | .Select((child, index) => (grandchild: child.Children.SingleOrDefaultExt(x => x.FilterState.In(FilterStates.Matched, FilterStates.DescendantMatched)), index)) 106 | .WhereT((grandchild, index) => grandchild != null) 107 | .ToList(); 108 | foreach (var (grandchild, index) in toPromote) { 109 | Children[index] = grandchild; 110 | } 111 | } 112 | 113 | public string Stringify(int indentLevel = 0) { 114 | var ret = new string(' ', indentLevel * 4) + Caption; 115 | foreach (var child in Children) { 116 | ret += "\n" + child.Stringify(indentLevel + 1); 117 | } 118 | return ret; 119 | } 120 | } 121 | } 122 | -------------------------------------------------------------------------------- /Serialization/PropertyValue.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Reflection; 3 | using static ZSpitz.Util.Functions; 4 | 5 | namespace ParseTreeVisualizer.Serialization { 6 | [Serializable] 7 | public class PropertyValue { 8 | public bool Custom { get; } 9 | public string Key { get; } 10 | public string? Value { get; } 11 | public PropertyValue(object instance, PropertyInfo prp) { 12 | if (prp is null) { throw new ArgumentNullException(nameof(prp)); } 13 | 14 | Key = prp.Name; 15 | 16 | // null values map to null strings 17 | // exceptions map to <...> delineated strings 18 | // other values map to result of RenderLiteral 19 | 20 | object? value = null; 21 | try { 22 | value = prp.GetValue(instance); 23 | } catch (Exception e) { 24 | Value = $"<{e.GetType()}: {e.Message}>"; 25 | } 26 | if (value is { }) { Value = StringValue(value, "C#"); } 27 | 28 | Custom = !prp.DeclaringType?.Namespace?.StartsWith("Antlr4", StringComparison.Ordinal) ?? false; 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /Serialization/Serialization.projitems: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | $(MSBuildAllProjects);$(MSBuildThisFileFullPath) 5 | true 6 | e3b0367b-3649-4b77-878a-85a8a11c4c09 7 | 8 | 9 | Serialization 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /Serialization/Serialization.shproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | e3b0367b-3649-4b77-878a-85a8a11c4c09 5 | 14.0 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /Serialization/Token.cs: -------------------------------------------------------------------------------- 1 | using Antlr4.Runtime; 2 | using Antlr4.Runtime.Tree; 3 | using System; 4 | using System.Collections.Generic; 5 | using ZSpitz.Util; 6 | 7 | namespace ParseTreeVisualizer.Serialization { 8 | [Serializable] 9 | public class Token { 10 | public int Index { get; } 11 | public string TokenType { get; } 12 | public int TokenTypeID { get; } 13 | public int Line { get; } 14 | public int Col { get; } 15 | public string Text { get; } 16 | public bool IsError { get; } 17 | public (int start, int stop) Span { get; } 18 | public bool IsWhitespace { get; } 19 | 20 | public Token(IToken itoken, Dictionary? tokenTypeMapping) { 21 | Index = itoken.TokenIndex; 22 | TokenTypeID = itoken.Type; 23 | Line = itoken.Line; 24 | Col = itoken.Column; 25 | Text = itoken.Text.ToVerbatimString("C#")[1..^1]; 26 | Span = (itoken.StartIndex, itoken.StopIndex); 27 | IsWhitespace = itoken.Text.IsNullOrWhitespace(); 28 | 29 | var tokenType = ""; 30 | TokenType = 31 | tokenTypeMapping?.TryGetValue(TokenTypeID, out tokenType) ?? false ? 32 | tokenType : 33 | $"{TokenTypeID}"; 34 | } 35 | 36 | public Token(TerminalNodeImpl terminalNode, Dictionary tokenTypeMapping) : this(terminalNode.Payload, tokenTypeMapping) { 37 | if (terminalNode is ErrorNodeImpl) { 38 | IsError = true; 39 | } 40 | } 41 | 42 | public bool ShowToken(Config config) { 43 | if (!config.HasTokenListFilter()) { return true; } 44 | var showToken = 45 | IsError ? config.ShowErrorTokens : 46 | IsWhitespace ? config.ShowWhitespaceTokens : 47 | config.ShowTextTokens; 48 | showToken &= config.SelectedTokenTypes.None() || TokenTypeID.In(config.SelectedTokenTypes); 49 | 50 | return showToken; 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /Serialization/VisualizerData.cs: -------------------------------------------------------------------------------- 1 | using Antlr4.Runtime; 2 | using Antlr4.Runtime.Tree; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using static System.Linq.Enumerable; 7 | using ZSpitz.Util; 8 | using static ZSpitz.Util.Functions; 9 | 10 | namespace ParseTreeVisualizer.Serialization { 11 | [Serializable] 12 | public class VisualizerData { 13 | public string Source { get; } 14 | public Config Config { get; } 15 | public ParseTreeNode? Root { get; } 16 | public List? Tokens { get; } 17 | public int SourceOffset { get; } 18 | public List AvailableParsers { get; } = new List(); 19 | public List AvailableLexers { get; } = new List(); 20 | public List AssemblyLoadErrors { get; } = new List(); 21 | public Dictionary? TokenTypeMapping { get; private set; } 22 | public List? UsedRuleContexts { get; } 23 | public bool CanSelectLexer { get; } 24 | public bool CanSelectParser { get; } 25 | 26 | public VisualizerData(object o, Config config) { 27 | if (config is null) { throw new ArgumentNullException(nameof(config)); } 28 | 29 | Config = config; 30 | 31 | Type[] types; 32 | T createInstance(string typename, object[]? args = null) => 33 | types.Single(x => x.FullName == typename).CreateInstance(args); 34 | 35 | { 36 | var baseTypes = new[] { typeof(Parser), typeof(Lexer) }; 37 | types = AppDomain.CurrentDomain.GetAssemblies() 38 | .Where(x => x != GetType().Assembly) 39 | .SelectMany(x => { 40 | var ret = Empty(); 41 | try { 42 | ret = x.GetTypes(); 43 | } catch { 44 | AssemblyLoadErrors.Add(x.FullName); 45 | } 46 | return ret; 47 | }) 48 | .Where(x => !x.IsAbstract) 49 | .ToArray(); 50 | foreach (var t in types) { 51 | if (t.InheritsFromOrImplements()) { 52 | AvailableParsers.Add(new ClassInfo(t, null, null, true)); 53 | } else if (t.InheritsFromOrImplements()) { 54 | AvailableLexers.Add(new ClassInfo(t)); 55 | } 56 | } 57 | 58 | Config.SelectedLexerName = checkSelection(AvailableLexers, Config.SelectedLexerName); 59 | Config.SelectedParserName = checkSelection(AvailableParsers, Config.SelectedParserName); 60 | if (!Config.SelectedParserName.IsNullOrWhitespace()) { 61 | var parserInfo = AvailableParsers.SingleOrDefaultExt(x => x.FullName == Config.SelectedParserName); 62 | if (parserInfo is null) { 63 | Config.ParseTokensWithRule = null; 64 | } else if (parserInfo.MethodNames is not null) { 65 | if (Config.ParseTokensWithRule.NotIn(parserInfo.MethodNames)) { 66 | Config.ParseTokensWithRule = null; 67 | } 68 | if (Config.ParseTokensWithRule is null) { 69 | Config.ParseTokensWithRule = parserInfo.MethodNames.SingleOrDefaultExt(); 70 | } 71 | } 72 | } 73 | } 74 | 75 | string? source = null; 76 | BufferedTokenStream? tokenStream = null; 77 | IParseTree? tree = null; 78 | IVocabulary? vocabulary = null; 79 | 80 | // these three are mutually exclusive 81 | switch (o) { 82 | case string source1: 83 | source = source1; 84 | CanSelectLexer = true; 85 | CanSelectParser = true; 86 | Source = source; 87 | break; 88 | case BufferedTokenStream tokenStream1: 89 | tokenStream = tokenStream1; 90 | CanSelectParser = true; 91 | Source = tokenStream.TokenSource.InputStream.ToString(); 92 | break; 93 | case IParseTree tree1: 94 | tree = tree1; 95 | Source = tree.GetPositionedText(); 96 | break; 97 | default: 98 | throw new ArgumentException("Unhandled type"); 99 | } 100 | 101 | if (source != null && !Config.SelectedLexerName.IsNullOrWhitespace()) { 102 | var input = new AntlrInputStream(source); 103 | var lexer = createInstance(Config.SelectedLexerName!, new[] { input }); 104 | tokenStream = new CommonTokenStream(lexer); 105 | vocabulary = lexer.Vocabulary; 106 | } 107 | 108 | if ( 109 | tokenStream != null && 110 | !Config.SelectedParserName.IsNullOrWhitespace() && 111 | !Config.ParseTokensWithRule.IsNullOrWhitespace() 112 | ) { 113 | var parser = createInstance(Config.SelectedParserName, new[] { tokenStream }); 114 | tree = (IParseTree)parser.GetType().GetMethod(Config.ParseTokensWithRule)!.Invoke(parser, EmptyArray())!; 115 | vocabulary = parser.Vocabulary; 116 | } 117 | 118 | if (tree is null && tokenStream is null) { 119 | return; 120 | } 121 | 122 | if (tree is null) { 123 | tokenStream!.Fill(); 124 | Tokens = tokenStream.GetTokens() 125 | .Select(token => new Token(token, getTokenTypeMapping())) 126 | .Where(token => token.ShowToken(config)) 127 | .ToList(); 128 | return; 129 | } 130 | 131 | if (!config.RootNodePath.IsNullOrWhitespace()) { 132 | var pathParts = config.RootNodePath.Split('.').Select(x => 133 | int.TryParse(x, out var ret) ? 134 | ret : 135 | -1 136 | ).ToArray(); 137 | foreach (var pathPart in pathParts) { 138 | var nextTree = tree.GetChild(pathPart); 139 | if (nextTree == null) { 140 | break; 141 | } 142 | tree = tree.GetChild(pathPart); 143 | } 144 | } 145 | 146 | var parserType = tree.GetType().DeclaringType; 147 | Config.SelectedParserName = parserType.FullName; 148 | if (vocabulary is null) { 149 | vocabulary = parserType.GetField("DefaultVocabulary").GetValue(null) as IVocabulary; 150 | } 151 | 152 | var tokenTypeMapping = getTokenTypeMapping()!; 153 | 154 | var ruleNames = (parserType.GetField("ruleNames").GetValue(null) as string[])!; 155 | var rulenameMapping = new Dictionary(); 156 | Tokens = new List(); 157 | var actualRoot = new ParseTreeNode(tree, Tokens, ruleNames, tokenTypeMapping, config, rulenameMapping, Config.RootNodePath); 158 | if (config.RootNodePath.IsNullOrWhitespace()) { 159 | Root = actualRoot; 160 | } else { 161 | Root = ParseTreeNode.GetPlaceholder(actualRoot); 162 | SourceOffset = actualRoot.CharSpan.startChar; 163 | Source = Source[actualRoot.CharSpan.startChar..actualRoot.CharSpan.endChar]; 164 | } 165 | 166 | UsedRuleContexts = rulenameMapping.Keys 167 | .Select(x => { 168 | rulenameMapping.TryGetValue(x, out var y); 169 | return new ClassInfo(x, y.name, y.index); 170 | }) 171 | .OrderBy(x => x.Name) 172 | .ToList(); 173 | 174 | Dictionary? getTokenTypeMapping() { 175 | if (vocabulary is null) { return null; } 176 | #if ANTLR_LEGACY 177 | var maxTokenType = vocabulary.MaxTokenType; 178 | #else 179 | var maxTokenType = (vocabulary as Vocabulary)!.getMaxTokenType(); 180 | #endif 181 | TokenTypeMapping = Range(1, maxTokenType).Select(x => (x, vocabulary.GetSymbolicName(x))).ToDictionary(); 182 | return TokenTypeMapping; 183 | } 184 | } 185 | 186 | private string? checkSelection(List lst, string? selected) { 187 | if (lst.None(x => x.FullName == selected)) { 188 | selected = null; 189 | } 190 | if (selected.IsNullOrWhitespace()) { 191 | selected = ( 192 | lst.SingleOrDefaultExt(x => x.Antlr != "Runtime" && x.HasRelevantConstructor) ?? 193 | lst.SingleOrDefaultExt(x => x.HasRelevantConstructor) 194 | )?.FullName; 195 | } 196 | return selected; 197 | } 198 | } 199 | } 200 | -------------------------------------------------------------------------------- /Standard/Debuggee/Standard.Debuggee.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netstandard2.0 5 | ParseTreeVisualizer.Debuggee 6 | ParseTreeVisualizer.Standard.Debuggee 7 | 9.0 8 | enable 9 | true 10 | VISUALIZER_DEBUGGEE 11 | true 12 | 13 | 14 | 15 | 16 | 17 | 18 | ..\..\..\..\..\..\..\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\PublicAssemblies\Microsoft.VisualStudio.DebuggerVisualizers.dll 19 | false 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /Standard/Debugger/Standard.Debugger.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | net472 5 | ParseTreeVisualizer 6 | ParseTreeVisualizer.Standard.Debugger 7 | 9.0 8 | enable 9 | true 10 | VISUALIZER_DEBUGGEE 11 | true 12 | 0.0.0 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | ..\..\..\..\..\..\..\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\PublicAssemblies\Microsoft.VisualStudio.DebuggerVisualizers.dll 21 | false 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /Standard/Package/Standard.Package.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | net472;netcoreapp3.1 5 | ParseTreeVisualizer 6 | ParseTreeVisualizer.UI.Standard 7 | 9.0 8 | enable 9 | true 10 | true 11 | 12 | 1.0.0 13 | ANTLR4 ParseTree Visualizer UI (Standard) 14 | Zev Spitz 15 | UI components for visualizing ANTLR tokens and parse trees 16 | Copyright (c) 2021 Zev Spitz 17 | MIT 18 | https://github.com/zspitz/ANTLR4ParseTreeVisualizer 19 | https://github.com/zspitz/ANTLR4ParseTreeVisualizer 20 | git 21 | .net csharp antlr4 22 | Initial release 23 | true 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /Test/Test.Legacy/Test.Legacy.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | net5.0-windows 5 | ParseTreeVisualizer.Test 6 | false 7 | true 8 | 9 | 10 | 11 | 12 | all 13 | runtime; build; native; contentfiles; analyzers; buildtransitive 14 | 15 | 16 | 17 | 18 | 19 | runtime; build; native; contentfiles; analyzers; buildtransitive 20 | all 21 | 22 | 23 | runtime; build; native; contentfiles; analyzers; buildtransitive 24 | all 25 | 26 | 27 | 28 | 29 | 30 | MSBuild:Compile 31 | ParseTreeVisualizer.Test 32 | False 33 | False 34 | 35 | 36 | 37 | MSBuild:Compile 38 | ParseTreeVisualizer.Test 39 | False 40 | False 41 | 42 | 43 | 44 | MSBuild:Compile 45 | ParseTreeVisualizer.Test 46 | False 47 | False 48 | 49 | 50 | 51 | MSBuild:Compile 52 | ParseTreeVisualizer.Test 53 | False 54 | False 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | -------------------------------------------------------------------------------- /Test/Test.Shared/Extensions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using Xunit; 7 | 8 | namespace ParseTreeVisualizer.Test { 9 | public static class Extensions { 10 | public static TheoryData ToTheoryData(this IEnumerable<(T1, T2)> src) { 11 | var ret = new TheoryData(); 12 | foreach (var (a, b) in src) { 13 | ret.Add(a, b); 14 | } 15 | return ret; 16 | } 17 | public static TheoryData ToTheoryData(this IEnumerable<(T1, T2, T3, T4)> src) { 18 | var ret = new TheoryData(); 19 | foreach (var (a, b, c, d) in src) { 20 | ret.Add(a, b, c, d); 21 | } 22 | return ret; 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Test/Test.Shared/Files/Simple.java: -------------------------------------------------------------------------------- 1 | public class Dog 2 | { 3 | // Instance Variables 4 | String name; 5 | String breed; 6 | int age; 7 | String color; 8 | 9 | // Constructor Declaration of Class 10 | public Dog(String name, String breed, 11 | int age, String color) 12 | { 13 | this.name = name; 14 | this.breed = breed; 15 | this.age = age; 16 | this.color = color; 17 | } 18 | 19 | // method 1 20 | public String getName() 21 | { 22 | return name; 23 | } 24 | 25 | // method 2 26 | public String getBreed() 27 | { 28 | return breed; 29 | } 30 | 31 | // method 3 32 | public int getAge() 33 | { 34 | return age; 35 | } 36 | 37 | // method 4 38 | public String getColor() 39 | { 40 | return color; 41 | } 42 | 43 | @Override 44 | public String toString() 45 | { 46 | return(""Hi my name is ""+ this.getName()+ 47 | "".\nMy breed,age and color are "" + 48 | this.getBreed()+"","" + this.getAge()+ 49 | "",""+ this.getColor()); 50 | } 51 | 52 | public static void main(String[] args) 53 | { 54 | Dog tuffy = new Dog(""tuffy"",""papillon"", 5, ""white""); 55 | System.out.println(tuffy.toString()); 56 | } 57 | } -------------------------------------------------------------------------------- /Test/Test.Shared/Files/WindowsFunctionsForSqLite.sql: -------------------------------------------------------------------------------- 1 | SELECT 2 | Name, 3 | printf('%,d',Bytes) Size, 4 | FIRST_VALUE(Name) OVER ( 5 | ORDER BY Bytes 6 | ) AS SmallestTrack 7 | FROM 8 | tracks 9 | WHERE 10 | AlbumId = 1; 11 | 12 | SELECT 13 | AlbumId, 14 | Name, 15 | printf('%,d',Bytes) Size, 16 | FIRST_VALUE(Name) OVER ( 17 | PARTITION BY AlbumId 18 | ORDER BY Bytes DESC 19 | ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING 20 | ) AS LargestTrack 21 | FROM 22 | tracks; 23 | select * from COMPANY; 24 | 25 | SELECT C.ID, C.NAME, C.AGE, D.DEPT 26 | FROM COMPANY AS C, DEPARTMENT AS D 27 | WHERE C.ID = D.EMP_ID; 28 | 29 | SELECT C.ID AS COMPANY_ID, C.NAME AS COMPANY_NAME, C.AGE, D.DEPT 30 | FROM COMPANY AS C, DEPARTMENT AS D 31 | WHERE C.ID = D.EMP_ID; 32 | 33 | SELECT 34 | Value, 35 | CUME_DIST() 36 | OVER ( 37 | ORDER BY value 38 | ) CumulativeDistribution 39 | FROM 40 | CumeDistDemo; 41 | SELECT 42 | Val, 43 | DENSE_RANK () OVER ( 44 | ORDER BY Val ) 45 | ValRank 46 | FROM 47 | DenseRankDemo; 48 | 49 | 50 | SELECT 51 | CustomerId, 52 | Year, 53 | Total, 54 | LAG ( Total, 1, 0 ) OVER ( 55 | ORDER BY Year 56 | ) PreviousYearTotal 57 | FROM 58 | CustomerInvoices 59 | WHERE 60 | CustomerId = 4; 61 | 62 | SELECT 63 | CustomerId, 64 | Year, 65 | Total, 66 | LAG ( Total,1,0) OVER ( 67 | PARTITION BY CustomerId 68 | ORDER BY Year ) PreviousYearTotal 69 | FROM 70 | CustomerInvoices; 71 | 72 | 73 | SELECT 74 | Name, 75 | printf ( '%.f minutes', 76 | Milliseconds / 1000 / 60 ) 77 | AS Length, 78 | LAST_VALUE ( Name ) OVER ( 79 | ORDER BY Milliseconds 80 | RANGE BETWEEN UNBOUNDED PRECEDING AND 81 | UNBOUNDED FOLLOWING 82 | ) AS LongestTrack 83 | FROM 84 | tracks 85 | WHERE 86 | AlbumId = 4; 87 | 88 | 89 | SELECT 90 | AlbumId, 91 | Name, 92 | printf ( '%.f minutes', 93 | Milliseconds / 1000 / 60 ) 94 | AS Length, 95 | LAST_VALUE ( Name ) OVER ( 96 | PARTITION BY AlbumId 97 | ORDER BY Milliseconds DESC 98 | RANGE BETWEEN UNBOUNDED PRECEDING AND 99 | UNBOUNDED FOLLOWING 100 | ) AS ShortestTrack 101 | FROM 102 | tracks; 103 | 104 | SELECT 105 | CustomerId, 106 | Year, 107 | Total, 108 | LEAD ( Total,1,0) OVER ( ORDER BY Year ) NextYearTotal 109 | FROM 110 | CustomerInvoices 111 | WHERE 112 | CustomerId = 1; 113 | 114 | SELECT 115 | CustomerId, 116 | Year, 117 | Total, 118 | LEAD ( Total, 1, 0 ) OVER ( 119 | PARTITION BY CustomerId 120 | ORDER BY Year 121 | ) NextYearTotal 122 | FROM 123 | CustomerInvoices; 124 | 125 | SELECT 126 | AlbumId, 127 | Name, 128 | Milliseconds Length, 129 | NTH_VALUE ( Name,2 ) OVER ( 130 | PARTITION BY AlbumId 131 | ORDER BY Milliseconds DESC 132 | RANGE BETWEEN 133 | UNBOUNDED PRECEDING AND 134 | UNBOUNDED FOLLOWING 135 | ) AS SecondLongestTrack 136 | FROM 137 | tracks; 138 | 139 | SELECT 140 | Name, 141 | Milliseconds Length, 142 | NTH_VALUE(name,2) OVER ( 143 | ORDER BY Milliseconds DESC 144 | ) SecondLongestTrack 145 | FROM 146 | tracks; 147 | 148 | SELECT 149 | Name, 150 | Milliseconds, 151 | NTILE ( 4 ) OVER ( 152 | ORDER BY Milliseconds ) LengthBucket 153 | FROM 154 | tracks 155 | WHERE 156 | AlbumId = 1; 157 | 158 | SELECT 159 | AlbumId, 160 | Name, 161 | Milliseconds, 162 | NTILE ( 3 ) OVER ( 163 | PARTITION BY AlbumId 164 | ORDER BY Bytes ) SizeBucket 165 | FROM 166 | tracks; 167 | 168 | SELECT 169 | Name, 170 | Milliseconds, 171 | PERCENT_RANK() OVER( 172 | ORDER BY Milliseconds 173 | ) LengthPercentRank 174 | FROM 175 | tracks 176 | WHERE 177 | AlbumId = 1; 178 | 179 | SELECT 180 | Name, 181 | Milliseconds, 182 | printf('%.2f',PERCENT_RANK() OVER( 183 | ORDER BY Milliseconds 184 | )) LengthPercentRank 185 | FROM 186 | tracks 187 | WHERE 188 | AlbumId = 1; 189 | 190 | SELECT 191 | AlbumId, 192 | Name, 193 | Bytes, 194 | printf('%.2f',PERCENT_RANK() OVER( 195 | PARTITION BY AlbumId 196 | ORDER BY Bytes 197 | )) SizePercentRank 198 | FROM 199 | tracks; 200 | 201 | SELECT 202 | Val, 203 | RANK () OVER ( 204 | ORDER BY Val 205 | ) ValRank 206 | FROM 207 | RankDemo; 208 | 209 | SELECT 210 | Name, 211 | Milliseconds, 212 | RANK () OVER ( 213 | ORDER BY Milliseconds DESC 214 | ) LengthRank 215 | FROM 216 | tracks; 217 | 218 | SELECT 219 | Name, 220 | Milliseconds, 221 | AlbumId, 222 | RANK () OVER ( 223 | PARTITION BY AlbumId 224 | ORDER BY Milliseconds DESC 225 | ) LengthRank 226 | FROM 227 | tracks; 228 | 229 | 230 | SELECT 231 | * 232 | FROM ( 233 | SELECT 234 | Name, 235 | Milliseconds, 236 | AlbumId, 237 | RANK () OVER ( 238 | PARTITION BY AlbumId 239 | ORDER BY Milliseconds DESC 240 | ) LengthRank 241 | FROM 242 | tracks 243 | ) 244 | WHERE 245 | LengthRank = 2; 246 | 247 | SELECT 248 | ROW_NUMBER () OVER ( 249 | ORDER BY Country 250 | ) RowNum, 251 | FirstName, 252 | LastName, 253 | country 254 | FROM 255 | customers; 256 | 257 | SELECT 258 | ROW_NUMBER () OVER ( 259 | PARTITION BY Country 260 | ORDER BY FirstName 261 | ) RowNum, 262 | FirstName, 263 | LastName, 264 | country 265 | FROM 266 | customers; 267 | 268 | SELECT * FROM ( 269 | SELECT 270 | ROW_NUMBER () OVER ( 271 | ORDER BY FirstName 272 | ) RowNum, 273 | FirstName, 274 | LastName, 275 | Country 276 | FROM 277 | customers 278 | ) t 279 | WHERE 280 | RowNum > 20 AND RowNum <= 30; 281 | 282 | 283 | SELECT 284 | Country, 285 | FirstName, 286 | LastName, 287 | Amount 288 | FROM ( 289 | SELECT 290 | Country, 291 | FirstName, 292 | LastName, 293 | Amount, 294 | ROW_NUMBER() OVER ( 295 | PARTITION BY country 296 | ORDER BY Amount DESC 297 | ) RowNum 298 | FROM 299 | Sales ) 300 | WHERE 301 | RowNum = 1; -------------------------------------------------------------------------------- /Test/Test.Shared/GlobalSuppressions.cs: -------------------------------------------------------------------------------- 1 | [assembly: System.CLSCompliant(false)] -------------------------------------------------------------------------------- /Test/Test.Shared/Grammars/Java8Lexer.g4: -------------------------------------------------------------------------------- 1 | /* 2 | * [The "BSD license"] 3 | * Copyright (c) 2014 Terence Parr 4 | * Copyright (c) 2014 Sam Harwell 5 | * Copyright (c) 2019 Student Main (Make it universal) 6 | * All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following conditions 10 | * are met: 11 | * 12 | * 1. Redistributions of source code must retain the above copyright 13 | * notice, this list of conditions and the following disclaimer. 14 | * 2. Redistributions in binary form must reproduce the above copyright 15 | * notice, this list of conditions and the following disclaimer in the 16 | * documentation and/or other materials provided with the distribution. 17 | * 3. The name of the author may not be used to endorse or promote products 18 | * derived from this software without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 21 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 22 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 23 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 24 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 25 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 29 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | */ 31 | 32 | /** 33 | * A Java 8 grammar for ANTLR 4 derived from the Java Language Specification 34 | * chapter 19. 35 | * 36 | * NOTE: This grammar results in a generated parser that is much slower 37 | * than the Java 7 grammar in the grammars-v4/java directory. This 38 | * one is, however, extremely close to the spec. 39 | * 40 | * You can test with 41 | * 42 | * $ antlr4 Java8.g4 43 | * $ javac *.java 44 | * $ grun Java8 compilationUnit *.java 45 | * 46 | * Or, 47 | ~/antlr/code/grammars-v4/java8 $ java Test . 48 | /Users/parrt/antlr/code/grammars-v4/java8/./Java8BaseListener.java 49 | /Users/parrt/antlr/code/grammars-v4/java8/./Java8Lexer.java 50 | /Users/parrt/antlr/code/grammars-v4/java8/./Java8Listener.java 51 | /Users/parrt/antlr/code/grammars-v4/java8/./Java8Parser.java 52 | /Users/parrt/antlr/code/grammars-v4/java8/./Test.java 53 | Total lexer+parser time 30844ms. 54 | */ 55 | lexer grammar Java8Lexer; 56 | 57 | // LEXER 58 | 59 | // §3.9 Keywords 60 | 61 | ABSTRACT : 'abstract'; 62 | ASSERT : 'assert'; 63 | BOOLEAN : 'boolean'; 64 | BREAK : 'break'; 65 | BYTE : 'byte'; 66 | CASE : 'case'; 67 | CATCH : 'catch'; 68 | CHAR : 'char'; 69 | CLASS : 'class'; 70 | CONST : 'const'; 71 | CONTINUE : 'continue'; 72 | DEFAULT : 'default'; 73 | DO : 'do'; 74 | DOUBLE : 'double'; 75 | ELSE : 'else'; 76 | ENUM : 'enum'; 77 | EXTENDS : 'extends'; 78 | FINAL : 'final'; 79 | FINALLY : 'finally'; 80 | FLOAT : 'float'; 81 | FOR : 'for'; 82 | IF : 'if'; 83 | GOTO : 'goto'; 84 | IMPLEMENTS : 'implements'; 85 | IMPORT : 'import'; 86 | INSTANCEOF : 'instanceof'; 87 | INT : 'int'; 88 | INTERFACE : 'interface'; 89 | LONG : 'long'; 90 | NATIVE : 'native'; 91 | NEW : 'new'; 92 | PACKAGE : 'package'; 93 | PRIVATE : 'private'; 94 | PROTECTED : 'protected'; 95 | PUBLIC : 'public'; 96 | RETURN : 'return'; 97 | SHORT : 'short'; 98 | STATIC : 'static'; 99 | STRICTFP : 'strictfp'; 100 | SUPER : 'super'; 101 | SWITCH : 'switch'; 102 | SYNCHRONIZED : 'synchronized'; 103 | THIS : 'this'; 104 | THROW : 'throw'; 105 | THROWS : 'throws'; 106 | TRANSIENT : 'transient'; 107 | TRY : 'try'; 108 | VOID : 'void'; 109 | VOLATILE : 'volatile'; 110 | WHILE : 'while'; 111 | 112 | // §3.10.1 Integer Literals 113 | 114 | IntegerLiteral 115 | : DecimalIntegerLiteral 116 | | HexIntegerLiteral 117 | | OctalIntegerLiteral 118 | | BinaryIntegerLiteral 119 | ; 120 | 121 | fragment 122 | DecimalIntegerLiteral 123 | : DecimalNumeral IntegerTypeSuffix? 124 | ; 125 | 126 | fragment 127 | HexIntegerLiteral 128 | : HexNumeral IntegerTypeSuffix? 129 | ; 130 | 131 | fragment 132 | OctalIntegerLiteral 133 | : OctalNumeral IntegerTypeSuffix? 134 | ; 135 | 136 | fragment 137 | BinaryIntegerLiteral 138 | : BinaryNumeral IntegerTypeSuffix? 139 | ; 140 | 141 | fragment 142 | IntegerTypeSuffix 143 | : [lL] 144 | ; 145 | 146 | fragment 147 | DecimalNumeral 148 | : '0' 149 | | NonZeroDigit (Digits? | Underscores Digits) 150 | ; 151 | 152 | fragment 153 | Digits 154 | : Digit (DigitsAndUnderscores? Digit)? 155 | ; 156 | 157 | fragment 158 | Digit 159 | : '0' 160 | | NonZeroDigit 161 | ; 162 | 163 | fragment 164 | NonZeroDigit 165 | : [1-9] 166 | ; 167 | 168 | fragment 169 | DigitsAndUnderscores 170 | : DigitOrUnderscore+ 171 | ; 172 | 173 | fragment 174 | DigitOrUnderscore 175 | : Digit 176 | | '_' 177 | ; 178 | 179 | fragment 180 | Underscores 181 | : '_'+ 182 | ; 183 | 184 | fragment 185 | HexNumeral 186 | : '0' [xX] HexDigits 187 | ; 188 | 189 | fragment 190 | HexDigits 191 | : HexDigit (HexDigitsAndUnderscores? HexDigit)? 192 | ; 193 | 194 | fragment 195 | HexDigit 196 | : [0-9a-fA-F] 197 | ; 198 | 199 | fragment 200 | HexDigitsAndUnderscores 201 | : HexDigitOrUnderscore+ 202 | ; 203 | 204 | fragment 205 | HexDigitOrUnderscore 206 | : HexDigit 207 | | '_' 208 | ; 209 | 210 | fragment 211 | OctalNumeral 212 | : '0' Underscores? OctalDigits 213 | ; 214 | 215 | fragment 216 | OctalDigits 217 | : OctalDigit (OctalDigitsAndUnderscores? OctalDigit)? 218 | ; 219 | 220 | fragment 221 | OctalDigit 222 | : [0-7] 223 | ; 224 | 225 | fragment 226 | OctalDigitsAndUnderscores 227 | : OctalDigitOrUnderscore+ 228 | ; 229 | 230 | fragment 231 | OctalDigitOrUnderscore 232 | : OctalDigit 233 | | '_' 234 | ; 235 | 236 | fragment 237 | BinaryNumeral 238 | : '0' [bB] BinaryDigits 239 | ; 240 | 241 | fragment 242 | BinaryDigits 243 | : BinaryDigit (BinaryDigitsAndUnderscores? BinaryDigit)? 244 | ; 245 | 246 | fragment 247 | BinaryDigit 248 | : [01] 249 | ; 250 | 251 | fragment 252 | BinaryDigitsAndUnderscores 253 | : BinaryDigitOrUnderscore+ 254 | ; 255 | 256 | fragment 257 | BinaryDigitOrUnderscore 258 | : BinaryDigit 259 | | '_' 260 | ; 261 | 262 | // §3.10.2 Floating-Point Literals 263 | 264 | FloatingPointLiteral 265 | : DecimalFloatingPointLiteral 266 | | HexadecimalFloatingPointLiteral 267 | ; 268 | 269 | fragment 270 | DecimalFloatingPointLiteral 271 | : Digits '.' Digits? ExponentPart? FloatTypeSuffix? 272 | | '.' Digits ExponentPart? FloatTypeSuffix? 273 | | Digits ExponentPart FloatTypeSuffix? 274 | | Digits FloatTypeSuffix 275 | ; 276 | 277 | fragment 278 | ExponentPart 279 | : ExponentIndicator SignedInteger 280 | ; 281 | 282 | fragment 283 | ExponentIndicator 284 | : [eE] 285 | ; 286 | 287 | fragment 288 | SignedInteger 289 | : Sign? Digits 290 | ; 291 | 292 | fragment 293 | Sign 294 | : [+-] 295 | ; 296 | 297 | fragment 298 | FloatTypeSuffix 299 | : [fFdD] 300 | ; 301 | 302 | fragment 303 | HexadecimalFloatingPointLiteral 304 | : HexSignificand BinaryExponent FloatTypeSuffix? 305 | ; 306 | 307 | fragment 308 | HexSignificand 309 | : HexNumeral '.'? 310 | | '0' [xX] HexDigits? '.' HexDigits 311 | ; 312 | 313 | fragment 314 | BinaryExponent 315 | : BinaryExponentIndicator SignedInteger 316 | ; 317 | 318 | fragment 319 | BinaryExponentIndicator 320 | : [pP] 321 | ; 322 | 323 | // §3.10.3 Boolean Literals 324 | 325 | BooleanLiteral 326 | : 'true' 327 | | 'false' 328 | ; 329 | 330 | // §3.10.4 Character Literals 331 | 332 | CharacterLiteral 333 | : '\'' SingleCharacter '\'' 334 | | '\'' EscapeSequence '\'' 335 | ; 336 | 337 | fragment 338 | SingleCharacter 339 | : ~['\\\r\n] 340 | ; 341 | 342 | // §3.10.5 String Literals 343 | 344 | StringLiteral 345 | : '"' StringCharacters? '"' 346 | ; 347 | 348 | fragment 349 | StringCharacters 350 | : StringCharacter+ 351 | ; 352 | 353 | fragment 354 | StringCharacter 355 | : ~["\\\r\n] 356 | | EscapeSequence 357 | ; 358 | 359 | // §3.10.6 Escape Sequences for Character and String Literals 360 | 361 | fragment 362 | EscapeSequence 363 | : '\\' [btnfr"'\\] 364 | | OctalEscape 365 | | UnicodeEscape // This is not in the spec but prevents having to preprocess the input 366 | ; 367 | 368 | fragment 369 | OctalEscape 370 | : '\\' OctalDigit 371 | | '\\' OctalDigit OctalDigit 372 | | '\\' ZeroToThree OctalDigit OctalDigit 373 | ; 374 | 375 | fragment 376 | ZeroToThree 377 | : [0-3] 378 | ; 379 | 380 | // This is not in the spec but prevents having to preprocess the input 381 | fragment 382 | UnicodeEscape 383 | : '\\' 'u'+ HexDigit HexDigit HexDigit HexDigit 384 | ; 385 | 386 | // §3.10.7 The Null Literal 387 | 388 | NullLiteral 389 | : 'null' 390 | ; 391 | 392 | // §3.11 Separators 393 | 394 | LPAREN : '('; 395 | RPAREN : ')'; 396 | LBRACE : '{'; 397 | RBRACE : '}'; 398 | LBRACK : '['; 399 | RBRACK : ']'; 400 | SEMI : ';'; 401 | COMMA : ','; 402 | DOT : '.'; 403 | 404 | // §3.12 Operators 405 | 406 | ASSIGN : '='; 407 | GT : '>'; 408 | LT : '<'; 409 | BANG : '!'; 410 | TILDE : '~'; 411 | QUESTION : '?'; 412 | COLON : ':'; 413 | EQUAL : '=='; 414 | LE : '<='; 415 | GE : '>='; 416 | NOTEQUAL : '!='; 417 | AND : '&&'; 418 | OR : '||'; 419 | INC : '++'; 420 | DEC : '--'; 421 | ADD : '+'; 422 | SUB : '-'; 423 | MUL : '*'; 424 | DIV : '/'; 425 | BITAND : '&'; 426 | BITOR : '|'; 427 | CARET : '^'; 428 | MOD : '%'; 429 | ARROW : '->'; 430 | COLONCOLON : '::'; 431 | 432 | ADD_ASSIGN : '+='; 433 | SUB_ASSIGN : '-='; 434 | MUL_ASSIGN : '*='; 435 | DIV_ASSIGN : '/='; 436 | AND_ASSIGN : '&='; 437 | OR_ASSIGN : '|='; 438 | XOR_ASSIGN : '^='; 439 | MOD_ASSIGN : '%='; 440 | LSHIFT_ASSIGN : '<<='; 441 | RSHIFT_ASSIGN : '>>='; 442 | URSHIFT_ASSIGN : '>>>='; 443 | 444 | // §3.8 Identifiers (must appear after all keywords in the grammar) 445 | 446 | Identifier 447 | : IdentifierStart IdentifierPart* 448 | ; 449 | /* 450 | fragment 451 | JavaLetter 452 | : [a-zA-Z$_] // these are the "java letters" below 0x7F 453 | | // covers all characters above 0x7F which are not a surrogate 454 | ~[\u0000-\u007F\uD800-\uDBFF] {this.wasJavaIdentiferStart()}? 455 | | // covers UTF-16 surrogate pairs encodings for U+10000 to U+10FFFF 456 | [\uD800-\uDBFF] [\uDC00-\uDFFF] {this.wasJavaIdentiferStartUTF16()}? 457 | ; 458 | 459 | fragment 460 | JavaLetterOrDigit 461 | : [a-zA-Z0-9$_] // these are the "java letters or digits" below 0x7F 462 | | // covers all characters above 0x7F which are not a surrogate 463 | ~[\u0000-\u007F\uD800-\uDBFF] {this.wasJavaIdentiferPart()}? 464 | | // covers UTF-16 surrogate pairs encodings for U+10000 to U+10FFFF 465 | [\uD800-\uDBFF] [\uDC00-\uDFFF] {this.wasJavaIdentiferPartUTF16()}? 466 | ;*/ 467 | 468 | // Dropped SMP support as ANTLR has no native support for it 469 | fragment IdentifierStart 470 | : [\u0024] 471 | | [\u0041-\u005A] 472 | | [\u005F] 473 | | [\u0061-\u007A] 474 | | [\u00A2-\u00A5] 475 | | [\u00AA] 476 | | [\u00B5] 477 | | [\u00BA] 478 | | [\u00C0-\u00D6] 479 | | [\u00D8-\u00F6] 480 | | [\u00F8-\u02C1] 481 | | [\u02C6-\u02D1] 482 | | [\u02E0-\u02E4] 483 | | [\u02EC] 484 | | [\u02EE] 485 | | [\u0370-\u0374] 486 | | [\u0376-\u0377] 487 | | [\u037A-\u037D] 488 | | [\u037F] 489 | | [\u0386] 490 | | [\u0388-\u038A] 491 | | [\u038C] 492 | | [\u038E-\u03A1] 493 | | [\u03A3-\u03F5] 494 | | [\u03F7-\u0481] 495 | | [\u048A-\u052F] 496 | | [\u0531-\u0556] 497 | | [\u0559] 498 | | [\u0561-\u0587] 499 | | [\u058F] 500 | | [\u05D0-\u05EA] 501 | | [\u05F0-\u05F2] 502 | | [\u060B] 503 | | [\u0620-\u064A] 504 | | [\u066E-\u066F] 505 | | [\u0671-\u06D3] 506 | | [\u06D5] 507 | | [\u06E5-\u06E6] 508 | | [\u06EE-\u06EF] 509 | | [\u06FA-\u06FC] 510 | | [\u06FF] 511 | | [\u0710] 512 | | [\u0712-\u072F] 513 | | [\u074D-\u07A5] 514 | | [\u07B1] 515 | | [\u07CA-\u07EA] 516 | | [\u07F4-\u07F5] 517 | | [\u07FA] 518 | | [\u0800-\u0815] 519 | | [\u081A] 520 | | [\u0824] 521 | | [\u0828] 522 | | [\u0840-\u0858] 523 | | [\u0860-\u086A] 524 | | [\u08A0-\u08B4] 525 | | [\u08B6-\u08BD] 526 | | [\u0904-\u0939] 527 | | [\u093D] 528 | | [\u0950] 529 | | [\u0958-\u0961] 530 | | [\u0971-\u0980] 531 | | [\u0985-\u098C] 532 | | [\u098F-\u0990] 533 | | [\u0993-\u09A8] 534 | | [\u09AA-\u09B0] 535 | | [\u09B2] 536 | | [\u09B6-\u09B9] 537 | | [\u09BD] 538 | | [\u09CE] 539 | | [\u09DC-\u09DD] 540 | | [\u09DF-\u09E1] 541 | | [\u09F0-\u09F3] 542 | | [\u09FB-\u09FC] 543 | | [\u0A05-\u0A0A] 544 | | [\u0A0F-\u0A10] 545 | | [\u0A13-\u0A28] 546 | | [\u0A2A-\u0A30] 547 | | [\u0A32-\u0A33] 548 | | [\u0A35-\u0A36] 549 | | [\u0A38-\u0A39] 550 | | [\u0A59-\u0A5C] 551 | | [\u0A5E] 552 | | [\u0A72-\u0A74] 553 | | [\u0A85-\u0A8D] 554 | | [\u0A8F-\u0A91] 555 | | [\u0A93-\u0AA8] 556 | | [\u0AAA-\u0AB0] 557 | | [\u0AB2-\u0AB3] 558 | | [\u0AB5-\u0AB9] 559 | | [\u0ABD] 560 | | [\u0AD0] 561 | | [\u0AE0-\u0AE1] 562 | | [\u0AF1] 563 | | [\u0AF9] 564 | | [\u0B05-\u0B0C] 565 | | [\u0B0F-\u0B10] 566 | | [\u0B13-\u0B28] 567 | | [\u0B2A-\u0B30] 568 | | [\u0B32-\u0B33] 569 | | [\u0B35-\u0B39] 570 | | [\u0B3D] 571 | | [\u0B5C-\u0B5D] 572 | | [\u0B5F-\u0B61] 573 | | [\u0B71] 574 | | [\u0B83] 575 | | [\u0B85-\u0B8A] 576 | | [\u0B8E-\u0B90] 577 | | [\u0B92-\u0B95] 578 | | [\u0B99-\u0B9A] 579 | | [\u0B9C] 580 | | [\u0B9E-\u0B9F] 581 | | [\u0BA3-\u0BA4] 582 | | [\u0BA8-\u0BAA] 583 | | [\u0BAE-\u0BB9] 584 | | [\u0BD0] 585 | | [\u0BF9] 586 | | [\u0C05-\u0C0C] 587 | | [\u0C0E-\u0C10] 588 | | [\u0C12-\u0C28] 589 | | [\u0C2A-\u0C39] 590 | | [\u0C3D] 591 | | [\u0C58-\u0C5A] 592 | | [\u0C60-\u0C61] 593 | | [\u0C80] 594 | | [\u0C85-\u0C8C] 595 | | [\u0C8E-\u0C90] 596 | | [\u0C92-\u0CA8] 597 | | [\u0CAA-\u0CB3] 598 | | [\u0CB5-\u0CB9] 599 | | [\u0CBD] 600 | | [\u0CDE] 601 | | [\u0CE0-\u0CE1] 602 | | [\u0CF1-\u0CF2] 603 | | [\u0D05-\u0D0C] 604 | | [\u0D0E-\u0D10] 605 | | [\u0D12-\u0D3A] 606 | | [\u0D3D] 607 | | [\u0D4E] 608 | | [\u0D54-\u0D56] 609 | | [\u0D5F-\u0D61] 610 | | [\u0D7A-\u0D7F] 611 | | [\u0D85-\u0D96] 612 | | [\u0D9A-\u0DB1] 613 | | [\u0DB3-\u0DBB] 614 | | [\u0DBD] 615 | | [\u0DC0-\u0DC6] 616 | | [\u0E01-\u0E30] 617 | | [\u0E32-\u0E33] 618 | | [\u0E3F-\u0E46] 619 | | [\u0E81-\u0E82] 620 | | [\u0E84] 621 | | [\u0E87-\u0E88] 622 | | [\u0E8A] 623 | | [\u0E8D] 624 | | [\u0E94-\u0E97] 625 | | [\u0E99-\u0E9F] 626 | | [\u0EA1-\u0EA3] 627 | | [\u0EA5] 628 | | [\u0EA7] 629 | | [\u0EAA-\u0EAB] 630 | | [\u0EAD-\u0EB0] 631 | | [\u0EB2-\u0EB3] 632 | | [\u0EBD] 633 | | [\u0EC0-\u0EC4] 634 | | [\u0EC6] 635 | | [\u0EDC-\u0EDF] 636 | | [\u0F00] 637 | | [\u0F40-\u0F47] 638 | | [\u0F49-\u0F6C] 639 | | [\u0F88-\u0F8C] 640 | | [\u1000-\u102A] 641 | | [\u103F] 642 | | [\u1050-\u1055] 643 | | [\u105A-\u105D] 644 | | [\u1061] 645 | | [\u1065-\u1066] 646 | | [\u106E-\u1070] 647 | | [\u1075-\u1081] 648 | | [\u108E] 649 | | [\u10A0-\u10C5] 650 | | [\u10C7] 651 | | [\u10CD] 652 | | [\u10D0-\u10FA] 653 | | [\u10FC-\u1248] 654 | | [\u124A-\u124D] 655 | | [\u1250-\u1256] 656 | | [\u1258] 657 | | [\u125A-\u125D] 658 | | [\u1260-\u1288] 659 | | [\u128A-\u128D] 660 | | [\u1290-\u12B0] 661 | | [\u12B2-\u12B5] 662 | | [\u12B8-\u12BE] 663 | | [\u12C0] 664 | | [\u12C2-\u12C5] 665 | | [\u12C8-\u12D6] 666 | | [\u12D8-\u1310] 667 | | [\u1312-\u1315] 668 | | [\u1318-\u135A] 669 | | [\u1380-\u138F] 670 | | [\u13A0-\u13F5] 671 | | [\u13F8-\u13FD] 672 | | [\u1401-\u166C] 673 | | [\u166F-\u167F] 674 | | [\u1681-\u169A] 675 | | [\u16A0-\u16EA] 676 | | [\u16EE-\u16F8] 677 | | [\u1700-\u170C] 678 | | [\u170E-\u1711] 679 | | [\u1720-\u1731] 680 | | [\u1740-\u1751] 681 | | [\u1760-\u176C] 682 | | [\u176E-\u1770] 683 | | [\u1780-\u17B3] 684 | | [\u17D7] 685 | | [\u17DB-\u17DC] 686 | | [\u1820-\u1877] 687 | | [\u1880-\u1884] 688 | | [\u1887-\u18A8] 689 | | [\u18AA] 690 | | [\u18B0-\u18F5] 691 | | [\u1900-\u191E] 692 | | [\u1950-\u196D] 693 | | [\u1970-\u1974] 694 | | [\u1980-\u19AB] 695 | | [\u19B0-\u19C9] 696 | | [\u1A00-\u1A16] 697 | | [\u1A20-\u1A54] 698 | | [\u1AA7] 699 | | [\u1B05-\u1B33] 700 | | [\u1B45-\u1B4B] 701 | | [\u1B83-\u1BA0] 702 | | [\u1BAE-\u1BAF] 703 | | [\u1BBA-\u1BE5] 704 | | [\u1C00-\u1C23] 705 | | [\u1C4D-\u1C4F] 706 | | [\u1C5A-\u1C7D] 707 | | [\u1C80-\u1C88] 708 | | [\u1CE9-\u1CEC] 709 | | [\u1CEE-\u1CF1] 710 | | [\u1CF5-\u1CF6] 711 | | [\u1D00-\u1DBF] 712 | | [\u1E00-\u1F15] 713 | | [\u1F18-\u1F1D] 714 | | [\u1F20-\u1F45] 715 | | [\u1F48-\u1F4D] 716 | | [\u1F50-\u1F57] 717 | | [\u1F59] 718 | | [\u1F5B] 719 | | [\u1F5D] 720 | | [\u1F5F-\u1F7D] 721 | | [\u1F80-\u1FB4] 722 | | [\u1FB6-\u1FBC] 723 | | [\u1FBE] 724 | | [\u1FC2-\u1FC4] 725 | | [\u1FC6-\u1FCC] 726 | | [\u1FD0-\u1FD3] 727 | | [\u1FD6-\u1FDB] 728 | | [\u1FE0-\u1FEC] 729 | | [\u1FF2-\u1FF4] 730 | | [\u1FF6-\u1FFC] 731 | | [\u203F-\u2040] 732 | | [\u2054] 733 | | [\u2071] 734 | | [\u207F] 735 | | [\u2090-\u209C] 736 | | [\u20A0-\u20BF] 737 | | [\u2102] 738 | | [\u2107] 739 | | [\u210A-\u2113] 740 | | [\u2115] 741 | | [\u2119-\u211D] 742 | | [\u2124] 743 | | [\u2126] 744 | | [\u2128] 745 | | [\u212A-\u212D] 746 | | [\u212F-\u2139] 747 | | [\u213C-\u213F] 748 | | [\u2145-\u2149] 749 | | [\u214E] 750 | | [\u2160-\u2188] 751 | | [\u2C00-\u2C2E] 752 | | [\u2C30-\u2C5E] 753 | | [\u2C60-\u2CE4] 754 | | [\u2CEB-\u2CEE] 755 | | [\u2CF2-\u2CF3] 756 | | [\u2D00-\u2D25] 757 | | [\u2D27] 758 | | [\u2D2D] 759 | | [\u2D30-\u2D67] 760 | | [\u2D6F] 761 | | [\u2D80-\u2D96] 762 | | [\u2DA0-\u2DA6] 763 | | [\u2DA8-\u2DAE] 764 | | [\u2DB0-\u2DB6] 765 | | [\u2DB8-\u2DBE] 766 | | [\u2DC0-\u2DC6] 767 | | [\u2DC8-\u2DCE] 768 | | [\u2DD0-\u2DD6] 769 | | [\u2DD8-\u2DDE] 770 | | [\u2E2F] 771 | | [\u3005-\u3007] 772 | | [\u3021-\u3029] 773 | | [\u3031-\u3035] 774 | | [\u3038-\u303C] 775 | | [\u3041-\u3096] 776 | | [\u309D-\u309F] 777 | | [\u30A1-\u30FA] 778 | | [\u30FC-\u30FF] 779 | | [\u3105-\u312E] 780 | | [\u3131-\u318E] 781 | | [\u31A0-\u31BA] 782 | | [\u31F0-\u31FF] 783 | | [\u3400-\u4DB5] 784 | | [\u4E00-\u9FEA] 785 | | [\uA000-\uA48C] 786 | | [\uA4D0-\uA4FD] 787 | | [\uA500-\uA60C] 788 | | [\uA610-\uA61F] 789 | | [\uA62A-\uA62B] 790 | | [\uA640-\uA66E] 791 | | [\uA67F-\uA69D] 792 | | [\uA6A0-\uA6EF] 793 | | [\uA717-\uA71F] 794 | | [\uA722-\uA788] 795 | | [\uA78B-\uA7AE] 796 | | [\uA7B0-\uA7B7] 797 | | [\uA7F7-\uA801] 798 | | [\uA803-\uA805] 799 | | [\uA807-\uA80A] 800 | | [\uA80C-\uA822] 801 | | [\uA838] 802 | | [\uA840-\uA873] 803 | | [\uA882-\uA8B3] 804 | | [\uA8F2-\uA8F7] 805 | | [\uA8FB] 806 | | [\uA8FD] 807 | | [\uA90A-\uA925] 808 | | [\uA930-\uA946] 809 | | [\uA960-\uA97C] 810 | | [\uA984-\uA9B2] 811 | | [\uA9CF] 812 | | [\uA9E0-\uA9E4] 813 | | [\uA9E6-\uA9EF] 814 | | [\uA9FA-\uA9FE] 815 | | [\uAA00-\uAA28] 816 | | [\uAA40-\uAA42] 817 | | [\uAA44-\uAA4B] 818 | | [\uAA60-\uAA76] 819 | | [\uAA7A] 820 | | [\uAA7E-\uAAAF] 821 | | [\uAAB1] 822 | | [\uAAB5-\uAAB6] 823 | | [\uAAB9-\uAABD] 824 | | [\uAAC0] 825 | | [\uAAC2] 826 | | [\uAADB-\uAADD] 827 | | [\uAAE0-\uAAEA] 828 | | [\uAAF2-\uAAF4] 829 | | [\uAB01-\uAB06] 830 | | [\uAB09-\uAB0E] 831 | | [\uAB11-\uAB16] 832 | | [\uAB20-\uAB26] 833 | | [\uAB28-\uAB2E] 834 | | [\uAB30-\uAB5A] 835 | | [\uAB5C-\uAB65] 836 | | [\uAB70-\uABE2] 837 | | [\uAC00-\uD7A3] 838 | | [\uD7B0-\uD7C6] 839 | | [\uD7CB-\uD7FB] 840 | | [\uF900-\uFA6D] 841 | | [\uFA70-\uFAD9] 842 | | [\uFB00-\uFB06] 843 | | [\uFB13-\uFB17] 844 | | [\uFB1D] 845 | | [\uFB1F-\uFB28] 846 | | [\uFB2A-\uFB36] 847 | | [\uFB38-\uFB3C] 848 | | [\uFB3E] 849 | | [\uFB40-\uFB41] 850 | | [\uFB43-\uFB44] 851 | | [\uFB46-\uFBB1] 852 | | [\uFBD3-\uFD3D] 853 | | [\uFD50-\uFD8F] 854 | | [\uFD92-\uFDC7] 855 | | [\uFDF0-\uFDFC] 856 | | [\uFE33-\uFE34] 857 | | [\uFE4D-\uFE4F] 858 | | [\uFE69] 859 | | [\uFE70-\uFE74] 860 | | [\uFE76-\uFEFC] 861 | | [\uFF04] 862 | | [\uFF21-\uFF3A] 863 | | [\uFF3F] 864 | | [\uFF41-\uFF5A] 865 | | [\uFF66-\uFFBE] 866 | | [\uFFC2-\uFFC7] 867 | | [\uFFCA-\uFFCF] 868 | | [\uFFD2-\uFFD7] 869 | | [\uFFDA-\uFFDC] 870 | | [\uFFE0-\uFFE1] 871 | | [\uFFE5-\uFFE6] 872 | ; 873 | 874 | fragment IdentifierPart 875 | : IdentifierStart 876 | | [\u0030-\u0039] 877 | | [\u007F-\u009F] 878 | | [\u00AD] 879 | | [\u0300-\u036F] 880 | | [\u0483-\u0487] 881 | | [\u0591-\u05BD] 882 | | [\u05BF] 883 | | [\u05C1-\u05C2] 884 | | [\u05C4-\u05C5] 885 | | [\u05C7] 886 | | [\u0600-\u0605] 887 | | [\u0610-\u061A] 888 | | [\u061C] 889 | | [\u064B-\u0669] 890 | | [\u0670] 891 | | [\u06D6-\u06DD] 892 | | [\u06DF-\u06E4] 893 | | [\u06E7-\u06E8] 894 | | [\u06EA-\u06ED] 895 | | [\u06F0-\u06F9] 896 | | [\u070F] 897 | | [\u0711] 898 | | [\u0730-\u074A] 899 | | [\u07A6-\u07B0] 900 | | [\u07C0-\u07C9] 901 | | [\u07EB-\u07F3] 902 | | [\u0816-\u0819] 903 | | [\u081B-\u0823] 904 | | [\u0825-\u0827] 905 | | [\u0829-\u082D] 906 | | [\u0859-\u085B] 907 | | [\u08D4-\u0903] 908 | | [\u093A-\u093C] 909 | | [\u093E-\u094F] 910 | | [\u0951-\u0957] 911 | | [\u0962-\u0963] 912 | | [\u0966-\u096F] 913 | | [\u0981-\u0983] 914 | | [\u09BC] 915 | | [\u09BE-\u09C4] 916 | | [\u09C7-\u09C8] 917 | | [\u09CB-\u09CD] 918 | | [\u09D7] 919 | | [\u09E2-\u09E3] 920 | | [\u09E6-\u09EF] 921 | | [\u0A01-\u0A03] 922 | | [\u0A3C] 923 | | [\u0A3E-\u0A42] 924 | | [\u0A47-\u0A48] 925 | | [\u0A4B-\u0A4D] 926 | | [\u0A51] 927 | | [\u0A66-\u0A71] 928 | | [\u0A75] 929 | | [\u0A81-\u0A83] 930 | | [\u0ABC] 931 | | [\u0ABE-\u0AC5] 932 | | [\u0AC7-\u0AC9] 933 | | [\u0ACB-\u0ACD] 934 | | [\u0AE2-\u0AE3] 935 | | [\u0AE6-\u0AEF] 936 | | [\u0AFA-\u0AFF] 937 | | [\u0B01-\u0B03] 938 | | [\u0B3C] 939 | | [\u0B3E-\u0B44] 940 | | [\u0B47-\u0B48] 941 | | [\u0B4B-\u0B4D] 942 | | [\u0B56-\u0B57] 943 | | [\u0B62-\u0B63] 944 | | [\u0B66-\u0B6F] 945 | | [\u0B82] 946 | | [\u0BBE-\u0BC2] 947 | | [\u0BC6-\u0BC8] 948 | | [\u0BCA-\u0BCD] 949 | | [\u0BD7] 950 | | [\u0BE6-\u0BEF] 951 | | [\u0C00-\u0C03] 952 | | [\u0C3E-\u0C44] 953 | | [\u0C46-\u0C48] 954 | | [\u0C4A-\u0C4D] 955 | | [\u0C55-\u0C56] 956 | | [\u0C62-\u0C63] 957 | | [\u0C66-\u0C6F] 958 | | [\u0C81-\u0C83] 959 | | [\u0CBC] 960 | | [\u0CBE-\u0CC4] 961 | | [\u0CC6-\u0CC8] 962 | | [\u0CCA-\u0CCD] 963 | | [\u0CD5-\u0CD6] 964 | | [\u0CE2-\u0CE3] 965 | | [\u0CE6-\u0CEF] 966 | | [\u0D00-\u0D03] 967 | | [\u0D3B-\u0D3C] 968 | | [\u0D3E-\u0D44] 969 | | [\u0D46-\u0D48] 970 | | [\u0D4A-\u0D4D] 971 | | [\u0D57] 972 | | [\u0D62-\u0D63] 973 | | [\u0D66-\u0D6F] 974 | | [\u0D82-\u0D83] 975 | | [\u0DCA] 976 | | [\u0DCF-\u0DD4] 977 | | [\u0DD6] 978 | | [\u0DD8-\u0DDF] 979 | | [\u0DE6-\u0DEF] 980 | | [\u0DF2-\u0DF3] 981 | | [\u0E31] 982 | | [\u0E34-\u0E3A] 983 | | [\u0E47-\u0E4E] 984 | | [\u0E50-\u0E59] 985 | | [\u0EB1] 986 | | [\u0EB4-\u0EB9] 987 | | [\u0EBB-\u0EBC] 988 | | [\u0EC8-\u0ECD] 989 | | [\u0ED0-\u0ED9] 990 | | [\u0F18-\u0F19] 991 | | [\u0F20-\u0F29] 992 | | [\u0F35] 993 | | [\u0F37] 994 | | [\u0F39] 995 | | [\u0F3E-\u0F3F] 996 | | [\u0F71-\u0F84] 997 | | [\u0F86-\u0F87] 998 | | [\u0F8D-\u0F97] 999 | | [\u0F99-\u0FBC] 1000 | | [\u0FC6] 1001 | | [\u102B-\u103E] 1002 | | [\u1040-\u1049] 1003 | | [\u1056-\u1059] 1004 | | [\u105E-\u1060] 1005 | | [\u1062-\u1064] 1006 | | [\u1067-\u106D] 1007 | | [\u1071-\u1074] 1008 | | [\u1082-\u108D] 1009 | | [\u108F-\u109D] 1010 | | [\u135D-\u135F] 1011 | | [\u1712-\u1714] 1012 | | [\u1732-\u1734] 1013 | | [\u1752-\u1753] 1014 | | [\u1772-\u1773] 1015 | | [\u17B4-\u17D3] 1016 | | [\u17DD] 1017 | | [\u17E0-\u17E9] 1018 | | [\u180B-\u180E] 1019 | | [\u1810-\u1819] 1020 | | [\u1885-\u1886] 1021 | | [\u18A9] 1022 | | [\u1920-\u192B] 1023 | | [\u1930-\u193B] 1024 | | [\u1946-\u194F] 1025 | | [\u19D0-\u19D9] 1026 | | [\u1A17-\u1A1B] 1027 | | [\u1A55-\u1A5E] 1028 | | [\u1A60-\u1A7C] 1029 | | [\u1A7F-\u1A89] 1030 | | [\u1A90-\u1A99] 1031 | | [\u1AB0-\u1ABD] 1032 | | [\u1B00-\u1B04] 1033 | | [\u1B34-\u1B44] 1034 | | [\u1B50-\u1B59] 1035 | | [\u1B6B-\u1B73] 1036 | | [\u1B80-\u1B82] 1037 | | [\u1BA1-\u1BAD] 1038 | | [\u1BB0-\u1BB9] 1039 | | [\u1BE6-\u1BF3] 1040 | | [\u1C24-\u1C37] 1041 | | [\u1C40-\u1C49] 1042 | | [\u1C50-\u1C59] 1043 | | [\u1CD0-\u1CD2] 1044 | | [\u1CD4-\u1CE8] 1045 | | [\u1CED] 1046 | | [\u1CF2-\u1CF4] 1047 | | [\u1CF7-\u1CF9] 1048 | | [\u1DC0-\u1DF9] 1049 | | [\u1DFB-\u1DFF] 1050 | | [\u200B-\u200F] 1051 | | [\u202A-\u202E] 1052 | | [\u2060-\u2064] 1053 | | [\u2066-\u206F] 1054 | | [\u20D0-\u20DC] 1055 | | [\u20E1] 1056 | | [\u20E5-\u20F0] 1057 | | [\u2CEF-\u2CF1] 1058 | | [\u2D7F] 1059 | | [\u2DE0-\u2DFF] 1060 | | [\u302A-\u302F] 1061 | | [\u3099-\u309A] 1062 | | [\uA620-\uA629] 1063 | | [\uA66F] 1064 | | [\uA674-\uA67D] 1065 | | [\uA69E-\uA69F] 1066 | | [\uA6F0-\uA6F1] 1067 | | [\uA802] 1068 | | [\uA806] 1069 | | [\uA80B] 1070 | | [\uA823-\uA827] 1071 | | [\uA880-\uA881] 1072 | | [\uA8B4-\uA8C5] 1073 | | [\uA8D0-\uA8D9] 1074 | | [\uA8E0-\uA8F1] 1075 | | [\uA900-\uA909] 1076 | | [\uA926-\uA92D] 1077 | | [\uA947-\uA953] 1078 | | [\uA980-\uA983] 1079 | | [\uA9B3-\uA9C0] 1080 | | [\uA9D0-\uA9D9] 1081 | | [\uA9E5] 1082 | | [\uA9F0-\uA9F9] 1083 | | [\uAA29-\uAA36] 1084 | | [\uAA43] 1085 | | [\uAA4C-\uAA4D] 1086 | | [\uAA50-\uAA59] 1087 | | [\uAA7B-\uAA7D] 1088 | | [\uAAB0] 1089 | | [\uAAB2-\uAAB4] 1090 | | [\uAAB7-\uAAB8] 1091 | | [\uAABE-\uAABF] 1092 | | [\uAAC1] 1093 | | [\uAAEB-\uAAEF] 1094 | | [\uAAF5-\uAAF6] 1095 | | [\uABE3-\uABEA] 1096 | | [\uABEC-\uABED] 1097 | | [\uABF0-\uABF9] 1098 | | [\uFB1E] 1099 | | [\uFE00-\uFE0F] 1100 | | [\uFE20-\uFE2F] 1101 | | [\uFEFF] 1102 | | [\uFF10-\uFF19] 1103 | | [\uFFF9-\uFFFB] 1104 | ; 1105 | 1106 | // 1107 | // Additional symbols not defined in the lexical specification 1108 | // 1109 | 1110 | AT : '@'; 1111 | ELLIPSIS : '...'; 1112 | 1113 | // 1114 | // Whitespace and comments 1115 | // 1116 | 1117 | WS : [ \t\r\n\u000C]+ -> skip 1118 | ; 1119 | 1120 | COMMENT 1121 | : '/*' .*? '*/' -> skip 1122 | ; 1123 | 1124 | LINE_COMMENT 1125 | : '//' ~[\r\n]* -> skip 1126 | ; 1127 | -------------------------------------------------------------------------------- /Test/Test.Shared/Grammars/SQLiteLexer.g4: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2020 by Martin Mirchev 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and 7 | * associated documentation files (the "Software"), to deal in the Software without restriction, 8 | * including without limitation the rights to use, copy, modify, merge, publish, distribute, 9 | * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all copies or 13 | * substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT 16 | * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 17 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 18 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | * 21 | * Project : sqlite-parser; an ANTLR4 grammar for SQLite https://github.com/bkiers/sqlite-parser 22 | * Developed by : Bart Kiers, bart@big-o.nl 23 | */ 24 | 25 | // $antlr-format alignTrailingComments on, columnLimit 150, maxEmptyLinesToKeep 1, reflowComments off, useTab off 26 | // $antlr-format allowShortRulesOnASingleLine on, alignSemicolons ownLine 27 | 28 | lexer grammar SQLiteLexer; 29 | 30 | SCOL: ';'; 31 | DOT: '.'; 32 | OPEN_PAR: '('; 33 | CLOSE_PAR: ')'; 34 | COMMA: ','; 35 | ASSIGN: '='; 36 | STAR: '*'; 37 | PLUS: '+'; 38 | MINUS: '-'; 39 | TILDE: '~'; 40 | PIPE2: '||'; 41 | DIV: '/'; 42 | MOD: '%'; 43 | LT2: '<<'; 44 | GT2: '>>'; 45 | AMP: '&'; 46 | PIPE: '|'; 47 | LT: '<'; 48 | LT_EQ: '<='; 49 | GT: '>'; 50 | GT_EQ: '>='; 51 | EQ: '=='; 52 | NOT_EQ1: '!='; 53 | NOT_EQ2: '<>'; 54 | 55 | // http://www.sqlite.org/lang_keywords.html 56 | ABORT_: A B O R T; 57 | ACTION_: A C T I O N; 58 | ADD_: A D D; 59 | AFTER_: A F T E R; 60 | ALL_: A L L; 61 | ALTER_: A L T E R; 62 | ANALYZE_: A N A L Y Z E; 63 | AND_: A N D; 64 | AS_: A S; 65 | ASC_: A S C; 66 | ATTACH_: A T T A C H; 67 | AUTOINCREMENT_: A U T O I N C R E M E N T; 68 | BEFORE_: B E F O R E; 69 | BEGIN_: B E G I N; 70 | BETWEEN_: B E T W E E N; 71 | BY_: B Y; 72 | CASCADE_: C A S C A D E; 73 | CASE_: C A S E; 74 | CAST_: C A S T; 75 | CHECK_: C H E C K; 76 | COLLATE_: C O L L A T E; 77 | COLUMN_: C O L U M N; 78 | COMMIT_: C O M M I T; 79 | CONFLICT_: C O N F L I C T; 80 | CONSTRAINT_: C O N S T R A I N T; 81 | CREATE_: C R E A T E; 82 | CROSS_: C R O S S; 83 | CURRENT_DATE_: C U R R E N T '_' D A T E; 84 | CURRENT_TIME_: C U R R E N T '_' T I M E; 85 | CURRENT_TIMESTAMP_: C U R R E N T '_' T I M E S T A M P; 86 | DATABASE_: D A T A B A S E; 87 | DEFAULT_: D E F A U L T; 88 | DEFERRABLE_: D E F E R R A B L E; 89 | DEFERRED_: D E F E R R E D; 90 | DELETE_: D E L E T E; 91 | DESC_: D E S C; 92 | DETACH_: D E T A C H; 93 | DISTINCT_: D I S T I N C T; 94 | DROP_: D R O P; 95 | EACH_: E A C H; 96 | ELSE_: E L S E; 97 | END_: E N D; 98 | ESCAPE_: E S C A P E; 99 | EXCEPT_: E X C E P T; 100 | EXCLUSIVE_: E X C L U S I V E; 101 | EXISTS_: E X I S T S; 102 | EXPLAIN_: E X P L A I N; 103 | FAIL_: F A I L; 104 | FOR_: F O R; 105 | FOREIGN_: F O R E I G N; 106 | FROM_: F R O M; 107 | FULL_: F U L L; 108 | GLOB_: G L O B; 109 | GROUP_: G R O U P; 110 | HAVING_: H A V I N G; 111 | IF_: I F; 112 | IGNORE_: I G N O R E; 113 | IMMEDIATE_: I M M E D I A T E; 114 | IN_: I N; 115 | INDEX_: I N D E X; 116 | INDEXED_: I N D E X E D; 117 | INITIALLY_: I N I T I A L L Y; 118 | INNER_: I N N E R; 119 | INSERT_: I N S E R T; 120 | INSTEAD_: I N S T E A D; 121 | INTERSECT_: I N T E R S E C T; 122 | INTO_: I N T O; 123 | IS_: I S; 124 | ISNULL_: I S N U L L; 125 | JOIN_: J O I N; 126 | KEY_: K E Y; 127 | LEFT_: L E F T; 128 | LIKE_: L I K E; 129 | LIMIT_: L I M I T; 130 | MATCH_: M A T C H; 131 | NATURAL_: N A T U R A L; 132 | NO_: N O; 133 | NOT_: N O T; 134 | NOTNULL_: N O T N U L L; 135 | NULL_: N U L L; 136 | OF_: O F; 137 | OFFSET_: O F F S E T; 138 | ON_: O N; 139 | OR_: O R; 140 | ORDER_: O R D E R; 141 | OUTER_: O U T E R; 142 | PLAN_: P L A N; 143 | PRAGMA_: P R A G M A; 144 | PRIMARY_: P R I M A R Y; 145 | QUERY_: Q U E R Y; 146 | RAISE_: R A I S E; 147 | RECURSIVE_: R E C U R S I V E; 148 | REFERENCES_: R E F E R E N C E S; 149 | REGEXP_: R E G E X P; 150 | REINDEX_: R E I N D E X; 151 | RELEASE_: R E L E A S E; 152 | RENAME_: R E N A M E; 153 | REPLACE_: R E P L A C E; 154 | RESTRICT_: R E S T R I C T; 155 | RIGHT_: R I G H T; 156 | ROLLBACK_: R O L L B A C K; 157 | ROW_: R O W; 158 | ROWS_: R O W S; 159 | SAVEPOINT_: S A V E P O I N T; 160 | SELECT_: S E L E C T; 161 | SET_: S E T; 162 | TABLE_: T A B L E; 163 | TEMP_: T E M P; 164 | TEMPORARY_: T E M P O R A R Y; 165 | THEN_: T H E N; 166 | TO_: T O; 167 | TRANSACTION_: T R A N S A C T I O N; 168 | TRIGGER_: T R I G G E R; 169 | UNION_: U N I O N; 170 | UNIQUE_: U N I Q U E; 171 | UPDATE_: U P D A T E; 172 | USING_: U S I N G; 173 | VACUUM_: V A C U U M; 174 | VALUES_: V A L U E S; 175 | VIEW_: V I E W; 176 | VIRTUAL_: V I R T U A L; 177 | WHEN_: W H E N; 178 | WHERE_: W H E R E; 179 | WITH_: W I T H; 180 | WITHOUT_: W I T H O U T; 181 | FIRST_VALUE_: F I R S T '_' V A L U E; 182 | OVER_: O V E R; 183 | PARTITION_: P A R T I T I O N; 184 | RANGE_: R A N G E; 185 | PRECEDING_: P R E C E D I N G; 186 | UNBOUNDED_: U N B O U N D E D; 187 | CURRENT_: C U R R E N T; 188 | FOLLOWING_: F O L L O W I N G; 189 | CUME_DIST_: C U M E '_' D I S T; 190 | DENSE_RANK_: D E N S E '_' R A N K; 191 | LAG_: L A G; 192 | LAST_VALUE_: L A S T '_' V A L U E; 193 | LEAD_: L E A D; 194 | NTH_VALUE_: N T H '_' V A L U E; 195 | NTILE_: N T I L E; 196 | PERCENT_RANK_: P E R C E N T '_' R A N K; 197 | RANK_: R A N K; 198 | ROW_NUMBER_: R O W '_' N U M B E R; 199 | GENERATED_: G E N E R A T E D; 200 | ALWAYS_: A L W A Y S; 201 | STORED_: S T O R E D; 202 | TRUE_: T R U E; 203 | FALSE_: F A L S E; 204 | WINDOW_: W I N D O W; 205 | NULLS_: N U L L S; 206 | FIRST_: F I R S T; 207 | LAST_: L A S T; 208 | FILTER_: F I L T E R; 209 | GROUPS_: G R O U P S; 210 | EXCLUDE_: E X C L U D E; 211 | TIES_: T I E S; 212 | OTHERS_: O T H E R S; 213 | DO_: D O; 214 | NOTHING_: N O T H I N G; 215 | 216 | IDENTIFIER: 217 | '"' (~'"' | '""')* '"' 218 | | '`' (~'`' | '``')* '`' 219 | | '[' ~']'* ']' 220 | | [a-zA-Z_] [a-zA-Z_0-9]* 221 | ; // TODO check: needs more chars in set 222 | 223 | NUMERIC_LITERAL: ((DIGIT+ ('.' DIGIT*)?) | ('.' DIGIT+)) (E [-+]? DIGIT+)? | '0x' HEX_DIGIT+; 224 | 225 | BIND_PARAMETER: '?' DIGIT* | [:@$] IDENTIFIER; 226 | 227 | STRING_LITERAL: '\'' ( ~'\'' | '\'\'')* '\''; 228 | 229 | BLOB_LITERAL: X STRING_LITERAL; 230 | 231 | SINGLE_LINE_COMMENT: '--' ~[\r\n]* (('\r'? '\n') | EOF) -> channel(HIDDEN); 232 | 233 | MULTILINE_COMMENT: '/*' .*? '*/' -> channel(HIDDEN); 234 | 235 | SPACES: [ \u000B\t\r\n] -> channel(HIDDEN); 236 | 237 | UNEXPECTED_CHAR: .; 238 | 239 | fragment HEX_DIGIT: [0-9a-fA-F]; 240 | fragment DIGIT: [0-9]; 241 | 242 | fragment A: [aA]; 243 | fragment B: [bB]; 244 | fragment C: [cC]; 245 | fragment D: [dD]; 246 | fragment E: [eE]; 247 | fragment F: [fF]; 248 | fragment G: [gG]; 249 | fragment H: [hH]; 250 | fragment I: [iI]; 251 | fragment J: [jJ]; 252 | fragment K: [kK]; 253 | fragment L: [lL]; 254 | fragment M: [mM]; 255 | fragment N: [nN]; 256 | fragment O: [oO]; 257 | fragment P: [pP]; 258 | fragment Q: [qQ]; 259 | fragment R: [rR]; 260 | fragment S: [sS]; 261 | fragment T: [tT]; 262 | fragment U: [uU]; 263 | fragment V: [vV]; 264 | fragment W: [wW]; 265 | fragment X: [xX]; 266 | fragment Y: [yY]; 267 | fragment Z: [zZ]; 268 | -------------------------------------------------------------------------------- /Test/Test.Shared/Grammars/SQLiteParser.g4: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2014 by Bart Kiers 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and 7 | * associated documentation files (the "Software"), to deal in the Software without restriction, 8 | * including without limitation the rights to use, copy, modify, merge, publish, distribute, 9 | * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all copies or 13 | * substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT 16 | * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 17 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 18 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | * 21 | * Project : sqlite-parser; an ANTLR4 grammar for SQLite https://github.com/bkiers/sqlite-parser 22 | * Developed by: 23 | * Bart Kiers, bart@big-o.nl 24 | * Martin Mirchev, marti_2203@abv.bg 25 | * Mike Lische, mike@lischke-online.de 26 | */ 27 | 28 | // $antlr-format alignTrailingComments on, columnLimit 130, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments off 29 | // $antlr-format useTab off, allowShortRulesOnASingleLine off, allowShortBlocksOnASingleLine on, alignSemicolons ownLine 30 | 31 | parser grammar SQLiteParser; 32 | 33 | options { 34 | tokenVocab = SQLiteLexer; 35 | } 36 | 37 | parse: (sql_stmt_list)* EOF 38 | ; 39 | 40 | sql_stmt_list: 41 | SCOL* sql_stmt (SCOL+ sql_stmt)* SCOL* 42 | ; 43 | 44 | sql_stmt: (EXPLAIN_ (QUERY_ PLAN_)?)? ( 45 | alter_table_stmt 46 | | analyze_stmt 47 | | attach_stmt 48 | | begin_stmt 49 | | commit_stmt 50 | | create_index_stmt 51 | | create_table_stmt 52 | | create_trigger_stmt 53 | | create_view_stmt 54 | | create_virtual_table_stmt 55 | | delete_stmt 56 | | delete_stmt_limited 57 | | detach_stmt 58 | | drop_stmt 59 | | insert_stmt 60 | | pragma_stmt 61 | | reindex_stmt 62 | | release_stmt 63 | | rollback_stmt 64 | | savepoint_stmt 65 | | select_stmt 66 | | update_stmt 67 | | update_stmt_limited 68 | | vacuum_stmt 69 | ) 70 | ; 71 | 72 | alter_table_stmt: 73 | ALTER_ TABLE_ (schema_name DOT)? table_name ( 74 | RENAME_ ( 75 | TO_ new_table_name 76 | | COLUMN_? old_column_name = column_name TO_ new_column_name = column_name 77 | ) 78 | | ADD_ COLUMN_? column_def 79 | ) 80 | ; 81 | 82 | analyze_stmt: 83 | ANALYZE_ (schema_name | (schema_name DOT)? table_or_index_name)? 84 | ; 85 | 86 | attach_stmt: 87 | ATTACH_ DATABASE_? expr AS_ schema_name 88 | ; 89 | 90 | begin_stmt: 91 | BEGIN_ (DEFERRED_ | IMMEDIATE_ | EXCLUSIVE_)? ( 92 | TRANSACTION_ transaction_name? 93 | )? 94 | ; 95 | 96 | commit_stmt: (COMMIT_ | END_) TRANSACTION_? 97 | ; 98 | 99 | rollback_stmt: 100 | ROLLBACK_ TRANSACTION_? (TO_ SAVEPOINT_? savepoint_name)? 101 | ; 102 | 103 | savepoint_stmt: 104 | SAVEPOINT_ savepoint_name 105 | ; 106 | 107 | release_stmt: 108 | RELEASE_ SAVEPOINT_? savepoint_name 109 | ; 110 | 111 | create_index_stmt: 112 | CREATE_ UNIQUE_? INDEX_ (IF_ NOT_ EXISTS_)? (schema_name DOT)? index_name ON_ table_name OPEN_PAR 113 | indexed_column (COMMA indexed_column)* CLOSE_PAR (WHERE_ expr)? 114 | ; 115 | 116 | indexed_column: (column_name | expr) (COLLATE_ collation_name)? asc_desc? 117 | ; 118 | 119 | create_table_stmt: 120 | CREATE_ (TEMP_ | TEMPORARY_)? TABLE_ (IF_ NOT_ EXISTS_)? ( 121 | schema_name DOT 122 | )? table_name ( 123 | OPEN_PAR column_def (COMMA column_def)*? (COMMA table_constraint)* CLOSE_PAR ( 124 | WITHOUT_ row_ROW_ID = IDENTIFIER 125 | )? 126 | | AS_ select_stmt 127 | ) 128 | ; 129 | 130 | column_def: 131 | column_name type_name? column_constraint* 132 | ; 133 | 134 | type_name: 135 | name+? ( 136 | OPEN_PAR signed_number CLOSE_PAR 137 | | OPEN_PAR signed_number COMMA signed_number CLOSE_PAR 138 | )? 139 | ; 140 | 141 | column_constraint: (CONSTRAINT_ name)? ( 142 | (PRIMARY_ KEY_ asc_desc? conflict_clause? AUTOINCREMENT_?) 143 | | (NOT_ NULL_ | UNIQUE_) conflict_clause? 144 | | CHECK_ OPEN_PAR expr CLOSE_PAR 145 | | DEFAULT_ (signed_number | literal_value | OPEN_PAR expr CLOSE_PAR) 146 | | COLLATE_ collation_name 147 | | foreign_key_clause 148 | | (GENERATED_ ALWAYS_)? AS_ OPEN_PAR expr CLOSE_PAR ( 149 | STORED_ 150 | | VIRTUAL_ 151 | )? 152 | ) 153 | ; 154 | 155 | signed_number: (PLUS | MINUS)? NUMERIC_LITERAL 156 | ; 157 | 158 | table_constraint: (CONSTRAINT_ name)? ( 159 | (PRIMARY_ KEY_ | UNIQUE_) OPEN_PAR indexed_column ( 160 | COMMA indexed_column 161 | )* CLOSE_PAR conflict_clause? 162 | | CHECK_ OPEN_PAR expr CLOSE_PAR 163 | | FOREIGN_ KEY_ OPEN_PAR column_name (COMMA column_name)* CLOSE_PAR foreign_key_clause 164 | ) 165 | ; 166 | 167 | foreign_key_clause: 168 | REFERENCES_ foreign_table ( 169 | OPEN_PAR column_name (COMMA column_name)* CLOSE_PAR 170 | )? ( 171 | ON_ (DELETE_ | UPDATE_) ( 172 | SET_ (NULL_ | DEFAULT_) 173 | | CASCADE_ 174 | | RESTRICT_ 175 | | NO_ ACTION_ 176 | ) 177 | | MATCH_ name 178 | )* (NOT_? DEFERRABLE_ (INITIALLY_ (DEFERRED_ | IMMEDIATE_))?)? 179 | ; 180 | 181 | conflict_clause: 182 | ON_ CONFLICT_ ( 183 | ROLLBACK_ 184 | | ABORT_ 185 | | FAIL_ 186 | | IGNORE_ 187 | | REPLACE_ 188 | ) 189 | ; 190 | 191 | create_trigger_stmt: 192 | CREATE_ (TEMP_ | TEMPORARY_)? TRIGGER_ (IF_ NOT_ EXISTS_)? ( 193 | schema_name DOT 194 | )? trigger_name (BEFORE_ | AFTER_ | INSTEAD_ OF_)? ( 195 | DELETE_ 196 | | INSERT_ 197 | | UPDATE_ (OF_ column_name ( COMMA column_name)*)? 198 | ) ON_ table_name (FOR_ EACH_ ROW_)? (WHEN_ expr)? BEGIN_ ( 199 | (update_stmt | insert_stmt | delete_stmt | select_stmt) SCOL 200 | )+ END_ 201 | ; 202 | 203 | create_view_stmt: 204 | CREATE_ (TEMP_ | TEMPORARY_)? VIEW_ (IF_ NOT_ EXISTS_)? ( 205 | schema_name DOT 206 | )? view_name (OPEN_PAR column_name (COMMA column_name)* CLOSE_PAR)? AS_ select_stmt 207 | ; 208 | 209 | create_virtual_table_stmt: 210 | CREATE_ VIRTUAL_ TABLE_ (IF_ NOT_ EXISTS_)? (schema_name DOT)? table_name USING_ module_name ( 211 | OPEN_PAR module_argument (COMMA module_argument)* CLOSE_PAR 212 | )? 213 | ; 214 | 215 | with_clause: 216 | WITH_ RECURSIVE_? cte_table_name AS_ OPEN_PAR select_stmt CLOSE_PAR ( 217 | COMMA cte_table_name AS_ OPEN_PAR select_stmt CLOSE_PAR 218 | )* 219 | ; 220 | 221 | cte_table_name: 222 | table_name (OPEN_PAR column_name ( COMMA column_name)* CLOSE_PAR)? 223 | ; 224 | 225 | recursive_cte: 226 | cte_table_name AS_ OPEN_PAR initial_select UNION_ ALL_? recursive__select CLOSE_PAR 227 | ; 228 | 229 | common_table_expression: 230 | table_name (OPEN_PAR column_name ( COMMA column_name)* CLOSE_PAR)? AS_ OPEN_PAR select_stmt CLOSE_PAR 231 | ; 232 | 233 | delete_stmt: 234 | with_clause? DELETE_ FROM_ qualified_table_name (WHERE_ expr)? 235 | ; 236 | 237 | delete_stmt_limited: 238 | with_clause? DELETE_ FROM_ qualified_table_name (WHERE_ expr)? ( 239 | order_by_stmt? limit_stmt 240 | )? 241 | ; 242 | 243 | detach_stmt: 244 | DETACH_ DATABASE_? schema_name 245 | ; 246 | 247 | drop_stmt: 248 | DROP_ object = (INDEX_ | TABLE_ | TRIGGER_ | VIEW_) ( 249 | IF_ EXISTS_ 250 | )? (schema_name DOT)? any_name 251 | ; 252 | 253 | /* 254 | SQLite understands the following binary operators, in order from highest to lowest precedence: 255 | || 256 | * / % 257 | + - 258 | << >> & | 259 | < <= > >= 260 | = == != <> IS IS NOT IN LIKE GLOB MATCH REGEXP 261 | AND 262 | OR 263 | */ 264 | expr: 265 | literal_value 266 | | BIND_PARAMETER 267 | | ((schema_name DOT)? table_name DOT)? column_name 268 | | unary_operator expr 269 | | expr PIPE2 expr 270 | | expr ( STAR | DIV | MOD) expr 271 | | expr ( PLUS | MINUS) expr 272 | | expr ( LT2 | GT2 | AMP | PIPE) expr 273 | | expr ( LT | LT_EQ | GT | GT_EQ) expr 274 | | expr ( 275 | ASSIGN 276 | | EQ 277 | | NOT_EQ1 278 | | NOT_EQ2 279 | | IS_ 280 | | IS_ NOT_ 281 | | IN_ 282 | | LIKE_ 283 | | GLOB_ 284 | | MATCH_ 285 | | REGEXP_ 286 | ) expr 287 | | expr AND_ expr 288 | | expr OR_ expr 289 | | function_name OPEN_PAR ((DISTINCT_? expr ( COMMA expr)*) | STAR)? CLOSE_PAR filter_clause? over_clause? 290 | | OPEN_PAR expr (COMMA expr)* CLOSE_PAR 291 | | CAST_ OPEN_PAR expr AS_ type_name CLOSE_PAR 292 | | expr COLLATE_ collation_name 293 | | expr NOT_? (LIKE_ | GLOB_ | REGEXP_ | MATCH_) expr ( 294 | ESCAPE_ expr 295 | )? 296 | | expr ( ISNULL_ | NOTNULL_ | NOT_ NULL_) 297 | | expr IS_ NOT_? expr 298 | | expr NOT_? BETWEEN_ expr AND_ expr 299 | | expr NOT_? IN_ ( 300 | OPEN_PAR (select_stmt | expr ( COMMA expr)*)? CLOSE_PAR 301 | | ( schema_name DOT)? table_name 302 | | (schema_name DOT)? table_function_name OPEN_PAR (expr (COMMA expr)*)? CLOSE_PAR 303 | ) 304 | | ((NOT_)? EXISTS_)? OPEN_PAR select_stmt CLOSE_PAR 305 | | CASE_ expr? (WHEN_ expr THEN_ expr)+ (ELSE_ expr)? END_ 306 | | raise_function 307 | ; 308 | 309 | raise_function: 310 | RAISE_ OPEN_PAR ( 311 | IGNORE_ 312 | | (ROLLBACK_ | ABORT_ | FAIL_) COMMA error_message 313 | ) CLOSE_PAR 314 | ; 315 | 316 | literal_value: 317 | NUMERIC_LITERAL 318 | | STRING_LITERAL 319 | | BLOB_LITERAL 320 | | NULL_ 321 | | TRUE_ 322 | | FALSE_ 323 | | CURRENT_TIME_ 324 | | CURRENT_DATE_ 325 | | CURRENT_TIMESTAMP_ 326 | ; 327 | 328 | insert_stmt: 329 | with_clause? ( 330 | INSERT_ 331 | | REPLACE_ 332 | | INSERT_ OR_ ( 333 | REPLACE_ 334 | | ROLLBACK_ 335 | | ABORT_ 336 | | FAIL_ 337 | | IGNORE_ 338 | ) 339 | ) INTO_ (schema_name DOT)? table_name (AS_ table_alias)? ( 340 | OPEN_PAR column_name ( COMMA column_name)* CLOSE_PAR 341 | )? ( 342 | ( 343 | VALUES_ OPEN_PAR expr (COMMA expr)* CLOSE_PAR ( 344 | COMMA OPEN_PAR expr ( COMMA expr)* CLOSE_PAR 345 | )* 346 | | select_stmt 347 | ) upsert_clause? 348 | ) 349 | | DEFAULT_ VALUES_ 350 | ; 351 | 352 | upsert_clause: 353 | ON_ CONFLICT_ ( 354 | OPEN_PAR indexed_column (COMMA indexed_column)* CLOSE_PAR (WHERE_ expr)? 355 | )? DO_ ( 356 | NOTHING_ 357 | | UPDATE_ SET_ ( 358 | (column_name | column_name_list) EQ expr ( 359 | COMMA (column_name | column_name_list) EQ expr 360 | )* (WHERE_ expr)? 361 | ) 362 | ) 363 | ; 364 | 365 | pragma_stmt: 366 | PRAGMA_ (schema_name DOT)? pragma_name ( 367 | ASSIGN pragma_value 368 | | OPEN_PAR pragma_value CLOSE_PAR 369 | )? 370 | ; 371 | 372 | pragma_value: 373 | signed_number 374 | | name 375 | | STRING_LITERAL 376 | ; 377 | 378 | reindex_stmt: 379 | REINDEX_ (collation_name | (schema_name DOT)? (table_name | index_name))? 380 | ; 381 | 382 | select_stmt: 383 | common_table_stmt? select_core (compound_operator select_core)* order_by_stmt? limit_stmt? 384 | ; 385 | 386 | join_clause: 387 | table_or_subquery (join_operator table_or_subquery join_constraint?)* 388 | ; 389 | 390 | select_core: 391 | ( 392 | SELECT_ (DISTINCT_ | ALL_)? result_column (COMMA result_column)* ( 393 | FROM_ (table_or_subquery (COMMA table_or_subquery)* | join_clause) 394 | )? (WHERE_ expr)? (GROUP_ BY_ expr (COMMA expr)* (HAVING_ expr)?)? ( 395 | WINDOW_ window_name AS_ window_defn ( 396 | COMMA window_name AS_ window_defn 397 | )* 398 | )? 399 | ) 400 | | VALUES_ OPEN_PAR expr (COMMA expr)* CLOSE_PAR ( 401 | COMMA OPEN_PAR expr ( COMMA expr)* CLOSE_PAR 402 | )* 403 | ; 404 | 405 | factored_select_stmt: 406 | select_stmt 407 | ; 408 | 409 | simple_select_stmt: 410 | common_table_stmt? select_core order_by_stmt? limit_stmt? 411 | ; 412 | 413 | compound_select_stmt: 414 | common_table_stmt? select_core ( 415 | (UNION_ ALL_? | INTERSECT_ | EXCEPT_) select_core 416 | )+ order_by_stmt? limit_stmt? 417 | ; 418 | 419 | table_or_subquery: ( 420 | (schema_name DOT)? table_name (AS_? table_alias)? ( 421 | INDEXED_ BY_ index_name 422 | | NOT_ INDEXED_ 423 | )? 424 | ) 425 | | (schema_name DOT)? table_function_name OPEN_PAR expr (COMMA expr)* CLOSE_PAR ( 426 | AS_? table_alias 427 | )? 428 | | OPEN_PAR (table_or_subquery (COMMA table_or_subquery)* | join_clause) CLOSE_PAR 429 | | OPEN_PAR select_stmt CLOSE_PAR (AS_? table_alias)? 430 | ; 431 | 432 | result_column: 433 | STAR 434 | | table_name DOT STAR 435 | | expr ( AS_? column_alias)? 436 | ; 437 | 438 | join_operator: 439 | COMMA 440 | | NATURAL_? (LEFT_ OUTER_? | INNER_ | CROSS_)? JOIN_ 441 | ; 442 | 443 | join_constraint: 444 | ON_ expr 445 | | USING_ OPEN_PAR column_name ( COMMA column_name)* CLOSE_PAR 446 | ; 447 | 448 | compound_operator: 449 | UNION_ ALL_? 450 | | INTERSECT_ 451 | | EXCEPT_ 452 | ; 453 | 454 | update_stmt: 455 | with_clause? UPDATE_ ( 456 | OR_ (ROLLBACK_ | ABORT_ | REPLACE_ | FAIL_ | IGNORE_) 457 | )? qualified_table_name SET_ (column_name | column_name_list) ASSIGN expr ( 458 | COMMA (column_name | column_name_list) ASSIGN expr 459 | )* (WHERE_ expr)? 460 | ; 461 | 462 | column_name_list: 463 | OPEN_PAR column_name (COMMA column_name)* CLOSE_PAR 464 | ; 465 | 466 | update_stmt_limited: 467 | with_clause? UPDATE_ ( 468 | OR_ (ROLLBACK_ | ABORT_ | REPLACE_ | FAIL_ | IGNORE_) 469 | )? qualified_table_name SET_ (column_name | column_name_list) ASSIGN expr ( 470 | COMMA (column_name | column_name_list) ASSIGN expr 471 | )* (WHERE_ expr)? (order_by_stmt? limit_stmt)? 472 | ; 473 | 474 | qualified_table_name: (schema_name DOT)? table_name (AS_ alias)? ( 475 | INDEXED_ BY_ index_name 476 | | NOT_ INDEXED_ 477 | )? 478 | ; 479 | 480 | vacuum_stmt: 481 | VACUUM_ schema_name? (INTO_ filename)? 482 | ; 483 | 484 | filter_clause: 485 | FILTER_ OPEN_PAR WHERE_ expr CLOSE_PAR 486 | ; 487 | 488 | window_defn: 489 | OPEN_PAR base_window_name? (PARTITION_ BY_ expr (COMMA expr)*)? ( 490 | ORDER_ BY_ ordering_term (COMMA ordering_term)* 491 | ) frame_spec? CLOSE_PAR 492 | ; 493 | 494 | over_clause: 495 | OVER_ ( 496 | window_name 497 | | OPEN_PAR base_window_name? (PARTITION_ BY_ expr (COMMA expr)*)? ( 498 | ORDER_ BY_ ordering_term (COMMA ordering_term)* 499 | )? frame_spec? CLOSE_PAR 500 | ) 501 | ; 502 | 503 | frame_spec: 504 | frame_clause ( 505 | EXCLUDE_ (NO_ OTHERS_) 506 | | CURRENT_ ROW_ 507 | | GROUP_ 508 | | TIES_ 509 | )? 510 | ; 511 | 512 | frame_clause: (RANGE_ | ROWS_ | GROUPS_) ( 513 | frame_single 514 | | BETWEEN_ frame_left AND_ frame_right 515 | ) 516 | ; 517 | 518 | simple_function_invocation: 519 | simple_func OPEN_PAR (expr (COMMA expr)* | STAR) CLOSE_PAR 520 | ; 521 | 522 | aggregate_function_invocation: 523 | aggregate_func OPEN_PAR (DISTINCT_? expr (COMMA expr)* | STAR)? CLOSE_PAR filter_clause? 524 | ; 525 | 526 | window_function_invocation: 527 | window_function OPEN_PAR (expr (COMMA expr)* | STAR)? CLOSE_PAR filter_clause? OVER_ ( 528 | window_defn 529 | | window_name 530 | ) 531 | ; 532 | 533 | common_table_stmt: //additional structures 534 | WITH_ RECURSIVE_? common_table_expression (COMMA common_table_expression)* 535 | ; 536 | 537 | order_by_stmt: 538 | ORDER_ BY_ ordering_term (COMMA ordering_term)* 539 | ; 540 | 541 | limit_stmt: 542 | LIMIT_ expr ((OFFSET_ | COMMA) expr)? 543 | ; 544 | 545 | ordering_term: 546 | expr (COLLATE_ collation_name)? asc_desc? (NULLS_ (FIRST_ | LAST_))? 547 | ; 548 | 549 | asc_desc: 550 | ASC_ 551 | | DESC_ 552 | ; 553 | 554 | frame_left: 555 | expr PRECEDING_ 556 | | expr FOLLOWING_ 557 | | CURRENT_ ROW_ 558 | | UNBOUNDED_ PRECEDING_ 559 | ; 560 | 561 | frame_right: 562 | expr PRECEDING_ 563 | | expr FOLLOWING_ 564 | | CURRENT_ ROW_ 565 | | UNBOUNDED_ FOLLOWING_ 566 | ; 567 | 568 | frame_single: 569 | expr PRECEDING_ 570 | | UNBOUNDED_ PRECEDING_ 571 | | CURRENT_ ROW_ 572 | ; 573 | 574 | // unknown 575 | 576 | window_function: 577 | (FIRST_VALUE_ | LAST_VALUE_) OPEN_PAR expr CLOSE_PAR OVER_ OPEN_PAR partition_by? order_by_expr_asc_desc frame_clause 578 | ? CLOSE_PAR 579 | | (CUME_DIST_ | PERCENT_RANK_) OPEN_PAR CLOSE_PAR OVER_ OPEN_PAR partition_by? order_by_expr? CLOSE_PAR 580 | | (DENSE_RANK_ | RANK_ | ROW_NUMBER_) OPEN_PAR CLOSE_PAR OVER_ OPEN_PAR partition_by? order_by_expr_asc_desc 581 | CLOSE_PAR 582 | | (LAG_ | LEAD_) OPEN_PAR expr of_OF_fset? default_DEFAULT__value? CLOSE_PAR OVER_ OPEN_PAR partition_by? 583 | order_by_expr_asc_desc CLOSE_PAR 584 | | NTH_VALUE_ OPEN_PAR expr COMMA signed_number CLOSE_PAR OVER_ OPEN_PAR partition_by? order_by_expr_asc_desc 585 | frame_clause? CLOSE_PAR 586 | | NTILE_ OPEN_PAR expr CLOSE_PAR OVER_ OPEN_PAR partition_by? order_by_expr_asc_desc CLOSE_PAR 587 | ; 588 | 589 | of_OF_fset: 590 | COMMA signed_number 591 | ; 592 | 593 | default_DEFAULT__value: 594 | COMMA signed_number 595 | ; 596 | 597 | partition_by: 598 | PARTITION_ BY_ expr+ 599 | ; 600 | 601 | order_by_expr: 602 | ORDER_ BY_ expr+ 603 | ; 604 | 605 | order_by_expr_asc_desc: 606 | ORDER_ BY_ order_by_expr_asc_desc 607 | ; 608 | 609 | expr_asc_desc: 610 | expr asc_desc? (COMMA expr asc_desc?)* 611 | ; 612 | 613 | //TODO BOTH OF THESE HAVE TO BE REWORKED TO FOLLOW THE SPEC 614 | initial_select: 615 | select_stmt 616 | ; 617 | 618 | recursive__select: 619 | select_stmt 620 | ; 621 | 622 | unary_operator: 623 | MINUS 624 | | PLUS 625 | | TILDE 626 | | NOT_ 627 | ; 628 | 629 | error_message: 630 | STRING_LITERAL 631 | ; 632 | 633 | module_argument: // TODO check what exactly is permitted here 634 | expr 635 | | column_def 636 | ; 637 | 638 | column_alias: 639 | IDENTIFIER 640 | | STRING_LITERAL 641 | ; 642 | 643 | keyword: 644 | ABORT_ 645 | | ACTION_ 646 | | ADD_ 647 | | AFTER_ 648 | | ALL_ 649 | | ALTER_ 650 | | ANALYZE_ 651 | | AND_ 652 | | AS_ 653 | | ASC_ 654 | | ATTACH_ 655 | | AUTOINCREMENT_ 656 | | BEFORE_ 657 | | BEGIN_ 658 | | BETWEEN_ 659 | | BY_ 660 | | CASCADE_ 661 | | CASE_ 662 | | CAST_ 663 | | CHECK_ 664 | | COLLATE_ 665 | | COLUMN_ 666 | | COMMIT_ 667 | | CONFLICT_ 668 | | CONSTRAINT_ 669 | | CREATE_ 670 | | CROSS_ 671 | | CURRENT_DATE_ 672 | | CURRENT_TIME_ 673 | | CURRENT_TIMESTAMP_ 674 | | DATABASE_ 675 | | DEFAULT_ 676 | | DEFERRABLE_ 677 | | DEFERRED_ 678 | | DELETE_ 679 | | DESC_ 680 | | DETACH_ 681 | | DISTINCT_ 682 | | DROP_ 683 | | EACH_ 684 | | ELSE_ 685 | | END_ 686 | | ESCAPE_ 687 | | EXCEPT_ 688 | | EXCLUSIVE_ 689 | | EXISTS_ 690 | | EXPLAIN_ 691 | | FAIL_ 692 | | FOR_ 693 | | FOREIGN_ 694 | | FROM_ 695 | | FULL_ 696 | | GLOB_ 697 | | GROUP_ 698 | | HAVING_ 699 | | IF_ 700 | | IGNORE_ 701 | | IMMEDIATE_ 702 | | IN_ 703 | | INDEX_ 704 | | INDEXED_ 705 | | INITIALLY_ 706 | | INNER_ 707 | | INSERT_ 708 | | INSTEAD_ 709 | | INTERSECT_ 710 | | INTO_ 711 | | IS_ 712 | | ISNULL_ 713 | | JOIN_ 714 | | KEY_ 715 | | LEFT_ 716 | | LIKE_ 717 | | LIMIT_ 718 | | MATCH_ 719 | | NATURAL_ 720 | | NO_ 721 | | NOT_ 722 | | NOTNULL_ 723 | | NULL_ 724 | | OF_ 725 | | OFFSET_ 726 | | ON_ 727 | | OR_ 728 | | ORDER_ 729 | | OUTER_ 730 | | PLAN_ 731 | | PRAGMA_ 732 | | PRIMARY_ 733 | | QUERY_ 734 | | RAISE_ 735 | | RECURSIVE_ 736 | | REFERENCES_ 737 | | REGEXP_ 738 | | REINDEX_ 739 | | RELEASE_ 740 | | RENAME_ 741 | | REPLACE_ 742 | | RESTRICT_ 743 | | RIGHT_ 744 | | ROLLBACK_ 745 | | ROW_ 746 | | ROWS_ 747 | | SAVEPOINT_ 748 | | SELECT_ 749 | | SET_ 750 | | TABLE_ 751 | | TEMP_ 752 | | TEMPORARY_ 753 | | THEN_ 754 | | TO_ 755 | | TRANSACTION_ 756 | | TRIGGER_ 757 | | UNION_ 758 | | UNIQUE_ 759 | | UPDATE_ 760 | | USING_ 761 | | VACUUM_ 762 | | VALUES_ 763 | | VIEW_ 764 | | VIRTUAL_ 765 | | WHEN_ 766 | | WHERE_ 767 | | WITH_ 768 | | WITHOUT_ 769 | | FIRST_VALUE_ 770 | | OVER_ 771 | | PARTITION_ 772 | | RANGE_ 773 | | PRECEDING_ 774 | | UNBOUNDED_ 775 | | CURRENT_ 776 | | FOLLOWING_ 777 | | CUME_DIST_ 778 | | DENSE_RANK_ 779 | | LAG_ 780 | | LAST_VALUE_ 781 | | LEAD_ 782 | | NTH_VALUE_ 783 | | NTILE_ 784 | | PERCENT_RANK_ 785 | | RANK_ 786 | | ROW_NUMBER_ 787 | | GENERATED_ 788 | | ALWAYS_ 789 | | STORED_ 790 | | TRUE_ 791 | | FALSE_ 792 | | WINDOW_ 793 | | NULLS_ 794 | | FIRST_ 795 | | LAST_ 796 | | FILTER_ 797 | | GROUPS_ 798 | | EXCLUDE_ 799 | ; 800 | 801 | // TODO: check all names below 802 | 803 | name: 804 | any_name 805 | ; 806 | 807 | function_name: 808 | any_name 809 | ; 810 | 811 | schema_name: 812 | any_name 813 | ; 814 | 815 | table_name: 816 | any_name 817 | ; 818 | 819 | table_or_index_name: 820 | any_name 821 | ; 822 | 823 | new_table_name: 824 | any_name 825 | ; 826 | 827 | column_name: 828 | any_name 829 | ; 830 | 831 | collation_name: 832 | any_name 833 | ; 834 | 835 | foreign_table: 836 | any_name 837 | ; 838 | 839 | index_name: 840 | any_name 841 | ; 842 | 843 | trigger_name: 844 | any_name 845 | ; 846 | 847 | view_name: 848 | any_name 849 | ; 850 | 851 | module_name: 852 | any_name 853 | ; 854 | 855 | pragma_name: 856 | any_name 857 | ; 858 | 859 | savepoint_name: 860 | any_name 861 | ; 862 | 863 | table_alias: 864 | any_name 865 | ; 866 | 867 | transaction_name: 868 | any_name 869 | ; 870 | 871 | window_name: 872 | any_name 873 | ; 874 | 875 | alias: 876 | any_name 877 | ; 878 | 879 | filename: 880 | any_name 881 | ; 882 | 883 | base_window_name: 884 | any_name 885 | ; 886 | 887 | simple_func: 888 | any_name 889 | ; 890 | 891 | aggregate_func: 892 | any_name 893 | ; 894 | 895 | table_function_name: 896 | any_name 897 | ; 898 | 899 | any_name: 900 | IDENTIFIER 901 | | keyword 902 | | STRING_LITERAL 903 | | OPEN_PAR any_name CLOSE_PAR 904 | ; 905 | -------------------------------------------------------------------------------- /Test/Test.Shared/Test.Shared.projitems: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | $(MSBuildAllProjects);$(MSBuildThisFileFullPath) 5 | true 6 | ed8baf15-5b0b-4027-9b23-dd14b24739db 7 | 8 | 9 | Test.Shared 10 | 11 | 12 | 13 | Always 14 | 15 | 16 | Always 17 | 18 | 19 | 20 | 21 | Always 22 | 23 | 24 | Always 25 | 26 | 27 | Always 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /Test/Test.Shared/Test.Shared.shproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | ed8baf15-5b0b-4027-9b23-dd14b24739db 5 | 14.0 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /Test/Test.Shared/TestContainer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | using Xunit; 4 | using static ZSpitz.Util.Functions; 5 | using Antlr4.Runtime; 6 | using ZSpitz.Util; 7 | using Antlr4.Runtime.Tree; 8 | using ParseTreeVisualizer.Serialization; 9 | using static System.IO.File; 10 | 11 | namespace ParseTreeVisualizer.Test { 12 | public class TestContainer { 13 | public static readonly (string lexer, string parser, string rule) InvalidSelection = ( 14 | "Invalid lexer", 15 | "Invalid parser", 16 | "Invalid rule" 17 | ); 18 | 19 | public static readonly TheoryData TestData = IIFE(() => { 20 | var java = ( 21 | lexer: typeof(Java8Lexer), 22 | parser: typeof(Java8Parser), 23 | parseMethod: typeof(Java8Parser).GetMethod(nameof(Java8Parser.compilationUnit))! 24 | ); 25 | 26 | var filesLexersParsers = new[] { 27 | ( 28 | "WindowsFunctionsForSqLite.sql", 29 | typeof(SQLiteLexer), 30 | typeof(SQLiteParser), 31 | typeof(SQLiteParser).GetMethod(nameof(SQLiteParser.parse))! 32 | ), 33 | ( 34 | "Simple.java", 35 | java.lexer, 36 | java.parser, 37 | java.parseMethod 38 | ) 39 | }; 40 | 41 | var sources = filesLexersParsers.SelectManyT((filename, lexerType, parserType, parseMethod) => { 42 | var source = ReadAllText($"Files/{filename}"); 43 | var input = new AntlrInputStream(source); 44 | var lexer = lexerType.CreateInstance(new[] { input }); 45 | var tokens = new CommonTokenStream(lexer); 46 | var parser = parserType.CreateInstance(new[] { tokens }); 47 | var tree = (IParseTree)parseMethod.Invoke(parser, Array.Empty())!; 48 | return new object[] { 49 | source, tokens, tree 50 | }.Select(x => ( 51 | source: x, 52 | lexerName: lexerType.Name, 53 | parserName: parserType.Name, 54 | parseMethodName: parseMethod.Name 55 | )); 56 | }).ToList(); 57 | 58 | return sources.SelectManyT((source, lexerName, parserName, parseMethodName) => { 59 | var configs = Enumerable.Range(0, 5).Select(x => new Config()).ToArray(); 60 | configs.Skip(1).ForEach(x => x.SelectedLexerName = lexerName); 61 | configs.Skip(2).ForEach(x => x.SelectedParserName = parserName); 62 | configs.Skip(3).ForEach(x => x.ParseTokensWithRule = parseMethodName); 63 | 64 | var invalid = configs[3]; 65 | invalid.SelectedLexerName = InvalidSelection.lexer; 66 | invalid.SelectedParserName = InvalidSelection.parser; 67 | invalid.ParseTokensWithRule = InvalidSelection.rule; 68 | 69 | return configs.Select(config => (source, config)); 70 | }).ToTheoryData(); 71 | }); 72 | 73 | [Theory] 74 | [MemberData(nameof(TestData))] 75 | public void TestMethod(object source, Config config) { 76 | var vd = new VisualizerData(source, config); 77 | _ = new ConfigViewModel(vd); 78 | _ = new VisualizerDataViewModel(vd, null, null, null); 79 | 80 | if (config.SelectedLexerName == InvalidSelection.lexer) { 81 | Assert.NotEqual(InvalidSelection.lexer, vd.Config.SelectedLexerName); 82 | Assert.NotEqual(InvalidSelection.parser, vd.Config.SelectedParserName); 83 | Assert.NotEqual(InvalidSelection.rule, vd.Config.ParseTokensWithRule); 84 | } 85 | } 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /Test/Test.Standard/Test.Standard.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | net5.0-windows 5 | ParseTreeVisualizer.Test 6 | true 7 | false 8 | 9 | 10 | 11 | 12 | 13 | 14 | runtime; build; native; contentfiles; analyzers; buildtransitive 15 | all 16 | 17 | 18 | runtime; build; native; contentfiles; analyzers; buildtransitive 19 | all 20 | 21 | 22 | 23 | all 24 | 25 | 26 | 27 | 28 | 29 | false 30 | false 31 | ParseTreeVisualizer.Test 32 | 33 | 34 | 35 | false 36 | false 37 | ParseTreeVisualizer.Test 38 | 39 | 40 | 41 | false 42 | false 43 | ParseTreeVisualizer.Test 44 | 45 | 46 | 47 | false 48 | false 49 | ParseTreeVisualizer.Test 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | -------------------------------------------------------------------------------- /UI/Converters.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Globalization; 4 | using System.Linq; 5 | using static System.Windows.Media.Brushes; 6 | using System.Windows.Media; 7 | using System.Windows; 8 | using ZSpitz.Util; 9 | using ZSpitz.Util.Wpf; 10 | using ParseTreeVisualizer.Serialization; 11 | using static ParseTreeVisualizer.Serialization.TreeNodeType; 12 | 13 | namespace ParseTreeVisualizer { 14 | public class RootConverter : ReadOnlyConverterBase { 15 | public override object Convert(object value, Type targetType, object parameter, CultureInfo culture) => 16 | new[] { value }; 17 | } 18 | 19 | public class NullConverter : ReadOnlyConverterBase { 20 | public override object Convert(object value, Type targetType, object parameter, CultureInfo culture) { 21 | if (value != null) { return UnsetValue; } 22 | 23 | if (targetType == typeof(Brush)) { 24 | return DarkGray; 25 | } else if (targetType == typeof(FontStyle)) { 26 | return FontStyles.Italic; 27 | } 28 | throw new InvalidOperationException("Converter only valid for Brush and FontStyle."); 29 | } 30 | } 31 | 32 | public class ErrorColorConverter : ReadOnlyConverterBase { 33 | public override object Convert(object value, Type targetType, object parameter, CultureInfo culture) => 34 | ((bool)value) ? Red : UnsetValue; 35 | } 36 | 37 | public class NodeForegroundConverter : ReadOnlyMultiConverterBase { 38 | public override object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) => 39 | // values[0] should be TreeNodeType; values[1] should be a Serialization.FilterStates 40 | values is null ? throw new ArgumentNullException(nameof(values)) : 41 | values[0] == UnsetValue || values[1] == UnsetValue ? UnsetValue : 42 | (values[0], values[1]) switch { 43 | (RuleContext or TreeNodeType.Token, null or Serialization.FilterStates.Matched) => Black, 44 | (RuleContext or TreeNodeType.Token, _) => LightGray, 45 | (ErrorToken, _) => Red, 46 | (WhitespaceToken, _) => UnsetValue, 47 | (Placeholder, _) => DarkGray, 48 | _ => throw new InvalidOperationException("Unmatched node type / filter state combination.") 49 | }; 50 | } 51 | 52 | public class NodeFontWeightConverter : ReadOnlyConverterBase { 53 | public override object Convert(object value, Type targetType, object parameter, CultureInfo culture) => 54 | ((TreeNodeType)value) == RuleContext ? FontWeights.Bold : UnsetValue; 55 | } 56 | 57 | public class NonEmptyListConverter : ReadOnlyMultiConverterBase { 58 | public override object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) => 59 | values.OfType>().FirstOrDefault(x => x != null && x.Any()); 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /UI/Extensions.cs: -------------------------------------------------------------------------------- 1 | using ParseTreeVisualizer.Serialization; 2 | using System; 3 | using System.Collections.Generic; 4 | using ZSpitz.Util.Wpf; 5 | 6 | namespace ParseTreeVisualizer.UI { 7 | public static class Extensions { 8 | public static (int start, int end)? SelectionCharSpan(this IEnumerable> tokens) { 9 | int? startChar = null; 10 | int? endChar = null; 11 | 12 | // TODO replace with tokens.Aggregate? 13 | 14 | foreach (var vm in tokens) { 15 | var token = vm.Model; 16 | if (vm.IsSelected) { 17 | startChar = 18 | startChar == null ? 19 | token.Span.start : 20 | Math.Min(startChar.Value, token.Span.start); 21 | endChar = 22 | endChar == null ? 23 | token.Span.stop : 24 | Math.Max(endChar.Value, token.Span.stop); 25 | } 26 | } 27 | 28 | return 29 | startChar.HasValue && endChar.HasValue ? 30 | (startChar.Value, endChar.Value) : 31 | null; 32 | } 33 | 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /UI/ParserRuleDisplayNameSelector.cs: -------------------------------------------------------------------------------- 1 | using System.Windows; 2 | using System.Windows.Controls; 3 | using ParseTreeVisualizer.Serialization; 4 | 5 | namespace ParseTreeVisualizer { 6 | public class ParserRuleDisplayNameSelector : DataTemplateSelector { 7 | public DataTemplate? RuleNameTemplate { get; set; } 8 | public DataTemplate? TypeNameTemplate { get; set; } 9 | public override DataTemplate? SelectTemplate(object item, DependencyObject container) => 10 | (item as ClassInfo)?.RuleName == null ? 11 | TypeNameTemplate : 12 | RuleNameTemplate; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /UI/SettingsControl.xaml: -------------------------------------------------------------------------------- 1 |  4 | 5 | 6 | 12 | 15 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | Show text tokens 68 | Show .NET whitespace tokens 69 | Show errors 70 | 71 | 72 | 73 | 74 | 75 | 76 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | Show text tokens 97 | Show .NET whitespace tokens 98 | Show errors 99 | Show rule contexts 100 | 101 | 102 | 103 | 104 | 105 | 106 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | -------------------------------------------------------------------------------- /UI/SettingsControl.xaml.cs: -------------------------------------------------------------------------------- 1 | namespace ParseTreeVisualizer { 2 | public partial class SettingsControl { 3 | public SettingsControl() => InitializeComponent(); 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /UI/UI.projitems: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | $(MSBuildAllProjects);$(MSBuildThisFileFullPath) 5 | true 6 | e2b06997-76f1-48de-abe6-cf90427423bb 7 | 8 | 9 | UI 10 | 11 | 12 | 13 | 14 | 15 | 16 | SettingsControl.xaml 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | VisualizerControl.xaml 25 | 26 | 27 | 28 | 29 | MSBuild:Compile 30 | Designer 31 | 32 | 33 | MSBuild:Compile 34 | Designer 35 | 36 | 37 | -------------------------------------------------------------------------------- /UI/UI.shproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | e2b06997-76f1-48de-abe6-cf90427423bb 5 | 14.0 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /UI/ViewModels/ConfigViewModel.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Collections.ObjectModel; 3 | using System.Linq; 4 | using ZSpitz.Util.Wpf; 5 | using ParseTreeVisualizer.Serialization; 6 | using ZSpitz.Util; 7 | 8 | namespace ParseTreeVisualizer { 9 | public class ConfigViewModel : ViewModelBase { 10 | public ConfigViewModel(VisualizerData vd) : 11 | this(vd.Config, vd.TokenTypeMapping, vd.UsedRuleContexts, vd.AvailableLexers, vd.AvailableParsers, vd.CanSelectLexer, vd.CanSelectParser) { } 12 | 13 | public ConfigViewModel( 14 | Config config, 15 | Dictionary? tokenTypeMapping, 16 | List? ruleContexts, 17 | List lexers, 18 | List parsers, 19 | bool canSelectLexer, 20 | bool canSelectParser 21 | ) : base(config) { 22 | 23 | TokenTypes = tokenTypeMapping?.SelectKVP((index, text) => { 24 | var ret = new TokenTypeViewModel(index, text) { 25 | IsSelected = index.In(Model.SelectedTokenTypes) 26 | }; 27 | ret.PropertyChanged += (s, e) => { 28 | if (e.PropertyName == "IsSelected") { 29 | Model.SelectedTokenTypes.AddRemove(ret.IsSelected, ret.Index); 30 | } 31 | }; 32 | return ret; 33 | }).OrderBy(x => x.Text).ToList().AsReadOnly(); 34 | 35 | RuleContexts = ruleContexts?.Select(x => { 36 | var ret = new Selectable(x) { 37 | IsSelected = x.FullName.In(Model.SelectedRuleContexts) 38 | }; 39 | ret.PropertyChanged += (s, e) => { 40 | if (e.PropertyName == "IsSelected") { 41 | Model.SelectedRuleContexts.AddRemove(ret.IsSelected, x.FullName); 42 | } 43 | }; 44 | return ret; 45 | }).ToList().AsReadOnly(); 46 | 47 | AvailableLexers = getVMList(lexers); 48 | AvailableParsers = getVMList(parsers); 49 | CanSelectLexer = canSelectLexer; 50 | CanSelectParser = canSelectParser; 51 | } 52 | 53 | private ReadOnlyCollection getVMList(List models) { 54 | var lst = models.OrderBy(x => x.Name).ToList(); 55 | lst.Insert(0, ClassInfo.None); 56 | return lst.AsReadOnly(); 57 | } 58 | 59 | public ReadOnlyCollection? TokenTypes { get; } 60 | public ReadOnlyCollection>? RuleContexts { get; } 61 | public ReadOnlyCollection AvailableParsers { get; } 62 | public ReadOnlyCollection AvailableLexers { get; } 63 | 64 | public bool CanSelectLexer { get; private set; } 65 | public bool CanSelectParser { get; private set; } 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /UI/ViewModels/ParseTreeNodeViewModel.cs: -------------------------------------------------------------------------------- 1 | using ParseTreeVisualizer.Serialization; 2 | using System.Collections.ObjectModel; 3 | using System.Linq; 4 | using System.Windows.Input; 5 | using ZSpitz.Util; 6 | using ZSpitz.Util.Wpf; 7 | 8 | namespace ParseTreeVisualizer { 9 | public class ParseTreeNodeViewModel : Selectable { 10 | private static readonly RelayCommand subtreeExpand = new( 11 | prm => ((ParseTreeNodeViewModel)prm).SetSubtreeExpanded(true) 12 | ); 13 | private static readonly RelayCommand subtreeCollapse = new( 14 | prm => ((ParseTreeNodeViewModel)prm).SetSubtreeExpanded(false) 15 | ); 16 | 17 | public ParseTreeNodeViewModel( 18 | ParseTreeNode model, 19 | ICommand? openInNewWindow = null, 20 | RelayCommand? copyWatchExpression = null, 21 | RelayCommand? setAsRootNode = null 22 | ) : base(model) { 23 | Children = ( 24 | model?.Children.Select(x => new ParseTreeNodeViewModel(x,openInNewWindow, copyWatchExpression, setAsRootNode)) ?? 25 | Enumerable.Empty() 26 | ).ToList().AsReadOnly(); 27 | 28 | OpenInNewWindow = openInNewWindow; 29 | CopyWatchExpression = copyWatchExpression; 30 | SetAsRootNode = setAsRootNode; 31 | } 32 | 33 | public ReadOnlyCollection Children { get; } 34 | 35 | public void ClearSelection() { 36 | IsSelected = false; 37 | foreach (var child in Children) { 38 | child.ClearSelection(); 39 | } 40 | } 41 | 42 | private bool isExpanded; 43 | public bool IsExpanded { 44 | get => isExpanded; 45 | set => NotifyChanged(ref isExpanded, value); 46 | } 47 | public void SetSubtreeExpanded(bool expand) { 48 | IsExpanded = expand; 49 | Children.ForEach(x => x.SetSubtreeExpanded(expand)); 50 | } 51 | 52 | public ICommand? OpenInNewWindow { get; private set; } 53 | public RelayCommand? CopyWatchExpression { get; private set; } 54 | 55 | public string? WatchFormatString => "{0}" + Model.Path?.Split('.').Joined("", x => $".GetChild({x})"); 56 | 57 | public RelayCommand SubtreeExpand => subtreeExpand; 58 | public RelayCommand SubtreeCollapse => subtreeCollapse; 59 | public RelayCommand? SetAsRootNode { get; } 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /UI/ViewModels/TokenTypeViewModel.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using ZSpitz.Util.Wpf; 3 | using static ZSpitz.Util.Functions; 4 | 5 | namespace ParseTreeVisualizer { 6 | public class TokenTypeViewModel : Selectable> { 7 | public int Index { get; } 8 | public string Text { get; } 9 | 10 | public TokenTypeViewModel(int index, string text): this(KVP(index,text)) { } 11 | 12 | public TokenTypeViewModel(KeyValuePair tokenType) : base(tokenType) => 13 | (Index, Text) = (tokenType.Key, tokenType.Value); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /UI/ViewModels/TokenViewModel.cs: -------------------------------------------------------------------------------- 1 | using ZSpitz.Util.Wpf; 2 | using ParseTreeVisualizer.Serialization; 3 | 4 | namespace ParseTreeVisualizer { 5 | public class TokenViewModel : Selectable { 6 | // we're deliberately not including IsError and TokenTypeID in the ViewModel; we don't want to display it in the autogenerated columns of the DataGrid 7 | public int Index => Model.Index; 8 | public string TokenType => Model.TokenType; 9 | public int Line => Model.Line; 10 | public int Col => Model.Col; 11 | public string Text => Model.Text; 12 | public (int start, int stop) Span => Model.Span; 13 | public bool IsWhitespace => Model.IsWhitespace; 14 | public TokenViewModel(Token model) : base(model) { } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /UI/ViewModels/VisualizerDataViewModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections; 3 | using System.Collections.ObjectModel; 4 | using System.Linq; 5 | using ZSpitz.Util.Wpf; 6 | using ParseTreeVisualizer.Serialization; 7 | using ZSpitz.Util; 8 | using System.Windows.Input; 9 | using ParseTreeVisualizer.UI; 10 | 11 | namespace ParseTreeVisualizer { 12 | public class VisualizerDataViewModel : ViewModelBase { 13 | private int sourceSelectionStart; 14 | public int SourceSelectionStart { 15 | get => sourceSelectionStart; 16 | set => NotifyChanged(ref sourceSelectionStart, value); 17 | } 18 | 19 | private int sourceSelectionLength; 20 | public int SourceSelectionLength { 21 | get => sourceSelectionLength; 22 | set => NotifyChanged(ref sourceSelectionLength, value); 23 | } 24 | 25 | private int sourceSelectionEnd => 26 | sourceSelectionLength == 0 ? 27 | sourceSelectionStart : 28 | sourceSelectionStart + sourceSelectionLength - 1; 29 | 30 | private TokenViewModel? firstSelectedToken; 31 | public TokenViewModel? FirstSelectedToken => firstSelectedToken; 32 | 33 | public ParseTreeNodeViewModel? Root { get; } 34 | public ReadOnlyCollection? Tokens { get; } 35 | 36 | public VisualizerDataViewModel(VisualizerData visualizerData, ICommand? openInNewWindow, RelayCommand? copyWatchExpression, RelayCommand? setAsRootNode) : base(visualizerData) { 37 | if (visualizerData.Root is not null) { 38 | Root = new ParseTreeNodeViewModel(visualizerData.Root, openInNewWindow, copyWatchExpression, setAsRootNode); 39 | } 40 | 41 | Tokens = visualizerData.Tokens?.OrderBy(x => x.Index).Select(x => { 42 | var vm = new TokenViewModel(x); 43 | vm.PropertyChanged += (s, e) => { 44 | if (e.PropertyName != nameof(vm.IsSelected)) { return; } 45 | 46 | if (vm.IsSelected) { 47 | if (firstSelectedToken is null || firstSelectedToken.Model.Index > vm.Model.Index) { 48 | NotifyChanged(ref firstSelectedToken, vm, nameof(FirstSelectedToken)); 49 | } 50 | } else { 51 | if (firstSelectedToken != null && firstSelectedToken.Model.Index == vm.Model.Index) { 52 | var firstSelected = Tokens.Where(x => x.IsSelected).OrderBy(x => x.Model.Index).FirstOrDefault(); 53 | NotifyChanged(ref firstSelectedToken, firstSelected, nameof(FirstSelectedToken)); 54 | } 55 | } 56 | }; 57 | return vm; 58 | }).ToList().AsReadOnly(); 59 | 60 | if (!(Root is null)) { 61 | if (visualizerData.Config.HasTreeFilter()) { 62 | Root.SetSubtreeExpanded(true); 63 | } else { 64 | Root.IsExpanded = true; 65 | } 66 | } 67 | 68 | ChangeSelection = new RelayCommand(sender => updateSelection(sender)); 69 | } 70 | 71 | private bool inUpdateSelection; 72 | private void updateSelection(object parameter) { 73 | if (inUpdateSelection) { return; } 74 | inUpdateSelection = true; 75 | 76 | // sender will be either VisualizerDataViewModel, treenode viewmodel, or token viewmodel 77 | // HACK the type of the sender also tells us which part of the viewmodel has been selected -- source, tree, or tokens 78 | 79 | (int start, int end)? charSpan = null; 80 | string source; 81 | if (parameter == this) { // textbox's data context 82 | charSpan = (sourceSelectionStart + Model.SourceOffset, sourceSelectionEnd + Model.SourceOffset); 83 | source = "Source"; 84 | } else if (parameter is ParseTreeNodeViewModel selectedNode) { // treeview.SelectedItem 85 | charSpan = selectedNode.Model?.CharSpan; 86 | source = "Root"; 87 | } else if (parameter is IList) { // selected items in datagrid 88 | charSpan = Tokens?.SelectionCharSpan(); 89 | source = "Tokens"; 90 | } else if (parameter is null) { 91 | inUpdateSelection = false; 92 | return; 93 | } else { 94 | throw new Exception("Unknown sender"); 95 | } 96 | 97 | var (start, end) = (charSpan ?? (-1, -1)); 98 | if (source != "Source") { 99 | if (charSpan != null && charSpan != (-1, -1)) { 100 | SourceSelectionStart = start - Model.SourceOffset; 101 | SourceSelectionLength = end - start + 1; 102 | } else { 103 | SourceSelectionLength = 0; 104 | SourceSelectionStart = 0; 105 | } 106 | } 107 | 108 | if (source != "Tokens" && !(Tokens is null)) { 109 | if (charSpan == null) { 110 | Tokens.ForEach(x => x.IsSelected = false); 111 | } else { 112 | Tokens.ForEach(x => 113 | x.IsSelected = x.Model.Span.start <= end && x.Model.Span.stop >= start 114 | ); 115 | } 116 | } 117 | 118 | if (source != "Root" && !(Root?.Model is null)) { 119 | Root.ClearSelection(); 120 | var selectedNode = Root; 121 | 122 | // returns true if the node encompasses the selection 123 | bool matcher(ParseTreeNodeViewModel x) { 124 | var (nodeStart, nodeEnd) = x.Model.CharSpan; 125 | return start >= nodeStart && end <= nodeEnd; 126 | } 127 | 128 | if (matcher(selectedNode)) { 129 | while (true) { 130 | var nextChild = selectedNode.Children.SingleOrDefaultExt(matcher); 131 | if (nextChild is null) { break; } 132 | selectedNode = nextChild; 133 | selectedNode.IsExpanded = true; 134 | } 135 | selectedNode.IsSelected = true; 136 | } 137 | } 138 | 139 | inUpdateSelection = false; 140 | } 141 | 142 | // TOOD move filtering to here 143 | 144 | public RelayCommand ChangeSelection { get; } 145 | 146 | public string WindowTitle { 147 | get { 148 | var (lexer, parser, rule) = Model.Config; 149 | return new[] { 150 | ("Lexer", lexer ), 151 | ("Parser", parser ), 152 | ("Rule context", rule ) 153 | } 154 | .WhereT((name, val) => val is not null) 155 | .JoinedT(" / ", (name, val) => $"{name}: {val}"); 156 | } 157 | } 158 | } 159 | } 160 | -------------------------------------------------------------------------------- /UI/VisualizerControl.xaml: -------------------------------------------------------------------------------- 1 |  5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 20 | 24 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | -------------------------------------------------------------------------------- /UI/VisualizerControl.xaml.cs: -------------------------------------------------------------------------------- 1 | using System.ComponentModel; 2 | using System.Linq; 3 | using System.Windows; 4 | using System.Windows.Controls; 5 | using ParseTreeVisualizer.Serialization; 6 | using ZSpitz.Util; 7 | using ZSpitz.Util.Wpf; 8 | using static System.Windows.SystemColors; 9 | 10 | namespace ParseTreeVisualizer { 11 | public partial class VisualizerControl { 12 | public VisualizerControl() { 13 | InitializeComponent(); 14 | 15 | // When a control loses focus, it should look no different from when it had the focus (e.g. selection color) 16 | Resources[InactiveSelectionHighlightBrushKey] = HighlightBrush; 17 | Resources[InactiveSelectionHighlightTextBrushKey] = HighlightTextBrush; 18 | 19 | tokens.AutoGeneratingColumn += (s, e) => { 20 | if (e.PropertyName.In( 21 | nameof(ViewModelBase.Model), 22 | nameof(Selectable.IsSelected) 23 | )) { 24 | e.Cancel = true; 25 | } 26 | 27 | if (e.PropertyName == nameof(TokenViewModel.Text)) { 28 | e.Column.Width = 150; 29 | (e.Column as DataGridTextColumn)!.ElementStyle = FindResource("TextTrimmedTextbox") as Style; 30 | } 31 | }; 32 | 33 | // scrolls the tree view item into view when selected 34 | AddHandler(TreeViewItem.SelectedEvent, (RoutedEventHandler)((s, e) => ((TreeViewItem)e.OriginalSource).BringIntoView())); 35 | 36 | Loaded += (s, e) => { 37 | source.LostFocus += (s1, e1) => e1.Handled = true; 38 | source.Focus(); 39 | source.SelectAll(); 40 | }; 41 | 42 | void handler(object s1, PropertyChangedEventArgs e1) { 43 | var vm = (VisualizerDataViewModel)s1; 44 | if (e1.PropertyName != nameof(VisualizerDataViewModel.FirstSelectedToken)) { return; } 45 | if (vm.FirstSelectedToken is null) { return; } 46 | tokens.ScrollIntoView(vm.FirstSelectedToken); 47 | } 48 | 49 | DataContextChanged += (s, e) => { 50 | if (e.OldValue is VisualizerDataViewModel vm) { 51 | vm.PropertyChanged -= handler; 52 | } 53 | if (e.NewValue is VisualizerDataViewModel vm1) { 54 | vm1.PropertyChanged += handler; 55 | } 56 | 57 | var assemblyLoadErrors = data.Model.AssemblyLoadErrors; 58 | if (assemblyLoadErrors.Any()) { 59 | MessageBox.Show($"Error loading the following assemblies:\n\n{assemblyLoadErrors.Joined("\n")}"); 60 | } 61 | }; 62 | } 63 | 64 | private VisualizerDataViewModel data => (VisualizerDataViewModel)DataContext; 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /Visualizer/Visualizer.cs: -------------------------------------------------------------------------------- 1 | using ParseTreeVisualizer.Serialization; 2 | using Periscope; 3 | using Periscope.Debuggee; 4 | using System.Diagnostics; 5 | 6 | [assembly: DebuggerVisualizer( 7 | visualizer: typeof(ParseTreeVisualizer.Visualizer), 8 | visualizerObjectSource: typeof(ParseTreeVisualizer.VisualizerDataObjectSource), 9 | Target = typeof(Antlr4.Runtime.RuleContext), 10 | #if ANTLR_LEGACY 11 | Description = "ANTLR4 ParseTree Visualizer (Legacy)")] 12 | #else 13 | Description = "ANTLR4 ParseTree Visualizer")] 14 | #endif 15 | 16 | [assembly: DebuggerVisualizer( 17 | visualizer: typeof(ParseTreeVisualizer.Visualizer), 18 | visualizerObjectSource: typeof(ParseTreeVisualizer.VisualizerDataObjectSource), 19 | Target = typeof(string), 20 | #if ANTLR_LEGACY 21 | Description = "ANTLR4 ParseTree Visualizer (Legacy)")] 22 | #else 23 | Description = "ANTLR4 ParseTree Visualizer")] 24 | #endif 25 | 26 | [assembly: DebuggerVisualizer( 27 | visualizer: typeof(ParseTreeVisualizer.Visualizer), 28 | visualizerObjectSource: typeof(ParseTreeVisualizer.VisualizerDataObjectSource), 29 | Target = typeof(Antlr4.Runtime.BufferedTokenStream), 30 | #if ANTLR_LEGACY 31 | Description = "ANTLR4 ParseTree Visualizer (Legacy)")] 32 | #else 33 | Description = "ANTLR4 ParseTree Visualizer")] 34 | #endif 35 | 36 | namespace ParseTreeVisualizer { 37 | public abstract class VisualizerWindowBase : VisualizerWindowBase { }; 38 | 39 | public class Visualizer : VisualizerBase { 40 | static Visualizer() => SubfolderAssemblyResolver.Hook( 41 | #if ANTLR_LEGACY 42 | "ParseTreeVisualizer.Legacy" 43 | #else 44 | "ParseTreeVisualizer.Standard" 45 | #endif 46 | ); 47 | 48 | public Visualizer() : base(new GithubProjectInfo("zspitz", "antlr4parsetreevisualizer")) { } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /Visualizer/Visualizer.projitems: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | $(MSBuildAllProjects);$(MSBuildThisFileFullPath) 5 | true 6 | 3c553ffd-fa4e-4eab-ad03-9534c7cb8f3e 7 | 8 | 9 | Visualizer 10 | 11 | 12 | 13 | 14 | 15 | ExpressionRootPrompt.xaml 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | VisualizerWindowChrome.xaml 27 | 28 | 29 | 30 | VisualizerWindow.xaml 31 | 32 | 33 | 34 | 35 | MSBuild:Compile 36 | Designer 37 | 38 | 39 | MSBuild:Compile 40 | Designer 41 | 42 | 43 | Designer 44 | MSBuild:Compile 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | -------------------------------------------------------------------------------- /Visualizer/Visualizer.shproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 3c553ffd-fa4e-4eab-ad03-9534c7cb8f3e 5 | 14.0 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /Visualizer/VisualizerWindow.xaml: -------------------------------------------------------------------------------- 1 |  6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /Visualizer/VisualizerWindow.xaml.cs: -------------------------------------------------------------------------------- 1 | using ParseTreeVisualizer.Serialization; 2 | using System.Windows; 3 | using System.Windows.Controls.Primitives; 4 | using System.Windows.Input; 5 | using System; 6 | using ZSpitz.Util.Wpf; 7 | 8 | namespace ParseTreeVisualizer { 9 | public partial class VisualizerWindow { 10 | public VisualizerWindow() { 11 | InitializeComponent(); 12 | 13 | setAsRootNode = new( 14 | o => { 15 | if (Config is null) { return; } 16 | var newConfig = Config.Clone(); 17 | newConfig.RootNodePath = ((ParseTreeNodeViewModel)o).Model.Path; 18 | Initialize(newConfig); 19 | } 20 | ); 21 | } 22 | 23 | protected override (object windowContext, object optionsContext, Config config) GetViewState(object response, ICommand? OpenInNewWindow) => 24 | response is not VisualizerData vd ? 25 | throw new InvalidOperationException("Unrecognized response type; expected VisualizerData.") : 26 | ( 27 | new VisualizerDataViewModel(vd, OpenInNewWindow, Periscope.Visualizer.CopyWatchExpression, setAsRootNode), 28 | new ConfigViewModel(vd), 29 | vd.Config 30 | ); 31 | 32 | protected override void TransformConfig(Config config, object parameter) { 33 | if (parameter is ParseTreeNode ptn) { 34 | config.RootNodePath = ptn.Path; 35 | return; 36 | } 37 | throw new NotImplementedException(); 38 | } 39 | 40 | private readonly RelayCommand setAsRootNode; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /appveyor.yml: -------------------------------------------------------------------------------- 1 | version: 1.0.{build} 2 | image: Visual Studio 2019 3 | 4 | init: 5 | - git config --global core.autocrlf false 6 | 7 | branches: 8 | only: 9 | - master 10 | 11 | skip_tags: true 12 | 13 | only_commits: 14 | files: 15 | - Debuggee/ 16 | - Serialization/ 17 | - UI/ 18 | - Visualizer/ 19 | - Legacy/ 20 | - Standard/ 21 | - appveyor.yml 22 | - ANTLR4ParseTreeVisualizer.sln 23 | 24 | dotnet_csproj: 25 | patch: true 26 | file: '**\*.csproj' 27 | version: '{version}' 28 | package_version: '{version}' 29 | assembly_version: '{version}' 30 | file_version: '{version}' 31 | informational_version: '{version}' 32 | 33 | before_build: 34 | - cmd: dotnet restore ANTLR4ParseTreeVisualizer.sln 35 | 36 | install: 37 | - cmd: git submodule update --init --recursive 38 | 39 | matrix: 40 | fast_finish: true 41 | 42 | build: 43 | project: ANTLR4ParseTreeVisualizer.sln 44 | 45 | after_build: 46 | - 7z a %APPVEYOR_BUILD_FOLDER%\ParseTreeVisualizer.Legacy.2017.zip -r %APPVEYOR_BUILD_FOLDER%\Legacy\Debuggee\bin\Debug\net2.0\*.dll 47 | - 7z a %APPVEYOR_BUILD_FOLDER%\ParseTreeVisualizer.Legacy.2017.zip -r %APPVEYOR_BUILD_FOLDER%\Legacy\Debugger\bin\Debug\net472\*.dll 48 | - 7z a %APPVEYOR_BUILD_FOLDER%\ParseTreeVisualizer.Legacy.2019.zip -r %APPVEYOR_BUILD_FOLDER%\Legacy\Debuggee\bin\Debug\*.dll 49 | - 7z a %APPVEYOR_BUILD_FOLDER%\ParseTreeVisualizer.Legacy.2019.zip -r %APPVEYOR_BUILD_FOLDER%\Legacy\Debugger\bin\Debug\net472\*.dll 50 | - 7z a %APPVEYOR_BUILD_FOLDER%\ParseTreeVisualizer.Standard.2017.zip -r %APPVEYOR_BUILD_FOLDER%\Standard\Debuggee\bin\Debug\netstandard2.0\*.dll 51 | - 7z a %APPVEYOR_BUILD_FOLDER%\ParseTreeVisualizer.Standard.2017.zip -r %APPVEYOR_BUILD_FOLDER%\Standard\Debugger\bin\Debug\net472\*.dll 52 | - 7z a %APPVEYOR_BUILD_FOLDER%\ParseTreeVisualizer.Standard.2019.zip -r %APPVEYOR_BUILD_FOLDER%\Standard\Debuggee\bin\Debug\*.dll 53 | - 7z a %APPVEYOR_BUILD_FOLDER%\ParseTreeVisualizer.Standard.2019.zip -r %APPVEYOR_BUILD_FOLDER%\Standard\Debugger\bin\Debug\net472\*.dll 54 | 55 | artifacts: 56 | - path: '*.zip' 57 | name: ParseTreeVisualizer 58 | 59 | - path: '**\*.nupkg' 60 | type: NuGetPackage 61 | 62 | deploy: 63 | - provider: GitHub 64 | description: '' 65 | auth_token: 66 | secure: NgxEvJd/ApBpuz6rwCNDfOI5c6nAvBIabLMj1vAtzuV4ozyaVDfjRJKa7WeJK2Ri 67 | artifact: ParseTreeVisualizer 68 | 69 | - provider: NuGet 70 | api_key: 71 | secure: Wca6odTGXdgBDMEPs0ypFUcyMkfpv5f6lLjRaoqBy0zE5TyuRPXAXNuCtJ5yk/Ne 72 | artifact: /.*\.nupkg/ 73 | -------------------------------------------------------------------------------- /choose-parser.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zspitz/ANTLR4ParseTreeVisualizer/94b95b6a8615325341f1becf7cdccf1277b6c56d/choose-parser.gif -------------------------------------------------------------------------------- /parse-tree-filtering.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zspitz/ANTLR4ParseTreeVisualizer/94b95b6a8615325341f1becf7cdccf1277b6c56d/parse-tree-filtering.gif -------------------------------------------------------------------------------- /screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zspitz/ANTLR4ParseTreeVisualizer/94b95b6a8615325341f1becf7cdccf1277b6c56d/screenshot.png -------------------------------------------------------------------------------- /selection-sync.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zspitz/ANTLR4ParseTreeVisualizer/94b95b6a8615325341f1becf7cdccf1277b6c56d/selection-sync.gif -------------------------------------------------------------------------------- /set-root.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zspitz/ANTLR4ParseTreeVisualizer/94b95b6a8615325341f1becf7cdccf1277b6c56d/set-root.gif -------------------------------------------------------------------------------- /token-filtering.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zspitz/ANTLR4ParseTreeVisualizer/94b95b6a8615325341f1becf7cdccf1277b6c56d/token-filtering.gif -------------------------------------------------------------------------------- /visualize-string.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zspitz/ANTLR4ParseTreeVisualizer/94b95b6a8615325341f1becf7cdccf1277b6c56d/visualize-string.gif --------------------------------------------------------------------------------