From deb409d00d5db079006a9f084bde7755a0ad11c6 Mon Sep 17 00:00:00 2001 From: Feng <2165926681@qq.com> Date: Thu, 10 Oct 2024 01:26:53 +0800 Subject: [PATCH] fix fields with format attr1=attr2 not recognized --- rvdecoderdb/src/parser/SameValue.scala | 13 +++++++++++++ rvdecoderdb/src/parser/parse.scala | 2 ++ 2 files changed, 15 insertions(+) create mode 100644 rvdecoderdb/src/parser/SameValue.scala diff --git a/rvdecoderdb/src/parser/SameValue.scala b/rvdecoderdb/src/parser/SameValue.scala new file mode 100644 index 0000000..0062729 --- /dev/null +++ b/rvdecoderdb/src/parser/SameValue.scala @@ -0,0 +1,13 @@ +package org.chipsalliance.rvdecoderdb.parser +import org.chipsalliance.rvdecoderdb.parser.ArgLUT + +object SameValue { + def unapply(str: String): Option[ArgLUT] = str match { + case s"${attr1}=${attr2}" => ArgLUT.all.get(attr1) + case _ => None + } +} + +class SameValue(val attr1: String, val attr2: String) extends Token { + override def toString: String = s"$attr1=$attr2" +} diff --git a/rvdecoderdb/src/parser/parse.scala b/rvdecoderdb/src/parser/parse.scala index 86a797a..cb85d94 100644 --- a/rvdecoderdb/src/parser/parse.scala +++ b/rvdecoderdb/src/parser/parse.scala @@ -18,6 +18,7 @@ object parse { custom, content .split("\n") + .map(_.trim) .filter(!_.startsWith("#")) .filter(_.nonEmpty) .map( @@ -27,6 +28,7 @@ object parse { case "$import" => Import case "$pseudo_op" => PseudoOp case RefInst(i) => i + case SameValue(s) => s case FixedRangeValue(f) => f case BitValue(b) => b case ArgLUT(a) => a