Skip to Content.
Sympa Menu

k-user - Re: [[K-user] ] Help Needed: Hex to String

k-user AT lists.cs.illinois.edu

Subject: K-user mailing list

List archive

Re: [[K-user] ] Help Needed: Hex to String


Chronological Thread 
  • From: Sandeep Dasgupta <sdasgup3 AT illinois.edu>
  • To: "Park, Daejun" <dpark69 AT illinois.edu>
  • Cc: <sdasgup3 AT illinois.edu>, "k-user AT lists.cs.illinois.edu" <k-user AT lists.cs.illinois.edu>
  • Subject: Re: [[K-user] ] Help Needed: Hex to String
  • Date: Thu, 7 Dec 2017 13:43:20 -0600
  • Authentication-results: illinois.edu; spf=pass smtp.mailfrom=sdasgup3 AT illinois.edu

Thanks Daejun!

On 12/07/2017 01:28 PM, Park, Daejun wrote:
You can use `Id2String` or define your own using `STRING.token2string` hook as follows:

syntax String ::= HexConstant2String ( HexConstant )    [function, hook(STRING.token2string)]

Best,
Daejun

On Nov 27, 2017, at 5:02 PM, Sandeep Dasgupta <sdasgup3 AT illinois.edu> wrote:

Hello Team,

I would like to parse a hex constant like

```
syntax HexConstant ::=  r"0x[0-9a-fA-F]*" [token]
```
and use the hook  `STRING.string2base` to get the `Int` equivalent, like


```
    syntax Int ::= HexStringtToInt(String, Int)  [function, hook(STRING.string2base)]

    rule convert(S:String) => HexStringtToInt(S, 16)
```


but for that i need the hex as String,
which I could not find how to get.

Can you guys please me with that?

Regards,
Sandeep





Archive powered by MHonArc 2.6.19.

Top of Page