зеркало из 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;
|
||||
|
@ -418,15 +416,15 @@ void testICG(World &world)
|
|||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
#if defined(XP_MAC) && !defined(XP_MAC_MPW)
|
||||
#if defined(XP_MAC) && !defined(XP_MAC_MPW)
|
||||
initConsole("\pJavaScript Shell", "Welcome to the js2 shell.\n", argc, argv);
|
||||
#endif
|
||||
#endif
|
||||
World world;
|
||||
#if 1
|
||||
#if 0
|
||||
testICG(world);
|
||||
#else
|
||||
#else
|
||||
readEvalPrint(std::cin, world);
|
||||
#endif
|
||||
#endif
|
||||
return 0;
|
||||
|
||||
//return ProcessArgs(argv + 1, argc - 1);
|
||||
|
|
|
@ -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;
|
||||
|
@ -418,15 +416,15 @@ void testICG(World &world)
|
|||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
#if defined(XP_MAC) && !defined(XP_MAC_MPW)
|
||||
#if defined(XP_MAC) && !defined(XP_MAC_MPW)
|
||||
initConsole("\pJavaScript Shell", "Welcome to the js2 shell.\n", argc, argv);
|
||||
#endif
|
||||
#endif
|
||||
World world;
|
||||
#if 1
|
||||
#if 0
|
||||
testICG(world);
|
||||
#else
|
||||
#else
|
||||
readEvalPrint(std::cin, world);
|
||||
#endif
|
||||
#endif
|
||||
return 0;
|
||||
|
||||
//return ProcessArgs(argv + 1, argc - 1);
|
||||
|
|
Загрузка…
Ссылка в новой задаче