Class: Mingle::MingleLexer
- Inherits:
-
BitGirderClass
- Object
- BitGirderClass
- Mingle::MingleLexer
- Defined in:
- lib/mingle.rb
Constant Summary collapse
- LC_ALPHA =
( ?a .. ?z )
- IDENT_SEPS =
[ ?-, ?_ ]
- UC_ALPHA =
( ?A .. ?Z )
- DIGIT =
( ?0 .. ?9 )
- UC_HEX =
( ?A .. ?F )
- LC_HEX =
( ?a .. ?f )
- LEAD_SURROGATE =
( 0xD800 ... 0xDC00 )
- TRAIL_SURROGATE =
( 0xDC00 ... 0xE000 )
Instance Method Summary collapse
- #create_loc(col_adj = 0) ⇒ Object
- #eof? ⇒ Boolean
- #expect_token(typ = nil) ⇒ Object
- #read_token(typ = nil) ⇒ Object
Instance Method Details
#create_loc(col_adj = 0) ⇒ Object
639 640 641 |
# File 'lib/mingle.rb', line 639 def create_loc( col_adj = 0 ) ParseLocation.new( :col => @col + col_adj, :line => @line ) end |
#eof? ⇒ Boolean
634 635 636 |
# File 'lib/mingle.rb', line 634 def eof? @io.eof? end |
#expect_token(typ = nil) ⇒ Object
1174 1175 1176 1177 1178 1179 1180 1181 1182 |
# File 'lib/mingle.rb', line 1174 def expect_token( typ = nil ) case when typ == nil then read_token || fail_unexpected_end when typ == StringToken || typ == NumericToken || typ == MingleIdentifier || typ == DeclaredTypeName read_token( typ ) else raise "Unhandled token expect type: #{typ}" end end |
#read_token(typ = nil) ⇒ Object
1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 |
# File 'lib/mingle.rb', line 1149 def read_token( typ = nil ) # Don't peek -- do get/unget so we get a true loc ch = get_char loc = create_loc unget_char( ch ) case when typ == StringToken then res = read_string when typ == NumericToken then res = read_number when typ == MingleIdentifier then res = read_ident when typ == DeclaredTypeName then res = read_decl_type_name when ident_start?( ch ) then res = read_ident when decl_nm_start?( ch ) then res = read_decl_type_name when special_char?( ch ) then res = read_special when whitespace?( ch ) then res = read_whitespace when ch == ?" then res = read_string when starts_num?( ch ) then res = read_number else fail_parsef( "Unrecognized token: #{err_ch( get_char )}" ) end [ res, loc ] end |