Commit 91e3a5b4 authored by Peter's avatar Peter
Browse files

dev

parent 577e37f6
Loading
Loading
Loading
Loading
Loading
+4 −4
Changes for src/main/java/hk/quantr/verilogcompiler/VerilogHelper.java: 4 added lines, 4 removed lines.
Original line number Diff line number Diff line
@@ -258,7 +258,7 @@ public class VerilogHelper {
		String sourceContent = VerilogHelper.getContentReplacedWithMacro(1, content, VerilogHelper.scanMacroDefinitions(file, file.getParentFile()), ps);
//		FileUtils.writeStringToFile(new File("aaaa.v"), sourceContent, "utf-8");
//		CommonLib.printWithLineNumber(sourceContent);
		System.out.println(ps);
//		System.out.println(ps);
//		System.out.println("+".repeat(100));
		VerilogLexer lexer = new VerilogLexer(CharStreams.fromString(sourceContent));
		CommonTokenStream tokenStream = new CommonTokenStream(lexer);
@@ -266,16 +266,16 @@ public class VerilogHelper {
		ParseTree tree = parser.source_text();
//		System.out.println("-".repeat(100));

		// add out own macro
		// add our own macro
		VerilogPreProcessorListener listener = new VerilogPreProcessorListener(tokenStream, sourceContent, ps);
		ParseTreeWalker walker = new ParseTreeWalker();
		walker.walk(listener, tree);
		System.out.println(ps);
//		System.out.println(ps);

		List<MacroListing> list = ps.fatternMacroListing().stream().filter(c -> c.type == Type.PROFILING).sorted((MacroListing o1, MacroListing o2) -> Integer.valueOf(o2.lineNo).compareTo(o1.lineNo)).collect(Collectors.toList());
		List<String> lines = new ArrayList(Arrays.asList(content.split("\r?\n")));
		for (MacroListing temp : list) {
			System.out.println(temp + " = " + temp.getTopParent());
//			System.out.println(temp + " = " + temp.getTopParent());
			lines.add(temp.getTopParent().originalLineNo + 1, temp.line);
		}

+1 −1
Changes for src/main/java/hk/quantr/verilogcompiler/listener/preprocess/VerilogPreProcessorListener.java: 1 added line, 1 removed line.
Original line number Diff line number Diff line
@@ -42,7 +42,7 @@ public class VerilogPreProcessorListener extends VerilogParserBaseListener {
			System.out.println("parentMacro is null, " + lineNo);
			System.exit(929);
		}
		parentMacro.children.add(new MacroListing(parentMacro, parentMacro.parseNo + 1, lineNo, parentMacro.originalLineNo, "saveData(\"" + ctx.variable_lvalue().getText() + "\");", MacroListing.Type.PROFILING));
		parentMacro.children.add(new MacroListing(parentMacro, parentMacro.parseNo + 1, lineNo, parentMacro.originalLineNo, "profile(\"" + ctx.variable_lvalue().getText() + "\");", MacroListing.Type.PROFILING));
	}

	@Override