1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 03:17:35 +00:00
serenity/Libraries
mattco98 adb4accab3 LibJS: Add template literals
Adds fully functioning template literals. Because template literals
contain expressions, most of the work has to be done in the Lexer rather
than the Parser. And because of the complexity of template literals
(expressions, nesting, escapes, etc), the Lexer needs to have some
template-related state.

When entering a new template literal, a TemplateLiteralStart token is
emitted. When inside a literal, all text will be parsed up until a '${'
or '`' (or EOF, but that's a syntax error) is seen, and then a
TemplateLiteralExprStart token is emitted. At this point, the Lexer
proceeds as normal, however it keeps track of the number of opening
and closing curly braces it has seen in order to determine the close
of the expression. Once it finds a matching curly brace for the '${',
a TemplateLiteralExprEnd token is emitted and the state is updated
accordingly.

When the Lexer is inside of a template literal, but not an expression,
and sees a '`', this must be the closing grave: a TemplateLiteralEnd
token is emitted.

The state required to correctly parse template strings consists of a
vector (for nesting) of two pieces of information: whether or not we
are in a template expression (as opposed to a template string); and
the count of the number of unmatched open curly braces we have seen
(only applicable if the Lexer is currently in a template expression).

TODO: Add support for template literal newlines in the JS REPL (this will
cause a syntax error currently):

    > `foo
    > bar`
    'foo
    bar'
2020-05-04 16:46:31 +02:00
..
LibAudio LibAudio: Use NumericLimits<T> 2020-04-15 16:58:46 +02:00
LibBareMetal AK: Add ALWAYS_INLINE, NEVER_INLINE and FLATTEN macros 2020-04-30 11:43:25 +02:00
LibC LibC: added F_SETLK and SO_TYPE defs 2020-05-02 14:12:07 +02:00
LibCore ProtocolServer: Implement and handle download progress 2020-05-03 12:59:26 +02:00
LibCrypto LibCrypto: Manage vector sizing manually in performance-critical places 2020-05-03 19:14:50 +02:00
LibDebug LibDebug: Add remove_breakpoint 2020-04-25 13:16:46 +02:00
LibELF LibELF: Make ELF::Loader RefCounted 2020-04-20 17:25:50 +02:00
LibGfx LibGfx: Decode paletted and grayscale images with 1/2/4 bit depth 2020-05-02 01:28:18 +02:00
LibGUI LibJS: Add template literals 2020-05-04 16:46:31 +02:00
LibHTTP LibHTTP: Put some debug spam behind an #ifdef 2020-05-03 19:14:50 +02:00
LibIPC LibIPC: Add a simple IPC::Dictionary type (String key -> String value) 2020-05-03 23:01:58 +02:00
LibJS LibJS: Add template literals 2020-05-04 16:46:31 +02:00
LibLine LibLine: Handle ^L while in search mode 2020-05-02 11:57:21 +02:00
LibM LibM: Implement fmodf() 2020-05-02 01:23:30 +02:00
LibMarkdown LibMarkdown: Add support for images :^) 2020-04-30 11:30:27 +02:00
LibPCIDB Meta: Add license header to source files 2020-01-18 09:45:54 +01:00
LibProtocol ProtocolServer: Pass HTTP response headers to the client 2020-05-03 23:01:58 +02:00
LibPthread LibPthread: Hookup abstime argument to pthread_cond_timedwait 2020-04-26 21:31:52 +02:00
LibTextCodec LibTextCodec: Start fleshing out a simple text codec library 2020-05-03 23:01:58 +02:00
LibThread AK: Add ALWAYS_INLINE, NEVER_INLINE and FLATTEN macros 2020-04-30 11:43:25 +02:00
LibTLS LibTLS: Put some debug spam behind an #ifdef 2020-05-03 19:14:50 +02:00
LibVT LibVT: Handle ctrl+arrow keys 2020-04-20 20:23:26 +02:00
LibWeb LibWeb: Add basic support for redirects 2020-05-04 00:01:31 +02:00
LibX86 LibX86: Simplify "register index to string" functions a bit 2020-05-04 13:49:15 +02:00
Makefile Build: Only look at SUBDIRS with Makefiles 2020-02-25 19:56:48 +01:00