Skip to content

SyntaxError: Unexpected reserved word #43

Open

Description

@Bizarrus

I've tryed out these interpreter. An simple console.log will work - But when i try to use ES6 classes, i've got following Exception:

Noesis.Javascript.JavascriptException: SyntaxError: Unexpected reserved word

   bei Noesis.Javascript.CompileScript(Local<v8::Script>* , Char* source_code, Char* resource_name)
   bei Noesis.Javascript.JavascriptContext.Run(String iSourceCode)
   bei ReactSharp.Program.Main(String[] args) in c:\Users\info\Documents\SharpDevelop Projects\ReactSharp\ReactSharp\Program.cs:Zeile 48.

Program.cs

using System;
using System.IO;
using Noesis.Javascript;

namespace Sample {
	public class SystemConsole {
		public SystemConsole() {}

		public void log(string iString) {
			Console.WriteLine(iString);
			System.Diagnostics.Debug.WriteLine(iString);
		}
	}

	internal sealed class Program {
		[STAThread]
		private static void Main(string[] args) {
			System.Diagnostics.Debug.WriteLine("HI");
		
			using(JavascriptContext context = new JavascriptContext()) {
				context.SetParameter("console", new SystemConsole());
				
				// Read the "main.js"
				string contents = File.ReadAllText(@"main.js");
				
				// Run the script
				context.Run(contents);
			}
		}
	}
}

main.js

class Example {
	constructor() {
		console.log("Hello World, APP!");
	}
}

Activity

  1. oliverbock commented on Jul 19, 2018

    @oliverbock
    Contributor

    You probably need to build from source to get a version that supports ES6 classes. Someone may provide more help if you specify which version of JavaScript.Net you are using, and cut the example down to work out which reserved word is the problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions