mirror of
https://github.com/polserver/polserver
synced 2026-08-13 08:23:08 -04:00
* Update grammar to support interpolated strings
* Struct initializers, case switchs are regular strings
* Initial stub for interpolated string in AST
This splits the previous STRING_LITERAL terminal into a production,
stringLiteral, to handle REGULAR_STRING terminal and interpolatedString
production.
* Change interpolated strings to expressions
* Fix mode handling in grammar
* Grammar fixes
- Fix mode handling in lexer
- Interpolated strings only have one expression
* Can successfully parse, stub compile interstrings
$"He {there + print("hello")}";
* Add formatting string to grammar
* Fix tests, and add test stubs
* Rename curleys to brace; better AST generation
* initial work interstring instruction
* Initial work on formatted string instruction: emit
* Formatted string instruction: execution
* Add simple formatted string test
* Add formatted string test src
* Review changes #1
- Rename `FormattedString` to `FormatExpression`
- Rename overloaded `try_to_format()` to `get_formatted()`
* Review changes part 2
- Rename `InterpolatedString` ast node to `InterpolateString`
* Review changes part 3
- Modify `ins_interpolate_string`
* Review changes part 4
- Remove unused formal parameter
* Add negative tests
* Spruce up positive tests
* Fix braces, escape chars inside interstring
* Fix, add tests for escaped char and double brace
* Address differences for new lines in tests
* Update Escript version
* Make empty expression an error
* Add documentation for interpolated strings
* Quick touchup on docs
26 lines
665 B
C++
26 lines
665 B
C++
#include "InterpolateString.h"
|
|
|
|
#include <format/format.h>
|
|
|
|
#include "clib/strutil.h"
|
|
#include "compiler/ast/NodeVisitor.h"
|
|
|
|
namespace Pol::Bscript::Compiler
|
|
{
|
|
InterpolateString::InterpolateString( const SourceLocation& source_location,
|
|
std::vector<std::unique_ptr<Expression>> children )
|
|
: Expression( source_location, std::move( children ) )
|
|
{
|
|
}
|
|
|
|
void InterpolateString::accept( NodeVisitor& visitor )
|
|
{
|
|
visitor.visit_interpolate_string( *this );
|
|
}
|
|
|
|
void InterpolateString::describe_to( fmt::Writer& w ) const
|
|
{
|
|
w << "interpolate-string (" << children.size() << " parts)";
|
|
}
|
|
|
|
} // namespace Pol::Bscript::Compiler
|