JavaScript 2.0
根拠
単位パターン
previousupnext

06/30/2003 (Mon)

以下の LALR(1) 文法は引用符付き単位パターンの構文を記述するものである。セマンティクスはレキシカルアナライザが単位パターンを解釈するためにとるアクションを示す。この文法とセマンティクスに対する入力は文字列リテラルが処理された後は単位文字列リテラルの内容である。「セマンティクス表記法」も見よ。

このドキュメントは RTF 版 [英語] も用意した。

開始非終端記号は UnitPattern である。

空白類文字

構文

  {wsoptwsreq}
WhiteSpaceCharacter 
   «TAB» | «VT» | «FF» | «SP» | «u00A0»
|  «u2000» | «u2001» | «u2002» | «u2003» | «u2004» | «u2005» | «u2006» | «u2007»
|  «u2008» | «u2009» | «u200A» | «u200B»
|  «u3000»
LineTerminator  «LF» | «CR» | «u0085» | «u2028» | «u2029»
RequiredWhiteSpace 
   WhiteSpaceCharacter
|  LineTerminator
|  RequiredWhiteSpace WhiteSpaceCharacter
|  RequiredWhiteSpace LineTerminator
WhiteSpacewsopt 
   RequiredWhiteSpace
|  «empty»
WhiteSpacewsreq  RequiredWhiteSpace

単位パターン

構文

UnitPattern  WhiteSpacewsopt UnitQuotient
UnitQuotient 
   UnitProductwsopt
|  UnitProductwsopt / WhiteSpacewsopt UnitProductwsopt
UnitProduct 
   UnitFactor
|  UnitProductwsopt * WhiteSpacewsopt UnitFactor
|  UnitProductwsreq UnitFactor
UnitFactor 
   1 WhiteSpace
|  1 WhiteSpacewsopt ^ WhiteSpacewsopt SignedInteger WhiteSpace
|  Identifier WhiteSpace
|  Identifier WhiteSpacewsopt ^ WhiteSpacewsopt SignedInteger WhiteSpace

セマンティクス

tuple UnitFactor
identifierString,
exponentInteger
end tuple;
UnitList = UnitFactor[];
proc unitReciprocal(valueUnitList): UnitList
return [UnitFactoridentifierf.identifierexponent: –f.exponent | f  value]
end proc;
Value[UnitPattern  WhiteSpacewsopt UnitQuotient]: UnitList = Value[UnitQuotient];
Value[UnitQuotient]: UnitList;
Value[UnitQuotient  UnitProductwsopt] = Value[UnitProductwsopt];
Value[UnitQuotient  UnitProductwsopt1 / WhiteSpacewsopt UnitProductwsopt2] = Value[UnitProductwsopt1 unitReciprocal(Value[UnitProductwsopt2]);
Value[UnitProduct]: UnitList;
Value[UnitProduct  UnitFactor] = Value[UnitFactor];
Value[UnitProduct0  UnitProductwsopt1 * WhiteSpacewsopt UnitFactor] = Value[UnitProductwsopt1 Value[UnitFactor];
Value[UnitProduct0  UnitProductwsreq1 UnitFactor] = Value[UnitProductwsreq1 Value[UnitFactor];
Value[UnitFactor]: UnitList;
Value[UnitFactor  1 WhiteSpace] = [];
Value[UnitFactor  1 WhiteSpacewsopt ^ WhiteSpacewsopt SignedInteger WhiteSpace] = [];
Value[UnitFactor  Identifier WhiteSpace] = [UnitFactoridentifierName[Identifier], exponent: 1];
Value[UnitFactor  Identifier WhiteSpacewsopt ^ WhiteSpacewsopt SignedInteger WhiteSpace] = [UnitFactoridentifierName[Identifier], exponentIntegerValue[SignedInteger]];

符号付き整数

構文

SignedInteger 
   DecimalDigits
|  + DecimalDigits
|  - DecimalDigits
DecimalDigits 
   ASCIIDigit
|  DecimalDigits ASCIIDigit
ASCIIDigit  0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9

セマンティクス

IntegerValue[SignedInteger]: Integer;
IntegerValue[SignedInteger  DecimalDigits] = IntegerValue[DecimalDigits];
IntegerValue[SignedInteger  + DecimalDigits] = IntegerValue[DecimalDigits];
IntegerValue[SignedInteger  - DecimalDigits] = –IntegerValue[DecimalDigits];
IntegerValue[DecimalDigits]: Integer;
IntegerValue[DecimalDigits  ASCIIDigit] = DecimalValue[ASCIIDigit];
IntegerValue[DecimalDigits0  DecimalDigits1 ASCIIDigit] = 10IntegerValue[DecimalDigits1] + DecimalValue[ASCIIDigit];
DecimalValue[ASCIIDigit]: Integer = digitValue(ASCIIDigit);

識別子

構文

Identifier 
   InitialIdentifierCharacter
|  Identifier ContinuingIdentifierCharacter
InitialIdentifierCharacter  UnicodeInitialAlphabetic | $ | _
ContinuingIdentifierCharacter  UnicodeAlphanumeric | $ | _
UnicodeInitialAlphabetic  Any Unicode initial alphabetic character (includes ASCII A-Z and a-z)
UnicodeAlphanumeric  Any Unicode alphabetic or decimal digit character (includes ASCII 0-9, A-Z, and a-z)

セマンティクス

Name[Identifier]: String;
Name[Identifier0  Identifier1 ContinuingIdentifierCharacter] = Name[Identifier1 [ContinuingIdentifierCharacter];

Waldemar Horwat
最終更新: 2003年6月30日 (月)
previousupnext
訳者: exeal <exeal@student.interq.or.jp>
このドキュメントのオリジナルは mozilla.org において英語で公布されています。
この和訳は、利用者の利便のために Mozilla Japan 翻訳部門 によって提供されています。
内容に関してご不明な点がありましたら webmaster までお問い合わせください。