GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Support for if/else if/else with empty final else. Fixes #16. · hellcoderz/java2python@fa8a410

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • java2python/compiler
    • visitor.py
  • test
    • If7.java
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎java2python/compiler/visitor.py‎

Copy file name to clipboardExpand all lines: java2python/compiler/visitor.py
+5-2Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -495,8 +495,11 @@ def acceptIf(self, node, memo):
495495
elseBlock = self.factory.expr(parent=elseStat)
496496
elseBlock.walk(nextNode, memo)
497497
elif nextType: # nextType != tokens.BLOCK_SCOPE:
498-
self.factory.statement('else', fs=FS.lc, parent=self)
499-
self.factory.methodContent(parent=self).walk(nextNode, memo)
498+
elseStat = self.factory.statement('else', fs=FS.lc, parent=self)
499+
if nextNode.children:
500+
self.factory.methodContent(parent=self).walk(nextNode, memo)
501+
else:
502+
self.factory.expr(left='pass', parent=elseStat)
500503

501504

502505
def acceptSwitch(self, node, memo):
Collapse file

‎test/If7.java‎

Copy file name to clipboard
+10Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
class If7 {
2+
public static void main(String[] args) {
3+
if (false) {
4+
System.out.println("fail 1");
5+
} else if (false) {
6+
System.out.println("fail 2");
7+
} else {
8+
}
9+
}
10+
}

0 commit comments

Comments
0 (0)
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.