Allow XPath idents to start with an underscore.
This is valid in XML so XPath should support it as well.
This commit is contained in:
		
							parent
							
								
									eb3a3e7630
								
							
						
					
					
						commit
						f1316c50fb
					
				|  | @ -194,7 +194,7 @@ module Oga | ||||||
|         # Identifiers are used for element names, namespaces, attribute names, |         # Identifiers are used for element names, namespaces, attribute names, | ||||||
|         # etc. Identifiers have to start with a letter. |         # etc. Identifiers have to start with a letter. | ||||||
| 
 | 
 | ||||||
|         identifier = '*' | [a-zA-Z*]+ [a-zA-Z\-_0-9]*; |         identifier = '*' | [a-zA-Z*_]+ [a-zA-Z\-_0-9]*; | ||||||
| 
 | 
 | ||||||
|         action emit_identifier { |         action emit_identifier { | ||||||
|           emit(:T_IDENT, ts, te) |           emit(:T_IDENT, ts, te) | ||||||
|  |  | ||||||
|  | @ -6,6 +6,10 @@ describe Oga::XPath::Lexer do | ||||||
|       lex_xpath('/foo').should == [[:T_SLASH, nil], [:T_IDENT, 'foo']] |       lex_xpath('/foo').should == [[:T_SLASH, nil], [:T_IDENT, 'foo']] | ||||||
|     end |     end | ||||||
| 
 | 
 | ||||||
|  |     example 'lex a simple expression with a test starting with an underscore' do | ||||||
|  |       lex_xpath('/_foo').should == [[:T_SLASH, nil], [:T_IDENT, '_foo']] | ||||||
|  |     end | ||||||
|  | 
 | ||||||
|     example 'lex a node test using a namespace' do |     example 'lex a node test using a namespace' do | ||||||
|       lex_xpath('/foo:bar').should == [ |       lex_xpath('/foo:bar').should == [ | ||||||
|         [:T_SLASH, nil], |         [:T_SLASH, nil], | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue