Hi,
I am getting unexpected token error. My code is:
var assert = require('assert');
const path = require("path");
const fs = require("fs");
module.exports = async function(callback) {
try {
var ctr =0;
const keyWordStr = [];
const files = new Array("A1.sol", "A2.sol", "A3.sol");
const keyWords = new Array("string1", "string2", "string3","string4", "string5", "string6", "string7");
const str = 0;
for (let i = 0; i < files.length; i++) {
const contractPath = path.resolve('/home/zulfi/Truffle_programs/search_opcode/','contracts',files[i]);
const contractCode2 = fs.readFileSync(contractPath, "utf8");
var lines = this.contractCode2.split(/\r\n|\n/);
for(var line = 0; line < lines.length-1; line++){
keyWordStr[ctr] = (lines[line].search(keyWords[ctr] >= 0 ? lines[line] : false);
console.log(line + " --> "+ lines[line]);
}//for (var...)
//const selfdestructExists2 = (contractCode2.search("pragma Solidity") >= 0 ? true : false);
//console.log('selfdestruct exists:', selfdestructExists2);
}//for(let..)
}//try
catch(error) {
console.log(error)
}
callback()
}
The complete error message is:
==
> SyntaxError: Unexpected token ;
> ```
>
> $ truffle exec tool2.js
> Using network 'development'.
>
> /home/zulfi/Truffle_programs/search_opcode/tool2.js:21
> keyWordStr[ctr] = (lines[line].search(keyWords[ctr] >= 0 ? lines[line] : false);
> ^
>
> SyntaxError: Unexpected token ;
> at new Script (vm.js:83:7)
> at Object.createScript (vm.js:277:10)
> at Object.file (/home/zulfi/.nvm/versions/node/v10.23.3/lib/node_modules/truffle/build/webpack:/packages/require/require.js:93:1)
> at Object.exec (/home/zulfi/.nvm/versions/node/v10.23.3/lib/node_modules/truffle/build/webpack:/packages/require/require.js:121:1)
> at Promise (internal/util.js:274:30)
> at new Promise (<anonymous>)
> at bound exec (internal/util.js:273:12)
> at Object.run (/home/zulfi/.nvm/versions/node/v10.23.3/lib/node_modules/truffle/build/webpack:/packages/core/lib/commands/exec.js:80:1)
> at process._tickCallback (internal/process/next_tick.js:68:7)
> Truffle v5.1.67 (core: 5.1.67)
> Node v10.23.3
Somebody please guide me.
Zulfi.