Skip to content

Commit

Permalink
Add TypeScript port.
Browse files Browse the repository at this point in the history
The type casting code does not work in typescript. Assuming structure is correct for "true" case.
  • Loading branch information
kaby76 committed Jul 17, 2023
1 parent 847799f commit 6a078ec
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
28 changes: 28 additions & 0 deletions cpp/TypeScript/CPP14ParserBase.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import {Parser, Lexer, Token, TokenStream, ParserRuleContext} from "antlr4";
import CPP14Parser from './CPP14Parser';
import ParametersAndQualifiersContext from './CPP14Parser';

export default abstract class CPP14ParserBase extends Parser {

constructor(input: TokenStream) {
super(input);
}

protected IsPureSpecifierAllowed() : boolean {
try {
var x = this._ctx; // memberDeclarator
var c = (x.children[0] as ParserRuleContext).children[0] as ParserRuleContext;
var c2 = c.children[0] as ParserRuleContext;
var p = c2.children[1] as ParserRuleContext;
if (p == undefined)
return false;
// console.log("P " + p);
// var q = p.constructor === ParametersAndQualifiersContext;
var q = p instanceof ParametersAndQualifiersContext;
// console.log("Q " + q);
return true;
} catch (e) {
}
return false;
}
}
2 changes: 1 addition & 1 deletion cpp/desc.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="UTF-8" ?>
<desc xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../_scripts/desc.xsd">
<targets>Cpp;CSharp;Dart;Java;JavaScript;Python3</targets>
<targets>Cpp;CSharp;Dart;Java;JavaScript;Python3;TypeScript</targets>
</desc>

0 comments on commit 6a078ec

Please sign in to comment.