Skip to content

Commit

Permalink
Completed fixes. Passes all tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
kaby76 committed Jul 12, 2023
1 parent 8a721c8 commit 32f0395
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 2 deletions.
2 changes: 1 addition & 1 deletion cpp/CPP14Parser.g4
Original file line number Diff line number Diff line change
Expand Up @@ -630,7 +630,7 @@ memberDeclaratorList:
memberDeclarator (Comma memberDeclarator)*;

memberDeclarator:
declarator (virtualSpecifierSeq | { IsPureSpecifierAllowed() }? pureSpecifier | { IsPureSpecifierAllowed() }? virtualSpecifierSeq pureSpecifier | braceOrEqualInitializer)
declarator (virtualSpecifierSeq | { this.IsPureSpecifierAllowed() }? pureSpecifier | { this.IsPureSpecifierAllowed() }? virtualSpecifierSeq pureSpecifier | braceOrEqualInitializer)
| declarator
| Identifier? attributeSpecifierSeq? Colon constantExpression
;
Expand Down
28 changes: 28 additions & 0 deletions cpp/Dart/CPP14ParserBase.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import 'package:antlr4/antlr4.dart';
import 'dart:io';
import 'dart:convert';
import 'CPP14Parser.dart';

abstract class CPP14ParserBase extends Parser
{
CPP14ParserBase(TokenStream input) : super(input)
{
}

bool IsPureSpecifierAllowed()
{
try
{
var x = this.context; // memberDeclarator
var c = x?.getChild(0)?.getChild(0);
var c2 = c?.getChild(0);
var p = c2?.getChild(1);
if (p == null) return false;
return p.runtimeType == ParametersAndQualifiersContext;
}
catch (e)
{
}
return false;
}
}
2 changes: 1 addition & 1 deletion cpp/Java/CPP14ParserBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ protected boolean IsPureSpecifierAllowed()
if (p == null) return false;
return (p instanceof CPP14Parser.ParametersAndQualifiersContext);
}
catch
catch (Exception e)
{
}
return false;
Expand Down
20 changes: 20 additions & 0 deletions cpp/JavaScript/CPP14ParserBase.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import antlr4 from 'antlr4';
import CPP14Parser from './CPP14Parser.js';

export default class CPP14ParserBase extends antlr4.Parser {
constructor(input) {
super(input);
}

IsPureSpecifierAllowed() {
try {
var x = this._ctx; // memberDeclarator
var c = x.getChild(0).getChild(0);
var c2 = c.getChild(0);
var p = c2.getChild(1);
return p.constructor === CPP14Parser.ParametersAndQualifiersContext;
} catch (e) {
}
return false;
}
}

0 comments on commit 32f0395

Please sign in to comment.