Comments (2)
Problem
The issue is to decide what are valid escape sequences.
For now Aiken UPLC parser does not support any:
rule string() -> String
= "\"" s:[^ '"']* "\"" { String::from_iter(s) }
Plutus Spec
The Plutus Core Spec says in Appendix A.1:
Concrete syntax for strings. Strings are represented as sequences of Unicode characters enclosed in
double quotes, and may include standard escape sequences.
However despite some escape sequences being standardized for some languages, like C, there is as far as I know no "standard escape sequences".
PlutusTx
PlutusTx conText
seems to rely on megaparsec charLiteral
:
-- | Parser for string constants. They are wrapped in double quotes.
conText :: Parser T.Text
conText = lexeme . fmap T.pack $ char '\"' *> manyTill Lex.charLiteral (char '\"')
Which implements the Haskell Report grammar rules:
The literal character is parsed according to the grammar rules defined in the Haskell report.
I'm not sure what is supported by those exactly, it seems to be:
https://book.realworldhaskell.org/read/characters-strings-and-escaping-rules.html
Which includes quite a lot of non common ones and use \xHEX
for unicode escape sequence (instead of C \uHEX
or common \u{HEX}
like in rust).
Aiken
It may also make sense to have the same escape sequences supported in UPLC Aiken compiler than in Aiken language.
For now Aiken seems to support a few single character escape sequences in escape lexer, but no unicode ones:
let escape = just('\\').ignore_then(
just('\\')
.or(just('/'))
.or(just('"'))
.or(just('b').to('\x08'))
.or(just('f').to('\x0C'))
.or(just('n').to('\n'))
.or(just('r').to('\r'))
.or(just('t').to('\t')),
);
Also not sure why it supports the weird \/
one that does not require escaping.
Conclusion
- We need to decide on a "standard" set of escape sequences and if it should match PlutuxTx one or not, maybe trying to get it official in Plutus Core spec.
- We need to decide if we want the same one in Aiken language and Aiken UPLC compiler.
- We can then implement those, with tests and documentation in the guide.
from aiken.
cool that makes sense. Thanks for writing this.
from aiken.
Related Issues (20)
- aiken/string causes compilation error HOT 1
- lsp panic on bad field HOT 4
- A problem with Testing failures. Proposed solution: Change `fail` keyword to use it with expressions. HOT 7
- Union types HOT 1
- libssl issues post 1.0.26-xxx (can't upgrade to 1.0.28/1.0.29) HOT 3
- aiken tx rerun with traces inplace HOT 4
- not implemented: MkCons and MkPairData should be handled by an anon function or using [] or ( a, b, .., z) HOT 1
- aiken fmt bug HOT 2
- using side effects HOT 4
- Include return type in aiken export
- Pair missing from plutus.json definition HOT 1
- aiken output not cip57 compliant HOT 2
- Data missing from CIP57 specification HOT 1
- uplc - misleading error message returned by `eval_phase_two`
- Add a compatibility table for UPLC crate (AST versions, builtin versions, Plutus language versions)
- `aiken fmt` moves comment up to the wrong line
- aiken blueprint apply truncates output HOT 1
- Aiken bluprint remove traces
- tx simulate - fatal error HOT 1
- Error: Unknown type HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from aiken.