forked from mozilla/rhino
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding in initial support for Japanese.
- Loading branch information
Ming Iu
committed
Apr 26, 2012
1 parent
38292bd
commit 944734d
Showing
7 changed files
with
959 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
92 changes: 92 additions & 0 deletions
92
src/org/mozilla/javascript/babylscript/JapaneseTokenizer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,92 @@ | |||
/* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- | |||
* | |||
* ***** BEGIN LICENSE BLOCK ***** | |||
* Version: MPL 1.1/GPL 2.0 | |||
* | |||
* The contents of this file are subject to the Mozilla Public License Version | |||
* 1.1 (the "License"); you may not use this file except in compliance with | |||
* the License. You may obtain a copy of the License at | |||
* http://www.mozilla.org/MPL/ | |||
* | |||
* Software distributed under the License is distributed on an "AS IS" basis, | |||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License | |||
* for the specific language governing rights and limitations under the | |||
* License. | |||
* | |||
* The Original Code is Rhino code, released | |||
* May 6, 1999. | |||
* | |||
* The Initial Developer of the Original Code is | |||
* Netscape Communications Corporation. | |||
* Portions created by the Initial Developer are Copyright (C) 1997-1999 | |||
* the Initial Developer. All Rights Reserved. | |||
* | |||
* Contributor(s): | |||
* Roger Lawrence | |||
* Mike McCabe | |||
* Igor Bukanov | |||
* Ethan Hugg | |||
* Bob Jervis | |||
* Terry Lucas | |||
* Milen Nankov | |||
* | |||
* Alternatively, the contents of this file may be used under the terms of | |||
* the GNU General Public License Version 2 or later (the "GPL"), in which | |||
* case the provisions of the GPL are applicable instead of those above. If | |||
* you wish to allow use of your version of this file only under the terms of | |||
* the GPL and not to allow others to use your version of this file under the | |||
* MPL, indicate your decision by deleting the provisions above and replacing | |||
* them with the notice and other provisions required by the GPL. If you do | |||
* not delete the provisions above, a recipient may use your version of this | |||
* file under either the MPL or the GPL. | |||
* | |||
* ***** END LICENSE BLOCK ***** */ | |||
|
|||
package org.mozilla.javascript.babylscript; | |||
|
|||
import java.io.IOException; | |||
import java.util.Locale; | |||
import java.util.ResourceBundle; | |||
|
|||
import org.mozilla.javascript.BabylTokenizer; | |||
import org.mozilla.javascript.Parser; | |||
import org.mozilla.javascript.TokenCharStream; | |||
import org.mozilla.javascript.TokenStream; | |||
|
|||
public class JapaneseTokenizer extends BabylGenericTokenizer | |||
{ | |||
public JapaneseTokenizer(Parser p, TokenCharStream in, TokenStream ts) | |||
{ | |||
super(p, | |||
in, | |||
ts, | |||
new BabylTokenizer.DecimalNumberReader(), | |||
BabylscriptNoDefaultResourceBundle.getBundle("org/mozilla/javascript/babylscript/resources/Keywords", new Locale("ja"))); | |||
} | |||
|
|||
protected int matchSymbol(int c) throws IOException | |||
{ | |||
// For single-character symbols, we'll substitute kanji symbols with | |||
// their English equivalents | |||
|
|||
if (c == '\u3002') | |||
c = '.'; | |||
else if (c == '\u3001') | |||
c = ','; | |||
|
|||
return super.matchSymbol(c); | |||
} | |||
|
|||
protected boolean isStringDelimiter(int ch) | |||
{ | |||
return (ch == '\'' || ch == '\"' || ch == '\u300c' | |||
|| ch == '\u300e'); | |||
} | |||
protected int getMatchingStringDelimiter(int ch) | |||
{ | |||
if (ch == '\'') return '\''; | |||
if (ch == '\u300c') return '\u300d'; | |||
if (ch == '\u300e') return '\u300f'; | |||
return '\"'; | |||
} | |||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
src/org/mozilla/javascript/babylscript/resources/Keywords_ja.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,64 @@ | |||
#. Contributors = Yamakoshi Akihiro | |||
# Made available under the terms of CC0 | |||
|
|||
false = \u507d | |||
debugger = \u30c7\u30d0\u30c3\u30ac | |||
super = \u30b9\u30fc\u30d1\u30fc | |||
int = \u6574\u6570 | |||
abstract = \u62bd\u8c61 | |||
float = \u5358\u7cbe\u5ea6\u6d6e\u52d5\u5c11\u6570\u70b9\u6570 | |||
private = \u30d7\u30e9\u30a4\u30d9\u30fc\u30c8 | |||
char = \u6587\u5b57 | |||
interface = \u30a4\u30f3\u30bf\u30fc\u30d5\u30a7\u30a4\u30b9 | |||
boolean = \u30d6\u30fc\u30ea\u30a2\u30f3 | |||
static = \u9759\u7684 | |||
in = \u4e2d\u306b | |||
null = \u30cc\u30eb\u6587\u5b57 | |||
if = \u3082\u3057 | |||
const = \u5b9a\u6570 | |||
synchronized = \u540c\u671f | |||
for = \u306e\u305f\u3081 | |||
true = \u771f | |||
while = \u305a\u3063\u3068 | |||
long = \u9577\u3044\u6574\u6570 | |||
class = \u30af\u30e9\u30b9 | |||
finally = \u6700\u7d42\u306b | |||
protected = \u4fdd\u8b77\u3055\u308c\u305f | |||
extends = \u62e1\u5f35 | |||
implements = \u5b9f\u88c5\u3059\u308b | |||
var = \u5909\u6570 | |||
new = \u65b0\u3057\u3044 | |||
native = \u30cd\u30a4\u30c6\u30a3\u30d6 | |||
final = \u30d5\u30a1\u30a4\u30ca\u30eb | |||
function = \u95a2\u6570 | |||
do = \u884c\u3046 | |||
return = \u623b\u308b | |||
goto = \u306b\u884c\u304f | |||
void = \u7121 | |||
enum = \u5217\u6319\u5b9a\u6570 | |||
else = \u4ed6 | |||
break = \u30d6\u30ec\u30fc\u30af | |||
transient = \u4e00\u6642\u7684\u306a | |||
let = \u662f\u975e | |||
import = \u8f38\u5165 | |||
catch = \u30ad\u30e3\u30c3\u30c1 | |||
instanceof = \u306e\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9 | |||
byte = \u30d0\u30a4\u30c8 | |||
with = \u5171\u306b | |||
throw = \u30b9\u30ed\u30fc | |||
volatile = \u63ee\u767a\u6027 | |||
case = \u30b1\u30fc\u30b9 | |||
short = \u77ed\u3044\u6574\u6570 | |||
package = \u30d1\u30c3\u30b1\u30fc\u30b8 | |||
this = \u3053\u306e | |||
double = \u500d\u7cbe\u5ea6\u6d6e\u52d5\u5c11\u6570\u70b9\u6570 | |||
yield = \u53ce\u7387 | |||
public = \u30d1\u30d6\u30ea\u30c3\u30af | |||
try = \u8a66\u3059 | |||
default = \u30c7\u30d5\u30a9\u30eb\u30c8 | |||
switch = \u30b9\u30a4\u30c3\u30c1 | |||
continue = \u30b3\u30f3\u30c6\u30a3\u30cb\u30e5\u30fc | |||
typeof = \u306e\u30bf\u30a4\u30d7 | |||
export = \u8f38\u51fa | |||
throws = \u30b9\u30ed\u30fc | |||
delete = \u30c7\u30ea\u30fc\u30c8 |
Oops, something went wrong.