зеркало из https://github.com/mozilla/pjs.git
Updated lexer API
This commit is contained in:
Родитель
cf09318769
Коммит
a84c5b0547
|
@ -23,7 +23,6 @@
|
|||
//
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstdio>
|
||||
//#include <stdlib.h>
|
||||
#include "world.h"
|
||||
namespace JS = JavaScript;
|
||||
|
@ -149,7 +148,7 @@ static void readEvalPrint(istream &in, World &world)
|
|||
{
|
||||
String buffer;
|
||||
string line;
|
||||
String source = widenCString("console");
|
||||
String sourceLocation = widenCString("console");
|
||||
|
||||
while (promptLine(in, line, buffer.empty() ? "js> " : "")) {
|
||||
if (!buffer.empty())
|
||||
|
@ -157,11 +156,10 @@ static void readEvalPrint(istream &in, World &world)
|
|||
appendChars(buffer, line.data(), line.size());
|
||||
if (!buffer.empty()) {
|
||||
try {
|
||||
StringReader r(buffer, source);
|
||||
Lexer l(r, world);
|
||||
Lexer l(world, buffer, sourceLocation);
|
||||
while (true) {
|
||||
Token &t = l.get(true);
|
||||
if (t.kind == Token::End)
|
||||
const Token &t = l.get(true);
|
||||
if (t.hasKind(Token::end))
|
||||
break;
|
||||
String out;
|
||||
out += ' ';
|
||||
|
@ -330,12 +328,12 @@ ProcessArgs(char **argv, int argc)
|
|||
#endif
|
||||
|
||||
#include "icodegenerator.h"
|
||||
void testICG(World &world)
|
||||
static void testICG(World &world)
|
||||
{
|
||||
//
|
||||
// testing ICG
|
||||
//
|
||||
SourcePosition pos = { 0, 0, 0 };
|
||||
uint32 pos = 0;
|
||||
ICodeGenerator icg;
|
||||
|
||||
// var i,j; i = j + 2;
|
||||
|
@ -422,7 +420,7 @@ int main(int argc, char **argv)
|
|||
initConsole("\pJavaScript Shell", "Welcome to the js2 shell.\n", argc, argv);
|
||||
#endif
|
||||
World world;
|
||||
#if 1
|
||||
#if 0
|
||||
testICG(world);
|
||||
#else
|
||||
readEvalPrint(std::cin, world);
|
||||
|
|
|
@ -23,7 +23,6 @@
|
|||
//
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstdio>
|
||||
//#include <stdlib.h>
|
||||
#include "world.h"
|
||||
namespace JS = JavaScript;
|
||||
|
@ -149,7 +148,7 @@ static void readEvalPrint(istream &in, World &world)
|
|||
{
|
||||
String buffer;
|
||||
string line;
|
||||
String source = widenCString("console");
|
||||
String sourceLocation = widenCString("console");
|
||||
|
||||
while (promptLine(in, line, buffer.empty() ? "js> " : "")) {
|
||||
if (!buffer.empty())
|
||||
|
@ -157,11 +156,10 @@ static void readEvalPrint(istream &in, World &world)
|
|||
appendChars(buffer, line.data(), line.size());
|
||||
if (!buffer.empty()) {
|
||||
try {
|
||||
StringReader r(buffer, source);
|
||||
Lexer l(r, world);
|
||||
Lexer l(world, buffer, sourceLocation);
|
||||
while (true) {
|
||||
Token &t = l.get(true);
|
||||
if (t.kind == Token::End)
|
||||
const Token &t = l.get(true);
|
||||
if (t.hasKind(Token::end))
|
||||
break;
|
||||
String out;
|
||||
out += ' ';
|
||||
|
@ -330,12 +328,12 @@ ProcessArgs(char **argv, int argc)
|
|||
#endif
|
||||
|
||||
#include "icodegenerator.h"
|
||||
void testICG(World &world)
|
||||
static void testICG(World &world)
|
||||
{
|
||||
//
|
||||
// testing ICG
|
||||
//
|
||||
SourcePosition pos = { 0, 0, 0 };
|
||||
uint32 pos = 0;
|
||||
ICodeGenerator icg;
|
||||
|
||||
// var i,j; i = j + 2;
|
||||
|
@ -422,7 +420,7 @@ int main(int argc, char **argv)
|
|||
initConsole("\pJavaScript Shell", "Welcome to the js2 shell.\n", argc, argv);
|
||||
#endif
|
||||
World world;
|
||||
#if 1
|
||||
#if 0
|
||||
testICG(world);
|
||||
#else
|
||||
readEvalPrint(std::cin, world);
|
||||
|
|
Загрузка…
Ссылка в новой задаче